-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarification around offline & retry support #1419
Comments
Hi @jpalmowski, sorry for the delay. As you have already seen, looking into the code the retry backoff should be kicking in to delay the retry operation (based on your isRetryDisabled: false (which is also the default)). But this check occurs after this one So if the XHR implementation is returning something that satisifes this check that it's likely why the request is getting dropped. LocalStorage: We currently don't have any scheduled work to bring LocalStorage into the App Insights codebase, so I don't have a current timeframe for when this might occur. You are correct though in that because of the general design it's possible, and we do have an internal set of extensions that supports both LocalStorage and IndexedDb but at this point it doesn't work with the App Insights Sender. There is a general plan to move these internal plugins into the public space, but again no committed timeframe. |
Hi, @MSNev |
Yes, the SDK has a general assumption that it will be online all or most of the time and I don't believe that we have any general plans to assume complete offline or only online sometimes. Currently the SDK (by default) stores events into SessionStorage (controlled by However, this generally doesn't work for Mobile / complete offline scenarios. For those it would need the LocalStorage or IndexedDb support mentioned above as well as some refactoring of the current online / offline listener (currently only used for handling retries) All of this is current managed in the Sender.ts (channel). As part of the SDK, it is built on a "plugin" model (every component is a plugin -- including the Sender.ts), so you "could" implement an OfflinePlugin which when offline simply stored the events into some form of persistent storage and then just not call the "nextPlugin" (thus avoiding the Sender also trying to send the events). And once it detects that it's back online it could simply pickup to persisted events and send them on down the plugin chain there are some internal helpers which you should be able to "recreate" the plugin chain between instances or simply just call track again and when your plugin gets called again you just bypass your logic. If you want to go down this path I can provide some more details. As you mentioned ReactNative, this also seems like something that could be contributed (added) to the ReactNative extension as an optional capability. |
Can someone please help me understand this? I have a similar scenario. However, on every refresh I can clearly see that the AI_buffer field in session storage is cleared. Isn't the whole point of session storage that is should persist between refreshes of the same tab? Maybe this is a Ionic/webview thing, but it doesn't seem so. e.g. I can see the session_id in the cookie changing on every refresh. It's a little difficult to test this without Ionic (or some kind of pwa). So I wanted to ask first, is this normal, that the AI-buffer field is cleared on every refresh? If so, why? |
The Send buffer should be storing the values in the Session Storage and only clear them out after they have been sent. It also does in fact have an online / offline listener here which (should) be causing the events to be retried. If the events are getting dropped, then your probably hitting the The Sender probably should be changed to not attempt to send requests when offline, and I recall that there is a retry limit (can't find the config ATM). Another option might be to |
I'm not really following, honestly. The problem is that the send buffer is almost always empty. For testing purposes I've set the
So, I don't have an issue with DevTools.-.localhost_.2023-03-01.11-14-50-compressed.mp4 |
This can be used like: ``` import { LocalStorageSendBuffer } from "@microsoft/applicationinsights-channel-js"; const appInsights = new ApplicationInsights(...); appInsights.getSender().setBuffer(LocalStorageSendBuffer); ```
This can be used like: ``` const appInsights = new ApplicationInsights({ config: { enableSessionStorageBuffer: true, bufferOverride: "localStorage" } }); ```
…osoft#1419 This can be used like: ``` const appInsights = new ApplicationInsights({ config: { enableSessionStorageBuffer: true, bufferOverride: { getItem: (logger, key) => localStorage.getItem(key), setItem: (logger, key, value) => localStorage.setItem(key, value), } } }); ```
…osoft#1419 This can be used like: ``` const appInsights = new ApplicationInsights({ config: { enableSessionStorageBuffer: true, bufferOverride: { getItem: (logger, key) => localStorage.getItem(key), setItem: (logger, key, value) => localStorage.setItem(key, value), } } }); ```
…osoft#1419 This can be used like: ``` const appInsights = new ApplicationInsights({ config: { enableSessionStorageBuffer: true, bufferOverride: { getItem: (logger, key) => localStorage.getItem(key), setItem: (logger, key, value) => localStorage.setItem(key, value), } } }); ```
…osoft#1419 This can be used like: ``` const appInsights = new ApplicationInsights({ config: { enableSessionStorageBuffer: true, bufferOverride: { getItem: (logger, key) => localStorage.getItem(key), setItem: (logger, key, value) => localStorage.setItem(key, value), } } }); ```
#2037) This can be used like: ``` const appInsights = new ApplicationInsights({ config: { enableSessionStorageBuffer: true, bufferOverride: { getItem: (logger, key) => localStorage.getItem(key), setItem: (logger, key, value) => localStorage.setItem(key, value), } } }); ``` Co-authored-by: Nev <54870357+MSNev@users.noreply.github.com>
#2037) This can be used like: ``` const appInsights = new ApplicationInsights({ config: { enableSessionStorageBuffer: true, bufferOverride: { getItem: (logger, key) => localStorage.getItem(key), setItem: (logger, key, value) => localStorage.setItem(key, value), } } }); ``` Co-authored-by: Nev <54870357+MSNev@users.noreply.github.com>
* [BUG] The documentation for enableDebug is incorrect, it should reference enableDebugExceptions #2014 (#2022) * [BUG] SDK LOAD Failure reporting not working #2027 (#2038) * Add a simple interface to enable custom buffer storage solutions #1419 (#2037) This can be used like: ``` const appInsights = new ApplicationInsights({ config: { enableSessionStorageBuffer: true, bufferOverride: { getItem: (logger, key) => localStorage.getItem(key), setItem: (logger, key, value) => localStorage.setItem(key, value), } } }); ``` Co-authored-by: Nev <54870357+MSNev@users.noreply.github.com> * [Master] Add readme documentation for IStorageBuffer (#2045) * [Release] Increase version to 2.8.12 (#2046) --------- Co-authored-by: Philip Peitsch <philip.peitsch@gmail.com>
@zolakt a recent patch has been merged (2.8.12+ & 3+) which might allow you to address the issue you're seeing here. By default, AppInsights uses session storage, which is cleared whenever the tab/browser is reloaded, among other conditions. Possibly, it's worth seeing if switching to local storage resolves the issue you're seeing here? Instructions for doing this are outlined on #2037
|
FYI - We are now working on a new "extension" which may also help with this. |
If you want to see the PR's this (should) identify them |
Hi @MSNev :-) Will this latest release (3.1.0), which came out last week, make it possible to support offline situations in a react-native app? |
Depending on your detection of whether your offline -- maybe (not tried this)
No, It's not automatic you will need to also include the new Offline Channel which is used to "store" the batched events into LocalStorage / IndexedDb. There are a couple of additional changes which you will need as well as currently we only have a very basic IOfflineListener implementation (which is only listening to the browser events). We updated the interface to "handle" 2 levels of offline but we don't have any production implementation for this yet. The 2 levels are
@Karlie-777 is leading the development of the Offline Channel and we still need to provide more documentation around how to use it -- And, yes we are still making improvements, so please feel free to provide feedback. |
Great work on the 3.1 release! @MSNev @Karlie-777 I'm sure If you'd be willing to nudge us in the right direction with a minimal example how to implement the |
Thanks @p-hlp I will update the documentation soon! |
Hi I'm just seeking some clarification around the behaviour I'm seeing when the browser is offline
I can see code for exponential back off on retries so I'm assuming this should be a supported scenario but wanted to verify before I debugged any further.
I'm also seeking any information on if/when localStorage is going to be supported. It seems like it used to exist (#602) and I can see some lower level util code to support it - Given your architecture is pluggable and the interfaces for session and local storage are the same I'm wondering why this hasn't been included?
My config if it helps:
The text was updated successfully, but these errors were encountered: