@microsoft/applicationinsights-react-native 2.5.0-beta.2203-10 → 2.5.0-beta.2203-13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights react native plugin, 2.5.0-beta.2203-10
2
+ * Microsoft Application Insights react native plugin, 2.5.0-beta.2203-13
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - React Native Plugin, 2.5.0-beta.2203-10
2
+ * Application Insights JavaScript SDK - React Native Plugin, 2.5.0-beta.2203-13
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - React Native Plugin, 2.5.0-beta.2203-10
2
+ * Application Insights JavaScript SDK - React Native Plugin, 2.5.0-beta.2203-13
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - React Native Plugin, 2.5.0-beta.2203-10
2
+ * Application Insights JavaScript SDK - React Native Plugin, 2.5.0-beta.2203-13
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - React Native Plugin, 2.5.0-beta.2203-10
2
+ * Application Insights JavaScript SDK - React Native Plugin, 2.5.0-beta.2203-13
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  /**
@@ -34,11 +34,13 @@ var ReactNativePlugin = /** @class */ (function (_super) {
34
34
  var _this = _super.call(this) || this;
35
35
  _this.identifier = "AppInsightsReactNativePlugin";
36
36
  _this.priority = 140;
37
- var _device = {};
38
- var _config = config || _getDefaultConfig();
37
+ // Automatic defaults, don't set values here only set in _initDefaults()
38
+ var _device;
39
+ var _config;
39
40
  var _analyticsPlugin;
40
41
  var _defaultHandler;
41
42
  dynamicProto(ReactNativePlugin, _this, function (_self, _base) {
43
+ _initDefaults();
42
44
  _self.initialize = function (config, // need `| object` to coerce to interface
43
45
  core, extensions) {
44
46
  if (!_self.isInitialized()) {
@@ -90,6 +92,16 @@ var ReactNativePlugin = /** @class */ (function (_super) {
90
92
  _self.diagLog().warnToConsole("Failed to get DeviceInfo: " + getExceptionName(e) + " - " + dumpObj(e));
91
93
  }
92
94
  };
95
+ _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {
96
+ _resetGlobalErrorHandler();
97
+ _initDefaults();
98
+ };
99
+ function _initDefaults() {
100
+ _device = {};
101
+ _config = config || _getDefaultConfig();
102
+ _analyticsPlugin = null;
103
+ _defaultHandler = null;
104
+ }
93
105
  function _applyDeviceContext(item) {
94
106
  if (_device) {
95
107
  item.ext = item.ext || {};
@@ -116,9 +128,15 @@ var ReactNativePlugin = /** @class */ (function (_super) {
116
128
  if (_global && _global.ErrorUtils) {
117
129
  // intercept react-native error handling
118
130
  _defaultHandler = (typeof _global.ErrorUtils.getGlobalHandler === "function" && _global.ErrorUtils.getGlobalHandler()) || _global.ErrorUtils._globalHandler;
119
- _global.ErrorUtils.setGlobalHandler(_trackException.bind(_this));
131
+ _global.ErrorUtils.setGlobalHandler(_trackException);
120
132
  }
121
133
  };
134
+ function _resetGlobalErrorHandler() {
135
+ var _global = _getGlobal();
136
+ if (_global && _global.ErrorUtils && _global.ErrorUtils.getGlobalHandler() === _trackException) {
137
+ _global.ErrorUtils.setGlobalHandler(_defaultHandler || null);
138
+ }
139
+ }
122
140
  // default global error handler syntax: handleError(e, isFatal)
123
141
  function _trackException(e, isFatal) {
124
142
  var exception = { exception: e, severityLevel: SeverityLevel.Error };
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativePlugin.js.map","sources":["ReactNativePlugin.js"],"sourcesContent":["/**\r\n * ReactNativePlugin.ts\r\n * @copyright Microsoft 2019\r\n */\r\nimport { __extends } from \"tslib\";\r\nimport { LoggingSeverity, _InternalMessageId, BaseTelemetryPlugin, //,\r\narrForEach, dumpObj, getExceptionName, isObject, hasOwnProperty, isUndefined } from \"@microsoft/applicationinsights-core-js\";\r\nimport { ConfigurationManager, SeverityLevel, AnalyticsPluginIdentifier } from \"@microsoft/applicationinsights-common\";\r\nimport DeviceInfo from \"react-native-device-info\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { getGlobal, strShimUndefined } from \"@microsoft/applicationinsights-shims\";\r\n/**\r\n * This is a helper function for the equivalent of arForEach(objKeys(target), callbackFn), this is a\r\n * performance optimization to avoid the creation of a new array for large objects\r\n * @param target The target object to find and process the keys\r\n * @param callbackfn The function to call with the details\r\n */\r\nexport function objForEachKey(target, callbackfn) {\r\n if (target && isObject(target)) {\r\n for (var prop in target) {\r\n if (hasOwnProperty(target, prop)) {\r\n callbackfn.call(target, prop, target[prop]);\r\n }\r\n }\r\n }\r\n}\r\nvar ReactNativePlugin = /** @class */ (function (_super) {\r\n __extends(ReactNativePlugin, _super);\r\n function ReactNativePlugin(config) {\r\n var _this = _super.call(this) || this;\r\n _this.identifier = \"AppInsightsReactNativePlugin\";\r\n _this.priority = 140;\r\n var _device = {};\r\n var _config = config || _getDefaultConfig();\r\n var _analyticsPlugin;\r\n var _defaultHandler;\r\n dynamicProto(ReactNativePlugin, _this, function (_self, _base) {\r\n _self.initialize = function (config, // need `| object` to coerce to interface\r\n core, extensions) {\r\n if (!_self.isInitialized()) {\r\n _base.initialize(config, core, extensions);\r\n var inConfig_1 = config || {};\r\n var defaultConfig = _getDefaultConfig();\r\n objForEachKey(defaultConfig, function (option, value) {\r\n _config[option] = ConfigurationManager.getConfig(inConfig_1, option, _self.identifier, !isUndefined(_config[option]) ? _config[option] : value);\r\n });\r\n if (!_config.disableDeviceCollection) {\r\n _self._collectDeviceInfo();\r\n }\r\n if (extensions) {\r\n arrForEach(extensions, function (ext) {\r\n var identifier = ext.identifier;\r\n if (identifier === AnalyticsPluginIdentifier) {\r\n _analyticsPlugin = ext;\r\n }\r\n });\r\n }\r\n if (!_config.disableExceptionCollection) {\r\n _self._setExceptionHandler();\r\n }\r\n }\r\n };\r\n _self.processTelemetry = function (item, itemCtx) {\r\n _applyDeviceContext(item);\r\n _self.processNext(item, itemCtx);\r\n };\r\n _self.setDeviceId = function (newId) {\r\n _device.id = newId;\r\n };\r\n _self.setDeviceModel = function (newModel) {\r\n _device.model = newModel;\r\n };\r\n _self.setDeviceType = function (newType) {\r\n _device.deviceClass = newType;\r\n };\r\n /**\r\n * Automatically collects native device info for this device\r\n */\r\n _self._collectDeviceInfo = function () {\r\n try {\r\n _device.deviceClass = DeviceInfo.getDeviceType();\r\n _device.id = DeviceInfo.getUniqueId(); // Installation ID\r\n _device.model = DeviceInfo.getModel();\r\n }\r\n catch (e) {\r\n _self.diagLog().warnToConsole(\"Failed to get DeviceInfo: \" + getExceptionName(e) + \" - \" + dumpObj(e));\r\n }\r\n };\r\n function _applyDeviceContext(item) {\r\n if (_device) {\r\n item.ext = item.ext || {};\r\n item.ext.device = item.ext.device || {};\r\n if (typeof _device.id === \"string\") {\r\n item.ext.device.localId = _device.id;\r\n }\r\n if (typeof _device.model === \"string\") {\r\n item.ext.device.model = _device.model;\r\n }\r\n if (typeof _device.deviceClass === \"string\") {\r\n item.ext.device.deviceClass = _device.deviceClass;\r\n }\r\n }\r\n }\r\n function _getGlobal() {\r\n if (typeof global !== strShimUndefined && global) {\r\n return global;\r\n }\r\n return getGlobal();\r\n }\r\n _self._setExceptionHandler = function () {\r\n var _global = _getGlobal();\r\n if (_global && _global.ErrorUtils) {\r\n // intercept react-native error handling\r\n _defaultHandler = (typeof _global.ErrorUtils.getGlobalHandler === \"function\" && _global.ErrorUtils.getGlobalHandler()) || _global.ErrorUtils._globalHandler;\r\n _global.ErrorUtils.setGlobalHandler(_trackException.bind(_this));\r\n }\r\n };\r\n // default global error handler syntax: handleError(e, isFatal)\r\n function _trackException(e, isFatal) {\r\n var exception = { exception: e, severityLevel: SeverityLevel.Error };\r\n if (_analyticsPlugin) {\r\n _analyticsPlugin.trackException(exception);\r\n }\r\n else {\r\n _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, \"Analytics plugin is not available, ReactNative plugin telemetry will not be sent: \");\r\n }\r\n // call the _defaultHandler - react native also gets the error\r\n if (_defaultHandler) {\r\n _defaultHandler.call(global, e, isFatal);\r\n }\r\n }\r\n // Test Hooks\r\n _self._config = _config;\r\n _self._getDbgPlgTargets = function () {\r\n return [_device];\r\n };\r\n });\r\n function _getDefaultConfig() {\r\n return {\r\n // enable auto collection by default\r\n disableDeviceCollection: false,\r\n disableExceptionCollection: false\r\n };\r\n }\r\n return _this;\r\n }\r\n ReactNativePlugin.prototype.initialize = function (config, // need `| object` to coerce to interface\r\n core, extensions) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactNativePlugin.prototype.processTelemetry = function (env, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactNativePlugin.prototype.setDeviceId = function (newId) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactNativePlugin.prototype.setDeviceModel = function (newModel) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactNativePlugin.prototype.setDeviceType = function (newType) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return ReactNativePlugin;\r\n}(BaseTelemetryPlugin));\r\nexport { ReactNativePlugin };\r\n//# sourceMappingURL=ReactNativePlugin.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA,gFAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;8DAeM;AACN;AACA;AACA;AACA"}
1
+ {"version":3,"file":"ReactNativePlugin.js.map","sources":["ReactNativePlugin.js"],"sourcesContent":["/**\r\n * ReactNativePlugin.ts\r\n * @copyright Microsoft 2019\r\n */\r\nimport { __extends } from \"tslib\";\r\nimport { LoggingSeverity, _InternalMessageId, BaseTelemetryPlugin, //,\r\narrForEach, dumpObj, getExceptionName, isObject, hasOwnProperty, isUndefined } from \"@microsoft/applicationinsights-core-js\";\r\nimport { ConfigurationManager, SeverityLevel, AnalyticsPluginIdentifier } from \"@microsoft/applicationinsights-common\";\r\nimport DeviceInfo from \"react-native-device-info\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { getGlobal, strShimUndefined } from \"@microsoft/applicationinsights-shims\";\r\n/**\r\n * This is a helper function for the equivalent of arForEach(objKeys(target), callbackFn), this is a\r\n * performance optimization to avoid the creation of a new array for large objects\r\n * @param target The target object to find and process the keys\r\n * @param callbackfn The function to call with the details\r\n */\r\nexport function objForEachKey(target, callbackfn) {\r\n if (target && isObject(target)) {\r\n for (var prop in target) {\r\n if (hasOwnProperty(target, prop)) {\r\n callbackfn.call(target, prop, target[prop]);\r\n }\r\n }\r\n }\r\n}\r\nvar ReactNativePlugin = /** @class */ (function (_super) {\r\n __extends(ReactNativePlugin, _super);\r\n function ReactNativePlugin(config) {\r\n var _this = _super.call(this) || this;\r\n _this.identifier = \"AppInsightsReactNativePlugin\";\r\n _this.priority = 140;\r\n // Automatic defaults, don't set values here only set in _initDefaults()\r\n var _device;\r\n var _config;\r\n var _analyticsPlugin;\r\n var _defaultHandler;\r\n dynamicProto(ReactNativePlugin, _this, function (_self, _base) {\r\n _initDefaults();\r\n _self.initialize = function (config, // need `| object` to coerce to interface\r\n core, extensions) {\r\n if (!_self.isInitialized()) {\r\n _base.initialize(config, core, extensions);\r\n var inConfig_1 = config || {};\r\n var defaultConfig = _getDefaultConfig();\r\n objForEachKey(defaultConfig, function (option, value) {\r\n _config[option] = ConfigurationManager.getConfig(inConfig_1, option, _self.identifier, !isUndefined(_config[option]) ? _config[option] : value);\r\n });\r\n if (!_config.disableDeviceCollection) {\r\n _self._collectDeviceInfo();\r\n }\r\n if (extensions) {\r\n arrForEach(extensions, function (ext) {\r\n var identifier = ext.identifier;\r\n if (identifier === AnalyticsPluginIdentifier) {\r\n _analyticsPlugin = ext;\r\n }\r\n });\r\n }\r\n if (!_config.disableExceptionCollection) {\r\n _self._setExceptionHandler();\r\n }\r\n }\r\n };\r\n _self.processTelemetry = function (item, itemCtx) {\r\n _applyDeviceContext(item);\r\n _self.processNext(item, itemCtx);\r\n };\r\n _self.setDeviceId = function (newId) {\r\n _device.id = newId;\r\n };\r\n _self.setDeviceModel = function (newModel) {\r\n _device.model = newModel;\r\n };\r\n _self.setDeviceType = function (newType) {\r\n _device.deviceClass = newType;\r\n };\r\n /**\r\n * Automatically collects native device info for this device\r\n */\r\n _self._collectDeviceInfo = function () {\r\n try {\r\n _device.deviceClass = DeviceInfo.getDeviceType();\r\n _device.id = DeviceInfo.getUniqueId(); // Installation ID\r\n _device.model = DeviceInfo.getModel();\r\n }\r\n catch (e) {\r\n _self.diagLog().warnToConsole(\"Failed to get DeviceInfo: \" + getExceptionName(e) + \" - \" + dumpObj(e));\r\n }\r\n };\r\n _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {\r\n _resetGlobalErrorHandler();\r\n _initDefaults();\r\n };\r\n function _initDefaults() {\r\n _device = {};\r\n _config = config || _getDefaultConfig();\r\n _analyticsPlugin = null;\r\n _defaultHandler = null;\r\n }\r\n function _applyDeviceContext(item) {\r\n if (_device) {\r\n item.ext = item.ext || {};\r\n item.ext.device = item.ext.device || {};\r\n if (typeof _device.id === \"string\") {\r\n item.ext.device.localId = _device.id;\r\n }\r\n if (typeof _device.model === \"string\") {\r\n item.ext.device.model = _device.model;\r\n }\r\n if (typeof _device.deviceClass === \"string\") {\r\n item.ext.device.deviceClass = _device.deviceClass;\r\n }\r\n }\r\n }\r\n function _getGlobal() {\r\n if (typeof global !== strShimUndefined && global) {\r\n return global;\r\n }\r\n return getGlobal();\r\n }\r\n _self._setExceptionHandler = function () {\r\n var _global = _getGlobal();\r\n if (_global && _global.ErrorUtils) {\r\n // intercept react-native error handling\r\n _defaultHandler = (typeof _global.ErrorUtils.getGlobalHandler === \"function\" && _global.ErrorUtils.getGlobalHandler()) || _global.ErrorUtils._globalHandler;\r\n _global.ErrorUtils.setGlobalHandler(_trackException);\r\n }\r\n };\r\n function _resetGlobalErrorHandler() {\r\n var _global = _getGlobal();\r\n if (_global && _global.ErrorUtils && _global.ErrorUtils.getGlobalHandler() === _trackException) {\r\n _global.ErrorUtils.setGlobalHandler(_defaultHandler || null);\r\n }\r\n }\r\n // default global error handler syntax: handleError(e, isFatal)\r\n function _trackException(e, isFatal) {\r\n var exception = { exception: e, severityLevel: SeverityLevel.Error };\r\n if (_analyticsPlugin) {\r\n _analyticsPlugin.trackException(exception);\r\n }\r\n else {\r\n _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, \"Analytics plugin is not available, ReactNative plugin telemetry will not be sent: \");\r\n }\r\n // call the _defaultHandler - react native also gets the error\r\n if (_defaultHandler) {\r\n _defaultHandler.call(global, e, isFatal);\r\n }\r\n }\r\n // Test Hooks\r\n _self._config = _config;\r\n _self._getDbgPlgTargets = function () {\r\n return [_device];\r\n };\r\n });\r\n function _getDefaultConfig() {\r\n return {\r\n // enable auto collection by default\r\n disableDeviceCollection: false,\r\n disableExceptionCollection: false\r\n };\r\n }\r\n return _this;\r\n }\r\n ReactNativePlugin.prototype.initialize = function (config, // need `| object` to coerce to interface\r\n core, extensions) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactNativePlugin.prototype.processTelemetry = function (env, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactNativePlugin.prototype.setDeviceId = function (newId) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactNativePlugin.prototype.setDeviceModel = function (newModel) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactNativePlugin.prototype.setDeviceType = function (newType) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return ReactNativePlugin;\r\n}(BaseTelemetryPlugin));\r\nexport { ReactNativePlugin };\r\n//# sourceMappingURL=ReactNativePlugin.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA,gFAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;8DAeM;AACN;AACA;AACA;AACA"}
package/dist-esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - React Native Plugin, 2.5.0-beta.2203-10
2
+ * Application Insights JavaScript SDK - React Native Plugin, 2.5.0-beta.2203-13
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  import { ReactNativePlugin } from "./ReactNativePlugin";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/applicationinsights-react-native",
3
- "version": "2.5.0-beta.2203-10",
3
+ "version": "2.5.0-beta.2203-13",
4
4
  "description": "Microsoft Application Insights React Native Plugin",
5
5
  "main": "dist-esm/index.js",
6
6
  "types": "types/index.d.ts",
@@ -38,14 +38,14 @@
38
38
  "eslint-plugin-promise": "^5.1.0",
39
39
  "qunit": "^2.11.2",
40
40
  "react": "^17.0.2",
41
- "react-native": "^0.64.2",
41
+ "react-native": "^0.67.4",
42
42
  "react-native-device-info": "^5.6.5",
43
43
  "globby": "^11.0.0",
44
44
  "magic-string": "^0.25.7",
45
45
  "@rollup/plugin-commonjs": "^18.0.0",
46
46
  "@rollup/plugin-node-resolve": "^11.2.1",
47
47
  "@rollup/plugin-replace": "^2.3.3",
48
- "rollup-plugin-cleanup": "3.2.1",
48
+ "rollup-plugin-cleanup": "^3.2.1",
49
49
  "rollup-plugin-peer-deps-external": "^2.2.4",
50
50
  "rollup": "^2.32.0",
51
51
  "typescript": "^4.3.4",
@@ -53,8 +53,8 @@
53
53
  "uglify-js": "^3.11.0"
54
54
  },
55
55
  "dependencies": {
56
- "@microsoft/applicationinsights-common": "2.8.0-beta.2203-10",
57
- "@microsoft/applicationinsights-core-js": "2.8.0-beta.2203-10",
56
+ "@microsoft/applicationinsights-common": "2.8.0-beta.2203-13",
57
+ "@microsoft/applicationinsights-core-js": "2.8.0-beta.2203-13",
58
58
  "@microsoft/applicationinsights-shims": "2.0.1",
59
59
  "@microsoft/dynamicproto-js": "^1.1.4"
60
60
  },
@@ -17,7 +17,9 @@ import {
17
17
  getExceptionName,
18
18
  isObject,
19
19
  hasOwnProperty,
20
- isUndefined
20
+ isUndefined,
21
+ IProcessTelemetryUnloadContext,
22
+ ITelemetryUnloadState
21
23
  } from "@microsoft/applicationinsights-core-js";
22
24
  import { ConfigurationManager, IDevice, IExceptionTelemetry, IAppInsights, SeverityLevel, AnalyticsPluginIdentifier } from "@microsoft/applicationinsights-common";
23
25
  import DeviceInfo from "react-native-device-info";
@@ -56,12 +58,15 @@ export class ReactNativePlugin extends BaseTelemetryPlugin {
56
58
  constructor(config?: IReactNativePluginConfig) {
57
59
  super();
58
60
 
59
- let _device: INativeDevice = {};
60
- let _config: IReactNativePluginConfig = config || _getDefaultConfig();
61
+ // Automatic defaults, don't set values here only set in _initDefaults()
62
+ let _device: INativeDevice;
63
+ let _config: IReactNativePluginConfig;
61
64
  let _analyticsPlugin: IAppInsights;
62
65
  let _defaultHandler;
63
66
 
64
67
  dynamicProto(ReactNativePlugin, this, (_self, _base) => {
68
+ _initDefaults();
69
+
65
70
  _self.initialize = (
66
71
  config?: IReactNativePluginConfig | object, // need `| object` to coerce to interface
67
72
  core?: IAppInsightsCore,
@@ -130,6 +135,18 @@ export class ReactNativePlugin extends BaseTelemetryPlugin {
130
135
  }
131
136
  }
132
137
 
138
+ _self._doTeardown = (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void): void | boolean => {
139
+ _resetGlobalErrorHandler();
140
+ _initDefaults();
141
+ };
142
+
143
+ function _initDefaults() {
144
+ _device = {};
145
+ _config = config || _getDefaultConfig();
146
+ _analyticsPlugin = null;
147
+ _defaultHandler = null;
148
+ }
149
+
133
150
  function _applyDeviceContext(item: ITelemetryItem) {
134
151
  if (_device) {
135
152
  item.ext = item.ext || {};
@@ -159,7 +176,14 @@ export class ReactNativePlugin extends BaseTelemetryPlugin {
159
176
  if (_global && _global.ErrorUtils) {
160
177
  // intercept react-native error handling
161
178
  _defaultHandler = (typeof _global.ErrorUtils.getGlobalHandler === "function" && _global.ErrorUtils.getGlobalHandler()) || _global.ErrorUtils._globalHandler;
162
- _global.ErrorUtils.setGlobalHandler(_trackException.bind(this));
179
+ _global.ErrorUtils.setGlobalHandler(_trackException);
180
+ }
181
+ }
182
+
183
+ function _resetGlobalErrorHandler() {
184
+ const _global = _getGlobal();
185
+ if (_global && _global.ErrorUtils && _global.ErrorUtils.getGlobalHandler() === _trackException) {
186
+ _global.ErrorUtils.setGlobalHandler(_defaultHandler || null);
163
187
  }
164
188
  }
165
189
 
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.19.4"
8
+ "packageVersion": "7.19.5"
9
9
  }
10
10
  ]
11
11
  }