@microsoft/applicationinsights-react-native 2.5.6 → 3.0.0
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/README.md +44 -2
- package/browser/applicationinsights-react-native.js +105 -47
- 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 +216 -6
- package/dist/applicationinsights-react-native.api.md +12 -5
- package/dist/applicationinsights-react-native.d.ts +70 -1
- package/dist/applicationinsights-react-native.js +105 -47
- 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 +70 -1
- package/dist-esm/DeviceInfo/DeviceModule.js +38 -0
- package/dist-esm/DeviceInfo/DeviceModule.js.map +1 -0
- package/dist-esm/DeviceInfo/ReactNativeDeviceInfo.js +15 -0
- package/dist-esm/DeviceInfo/ReactNativeDeviceInfo.js.map +1 -0
- package/dist-esm/Interfaces/IDeviceInfoModule.js +8 -0
- package/dist-esm/Interfaces/IDeviceInfoModule.js.map +1 -0
- package/dist-esm/Interfaces/INativeDevice.js +3 -1
- package/dist-esm/Interfaces/INativeDevice.js.map +1 -1
- package/dist-esm/Interfaces/IReactNativePluginConfig.js +1 -1
- package/dist-esm/Interfaces/index.js +3 -1
- package/dist-esm/Interfaces/index.js.map +1 -1
- package/dist-esm/ReactNativePlugin.js +81 -41
- package/dist-esm/ReactNativePlugin.js.map +1 -1
- package/dist-esm/index.js +5 -1
- package/dist-esm/index.js.map +1 -1
- package/package.json +9 -8
- package/src/DeviceInfo/DeviceModule.ts +44 -0
- package/src/DeviceInfo/ReactNativeDeviceInfo.ts +13 -0
- package/src/Interfaces/IDeviceInfoModule.ts +31 -0
- package/src/Interfaces/INativeDevice.ts +3 -0
- package/src/Interfaces/IReactNativePluginConfig.ts +15 -0
- package/src/Interfaces/index.ts +3 -0
- package/src/ReactNativePlugin.ts +109 -41
- package/src/index.ts +8 -2
- package/types/DeviceInfo/DeviceModule.d.ts +10 -0
- package/types/DeviceInfo/ReactNativeDeviceInfo.d.ts +6 -0
- package/types/Interfaces/IDeviceInfoModule.d.ts +25 -0
- package/types/Interfaces/IReactNativePluginConfig.d.ts +11 -0
- package/types/ReactNativePlugin.d.ts +27 -11
- package/types/index.d.ts +4 -1
- package/types/tsdoc-metadata.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Microsoft Application Insights react native plugin,
|
|
2
|
+
* Microsoft Application Insights react native plugin, 3.0.0
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Microsoft Application Insights Team
|
|
@@ -20,6 +20,38 @@ import { IProcessTelemetryContext } from '@microsoft/applicationinsights-core-js
|
|
|
20
20
|
import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
|
|
21
21
|
import { ITelemetryPlugin } from '@microsoft/applicationinsights-core-js';
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Returns the "react-native-device-info" as the Device Info Module
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export declare function getReactNativeDeviceInfo(): IDeviceInfoModule;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Interface to abstract how the plugin can access the Device Info, this is a stripped
|
|
31
|
+
* down version of the "react-native-device-info" interface and is mostly supplied for
|
|
32
|
+
* testing.
|
|
33
|
+
*/
|
|
34
|
+
export declare interface IDeviceInfoModule {
|
|
35
|
+
/**
|
|
36
|
+
* Returns the Device Model
|
|
37
|
+
*/
|
|
38
|
+
getModel: () => string;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the device type
|
|
41
|
+
*/
|
|
42
|
+
getDeviceType: () => string;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the unique Id for the device, to support both the current version and previous
|
|
45
|
+
* versions react-native-device-info, this may return either a `string` or `Promise<string>`,
|
|
46
|
+
* when a promise is returned the plugin will "wait" for the promise to `resolve` or `reject`
|
|
47
|
+
* before processing any events. This WILL cause telemetry to be BLOCKED until either of these
|
|
48
|
+
* states, so when returning a Promise it MUST `resolve` or `reject` it can't just never resolve.
|
|
49
|
+
* There is a default timeout configured via `uniqueIdPromiseTimeout` to automatically unblock
|
|
50
|
+
* event processing when this issue occurs.
|
|
51
|
+
*/
|
|
52
|
+
getUniqueId: () => Promise<string> | string;
|
|
53
|
+
}
|
|
54
|
+
|
|
23
55
|
export declare interface INativeDevice {
|
|
24
56
|
/**
|
|
25
57
|
* Device type, e.g. Handset, Tablet, Tv
|
|
@@ -36,8 +68,19 @@ export declare interface INativeDevice {
|
|
|
36
68
|
}
|
|
37
69
|
|
|
38
70
|
export declare interface IReactNativePluginConfig {
|
|
71
|
+
/**
|
|
72
|
+
* Disable automatic device collection
|
|
73
|
+
*/
|
|
39
74
|
disableDeviceCollection?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Disable automatic exception collection
|
|
77
|
+
*/
|
|
40
78
|
disableExceptionCollection?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Timeout value to unblock the processing of events if the DeviceInfoModule
|
|
81
|
+
* returns a Promise.
|
|
82
|
+
*/
|
|
83
|
+
uniqueIdPromiseTimeout?: number;
|
|
41
84
|
}
|
|
42
85
|
|
|
43
86
|
export declare class ReactNativePlugin extends BaseTelemetryPlugin {
|
|
@@ -50,8 +93,34 @@ export declare class ReactNativePlugin extends BaseTelemetryPlugin {
|
|
|
50
93
|
initialize(config?: IReactNativePluginConfig | object, // need `| object` to coerce to interface
|
|
51
94
|
core?: IAppInsightsCore, extensions?: IPlugin[]): void;
|
|
52
95
|
processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
96
|
+
/**
|
|
97
|
+
* Set the module that will be used during initialization when collecting device is enabled
|
|
98
|
+
* (the default), automatic collection can be disabled via the `disableDeviceCollection`
|
|
99
|
+
* config. The `react-native-device-info` module will be used by default if no
|
|
100
|
+
* `deviceInfoModule` is set and collection is enabled.
|
|
101
|
+
* @param deviceInfoModule
|
|
102
|
+
*/
|
|
103
|
+
setDeviceInfoModule(deviceInfoModule: IDeviceInfoModule): void;
|
|
104
|
+
/**
|
|
105
|
+
* Manually set the deviceId, if set before initialization and automatic device info collection
|
|
106
|
+
* is enabled this value may get overwritten. If you want to keep this value disable auto
|
|
107
|
+
* collection by setting the `disableDeviceCollection` config to true.
|
|
108
|
+
* @param newId - The value to use as the device Id.
|
|
109
|
+
*/
|
|
53
110
|
setDeviceId(newId: string): void;
|
|
111
|
+
/**
|
|
112
|
+
* Manually set the device model, if set before initialization and automatic device info
|
|
113
|
+
* collection is enabled this value may get overwritten. If you want to keep this value
|
|
114
|
+
* disable auto collection by setting the `disableDeviceCollection` config to true.
|
|
115
|
+
* @param newModel - The value to use as the device model.
|
|
116
|
+
*/
|
|
54
117
|
setDeviceModel(newModel: string): void;
|
|
118
|
+
/**
|
|
119
|
+
* Manually set the device type (class), if set before initialization and automatic device
|
|
120
|
+
* info collection is enabled this value may get overwritten. If you want to keep this value
|
|
121
|
+
* disable auto collection by setting the `disableDeviceCollection` config to true.
|
|
122
|
+
* @param newType - The value to use as the device type
|
|
123
|
+
*/
|
|
55
124
|
setDeviceType(newType: string): void;
|
|
56
125
|
}
|
|
57
126
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Application Insights JavaScript SDK - React Native Plugin, 3.0.0
|
|
3
|
+
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import { objDefineAccessors } from "@microsoft/applicationinsights-core-js";
|
|
8
|
+
export var DEVICE_MODEL = "model";
|
|
9
|
+
export var DEVICE_TYPE = "type";
|
|
10
|
+
export var UNIQUE_ID = "id";
|
|
11
|
+
var DeviceModule = /** @class */ (function () {
|
|
12
|
+
function DeviceModule() {
|
|
13
|
+
var _self = this;
|
|
14
|
+
var _model = null;
|
|
15
|
+
var _deviceType = null;
|
|
16
|
+
var _uniqueId = null;
|
|
17
|
+
function _getModel() {
|
|
18
|
+
return _model;
|
|
19
|
+
}
|
|
20
|
+
function _getDeviceType() {
|
|
21
|
+
return _deviceType;
|
|
22
|
+
}
|
|
23
|
+
function _getUniqueId() {
|
|
24
|
+
return _uniqueId;
|
|
25
|
+
}
|
|
26
|
+
// Provide the public interface methods for accessing the values
|
|
27
|
+
_self.getModel = _getModel;
|
|
28
|
+
_self.getDeviceType = _getDeviceType;
|
|
29
|
+
_self.getUniqueId = _getUniqueId;
|
|
30
|
+
// Provide setters (for testing) and re-use the functions for minification
|
|
31
|
+
objDefineAccessors(_self, DEVICE_MODEL, _getModel, function (value) { return _model = value; });
|
|
32
|
+
objDefineAccessors(_self, DEVICE_TYPE, _getDeviceType, function (value) { return _deviceType = value; });
|
|
33
|
+
objDefineAccessors(_self, UNIQUE_ID, _getUniqueId, function (value) { return _uniqueId = value; });
|
|
34
|
+
}
|
|
35
|
+
return DeviceModule;
|
|
36
|
+
}());
|
|
37
|
+
export { DeviceModule };
|
|
38
|
+
//# sourceMappingURL=DeviceModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeviceModule.js.map","sources":["DeviceModule.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { objDefineAccessors } from \"@microsoft/applicationinsights-core-js\";\r\nexport var DEVICE_MODEL = \"model\";\r\nexport var DEVICE_TYPE = \"type\";\r\nexport var UNIQUE_ID = \"id\";\r\nvar DeviceModule = /** @class */ (function () {\r\n function DeviceModule() {\r\n var _self = this;\r\n var _model = null;\r\n var _deviceType = null;\r\n var _uniqueId = null;\r\n function _getModel() {\r\n return _model;\r\n }\r\n function _getDeviceType() {\r\n return _deviceType;\r\n }\r\n function _getUniqueId() {\r\n return _uniqueId;\r\n }\r\n // Provide the public interface methods for accessing the values\r\n _self.getModel = _getModel;\r\n _self.getDeviceType = _getDeviceType;\r\n _self.getUniqueId = _getUniqueId;\r\n // Provide setters (for testing) and re-use the functions for minification\r\n objDefineAccessors(_self, DEVICE_MODEL, _getModel, function (value) { return _model = value; });\r\n objDefineAccessors(_self, DEVICE_TYPE, _getDeviceType, function (value) { return _deviceType = value; });\r\n objDefineAccessors(_self, UNIQUE_ID, _getUniqueId, function (value) { return _uniqueId = value; });\r\n }\r\n return DeviceModule;\r\n}());\r\nexport { DeviceModule };\r\n//# sourceMappingURL=DeviceModule.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Application Insights JavaScript SDK - React Native Plugin, 3.0.0
|
|
3
|
+
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import DeviceInfo from "react-native-device-info";
|
|
8
|
+
/**
|
|
9
|
+
* Returns the "react-native-device-info" as the Device Info Module
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export function getReactNativeDeviceInfo() {
|
|
13
|
+
return DeviceInfo;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ReactNativeDeviceInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactNativeDeviceInfo.js.map","sources":["ReactNativeDeviceInfo.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport DeviceInfo from \"react-native-device-info\";\r\n/**\r\n * Returns the \"react-native-device-info\" as the Device Info Module\r\n * @returns\r\n */\r\nexport function getReactNativeDeviceInfo() {\r\n return DeviceInfo;\r\n}\r\n//# sourceMappingURL=ReactNativeDeviceInfo.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IDeviceInfoModule.js.map","sources":["IDeviceInfoModule.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nexport {};\r\n//# sourceMappingURL=IDeviceInfoModule.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - React Native Plugin,
|
|
2
|
+
* Application Insights JavaScript SDK - React Native Plugin, 3.0.0
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
|
+
|
|
6
|
+
|
|
5
7
|
export {};
|
|
6
8
|
//# sourceMappingURL=INativeDevice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"INativeDevice.js.map","sources":["INativeDevice.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"INativeDevice.js.map","sources":["INativeDevice.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nexport {};\r\n//# sourceMappingURL=INativeDevice.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - React Native Plugin,
|
|
2
|
+
* Application Insights JavaScript SDK - React Native Plugin, 3.0.0
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
|
+
|
|
6
|
+
|
|
5
7
|
export {};
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js.map","sources":["index.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js.map","sources":["index.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nexport {};\r\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA"}
|
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - React Native Plugin,
|
|
2
|
+
* Application Insights JavaScript SDK - React Native Plugin, 3.0.0
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @copyright Microsoft 2019
|
|
8
|
-
*/
|
|
5
|
+
|
|
6
|
+
|
|
9
7
|
import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
|
|
10
8
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
11
|
-
import DeviceInfo from "react-native-device-info";
|
|
12
9
|
import { AnalyticsPluginIdentifier, ConfigurationManager } from "@microsoft/applicationinsights-common";
|
|
13
|
-
import { BaseTelemetryPlugin, _throwInternal, _warnToConsole, arrForEach, dumpObj, getExceptionName,
|
|
10
|
+
import { BaseTelemetryPlugin, _throwInternal, _warnToConsole, arrForEach, dumpObj, getExceptionName, isUndefined, objForEachKey } from "@microsoft/applicationinsights-core-js";
|
|
14
11
|
import { getGlobal, strShimUndefined } from "@microsoft/applicationinsights-shims";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* performance optimization to avoid the creation of a new array for large objects
|
|
18
|
-
* @param target The target object to find and process the keys
|
|
19
|
-
* @param callbackfn The function to call with the details
|
|
20
|
-
*/
|
|
21
|
-
export function objForEachKey(target, callbackfn) {
|
|
22
|
-
if (target && isObject(target)) {
|
|
23
|
-
for (var prop in target) {
|
|
24
|
-
if (hasOwnProperty(target, prop)) {
|
|
25
|
-
callbackfn.call(target, prop, target[prop]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
12
|
+
import { isPromiseLike, isString } from "@nevware21/ts-utils";
|
|
13
|
+
import { getReactNativeDeviceInfo } from "./DeviceInfo/ReactNativeDeviceInfo";
|
|
30
14
|
var ReactNativePlugin = /** @class */ (function (_super) {
|
|
31
15
|
__extends(ReactNativePlugin, _super);
|
|
32
16
|
function ReactNativePlugin(config) {
|
|
@@ -38,10 +22,15 @@ var ReactNativePlugin = /** @class */ (function (_super) {
|
|
|
38
22
|
var _config;
|
|
39
23
|
var _analyticsPlugin;
|
|
40
24
|
var _defaultHandler;
|
|
25
|
+
var _waitingForId;
|
|
26
|
+
var _waitingTimer;
|
|
27
|
+
var _waitingItems = null;
|
|
28
|
+
var _deviceInfoModule;
|
|
41
29
|
dynamicProto(ReactNativePlugin, _this, function (_self, _base) {
|
|
42
30
|
_initDefaults();
|
|
43
31
|
_self.initialize = function (config, // need `| object` to coerce to interface
|
|
44
32
|
core, extensions) {
|
|
33
|
+
var _a;
|
|
45
34
|
if (!_self.isInitialized()) {
|
|
46
35
|
_base.initialize(config, core, extensions);
|
|
47
36
|
var inConfig_1 = config || {};
|
|
@@ -52,13 +41,8 @@ var ReactNativePlugin = /** @class */ (function (_super) {
|
|
|
52
41
|
if (!_config.disableDeviceCollection) {
|
|
53
42
|
_self._collectDeviceInfo();
|
|
54
43
|
}
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
var identifier = ext.identifier;
|
|
58
|
-
if (identifier === AnalyticsPluginIdentifier) {
|
|
59
|
-
_analyticsPlugin = ext;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
44
|
+
if (core && core.getPlugin) {
|
|
45
|
+
_analyticsPlugin = (_a = core.getPlugin(AnalyticsPluginIdentifier)) === null || _a === void 0 ? void 0 : _a.plugin;
|
|
62
46
|
}
|
|
63
47
|
if (!_config.disableExceptionCollection) {
|
|
64
48
|
_self._setExceptionHandler();
|
|
@@ -66,12 +50,24 @@ var ReactNativePlugin = /** @class */ (function (_super) {
|
|
|
66
50
|
}
|
|
67
51
|
};
|
|
68
52
|
_self.processTelemetry = function (item, itemCtx) {
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
if (!_waitingForId) {
|
|
54
|
+
_applyDeviceContext(item);
|
|
55
|
+
_self.processNext(item, itemCtx);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// Make sure we have an array for the waiting items
|
|
59
|
+
_waitingItems = _waitingItems || [];
|
|
60
|
+
_waitingItems.push({
|
|
61
|
+
item: item,
|
|
62
|
+
itemCtx: itemCtx
|
|
63
|
+
});
|
|
64
|
+
}
|
|
71
65
|
};
|
|
72
|
-
_self.
|
|
73
|
-
|
|
66
|
+
_self.setDeviceInfoModule = function (deviceInfoModule) {
|
|
67
|
+
// Set the configured deviceInfoModule
|
|
68
|
+
_deviceInfoModule = deviceInfoModule;
|
|
74
69
|
};
|
|
70
|
+
_self.setDeviceId = _setDeviceId;
|
|
75
71
|
_self.setDeviceModel = function (newModel) {
|
|
76
72
|
_device.model = newModel;
|
|
77
73
|
};
|
|
@@ -83,9 +79,30 @@ var ReactNativePlugin = /** @class */ (function (_super) {
|
|
|
83
79
|
*/
|
|
84
80
|
_self._collectDeviceInfo = function () {
|
|
85
81
|
try {
|
|
86
|
-
|
|
87
|
-
_device.
|
|
88
|
-
_device.model =
|
|
82
|
+
var deviceInfoModule = _deviceInfoModule || getReactNativeDeviceInfo();
|
|
83
|
+
_device.deviceClass = deviceInfoModule.getDeviceType();
|
|
84
|
+
_device.model = deviceInfoModule.getModel();
|
|
85
|
+
var uniqueId = deviceInfoModule.getUniqueId(); // Installation ID support different versions which return a promise vs string
|
|
86
|
+
if (isPromiseLike(uniqueId)) {
|
|
87
|
+
_waitingForId = true;
|
|
88
|
+
if (_waitingTimer) {
|
|
89
|
+
clearTimeout(_waitingTimer);
|
|
90
|
+
}
|
|
91
|
+
_waitingTimer = setTimeout(function () {
|
|
92
|
+
_waitingTimer = null;
|
|
93
|
+
_setDeviceId(_device.id);
|
|
94
|
+
});
|
|
95
|
+
uniqueId.then(function (value) {
|
|
96
|
+
_setDeviceId(value);
|
|
97
|
+
}, function (reason) {
|
|
98
|
+
_warnToConsole(_self.diagLog(), "Failed to get device id: " + dumpObj(reason));
|
|
99
|
+
// Just reuse the existing id (if any)
|
|
100
|
+
_setDeviceId(_device.id);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
else if (isString(uniqueId)) {
|
|
104
|
+
_device.id = uniqueId;
|
|
105
|
+
}
|
|
89
106
|
}
|
|
90
107
|
catch (e) {
|
|
91
108
|
_warnToConsole(_self.diagLog(), "Failed to get DeviceInfo: " + getExceptionName(e) + " - " + dumpObj(e));
|
|
@@ -100,18 +117,39 @@ var ReactNativePlugin = /** @class */ (function (_super) {
|
|
|
100
117
|
_config = config || _getDefaultConfig();
|
|
101
118
|
_analyticsPlugin = null;
|
|
102
119
|
_defaultHandler = null;
|
|
120
|
+
_waitingForId = false;
|
|
121
|
+
_deviceInfoModule = null;
|
|
122
|
+
}
|
|
123
|
+
function _setDeviceId(newId) {
|
|
124
|
+
_device.id = newId;
|
|
125
|
+
_waitingForId = false;
|
|
126
|
+
if (_waitingTimer) {
|
|
127
|
+
clearTimeout(_waitingTimer);
|
|
128
|
+
}
|
|
129
|
+
if (!_waitingForId && _waitingItems && _waitingItems.length > 0 && _self.isInitialized()) {
|
|
130
|
+
var items = _waitingItems;
|
|
131
|
+
_waitingItems = null;
|
|
132
|
+
arrForEach(items, function (value) {
|
|
133
|
+
try {
|
|
134
|
+
_self.processTelemetry(value.item, value.itemCtx);
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
// Just ignore
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
103
141
|
}
|
|
104
142
|
function _applyDeviceContext(item) {
|
|
105
143
|
if (_device) {
|
|
106
144
|
item.ext = item.ext || {};
|
|
107
145
|
item.ext.device = item.ext.device || {};
|
|
108
|
-
if (
|
|
146
|
+
if (isString(_device.id)) {
|
|
109
147
|
item.ext.device.localId = _device.id;
|
|
110
148
|
}
|
|
111
|
-
if (
|
|
149
|
+
if (isString(_device.model)) {
|
|
112
150
|
item.ext.device.model = _device.model;
|
|
113
151
|
}
|
|
114
|
-
if (
|
|
152
|
+
if (isString(_device.deviceClass)) {
|
|
115
153
|
item.ext.device.deviceClass = _device.deviceClass;
|
|
116
154
|
}
|
|
117
155
|
}
|
|
@@ -153,20 +191,22 @@ var ReactNativePlugin = /** @class */ (function (_super) {
|
|
|
153
191
|
// Test Hooks
|
|
154
192
|
_self._config = _config;
|
|
155
193
|
_self._getDbgPlgTargets = function () {
|
|
156
|
-
return [_device];
|
|
194
|
+
return [_device, _deviceInfoModule];
|
|
157
195
|
};
|
|
158
196
|
});
|
|
159
197
|
function _getDefaultConfig() {
|
|
160
198
|
return {
|
|
161
199
|
// enable auto collection by default
|
|
162
200
|
disableDeviceCollection: false,
|
|
163
|
-
disableExceptionCollection: false
|
|
201
|
+
disableExceptionCollection: false,
|
|
202
|
+
uniqueIdPromiseTimeout: 5000
|
|
164
203
|
};
|
|
165
204
|
}
|
|
166
205
|
return _this;
|
|
167
206
|
}
|
|
168
207
|
// Removed Stub for ReactNativePlugin.prototype.initialize.
|
|
169
208
|
// Removed Stub for ReactNativePlugin.prototype.processTelemetry.
|
|
209
|
+
// Removed Stub for ReactNativePlugin.prototype.setDeviceInfoModule.
|
|
170
210
|
// Removed Stub for ReactNativePlugin.prototype.setDeviceId.
|
|
171
211
|
// Removed Stub for ReactNativePlugin.prototype.setDeviceModel.
|
|
172
212
|
// Removed Stub for ReactNativePlugin.prototype.setDeviceType.
|
|
@@ -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 dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport DeviceInfo from \"react-native-device-info\";\r\nimport { AnalyticsPluginIdentifier, ConfigurationManager } from \"@microsoft/applicationinsights-common\";\r\nimport { BaseTelemetryPlugin, _throwInternal, _warnToConsole, arrForEach, dumpObj, getExceptionName, hasOwnProperty, isObject, isUndefined } from \"@microsoft/applicationinsights-core-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: 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];\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;;;;8DAeM,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 } 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"}
|
package/dist-esm/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - React Native Plugin,
|
|
2
|
+
* Application Insights JavaScript SDK - React Native Plugin, 3.0.0
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
|
+
|
|
6
|
+
|
|
5
7
|
import { ReactNativePlugin } from "./ReactNativePlugin";
|
|
8
|
+
import { getReactNativeDeviceInfo } from "./DeviceInfo/ReactNativeDeviceInfo";
|
|
6
9
|
export { ReactNativePlugin };
|
|
10
|
+
export { getReactNativeDeviceInfo };
|
|
7
11
|
//# sourceMappingURL=index.js.map
|
package/dist-esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js.map","sources":["index.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js.map","sources":["index.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { ReactNativePlugin } from \"./ReactNativePlugin\";\r\nimport { getReactNativeDeviceInfo } from \"./DeviceInfo/ReactNativeDeviceInfo\";\r\nexport { ReactNativePlugin };\r\nexport { getReactNativeDeviceInfo };\r\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/applicationinsights-react-native",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Microsoft Application Insights React Native Plugin",
|
|
5
5
|
"main": "dist-esm/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"application insights",
|
|
21
21
|
"microsoft",
|
|
22
22
|
"azure",
|
|
23
|
-
|
|
23
|
+
"react native"
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "npm run build:esm && npm run build:package && npm run dtsgen",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"eslint-plugin-node": "^11.1.0",
|
|
54
54
|
"eslint-plugin-promise": "^5.1.0",
|
|
55
55
|
"qunit": "^2.11.2",
|
|
56
|
-
"react": "^
|
|
57
|
-
"react-native": "^0.
|
|
58
|
-
"react-native-device-info": "^
|
|
56
|
+
"react": "^18.0.0",
|
|
57
|
+
"react-native": "^0.69.3",
|
|
58
|
+
"react-native-device-info": "^10.0.2",
|
|
59
59
|
"globby": "^11.0.0",
|
|
60
60
|
"magic-string": "^0.25.7",
|
|
61
61
|
"@rollup/plugin-commonjs": "^18.0.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@rollup/plugin-replace": "^2.3.3",
|
|
64
64
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
65
65
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
66
|
-
"rollup": "^2.
|
|
66
|
+
"rollup": "^2.77.2",
|
|
67
67
|
"typescript": "^4.3.4",
|
|
68
68
|
"tslib": "^2.0.0",
|
|
69
69
|
"uglify-js": "3.16.0"
|
|
@@ -72,11 +72,12 @@
|
|
|
72
72
|
"@microsoft/applicationinsights-common": "^2.8.5",
|
|
73
73
|
"@microsoft/applicationinsights-core-js": "^2.8.5",
|
|
74
74
|
"@microsoft/applicationinsights-shims": "^2.0.1",
|
|
75
|
-
"@microsoft/dynamicproto-js": "^1.1.6"
|
|
75
|
+
"@microsoft/dynamicproto-js": "^1.1.6",
|
|
76
|
+
"@nevware21/ts-utils": "^0.3.1"
|
|
76
77
|
},
|
|
77
78
|
"peerDependencies": {
|
|
78
79
|
"tslib": "*",
|
|
79
80
|
"react-native": "*",
|
|
80
|
-
"react-native-device-info": "
|
|
81
|
+
"react-native-device-info": ">=5.2.1"
|
|
81
82
|
}
|
|
82
83
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import { objDefineAccessors } from "@microsoft/applicationinsights-core-js";
|
|
5
|
+
import { IDeviceInfoModule } from "../Interfaces/IDeviceInfoModule";
|
|
6
|
+
|
|
7
|
+
export const DEVICE_MODEL = "model";
|
|
8
|
+
export const DEVICE_TYPE = "type";
|
|
9
|
+
export const UNIQUE_ID = "id";
|
|
10
|
+
|
|
11
|
+
export class DeviceModule implements IDeviceInfoModule {
|
|
12
|
+
public getModel: () => string;
|
|
13
|
+
public getDeviceType: () => string;
|
|
14
|
+
public getUniqueId: () => string | Promise<string>;
|
|
15
|
+
|
|
16
|
+
constructor() {
|
|
17
|
+
let _self = this;
|
|
18
|
+
let _model: string = null;
|
|
19
|
+
let _deviceType: string = null;
|
|
20
|
+
let _uniqueId: string | Promise<string> = null;
|
|
21
|
+
|
|
22
|
+
function _getModel() {
|
|
23
|
+
return _model;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function _getDeviceType() {
|
|
27
|
+
return _deviceType;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _getUniqueId() {
|
|
31
|
+
return _uniqueId;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Provide the public interface methods for accessing the values
|
|
35
|
+
_self.getModel = _getModel;
|
|
36
|
+
_self.getDeviceType = _getDeviceType;
|
|
37
|
+
_self.getUniqueId = _getUniqueId
|
|
38
|
+
|
|
39
|
+
// Provide setters (for testing) and re-use the functions for minification
|
|
40
|
+
objDefineAccessors(_self, DEVICE_MODEL, _getModel, (value) => _model = value);
|
|
41
|
+
objDefineAccessors(_self, DEVICE_TYPE, _getDeviceType, (value) => _deviceType = value);
|
|
42
|
+
objDefineAccessors(_self, UNIQUE_ID, _getUniqueId, (value) => _uniqueId = value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import DeviceInfo from "react-native-device-info";
|
|
5
|
+
import { IDeviceInfoModule } from "../Interfaces/IDeviceInfoModule";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the "react-native-device-info" as the Device Info Module
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export function getReactNativeDeviceInfo(): IDeviceInfoModule {
|
|
12
|
+
return DeviceInfo;
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Interface to abstract how the plugin can access the Device Info, this is a stripped
|
|
6
|
+
* down version of the "react-native-device-info" interface and is mostly supplied for
|
|
7
|
+
* testing.
|
|
8
|
+
*/
|
|
9
|
+
export interface IDeviceInfoModule {
|
|
10
|
+
/**
|
|
11
|
+
* Returns the Device Model
|
|
12
|
+
*/
|
|
13
|
+
getModel: () => string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Returns the device type
|
|
17
|
+
*/
|
|
18
|
+
getDeviceType: () => string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the unique Id for the device, to support both the current version and previous
|
|
22
|
+
* versions react-native-device-info, this may return either a `string` or `Promise<string>`,
|
|
23
|
+
* when a promise is returned the plugin will "wait" for the promise to `resolve` or `reject`
|
|
24
|
+
* before processing any events. This WILL cause telemetry to be BLOCKED until either of these
|
|
25
|
+
* states, so when returning a Promise it MUST `resolve` or `reject` it can't just never resolve.
|
|
26
|
+
* There is a default timeout configured via `uniqueIdPromiseTimeout` to automatically unblock
|
|
27
|
+
* event processing when this issue occurs.
|
|
28
|
+
*/
|
|
29
|
+
getUniqueId: () => Promise<string> | string;
|
|
30
|
+
}
|
|
31
|
+
|