-
Notifications
You must be signed in to change notification settings - Fork 256
Open
Labels
Description
Description/Screenshot
According to documentation, unload takes an isAsync param which is true by default. However the function does not return a promise unless isAsync is explicitly set to true
Steps to Reproduce
const promise = appInsights.unload(true); will return a promise object, whereas const promise = appInsights.unload(); returns undefined
- OS/Browser: MacOS, React Native
- SDK Version [e.g. 22]: 3.3.10
- How you initialized the SDK:
Expected behavior
const promise = appInsights.unload(); should return a promise object
Additional context
In the distributed js code, the unload function is declared thusly:
_self.unload = function (isAsync, unloadComplete, cbTimeout) {
var unloadDone = false;
var result;
if (isAsync && !unloadComplete) {
result = createPromise(function (resolve) {
unloadComplete = resolve;
});
}
function _unloadCallback(unloadState) {
if (!unloadDone) {
unloadDone = true;
_initDefaults();
unloadComplete && unloadComplete(unloadState);
}
}
_self[_DYN_ONUNLOAD_FLUSH ](isAsync);
_removePageEventHandlers();
_core.unload && _core.unload(isAsync, _unloadCallback, cbTimeout);
return result;
};
similar functions elsewhere in the code have a line such as if (isAsync === void 0) { isAsync = true; } to set isAsync to true, but unload does not do this and therefore returns undefined.
Copilot