@microsoft/applicationinsights-channel-js 2.7.5-nightly.2204-03 → 2.7.5-nightly.2204-23
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-channel-js.integrity.json +9 -9
- package/browser/applicationinsights-channel-js.js +438 -1212
- package/browser/applicationinsights-channel-js.js.map +1 -1
- package/browser/applicationinsights-channel-js.min.js +2 -2
- package/browser/applicationinsights-channel-js.min.js.map +1 -1
- package/dist/applicationinsights-channel-js.api.json +89 -32
- package/dist/applicationinsights-channel-js.api.md +2 -0
- package/dist/applicationinsights-channel-js.d.ts +2 -1
- package/dist/applicationinsights-channel-js.js +438 -1212
- package/dist/applicationinsights-channel-js.js.map +1 -1
- package/dist/applicationinsights-channel-js.min.js +2 -2
- package/dist/applicationinsights-channel-js.min.js.map +1 -1
- package/dist/applicationinsights-channel-js.rollup.d.ts +2 -1
- package/dist-esm/EnvelopeCreator.js +2 -2
- package/dist-esm/EnvelopeCreator.js.map +1 -1
- package/dist-esm/Interfaces.js +1 -1
- package/dist-esm/Offline.js +65 -77
- package/dist-esm/Offline.js.map +1 -1
- package/dist-esm/SendBuffer.js +1 -1
- package/dist-esm/Sender.js +62 -72
- package/dist-esm/Sender.js.map +1 -1
- package/dist-esm/Serializer.js +1 -1
- package/dist-esm/TelemetryProcessors/Sample.js +3 -3
- package/dist-esm/TelemetryProcessors/Sample.js.map +1 -1
- package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.js +1 -1
- package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.js +1 -1
- package/dist-esm/applicationinsights-channel-js.js +1 -1
- package/package.json +5 -5
- package/src/EnvelopeCreator.ts +2 -2
- package/src/Offline.ts +76 -88
- package/src/Sender.ts +90 -83
- package/src/Serializer.ts +8 -4
- package/src/TelemetryProcessors/Sample.ts +1 -1
- package/src/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.ts +1 -3
- package/types/Offline.d.ts +11 -8
- package/types/Sender.d.ts +1 -0
- package/types/TelemetryProcessors/Sample.d.ts +2 -2
- package/types/tsdoc-metadata.json +1 -1
package/dist-esm/Serializer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Channel, 2.7.5-nightly.2204-
|
|
2
|
+
* Application Insights JavaScript SDK - Channel, 2.7.5-nightly.2204-23
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
import { LoggingSeverity, _InternalMessageId, getJSON, objForEachKey, isFunction, isObject, isArray } from "@microsoft/applicationinsights-core-js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Channel, 2.7.5-nightly.2204-
|
|
2
|
+
* Application Insights JavaScript SDK - Channel, 2.7.5-nightly.2204-23
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -20,8 +20,8 @@ var Sample = /** @class */ (function () {
|
|
|
20
20
|
this.samplingScoreGenerator = new SamplingScoreGenerator();
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
* Determines if an envelope is sampled in (i.e. will be sent) or not (i.e. will be dropped).
|
|
24
|
+
*/
|
|
25
25
|
Sample.prototype.isSampledIn = function (envelope) {
|
|
26
26
|
var samplingPercentage = this.sampleRate; // 0 - 100
|
|
27
27
|
var isSampledIn = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sample.js.map","sources":["Sample.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { SamplingScoreGenerator } from \"./SamplingScoreGenerators/SamplingScoreGenerator\";\r\nimport { Metric } from \"@microsoft/applicationinsights-common\";\r\nimport { _InternalMessageId, LoggingSeverity, safeGetLogger } from \"@microsoft/applicationinsights-core-js\";\r\nvar Sample = /** @class */ (function () {\r\n function Sample(sampleRate, logger) {\r\n // We're using 32 bit math, hence max value is (2^31 - 1)\r\n this.INT_MAX_VALUE = 2147483647;\r\n var _logger = logger || safeGetLogger(null);\r\n if (sampleRate > 100 || sampleRate < 0) {\r\n _logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.SampleRateOutOfRange, \"Sampling rate is out of range (0..100). Sampling will be disabled, you may be sending too much data which may affect your AI service level.\", { samplingRate: sampleRate }, true);\r\n sampleRate = 100;\r\n }\r\n this.sampleRate = sampleRate;\r\n this.samplingScoreGenerator = new SamplingScoreGenerator();\r\n }\r\n /**\r\n
|
|
1
|
+
{"version":3,"file":"Sample.js.map","sources":["Sample.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { SamplingScoreGenerator } from \"./SamplingScoreGenerators/SamplingScoreGenerator\";\r\nimport { Metric } from \"@microsoft/applicationinsights-common\";\r\nimport { _InternalMessageId, LoggingSeverity, safeGetLogger } from \"@microsoft/applicationinsights-core-js\";\r\nvar Sample = /** @class */ (function () {\r\n function Sample(sampleRate, logger) {\r\n // We're using 32 bit math, hence max value is (2^31 - 1)\r\n this.INT_MAX_VALUE = 2147483647;\r\n var _logger = logger || safeGetLogger(null);\r\n if (sampleRate > 100 || sampleRate < 0) {\r\n _logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.SampleRateOutOfRange, \"Sampling rate is out of range (0..100). Sampling will be disabled, you may be sending too much data which may affect your AI service level.\", { samplingRate: sampleRate }, true);\r\n sampleRate = 100;\r\n }\r\n this.sampleRate = sampleRate;\r\n this.samplingScoreGenerator = new SamplingScoreGenerator();\r\n }\r\n /**\r\n * Determines if an envelope is sampled in (i.e. will be sent) or not (i.e. will be dropped).\r\n */\r\n Sample.prototype.isSampledIn = function (envelope) {\r\n var samplingPercentage = this.sampleRate; // 0 - 100\r\n var isSampledIn = false;\r\n if (samplingPercentage === null || samplingPercentage === undefined || samplingPercentage >= 100) {\r\n return true;\r\n }\r\n else if (envelope.baseType === Metric.dataType) {\r\n // exclude MetricData telemetry from sampling\r\n return true;\r\n }\r\n isSampledIn = this.samplingScoreGenerator.getSamplingScore(envelope) < samplingPercentage;\r\n return isSampledIn;\r\n };\r\n return Sample;\r\n}());\r\nexport { Sample };\r\n//# sourceMappingURL=Sample.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;AACA;AACA;AACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/applicationinsights-channel-js",
|
|
3
|
-
"version": "2.7.5-nightly.2204-
|
|
3
|
+
"version": "2.7.5-nightly.2204-23",
|
|
4
4
|
"description": "Microsoft Application Insights JavaScript SDK Channel",
|
|
5
5
|
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
|
|
6
6
|
"author": "Microsoft Application Insights Team",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@rollup/plugin-commonjs": "^18.0.0",
|
|
36
36
|
"@rollup/plugin-node-resolve": "^11.2.1",
|
|
37
37
|
"@rollup/plugin-replace": "^2.3.3",
|
|
38
|
-
"rollup-plugin-cleanup": "
|
|
38
|
+
"rollup-plugin-cleanup": "3.2.1",
|
|
39
39
|
"rollup": "^2.32.0",
|
|
40
40
|
"typescript": "^4.3.4",
|
|
41
41
|
"tslib": "^2.0.0",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"tslib": "*"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@microsoft/dynamicproto-js": "^1.1.
|
|
48
|
+
"@microsoft/dynamicproto-js": "^1.1.5",
|
|
49
49
|
"@microsoft/applicationinsights-shims": "2.0.1",
|
|
50
|
-
"@microsoft/applicationinsights-core-js": "2.7.5-nightly.2204-
|
|
51
|
-
"@microsoft/applicationinsights-common": "2.7.5-nightly.2204-
|
|
50
|
+
"@microsoft/applicationinsights-core-js": "2.7.5-nightly.2204-23",
|
|
51
|
+
"@microsoft/applicationinsights-common": "2.7.5-nightly.2204-23"
|
|
52
52
|
},
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"publishConfig": {
|
package/src/EnvelopeCreator.ts
CHANGED
|
@@ -175,7 +175,7 @@ function EnvelopeCreatorInit(logger: IDiagnosticLogger, telemetryItem: ITelemetr
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
export const EnvelopeCreator = {
|
|
178
|
-
Version: "2.7.5-nightly.2204-
|
|
178
|
+
Version: "2.7.5-nightly.2204-23"
|
|
179
179
|
};
|
|
180
180
|
|
|
181
181
|
export function DependencyEnvelopeCreator(logger: IDiagnosticLogger, telemetryItem: ITelemetryItem, customUndefinedValue?: any): IEnvelope {
|
|
@@ -279,7 +279,7 @@ export function PageViewEnvelopeCreator(logger: IDiagnosticLogger, telemetryItem
|
|
|
279
279
|
|
|
280
280
|
const bd = telemetryItem[strBaseData] as IPageViewTelemetryInternal;
|
|
281
281
|
|
|
282
|
-
|
|
282
|
+
// special case: pageview.id is grabbed from current operation id. Analytics plugin is decoupled from properties plugin, so this is done here instead. This can be made a default telemetry intializer instead if needed to be decoupled from channel
|
|
283
283
|
let currentContextId;
|
|
284
284
|
if (((telemetryItem.ext || {}).trace || {}).traceID) {
|
|
285
285
|
currentContextId = telemetryItem.ext.trace.traceID;
|
package/src/Offline.ts
CHANGED
|
@@ -1,104 +1,92 @@
|
|
|
1
|
-
import { getWindow, getDocument, getNavigator, isUndefined, isNullOrUndefined,
|
|
2
|
-
|
|
3
|
-
export interface IOfflineListener {
|
|
4
|
-
isOnline: () => boolean;
|
|
5
|
-
isListening: () => boolean;
|
|
6
|
-
unload: () => void;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function _disableEvents(target: any, evtNamespace: string | string[]) {
|
|
10
|
-
eventOff(target, null, null, evtNamespace);
|
|
11
|
-
}
|
|
1
|
+
import { getWindow, getDocument, getNavigator, isUndefined, isNullOrUndefined, attachEvent } from "@microsoft/applicationinsights-core-js";
|
|
2
|
+
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
12
3
|
|
|
13
4
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
5
|
+
* @description Monitors browser for offline events
|
|
6
|
+
* @export default - Offline: Static instance of OfflineListener
|
|
7
|
+
* @class OfflineListener
|
|
16
8
|
*/
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
9
|
+
export class OfflineListener {
|
|
10
|
+
public static Offline = new OfflineListener;
|
|
11
|
+
public isListening: boolean;
|
|
12
|
+
|
|
13
|
+
constructor() {
|
|
14
|
+
let _window = getWindow();
|
|
15
|
+
let _document = getDocument();
|
|
16
|
+
let isListening = false;
|
|
17
|
+
let _onlineStatus: boolean = true;
|
|
18
|
+
|
|
19
|
+
dynamicProto(OfflineListener, this, (_self) => {
|
|
20
|
+
try {
|
|
21
|
+
if (_window) {
|
|
22
|
+
if (attachEvent(_window, "online", _setOnline)) {
|
|
23
|
+
attachEvent(_window, "offline", _setOffline);
|
|
24
|
+
isListening = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (_document) {
|
|
29
|
+
// Also attach to the document.body or document
|
|
30
|
+
let target:any = _document.body || _document;
|
|
31
|
+
|
|
32
|
+
if (!isUndefined(target.ononline)) {
|
|
33
|
+
target.ononline = _setOnline;
|
|
34
|
+
target.onoffline = _setOffline;
|
|
35
|
+
isListening = true;
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
}
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
if (isListening) {
|
|
41
|
+
// We are listening to events so lets set the current status rather than assuming we are online #1538
|
|
42
|
+
var _navigator = getNavigator(); // Gets the window.navigator or workerNavigator depending on the global
|
|
43
|
+
if (_navigator && !isNullOrUndefined(_navigator.onLine)) { // navigator.onLine is undefined in react-native
|
|
44
|
+
_onlineStatus = _navigator.onLine;
|
|
45
|
+
}
|
|
36
46
|
}
|
|
47
|
+
} catch (e) {
|
|
48
|
+
|
|
49
|
+
// this makes react-native less angry
|
|
50
|
+
isListening = false;
|
|
37
51
|
}
|
|
38
|
-
|
|
52
|
+
|
|
53
|
+
_self.isListening = isListening;
|
|
54
|
+
|
|
55
|
+
_self.isOnline = (): boolean => {
|
|
56
|
+
let result = true;
|
|
57
|
+
var _navigator = getNavigator();
|
|
58
|
+
if (isListening) {
|
|
59
|
+
result = _onlineStatus
|
|
60
|
+
} else if (_navigator && !isNullOrUndefined(_navigator.onLine)) { // navigator.onLine is undefined in react-native
|
|
61
|
+
result = _navigator.onLine;
|
|
62
|
+
}
|
|
39
63
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} catch (e) {
|
|
47
|
-
// this makes react-native less angry
|
|
48
|
-
_isListening = false;
|
|
49
|
-
}
|
|
64
|
+
return result;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
_self.isOffline = (): boolean => {
|
|
68
|
+
return !_self.isOnline();
|
|
69
|
+
};
|
|
50
70
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (target) {
|
|
54
|
-
enabled = eventOn(target, "online", _setOnline, _evtNamespace);
|
|
55
|
-
if (enabled) {
|
|
56
|
-
eventOn(target, "offline", _setOffline, _evtNamespace);
|
|
71
|
+
function _setOnline() {
|
|
72
|
+
_onlineStatus = true;
|
|
57
73
|
}
|
|
58
|
-
}
|
|
59
74
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
_onlineStatus = true;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function _setOffline() {
|
|
68
|
-
_onlineStatus = false;
|
|
75
|
+
function _setOffline() {
|
|
76
|
+
_onlineStatus = false;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
69
79
|
}
|
|
70
80
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
result = _onlineStatus
|
|
75
|
-
} else if (_navigator && !isNullOrUndefined(_navigator.onLine)) { // navigator.onLine is undefined in react-native
|
|
76
|
-
result = _navigator.onLine;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return result;
|
|
81
|
+
public isOnline(): boolean {
|
|
82
|
+
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
83
|
+
return false;
|
|
80
84
|
}
|
|
81
85
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
_disableEvents(win, _evtNamespace);
|
|
86
|
-
|
|
87
|
-
if (_document) {
|
|
88
|
-
// Also attach to the document.body or document
|
|
89
|
-
let target:any = _document.body || _document;
|
|
90
|
-
if (!isUndefined(target.ononline)) {
|
|
91
|
-
_disableEvents(target, _evtNamespace);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
_isListening = false;
|
|
96
|
-
}
|
|
86
|
+
public isOffline(): boolean {
|
|
87
|
+
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
88
|
+
return false;
|
|
97
89
|
}
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
isOnline: _isOnline,
|
|
101
|
-
isListening: () => _isListening,
|
|
102
|
-
unload: _unload
|
|
103
|
-
};
|
|
104
90
|
}
|
|
91
|
+
|
|
92
|
+
export const Offline = OfflineListener.Offline;
|