@microsoft/applicationinsights-react-native 3.0.1-nightly.2301-01 → 3.0.1
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 +88 -17
- 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 +15 -5
- package/dist/applicationinsights-react-native.d.ts +1 -1
- package/dist/applicationinsights-react-native.js +88 -17
- 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/DeviceInfo/DeviceModule.js +1 -1
- package/dist-esm/DeviceInfo/ReactNativeDeviceInfo.js +1 -1
- package/dist-esm/Interfaces/IDeviceInfoModule.js +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 +7 -6
- package/dist-esm/ReactNativePlugin.js.map +1 -1
- package/dist-esm/index.js +1 -1
- package/package.json +83 -86
- package/src/ReactNativePlugin.ts +7 -6
- package/types/tsdoc-metadata.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - React Native Plugin, 3.0.1
|
|
2
|
+
* Application Insights JavaScript SDK - React Native Plugin, 3.0.1
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ import dynamicProto from "@microsoft/dynamicproto-js";
|
|
|
9
9
|
import { AnalyticsPluginIdentifier, ConfigurationManager } from "@microsoft/applicationinsights-common";
|
|
10
10
|
import { BaseTelemetryPlugin, _throwInternal, _warnToConsole, arrForEach, dumpObj, getExceptionName, isUndefined, objForEachKey } from "@microsoft/applicationinsights-core-js";
|
|
11
11
|
import { getGlobal, strShimUndefined } from "@microsoft/applicationinsights-shims";
|
|
12
|
-
import { isPromiseLike, isString } from "@nevware21/ts-utils";
|
|
12
|
+
import { isPromiseLike, isString, scheduleTimeout } from "@nevware21/ts-utils";
|
|
13
13
|
import { getReactNativeDeviceInfo } from "./DeviceInfo/ReactNativeDeviceInfo";
|
|
14
14
|
var ReactNativePlugin = /** @class */ (function (_super) {
|
|
15
15
|
__extends(ReactNativePlugin, _super);
|
|
@@ -86,12 +86,13 @@ var ReactNativePlugin = /** @class */ (function (_super) {
|
|
|
86
86
|
if (isPromiseLike(uniqueId)) {
|
|
87
87
|
_waitingForId = true;
|
|
88
88
|
if (_waitingTimer) {
|
|
89
|
-
|
|
89
|
+
_waitingTimer.cancel();
|
|
90
90
|
}
|
|
91
|
-
_waitingTimer =
|
|
91
|
+
_waitingTimer = scheduleTimeout(function () {
|
|
92
92
|
_waitingTimer = null;
|
|
93
93
|
_setDeviceId(_device.id);
|
|
94
|
-
});
|
|
94
|
+
}, 0);
|
|
95
|
+
_waitingTimer.unref();
|
|
95
96
|
uniqueId.then(function (value) {
|
|
96
97
|
_setDeviceId(value);
|
|
97
98
|
}, function (reason) {
|
|
@@ -124,7 +125,7 @@ var ReactNativePlugin = /** @class */ (function (_super) {
|
|
|
124
125
|
_device.id = newId;
|
|
125
126
|
_waitingForId = false;
|
|
126
127
|
if (_waitingTimer) {
|
|
127
|
-
|
|
128
|
+
_waitingTimer.cancel();
|
|
128
129
|
}
|
|
129
130
|
if (!_waitingForId && _waitingItems && _waitingItems.length > 0 && _self.isInitialized()) {
|
|
130
131
|
var items = _waitingItems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativePlugin.js.map","sources":["ReactNativePlugin.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { __extends } from \"tslib\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { AnalyticsPluginIdentifier, ConfigurationManager } from \"@microsoft/applicationinsights-common\";\r\nimport { BaseTelemetryPlugin, _throwInternal, _warnToConsole, arrForEach, dumpObj, getExceptionName, isUndefined, objForEachKey } from \"@microsoft/applicationinsights-core-js\";\r\nimport { getGlobal, strShimUndefined } from \"@microsoft/applicationinsights-shims\";\r\nimport { isPromiseLike, isString } from \"@nevware21/ts-utils\";\r\nimport { getReactNativeDeviceInfo } from \"./DeviceInfo/ReactNativeDeviceInfo\";\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 var _waitingForId;\r\n var _waitingTimer;\r\n var _waitingItems = null;\r\n var _deviceInfoModule;\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 var _a;\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 (core && core.getPlugin) {\r\n _analyticsPlugin = (_a = core.getPlugin(AnalyticsPluginIdentifier)) === null || _a === void 0 ? void 0 : _a.plugin;\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 if (!_waitingForId) {\r\n _applyDeviceContext(item);\r\n _self.processNext(item, itemCtx);\r\n }\r\n else {\r\n // Make sure we have an array for the waiting items\r\n _waitingItems = _waitingItems || [];\r\n _waitingItems.push({\r\n item: item,\r\n itemCtx: itemCtx\r\n });\r\n }\r\n };\r\n _self.setDeviceInfoModule = function (deviceInfoModule) {\r\n // Set the configured deviceInfoModule\r\n _deviceInfoModule = deviceInfoModule;\r\n };\r\n _self.setDeviceId = _setDeviceId;\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 var deviceInfoModule = _deviceInfoModule || getReactNativeDeviceInfo();\r\n _device.deviceClass = deviceInfoModule.getDeviceType();\r\n _device.model = deviceInfoModule.getModel();\r\n var uniqueId = deviceInfoModule.getUniqueId(); // Installation ID support different versions which return a promise vs string\r\n if (isPromiseLike(uniqueId)) {\r\n _waitingForId = true;\r\n if (_waitingTimer) {\r\n clearTimeout(_waitingTimer);\r\n }\r\n _waitingTimer = setTimeout(function () {\r\n _waitingTimer = null;\r\n _setDeviceId(_device.id);\r\n });\r\n uniqueId.then(function (value) {\r\n _setDeviceId(value);\r\n }, function (reason) {\r\n _warnToConsole(_self.diagLog(), \"Failed to get device id: \" + dumpObj(reason));\r\n // Just reuse the existing id (if any)\r\n _setDeviceId(_device.id);\r\n });\r\n }\r\n else if (isString(uniqueId)) {\r\n _device.id = uniqueId;\r\n }\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 _waitingForId = false;\r\n _deviceInfoModule = null;\r\n }\r\n function _setDeviceId(newId) {\r\n _device.id = newId;\r\n _waitingForId = false;\r\n if (_waitingTimer) {\r\n clearTimeout(_waitingTimer);\r\n }\r\n if (!_waitingForId && _waitingItems && _waitingItems.length > 0 && _self.isInitialized()) {\r\n var items = _waitingItems;\r\n _waitingItems = null;\r\n arrForEach(items, function (value) {\r\n try {\r\n _self.processTelemetry(value.item, value.itemCtx);\r\n }\r\n catch (e) {\r\n // Just ignore\r\n }\r\n });\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 (isString(_device.id)) {\r\n item.ext.device.localId = _device.id;\r\n }\r\n if (isString(_device.model)) {\r\n item.ext.device.model = _device.model;\r\n }\r\n if (isString(_device.deviceClass)) {\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: 3 /* eSeverityLevel.Error */ };\r\n if (_analyticsPlugin) {\r\n _analyticsPlugin.trackException(exception);\r\n }\r\n else {\r\n _throwInternal(_self.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, 64 /* _eInternalMessageId.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, _deviceInfoModule];\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 uniqueIdPromiseTimeout: 5000\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 /**\r\n * Set the module that will be used during initialization when collecting device is enabled\r\n * (the default), automatic collection can be disabled via the `disableDeviceCollection`\r\n * config. The `react-native-device-info` module will be used by default if no\r\n * `deviceInfoModule` is set and collection is enabled.\r\n * @param deviceInfoModule\r\n */\r\n ReactNativePlugin.prototype.setDeviceInfoModule = function (deviceInfoModule) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Manually set the deviceId, if set before initialization and automatic device info collection\r\n * is enabled this value may get overwritten. If you want to keep this value disable auto\r\n * collection by setting the `disableDeviceCollection` config to true.\r\n * @param newId - The value to use as the device Id.\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 /**\r\n * Manually set the device model, if set before initialization and automatic device info\r\n * collection is enabled this value may get overwritten. If you want to keep this value\r\n * disable auto collection by setting the `disableDeviceCollection` config to true.\r\n * @param newModel - The value to use as the device model.\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 /**\r\n * Manually set the device type (class), if set before initialization and automatic device\r\n * info collection is enabled this value may get overwritten. If you want to keep this value\r\n * disable auto collection by setting the `disableDeviceCollection` config to true.\r\n * @param newType - The value to use as the device type\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":";;;;AAA4D;AAC1B;AAClC,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;8DA2CM,CAAC;;;;;;6BACsB;AAC7B;AACA;AACA"}
|
|
1
|
+
{"version":3,"file":"ReactNativePlugin.js.map","sources":["ReactNativePlugin.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { __extends } from \"tslib\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { AnalyticsPluginIdentifier, ConfigurationManager } from \"@microsoft/applicationinsights-common\";\r\nimport { BaseTelemetryPlugin, _throwInternal, _warnToConsole, arrForEach, dumpObj, getExceptionName, isUndefined, objForEachKey } from \"@microsoft/applicationinsights-core-js\";\r\nimport { getGlobal, strShimUndefined } from \"@microsoft/applicationinsights-shims\";\r\nimport { isPromiseLike, isString, scheduleTimeout } from \"@nevware21/ts-utils\";\r\nimport { getReactNativeDeviceInfo } from \"./DeviceInfo/ReactNativeDeviceInfo\";\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 var _waitingForId;\r\n var _waitingTimer;\r\n var _waitingItems = null;\r\n var _deviceInfoModule;\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 var _a;\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 (core && core.getPlugin) {\r\n _analyticsPlugin = (_a = core.getPlugin(AnalyticsPluginIdentifier)) === null || _a === void 0 ? void 0 : _a.plugin;\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 if (!_waitingForId) {\r\n _applyDeviceContext(item);\r\n _self.processNext(item, itemCtx);\r\n }\r\n else {\r\n // Make sure we have an array for the waiting items\r\n _waitingItems = _waitingItems || [];\r\n _waitingItems.push({\r\n item: item,\r\n itemCtx: itemCtx\r\n });\r\n }\r\n };\r\n _self.setDeviceInfoModule = function (deviceInfoModule) {\r\n // Set the configured deviceInfoModule\r\n _deviceInfoModule = deviceInfoModule;\r\n };\r\n _self.setDeviceId = _setDeviceId;\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 var deviceInfoModule = _deviceInfoModule || getReactNativeDeviceInfo();\r\n _device.deviceClass = deviceInfoModule.getDeviceType();\r\n _device.model = deviceInfoModule.getModel();\r\n var uniqueId = deviceInfoModule.getUniqueId(); // Installation ID support different versions which return a promise vs string\r\n if (isPromiseLike(uniqueId)) {\r\n _waitingForId = true;\r\n if (_waitingTimer) {\r\n _waitingTimer.cancel();\r\n }\r\n _waitingTimer = scheduleTimeout(function () {\r\n _waitingTimer = null;\r\n _setDeviceId(_device.id);\r\n }, 0);\r\n _waitingTimer.unref();\r\n uniqueId.then(function (value) {\r\n _setDeviceId(value);\r\n }, function (reason) {\r\n _warnToConsole(_self.diagLog(), \"Failed to get device id: \" + dumpObj(reason));\r\n // Just reuse the existing id (if any)\r\n _setDeviceId(_device.id);\r\n });\r\n }\r\n else if (isString(uniqueId)) {\r\n _device.id = uniqueId;\r\n }\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 _waitingForId = false;\r\n _deviceInfoModule = null;\r\n }\r\n function _setDeviceId(newId) {\r\n _device.id = newId;\r\n _waitingForId = false;\r\n if (_waitingTimer) {\r\n _waitingTimer.cancel();\r\n }\r\n if (!_waitingForId && _waitingItems && _waitingItems.length > 0 && _self.isInitialized()) {\r\n var items = _waitingItems;\r\n _waitingItems = null;\r\n arrForEach(items, function (value) {\r\n try {\r\n _self.processTelemetry(value.item, value.itemCtx);\r\n }\r\n catch (e) {\r\n // Just ignore\r\n }\r\n });\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 (isString(_device.id)) {\r\n item.ext.device.localId = _device.id;\r\n }\r\n if (isString(_device.model)) {\r\n item.ext.device.model = _device.model;\r\n }\r\n if (isString(_device.deviceClass)) {\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: 3 /* eSeverityLevel.Error */ };\r\n if (_analyticsPlugin) {\r\n _analyticsPlugin.trackException(exception);\r\n }\r\n else {\r\n _throwInternal(_self.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, 64 /* _eInternalMessageId.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, _deviceInfoModule];\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 uniqueIdPromiseTimeout: 5000\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 /**\r\n * Set the module that will be used during initialization when collecting device is enabled\r\n * (the default), automatic collection can be disabled via the `disableDeviceCollection`\r\n * config. The `react-native-device-info` module will be used by default if no\r\n * `deviceInfoModule` is set and collection is enabled.\r\n * @param deviceInfoModule\r\n */\r\n ReactNativePlugin.prototype.setDeviceInfoModule = function (deviceInfoModule) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Manually set the deviceId, if set before initialization and automatic device info collection\r\n * is enabled this value may get overwritten. If you want to keep this value disable auto\r\n * collection by setting the `disableDeviceCollection` config to true.\r\n * @param newId - The value to use as the device Id.\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 /**\r\n * Manually set the device model, if set before initialization and automatic device info\r\n * collection is enabled this value may get overwritten. If you want to keep this value\r\n * disable auto collection by setting the `disableDeviceCollection` config to true.\r\n * @param newModel - The value to use as the device model.\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 /**\r\n * Manually set the device type (class), if set before initialization and automatic device\r\n * info collection is enabled this value may get overwritten. If you want to keep this value\r\n * disable auto collection by setting the `disableDeviceCollection` config to true.\r\n * @param newType - The value to use as the device type\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":";;;;AAA4D;AAC1B;AAClC,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;8DA2CM,CAAC;;;;;;6BACsB;AAC7B;AACA;AACA"}
|
package/dist-esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,86 +1,83 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@microsoft/applicationinsights-react-native",
|
|
3
|
-
"version": "3.0.1
|
|
4
|
-
"description": "Microsoft Application Insights React Native Plugin",
|
|
5
|
-
"main": "dist-esm/index.js",
|
|
6
|
-
"types": "types/index.d.ts",
|
|
7
|
-
"sideEffects": false,
|
|
8
|
-
"author": "Microsoft Application Insights Team",
|
|
9
|
-
"license": "MIT",
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "https://github.com/microsoft/applicationinsights-react-native"
|
|
13
|
-
},
|
|
14
|
-
"bugs": {
|
|
15
|
-
"url": "https://github.com/microsoft/applicationinsights-react-native/issues"
|
|
16
|
-
},
|
|
17
|
-
"homepage": "https://github.com/microsoft/applicationinsights-react-native#readme",
|
|
18
|
-
"keywords": [
|
|
19
|
-
"performance monitoring",
|
|
20
|
-
"application insights",
|
|
21
|
-
"microsoft",
|
|
22
|
-
"azure",
|
|
23
|
-
"react native"
|
|
24
|
-
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "npm run build:esm && npm run build:package && npm run dtsgen",
|
|
27
|
-
"build:esm": "grunt reactnative",
|
|
28
|
-
"build:package": "rollup -c",
|
|
29
|
-
"rebuild": "npm run build",
|
|
30
|
-
"test": "grunt reactnativetests",
|
|
31
|
-
"mintest": "grunt reactnative-mintests",
|
|
32
|
-
"testx": "npm run build:test && grunt reactnativetests",
|
|
33
|
-
"lint": "tslint -p tsconfig.json",
|
|
34
|
-
"dtsgen": "api-extractor run --local && node ../scripts/dtsgen.js \"Microsoft Application Insights react native plugin\"",
|
|
35
|
-
"ai-min": "grunt reactnative-min",
|
|
36
|
-
"ai-restore": "grunt reactnative-restore"
|
|
37
|
-
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@microsoft/ai-test-framework": "0.0.1",
|
|
40
|
-
"@microsoft/applicationinsights-rollup-es3": "1.1.3",
|
|
41
|
-
"@microsoft/api-extractor": "^7.18.1",
|
|
42
|
-
"grunt": "^1.5.3",
|
|
43
|
-
"grunt-cli": "^1.4.3",
|
|
44
|
-
"grunt-contrib-qunit": "^5.0.1",
|
|
45
|
-
"grunt-contrib-uglify": "^5.0.1",
|
|
46
|
-
"@nevware21/grunt-ts-plugin": "^0.4.3",
|
|
47
|
-
"@nevware21/grunt-eslint-ts": "^0.2.2",
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "^4.28.0",
|
|
49
|
-
"@typescript-eslint/parser": "^4.28.0",
|
|
50
|
-
"eslint": "^7.29.0",
|
|
51
|
-
"eslint-config-standard": "^16.0.3",
|
|
52
|
-
"eslint-plugin-import": "^2.23.4",
|
|
53
|
-
"eslint-plugin-node": "^11.1.0",
|
|
54
|
-
"eslint-plugin-promise": "^5.1.0",
|
|
55
|
-
"qunit": "^2.11.2",
|
|
56
|
-
"react": "^18.0.0",
|
|
57
|
-
"react-native": "^0.69.
|
|
58
|
-
"react-native-device-info": "^10.0.2",
|
|
59
|
-
"globby": "^11.0.0",
|
|
60
|
-
"magic-string": "^0.25.7",
|
|
61
|
-
"@rollup/plugin-commonjs": "^18.0.0",
|
|
62
|
-
"@rollup/plugin-node-resolve": "^11.2.1",
|
|
63
|
-
"@rollup/plugin-replace": "^2.3.3",
|
|
64
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
65
|
-
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
66
|
-
"rollup": "^2.77.2",
|
|
67
|
-
"typescript": "^4.3.4",
|
|
68
|
-
"tslib": "^2.0.0",
|
|
69
|
-
"uglify-js": "3.16.0"
|
|
70
|
-
},
|
|
71
|
-
"dependencies": {
|
|
72
|
-
"@microsoft/
|
|
73
|
-
"@microsoft/applicationinsights-
|
|
74
|
-
"@microsoft/applicationinsights-
|
|
75
|
-
"@microsoft/
|
|
76
|
-
"@nevware21/ts-utils": "
|
|
77
|
-
},
|
|
78
|
-
"peerDependencies": {
|
|
79
|
-
"tslib": "*",
|
|
80
|
-
"react-native": "*",
|
|
81
|
-
"react-native-device-info": ">=5.2.1"
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
"tag": "nightly"
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/applicationinsights-react-native",
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"description": "Microsoft Application Insights React Native Plugin",
|
|
5
|
+
"main": "dist-esm/index.js",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"author": "Microsoft Application Insights Team",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/microsoft/applicationinsights-react-native"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/microsoft/applicationinsights-react-native/issues"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/microsoft/applicationinsights-react-native#readme",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"performance monitoring",
|
|
20
|
+
"application insights",
|
|
21
|
+
"microsoft",
|
|
22
|
+
"azure",
|
|
23
|
+
"react native"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "npm run build:esm && npm run build:package && npm run dtsgen",
|
|
27
|
+
"build:esm": "grunt reactnative",
|
|
28
|
+
"build:package": "rollup -c",
|
|
29
|
+
"rebuild": "npm run build",
|
|
30
|
+
"test": "grunt reactnativetests",
|
|
31
|
+
"mintest": "grunt reactnative-mintests",
|
|
32
|
+
"testx": "npm run build:test && grunt reactnativetests",
|
|
33
|
+
"lint": "tslint -p tsconfig.json",
|
|
34
|
+
"dtsgen": "api-extractor run --local && node ../scripts/dtsgen.js \"Microsoft Application Insights react native plugin\"",
|
|
35
|
+
"ai-min": "grunt reactnative-min",
|
|
36
|
+
"ai-restore": "grunt reactnative-restore"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@microsoft/ai-test-framework": "0.0.1",
|
|
40
|
+
"@microsoft/applicationinsights-rollup-es3": "1.1.3",
|
|
41
|
+
"@microsoft/api-extractor": "^7.18.1",
|
|
42
|
+
"grunt": "^1.5.3",
|
|
43
|
+
"grunt-cli": "^1.4.3",
|
|
44
|
+
"grunt-contrib-qunit": "^5.0.1",
|
|
45
|
+
"grunt-contrib-uglify": "^5.0.1",
|
|
46
|
+
"@nevware21/grunt-ts-plugin": "^0.4.3",
|
|
47
|
+
"@nevware21/grunt-eslint-ts": "^0.2.2",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^4.28.0",
|
|
49
|
+
"@typescript-eslint/parser": "^4.28.0",
|
|
50
|
+
"eslint": "^7.29.0",
|
|
51
|
+
"eslint-config-standard": "^16.0.3",
|
|
52
|
+
"eslint-plugin-import": "^2.23.4",
|
|
53
|
+
"eslint-plugin-node": "^11.1.0",
|
|
54
|
+
"eslint-plugin-promise": "^5.1.0",
|
|
55
|
+
"qunit": "^2.11.2",
|
|
56
|
+
"react": "^18.0.0",
|
|
57
|
+
"react-native": "^0.69.8",
|
|
58
|
+
"react-native-device-info": "^10.0.2",
|
|
59
|
+
"globby": "^11.0.0",
|
|
60
|
+
"magic-string": "^0.25.7",
|
|
61
|
+
"@rollup/plugin-commonjs": "^18.0.0",
|
|
62
|
+
"@rollup/plugin-node-resolve": "^11.2.1",
|
|
63
|
+
"@rollup/plugin-replace": "^2.3.3",
|
|
64
|
+
"rollup-plugin-cleanup": "^3.2.1",
|
|
65
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
66
|
+
"rollup": "^2.77.2",
|
|
67
|
+
"typescript": "^4.3.4",
|
|
68
|
+
"tslib": "^2.0.0",
|
|
69
|
+
"uglify-js": "3.16.0"
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"@microsoft/dynamicproto-js": "^1.1.7",
|
|
73
|
+
"@microsoft/applicationinsights-common": "^2.8.10",
|
|
74
|
+
"@microsoft/applicationinsights-core-js": "^2.8.10",
|
|
75
|
+
"@microsoft/applicationinsights-shims": "^2.0.2",
|
|
76
|
+
"@nevware21/ts-utils": ">= 0.7 < 2.x"
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"tslib": "*",
|
|
80
|
+
"react-native": "*",
|
|
81
|
+
"react-native-device-info": ">=5.2.1"
|
|
82
|
+
}
|
|
83
|
+
}
|
package/src/ReactNativePlugin.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "@microsoft/applicationinsights-core-js";
|
|
13
13
|
import { getGlobal, strShimUndefined } from "@microsoft/applicationinsights-shims";
|
|
14
14
|
import { INativeDevice, IReactNativePluginConfig } from "./Interfaces";
|
|
15
|
-
import { isPromiseLike, isString } from "@nevware21/ts-utils";
|
|
15
|
+
import { isPromiseLike, isString, ITimerHandler, scheduleTimeout } from "@nevware21/ts-utils";
|
|
16
16
|
import { IDeviceInfoModule } from "./Interfaces/IDeviceInfoModule";
|
|
17
17
|
import { getReactNativeDeviceInfo } from "./DeviceInfo/ReactNativeDeviceInfo";
|
|
18
18
|
|
|
@@ -36,7 +36,7 @@ export class ReactNativePlugin extends BaseTelemetryPlugin {
|
|
|
36
36
|
let _analyticsPlugin: IAppInsights;
|
|
37
37
|
let _defaultHandler;
|
|
38
38
|
let _waitingForId: boolean;
|
|
39
|
-
let _waitingTimer:
|
|
39
|
+
let _waitingTimer: ITimerHandler;
|
|
40
40
|
let _waitingItems: { item: ITelemetryItem, itemCtx?: IProcessTelemetryContext }[] = null;
|
|
41
41
|
let _deviceInfoModule: IDeviceInfoModule;
|
|
42
42
|
|
|
@@ -118,12 +118,13 @@ export class ReactNativePlugin extends BaseTelemetryPlugin {
|
|
|
118
118
|
if (isPromiseLike(uniqueId)) {
|
|
119
119
|
_waitingForId = true;
|
|
120
120
|
if (_waitingTimer) {
|
|
121
|
-
|
|
121
|
+
_waitingTimer.cancel();
|
|
122
122
|
}
|
|
123
|
-
_waitingTimer =
|
|
123
|
+
_waitingTimer = scheduleTimeout(() => {
|
|
124
124
|
_waitingTimer = null;
|
|
125
125
|
_setDeviceId(_device.id);
|
|
126
|
-
});
|
|
126
|
+
}, 0);
|
|
127
|
+
_waitingTimer.unref();
|
|
127
128
|
uniqueId.then((value) => {
|
|
128
129
|
_setDeviceId(value);
|
|
129
130
|
}, (reason) => {
|
|
@@ -157,7 +158,7 @@ export class ReactNativePlugin extends BaseTelemetryPlugin {
|
|
|
157
158
|
_device.id = newId;
|
|
158
159
|
_waitingForId = false;
|
|
159
160
|
if (_waitingTimer) {
|
|
160
|
-
|
|
161
|
+
_waitingTimer.cancel();
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
if (!_waitingForId && _waitingItems && _waitingItems.length > 0 && _self.isInitialized()) {
|