@microsoft/applicationinsights-react-native 2.5.0-nightly.2202-06 → 2.5.0-nightly.2204-06
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.
- package/browser/applicationinsights-react-native.js +898 -360
- package/browser/applicationinsights-react-native.js.map +1 -1
- package/browser/applicationinsights-react-native.min.js +2 -2
- package/browser/applicationinsights-react-native.min.js.map +1 -1
- package/dist/applicationinsights-react-native.api.json +20 -11
- package/dist/applicationinsights-react-native.d.ts +1 -1
- package/dist/applicationinsights-react-native.js +898 -360
- package/dist/applicationinsights-react-native.js.map +1 -1
- package/dist/applicationinsights-react-native.min.js +2 -2
- package/dist/applicationinsights-react-native.min.js.map +1 -1
- package/dist/applicationinsights-react-native.rollup.d.ts +1 -1
- package/dist-esm/Interfaces/INativeDevice.js +1 -1
- package/dist-esm/Interfaces/IReactNativePluginConfig.js +1 -1
- package/dist-esm/Interfaces/index.js +1 -1
- package/dist-esm/ReactNativePlugin.js +26 -8
- package/dist-esm/ReactNativePlugin.js.map +1 -1
- package/dist-esm/index.js +1 -1
- package/package.json +5 -5
- package/src/ReactNativePlugin.ts +35 -10
- package/types/tsdoc-metadata.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - React Native Plugin, 2.5.0-nightly.
|
|
2
|
+
* Application Insights JavaScript SDK - React Native Plugin, 2.5.0-nightly.2204-06
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* @copyright Microsoft 2019
|
|
8
8
|
*/
|
|
9
9
|
import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
|
|
10
|
-
import {
|
|
11
|
-
arrForEach, dumpObj, getExceptionName, isObject, hasOwnProperty, isUndefined } from "@microsoft/applicationinsights-core-js";
|
|
10
|
+
import { BaseTelemetryPlugin, //,
|
|
11
|
+
arrForEach, dumpObj, getExceptionName, isObject, hasOwnProperty, isUndefined, _throwInternal, _warnToConsole } from "@microsoft/applicationinsights-core-js";
|
|
12
12
|
import { ConfigurationManager, SeverityLevel, AnalyticsPluginIdentifier } from "@microsoft/applicationinsights-common";
|
|
13
13
|
import DeviceInfo from "react-native-device-info";
|
|
14
14
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
@@ -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
|
-
|
|
38
|
-
var
|
|
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()) {
|
|
@@ -87,9 +89,19 @@ var ReactNativePlugin = /** @class */ (function (_super) {
|
|
|
87
89
|
_device.model = DeviceInfo.getModel();
|
|
88
90
|
}
|
|
89
91
|
catch (e) {
|
|
90
|
-
_self.diagLog()
|
|
92
|
+
_warnToConsole(_self.diagLog(), "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
|
|
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 };
|
|
@@ -126,7 +144,7 @@ var ReactNativePlugin = /** @class */ (function (_super) {
|
|
|
126
144
|
_analyticsPlugin.trackException(exception);
|
|
127
145
|
}
|
|
128
146
|
else {
|
|
129
|
-
_self.diagLog()
|
|
147
|
+
_throwInternal(_self.diagLog(), 1 /* CRITICAL */, 64 /* TelemetryInitializerFailed */, "Analytics plugin is not available, ReactNative plugin telemetry will not be sent: ");
|
|
130
148
|
}
|
|
131
149
|
// call the _defaultHandler - react native also gets the error
|
|
132
150
|
if (_defaultHandler) {
|
|
@@ -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 { BaseTelemetryPlugin, //,\r\narrForEach, dumpObj, getExceptionName, isObject, hasOwnProperty, isUndefined, _throwInternal, _warnToConsole } 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 _warnToConsole(_self.diagLog(), \"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 _throwInternal(_self.diagLog(), 1 /* CRITICAL */, 64 /* 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-nightly.
|
|
2
|
+
* Application Insights JavaScript SDK - React Native Plugin, 2.5.0-nightly.2204-06
|
|
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-nightly.
|
|
3
|
+
"version": "2.5.0-nightly.2204-06",
|
|
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.
|
|
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-nightly.
|
|
57
|
-
"@microsoft/applicationinsights-core-js": "2.8.0-nightly.
|
|
56
|
+
"@microsoft/applicationinsights-common": "2.8.0-nightly.2204-06",
|
|
57
|
+
"@microsoft/applicationinsights-core-js": "2.8.0-nightly.2204-06",
|
|
58
58
|
"@microsoft/applicationinsights-shims": "2.0.1",
|
|
59
59
|
"@microsoft/dynamicproto-js": "^1.1.4"
|
|
60
60
|
},
|
package/src/ReactNativePlugin.ts
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
ITelemetryItem,
|
|
9
9
|
IPlugin,
|
|
10
10
|
IAppInsightsCore,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
eLoggingSeverity,
|
|
12
|
+
_eInternalMessageId,
|
|
13
13
|
BaseTelemetryPlugin,
|
|
14
14
|
IProcessTelemetryContext,//,
|
|
15
15
|
arrForEach,
|
|
@@ -17,7 +17,10 @@ import {
|
|
|
17
17
|
getExceptionName,
|
|
18
18
|
isObject,
|
|
19
19
|
hasOwnProperty,
|
|
20
|
-
isUndefined
|
|
20
|
+
isUndefined,
|
|
21
|
+
IProcessTelemetryUnloadContext,
|
|
22
|
+
ITelemetryUnloadState,
|
|
23
|
+
_throwInternal, _warnToConsole
|
|
21
24
|
} from "@microsoft/applicationinsights-core-js";
|
|
22
25
|
import { ConfigurationManager, IDevice, IExceptionTelemetry, IAppInsights, SeverityLevel, AnalyticsPluginIdentifier } from "@microsoft/applicationinsights-common";
|
|
23
26
|
import DeviceInfo from "react-native-device-info";
|
|
@@ -34,7 +37,7 @@ declare var global: Window;
|
|
|
34
37
|
* @param target The target object to find and process the keys
|
|
35
38
|
* @param callbackfn The function to call with the details
|
|
36
39
|
*/
|
|
37
|
-
|
|
40
|
+
export function objForEachKey(target: any, callbackfn: (name: string, value: any) => void) {
|
|
38
41
|
if (target && isObject(target)) {
|
|
39
42
|
for (let prop in target) {
|
|
40
43
|
if (hasOwnProperty(target, prop)) {
|
|
@@ -56,12 +59,15 @@ export class ReactNativePlugin extends BaseTelemetryPlugin {
|
|
|
56
59
|
constructor(config?: IReactNativePluginConfig) {
|
|
57
60
|
super();
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
let
|
|
62
|
+
// Automatic defaults, don't set values here only set in _initDefaults()
|
|
63
|
+
let _device: INativeDevice;
|
|
64
|
+
let _config: IReactNativePluginConfig;
|
|
61
65
|
let _analyticsPlugin: IAppInsights;
|
|
62
66
|
let _defaultHandler;
|
|
63
67
|
|
|
64
68
|
dynamicProto(ReactNativePlugin, this, (_self, _base) => {
|
|
69
|
+
_initDefaults();
|
|
70
|
+
|
|
65
71
|
_self.initialize = (
|
|
66
72
|
config?: IReactNativePluginConfig | object, // need `| object` to coerce to interface
|
|
67
73
|
core?: IAppInsightsCore,
|
|
@@ -126,10 +132,22 @@ export class ReactNativePlugin extends BaseTelemetryPlugin {
|
|
|
126
132
|
_device.id = DeviceInfo.getUniqueId(); // Installation ID
|
|
127
133
|
_device.model = DeviceInfo.getModel();
|
|
128
134
|
} catch (e) {
|
|
129
|
-
_self.diagLog()
|
|
135
|
+
_warnToConsole(_self.diagLog(), "Failed to get DeviceInfo: " + getExceptionName(e) + " - " + dumpObj(e));
|
|
130
136
|
}
|
|
131
137
|
}
|
|
132
138
|
|
|
139
|
+
_self._doTeardown = (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void): void | boolean => {
|
|
140
|
+
_resetGlobalErrorHandler();
|
|
141
|
+
_initDefaults();
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
function _initDefaults() {
|
|
145
|
+
_device = {};
|
|
146
|
+
_config = config || _getDefaultConfig();
|
|
147
|
+
_analyticsPlugin = null;
|
|
148
|
+
_defaultHandler = null;
|
|
149
|
+
}
|
|
150
|
+
|
|
133
151
|
function _applyDeviceContext(item: ITelemetryItem) {
|
|
134
152
|
if (_device) {
|
|
135
153
|
item.ext = item.ext || {};
|
|
@@ -159,7 +177,14 @@ export class ReactNativePlugin extends BaseTelemetryPlugin {
|
|
|
159
177
|
if (_global && _global.ErrorUtils) {
|
|
160
178
|
// intercept react-native error handling
|
|
161
179
|
_defaultHandler = (typeof _global.ErrorUtils.getGlobalHandler === "function" && _global.ErrorUtils.getGlobalHandler()) || _global.ErrorUtils._globalHandler;
|
|
162
|
-
_global.ErrorUtils.setGlobalHandler(_trackException
|
|
180
|
+
_global.ErrorUtils.setGlobalHandler(_trackException);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function _resetGlobalErrorHandler() {
|
|
185
|
+
const _global = _getGlobal();
|
|
186
|
+
if (_global && _global.ErrorUtils && _global.ErrorUtils.getGlobalHandler() === _trackException) {
|
|
187
|
+
_global.ErrorUtils.setGlobalHandler(_defaultHandler || null);
|
|
163
188
|
}
|
|
164
189
|
}
|
|
165
190
|
|
|
@@ -170,8 +195,8 @@ export class ReactNativePlugin extends BaseTelemetryPlugin {
|
|
|
170
195
|
if (_analyticsPlugin) {
|
|
171
196
|
_analyticsPlugin.trackException(exception);
|
|
172
197
|
} else {
|
|
173
|
-
_self.diagLog()
|
|
174
|
-
|
|
198
|
+
_throwInternal(_self.diagLog(),
|
|
199
|
+
eLoggingSeverity.CRITICAL, _eInternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, ReactNative plugin telemetry will not be sent: ");
|
|
175
200
|
}
|
|
176
201
|
|
|
177
202
|
// call the _defaultHandler - react native also gets the error
|