@microsoft/applicationinsights-properties-js 2.8.4-nightly.2205-09 → 2.8.5-nightly.2206-02

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.
Files changed (37) hide show
  1. package/browser/applicationinsights-properties-js.integrity.json +9 -9
  2. package/browser/applicationinsights-properties-js.js +571 -499
  3. package/browser/applicationinsights-properties-js.js.map +1 -1
  4. package/browser/applicationinsights-properties-js.min.js +2 -2
  5. package/browser/applicationinsights-properties-js.min.js.map +1 -1
  6. package/dist/applicationinsights-properties-js.api.json +45 -1
  7. package/dist/applicationinsights-properties-js.api.md +4 -1
  8. package/dist/applicationinsights-properties-js.d.ts +4 -2
  9. package/dist/applicationinsights-properties-js.js +571 -499
  10. package/dist/applicationinsights-properties-js.js.map +1 -1
  11. package/dist/applicationinsights-properties-js.min.js +2 -2
  12. package/dist/applicationinsights-properties-js.min.js.map +1 -1
  13. package/dist/applicationinsights-properties-js.rollup.d.ts +4 -2
  14. package/dist-esm/Context/Application.js +1 -1
  15. package/dist-esm/Context/Device.js +1 -1
  16. package/dist-esm/Context/Internal.js +2 -2
  17. package/dist-esm/Context/Internal.js.map +1 -1
  18. package/dist-esm/Context/Location.js +1 -1
  19. package/dist-esm/Context/Session.js +1 -1
  20. package/dist-esm/Context/TelemetryTrace.js +3 -4
  21. package/dist-esm/Context/TelemetryTrace.js.map +1 -1
  22. package/dist-esm/Context/User.js +1 -1
  23. package/dist-esm/Interfaces/IPropTelemetryContext.js +1 -1
  24. package/dist-esm/Interfaces/ITelemetryConfig.js +1 -1
  25. package/dist-esm/PropertiesPlugin.js +28 -6
  26. package/dist-esm/PropertiesPlugin.js.map +1 -1
  27. package/dist-esm/TelemetryContext.js +11 -3
  28. package/dist-esm/TelemetryContext.js.map +1 -1
  29. package/dist-esm/applicationinsights-properties-js.js +1 -1
  30. package/package.json +3 -3
  31. package/src/Context/Internal.ts +1 -1
  32. package/src/Context/TelemetryTrace.ts +3 -3
  33. package/src/PropertiesPlugin.ts +33 -7
  34. package/src/TelemetryContext.ts +12 -3
  35. package/types/Context/TelemetryTrace.d.ts +1 -0
  36. package/types/TelemetryContext.d.ts +2 -2
  37. package/types/tsdoc-metadata.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights properties plugin, 2.8.4-nightly.2205-09
2
+ * Microsoft Application Insights properties plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -20,6 +20,7 @@ import { IConfig } from '@microsoft/applicationinsights-common';
20
20
  import { IConfiguration } from '@microsoft/applicationinsights-core-js';
21
21
  import { IDevice } from '@microsoft/applicationinsights-common';
22
22
  import { IDiagnosticLogger } from '@microsoft/applicationinsights-core-js';
23
+ import { IDistributedTraceContext } from '@microsoft/applicationinsights-core-js';
23
24
  import { IInternal } from '@microsoft/applicationinsights-common';
24
25
  import { ILocation } from '@microsoft/applicationinsights-common';
25
26
  import { IOperatingSystem } from '@microsoft/applicationinsights-common';
@@ -141,7 +142,7 @@ export declare class TelemetryContext implements IPropTelemetryContext {
141
142
  web: IWeb;
142
143
  appId: () => string;
143
144
  getSessionId: () => string;
144
- constructor(core: IAppInsightsCore, defaultConfig: ITelemetryConfig);
145
+ constructor(core: IAppInsightsCore, defaultConfig: ITelemetryConfig, previousTraceCtx?: IDistributedTraceContext);
145
146
  applySessionContext(evt: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
146
147
  applyOperatingSystemContxt(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
147
148
  applyApplicationContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
@@ -158,6 +159,7 @@ export declare class TelemetryTrace implements ITelemetryTrace {
158
159
  traceID: string;
159
160
  parentID: string;
160
161
  traceState: ITraceState;
162
+ traceFlags: number;
161
163
  name: string;
162
164
  constructor(id?: string, parentId?: string, name?: string, logger?: IDiagnosticLogger);
163
165
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,10 +1,10 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
 
7
- var Version = "2.8.4-nightly.2205-09";
7
+ var Version = "2.8.5-nightly.2206-02";
8
8
  var Internal = /** @class */ (function () {
9
9
  /**
10
10
  * Constructs a new instance of the internal telemetry data class.
@@ -1 +1 @@
1
- {"version":3,"file":"Internal.js.map","sources":["Internal.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nvar Version = \"2.8.4-nightly.2205-09\";\r\nvar Internal = /** @class */ (function () {\r\n /**\r\n * Constructs a new instance of the internal telemetry data class.\r\n */\r\n function Internal(config) {\r\n this.sdkVersion = (config.sdkExtension && config.sdkExtension() ? config.sdkExtension() + \"_\" : \"\") + \"javascript:\" + Version;\r\n }\r\n return Internal;\r\n}());\r\nexport { Internal };\r\n//# sourceMappingURL=Internal.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"Internal.js.map","sources":["Internal.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nvar Version = \"2.8.5-nightly.2206-02\";\r\nvar Internal = /** @class */ (function () {\r\n /**\r\n * Constructs a new instance of the internal telemetry data class.\r\n */\r\n function Internal(config) {\r\n this.sdkVersion = (config.sdkExtension && config.sdkExtension() ? config.sdkExtension() + \"_\" : \"\") + \"javascript:\" + Version;\r\n }\r\n return Internal;\r\n}());\r\nexport { Internal };\r\n//# sourceMappingURL=Internal.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -11,12 +11,11 @@ var TelemetryTrace = /** @class */ (function () {
11
11
  var _self = this;
12
12
  _self.traceID = id || generateW3CId();
13
13
  _self.parentID = parentId;
14
- _self.name = name;
15
14
  var location = getLocation();
16
15
  if (!name && location && location.pathname) {
17
- _self.name = location.pathname;
16
+ name = location.pathname;
18
17
  }
19
- _self.name = dataSanitizeString(logger, _self.name);
18
+ _self.name = dataSanitizeString(logger, name);
20
19
  }
21
20
  return TelemetryTrace;
22
21
  }());
@@ -1 +1 @@
1
- {"version":3,"file":"TelemetryTrace.js.map","sources":["TelemetryTrace.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { dataSanitizeString } from \"@microsoft/applicationinsights-common\";\r\nimport { generateW3CId, getLocation } from \"@microsoft/applicationinsights-core-js\";\r\nvar TelemetryTrace = /** @class */ (function () {\r\n function TelemetryTrace(id, parentId, name, logger) {\r\n var _self = this;\r\n _self.traceID = id || generateW3CId();\r\n _self.parentID = parentId;\r\n _self.name = name;\r\n var location = getLocation();\r\n if (!name && location && location.pathname) {\r\n _self.name = location.pathname;\r\n }\r\n _self.name = dataSanitizeString(logger, _self.name);\r\n }\r\n return TelemetryTrace;\r\n}());\r\nexport { TelemetryTrace };\r\n//# sourceMappingURL=TelemetryTrace.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"TelemetryTrace.js.map","sources":["TelemetryTrace.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { dataSanitizeString } from \"@microsoft/applicationinsights-common\";\r\nimport { generateW3CId, getLocation } from \"@microsoft/applicationinsights-core-js\";\r\nvar TelemetryTrace = /** @class */ (function () {\r\n function TelemetryTrace(id, parentId, name, logger) {\r\n var _self = this;\r\n _self.traceID = id || generateW3CId();\r\n _self.parentID = parentId;\r\n var location = getLocation();\r\n if (!name && location && location.pathname) {\r\n name = location.pathname;\r\n }\r\n _self.name = dataSanitizeString(logger, name);\r\n }\r\n return TelemetryTrace;\r\n}());\r\nexport { TelemetryTrace };\r\n//# sourceMappingURL=TelemetryTrace.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  /**
@@ -10,16 +10,18 @@ import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
10
10
  import dynamicProto from "@microsoft/dynamicproto-js";
11
11
  import { BaseTelemetryPlugin, isNullOrUndefined, _InternalLogMessage, getNavigator, objForEachKey, getSetValue, _logInternalMessage } from "@microsoft/applicationinsights-core-js";
12
12
  import { TelemetryContext } from "./TelemetryContext";
13
- import { PageView, BreezeChannelIdentifier, PropertiesPluginIdentifier, getExtensionByName } from "@microsoft/applicationinsights-common";
13
+ import { PageView, BreezeChannelIdentifier, PropertiesPluginIdentifier, createDistributedTraceContextFromTrace } from "@microsoft/applicationinsights-common";
14
14
  var PropertiesPlugin = /** @class */ (function (_super) {
15
15
  __extends(PropertiesPlugin, _super);
16
16
  function PropertiesPlugin() {
17
17
  var _this = _super.call(this) || this;
18
18
  _this.priority = 110;
19
19
  _this.identifier = PropertiesPluginIdentifier;
20
- var _breezeChannel; // optional. If exists, grab appId from it
21
20
  var _extensionConfig;
21
+ var _distributedTraceCtx;
22
+ var _previousTraceCtx;
22
23
  dynamicProto(PropertiesPlugin, _this, function (_self, _base) {
24
+ _initDefaults();
23
25
  _self.initialize = function (config, core, extensions, pluginChain) {
24
26
  _base.initialize(config, core, extensions, pluginChain);
25
27
  var ctx = _self._getTelCtx();
@@ -29,9 +31,14 @@ var PropertiesPlugin = /** @class */ (function (_super) {
29
31
  objForEachKey(defaultConfig, function (field, value) {
30
32
  _extensionConfig[field] = function () { return ctx.getConfig(identifier, field, value()); };
31
33
  });
32
- _self.context = new TelemetryContext(core, _extensionConfig);
33
- _breezeChannel = getExtensionByName(extensions, BreezeChannelIdentifier);
34
- _self.context.appId = function () { return _breezeChannel ? _breezeChannel["_appId"] : null; };
34
+ _previousTraceCtx = core.getTraceCtx(false);
35
+ _self.context = new TelemetryContext(core, _extensionConfig, _previousTraceCtx);
36
+ _distributedTraceCtx = createDistributedTraceContextFromTrace(_self.context.telemetryTrace, _previousTraceCtx);
37
+ core.setTraceCtx(_distributedTraceCtx);
38
+ _self.context.appId = function () {
39
+ var breezeChannel = core.getPlugin(BreezeChannelIdentifier);
40
+ return breezeChannel ? breezeChannel.plugin["_appId"] : null;
41
+ };
35
42
  // Test hook to allow accessing the internal values -- explicitly not defined as an available property on the class
36
43
  _self["_extConfig"] = _extensionConfig;
37
44
  };
@@ -69,6 +76,21 @@ var PropertiesPlugin = /** @class */ (function (_super) {
69
76
  _self.processNext(event, itemCtx);
70
77
  }
71
78
  };
79
+ _self._doTeardown = function (unloadCtx, unloadState) {
80
+ var core = (unloadCtx || {}).core();
81
+ if (core && core.getTraceCtx) {
82
+ var traceCtx = core.getTraceCtx(false);
83
+ if (traceCtx === _distributedTraceCtx) {
84
+ core.setTraceCtx(_previousTraceCtx);
85
+ }
86
+ }
87
+ _initDefaults();
88
+ };
89
+ function _initDefaults() {
90
+ _extensionConfig = null;
91
+ _distributedTraceCtx = null;
92
+ _previousTraceCtx = null;
93
+ }
72
94
  function _processTelemetryInternal(evt, itemCtx) {
73
95
  // Set Part A fields
74
96
  getSetValue(evt, "tags", []);
@@ -1 +1 @@
1
- {"version":3,"file":"PropertiesPlugin.js.map","sources":["PropertiesPlugin.js"],"sourcesContent":["/**\r\n * PropertiesPlugin.ts\r\n * @copyright Microsoft 2018\r\n */\r\nimport { __extends } from \"tslib\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { BaseTelemetryPlugin, isNullOrUndefined, _InternalLogMessage, getNavigator, objForEachKey, getSetValue, _logInternalMessage } from \"@microsoft/applicationinsights-core-js\";\r\nimport { TelemetryContext } from \"./TelemetryContext\";\r\nimport { PageView, BreezeChannelIdentifier, PropertiesPluginIdentifier, getExtensionByName } from \"@microsoft/applicationinsights-common\";\r\nvar PropertiesPlugin = /** @class */ (function (_super) {\r\n __extends(PropertiesPlugin, _super);\r\n function PropertiesPlugin() {\r\n var _this = _super.call(this) || this;\r\n _this.priority = 110;\r\n _this.identifier = PropertiesPluginIdentifier;\r\n var _breezeChannel; // optional. If exists, grab appId from it\r\n var _extensionConfig;\r\n dynamicProto(PropertiesPlugin, _this, function (_self, _base) {\r\n _self.initialize = function (config, core, extensions, pluginChain) {\r\n _base.initialize(config, core, extensions, pluginChain);\r\n var ctx = _self._getTelCtx();\r\n var identifier = _self.identifier;\r\n var defaultConfig = PropertiesPlugin.getDefaultConfig();\r\n _extensionConfig = _extensionConfig || {};\r\n objForEachKey(defaultConfig, function (field, value) {\r\n _extensionConfig[field] = function () { return ctx.getConfig(identifier, field, value()); };\r\n });\r\n _self.context = new TelemetryContext(core, _extensionConfig);\r\n _breezeChannel = getExtensionByName(extensions, BreezeChannelIdentifier);\r\n _self.context.appId = function () { return _breezeChannel ? _breezeChannel[\"_appId\"] : null; };\r\n // Test hook to allow accessing the internal values -- explicitly not defined as an available property on the class\r\n _self[\"_extConfig\"] = _extensionConfig;\r\n };\r\n /**\r\n * Add Part A fields to the event\r\n * @param event The event that needs to be processed\r\n */\r\n _self.processTelemetry = function (event, itemCtx) {\r\n if (isNullOrUndefined(event)) {\r\n // TODO(barustum): throw an internal event once we have support for internal logging\r\n }\r\n else {\r\n itemCtx = _self._getTelCtx(itemCtx);\r\n // If the envelope is PageView, reset the internal message count so that we can send internal telemetry for the new page.\r\n if (event.name === PageView.envelopeType) {\r\n itemCtx.diagLog().resetInternalMessageCount();\r\n }\r\n var theContext = (_self.context || {});\r\n if (theContext.session) {\r\n // If customer did not provide custom session id update the session manager\r\n if (typeof _self.context.session.id !== \"string\" && theContext.sessionManager) {\r\n theContext.sessionManager.update();\r\n }\r\n }\r\n var userCtx = theContext.user;\r\n if (userCtx && !userCtx.isUserCookieSet) {\r\n userCtx.update(theContext.user.id);\r\n }\r\n _processTelemetryInternal(event, itemCtx);\r\n if (userCtx && userCtx.isNewUser) {\r\n userCtx.isNewUser = false;\r\n var message = new _InternalLogMessage(72 /* _eInternalMessageId.SendBrowserInfoOnUserInit */, ((getNavigator() || {}).userAgent || \"\"));\r\n _logInternalMessage(itemCtx.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, message);\r\n }\r\n _self.processNext(event, itemCtx);\r\n }\r\n };\r\n function _processTelemetryInternal(evt, itemCtx) {\r\n // Set Part A fields\r\n getSetValue(evt, \"tags\", []);\r\n getSetValue(evt, \"ext\", {});\r\n var ctx = _self.context;\r\n ctx.applySessionContext(evt, itemCtx);\r\n ctx.applyApplicationContext(evt, itemCtx);\r\n ctx.applyDeviceContext(evt, itemCtx);\r\n ctx.applyOperationContext(evt, itemCtx);\r\n ctx.applyUserContext(evt, itemCtx);\r\n ctx.applyOperatingSystemContxt(evt, itemCtx);\r\n ctx.applyWebContext(evt, itemCtx);\r\n ctx.applyLocationContext(evt, itemCtx); // legacy tags\r\n ctx.applyInternalContext(evt, itemCtx); // legacy tags\r\n ctx.cleanUp(evt, itemCtx);\r\n }\r\n });\r\n return _this;\r\n }\r\n PropertiesPlugin.getDefaultConfig = function () {\r\n var defaultConfig = {\r\n instrumentationKey: function () { return undefined; },\r\n accountId: function () { return null; },\r\n sessionRenewalMs: function () { return 30 * 60 * 1000; },\r\n samplingPercentage: function () { return 100; },\r\n sessionExpirationMs: function () { return 24 * 60 * 60 * 1000; },\r\n cookieDomain: function () { return null; },\r\n sdkExtension: function () { return null; },\r\n isBrowserLinkTrackingEnabled: function () { return false; },\r\n appId: function () { return null; },\r\n getSessionId: function () { return null; },\r\n namePrefix: function () { return undefined; },\r\n sessionCookiePostfix: function () { return undefined; },\r\n userCookiePostfix: function () { return undefined; },\r\n idLength: function () { return 22; },\r\n getNewId: function () { return null; }\r\n };\r\n return defaultConfig;\r\n };\r\n PropertiesPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Add Part A fields to the event\r\n * @param event The event that needs to be processed\r\n */\r\n PropertiesPlugin.prototype.processTelemetry = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return PropertiesPlugin;\r\n}(BaseTelemetryPlugin));\r\nexport default PropertiesPlugin;\r\n//# sourceMappingURL=PropertiesPlugin.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;gEASM;AACN;AACA;AACA;AACA"}
1
+ {"version":3,"file":"PropertiesPlugin.js.map","sources":["PropertiesPlugin.js"],"sourcesContent":["/**\r\n * PropertiesPlugin.ts\r\n * @copyright Microsoft 2018\r\n */\r\nimport { __extends } from \"tslib\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { BaseTelemetryPlugin, isNullOrUndefined, _InternalLogMessage, getNavigator, objForEachKey, getSetValue, _logInternalMessage } from \"@microsoft/applicationinsights-core-js\";\r\nimport { TelemetryContext } from \"./TelemetryContext\";\r\nimport { PageView, BreezeChannelIdentifier, PropertiesPluginIdentifier, createDistributedTraceContextFromTrace } from \"@microsoft/applicationinsights-common\";\r\nvar PropertiesPlugin = /** @class */ (function (_super) {\r\n __extends(PropertiesPlugin, _super);\r\n function PropertiesPlugin() {\r\n var _this = _super.call(this) || this;\r\n _this.priority = 110;\r\n _this.identifier = PropertiesPluginIdentifier;\r\n var _extensionConfig;\r\n var _distributedTraceCtx;\r\n var _previousTraceCtx;\r\n dynamicProto(PropertiesPlugin, _this, function (_self, _base) {\r\n _initDefaults();\r\n _self.initialize = function (config, core, extensions, pluginChain) {\r\n _base.initialize(config, core, extensions, pluginChain);\r\n var ctx = _self._getTelCtx();\r\n var identifier = _self.identifier;\r\n var defaultConfig = PropertiesPlugin.getDefaultConfig();\r\n _extensionConfig = _extensionConfig || {};\r\n objForEachKey(defaultConfig, function (field, value) {\r\n _extensionConfig[field] = function () { return ctx.getConfig(identifier, field, value()); };\r\n });\r\n _previousTraceCtx = core.getTraceCtx(false);\r\n _self.context = new TelemetryContext(core, _extensionConfig, _previousTraceCtx);\r\n _distributedTraceCtx = createDistributedTraceContextFromTrace(_self.context.telemetryTrace, _previousTraceCtx);\r\n core.setTraceCtx(_distributedTraceCtx);\r\n _self.context.appId = function () {\r\n var breezeChannel = core.getPlugin(BreezeChannelIdentifier);\r\n return breezeChannel ? breezeChannel.plugin[\"_appId\"] : null;\r\n };\r\n // Test hook to allow accessing the internal values -- explicitly not defined as an available property on the class\r\n _self[\"_extConfig\"] = _extensionConfig;\r\n };\r\n /**\r\n * Add Part A fields to the event\r\n * @param event The event that needs to be processed\r\n */\r\n _self.processTelemetry = function (event, itemCtx) {\r\n if (isNullOrUndefined(event)) {\r\n // TODO(barustum): throw an internal event once we have support for internal logging\r\n }\r\n else {\r\n itemCtx = _self._getTelCtx(itemCtx);\r\n // If the envelope is PageView, reset the internal message count so that we can send internal telemetry for the new page.\r\n if (event.name === PageView.envelopeType) {\r\n itemCtx.diagLog().resetInternalMessageCount();\r\n }\r\n var theContext = (_self.context || {});\r\n if (theContext.session) {\r\n // If customer did not provide custom session id update the session manager\r\n if (typeof _self.context.session.id !== \"string\" && theContext.sessionManager) {\r\n theContext.sessionManager.update();\r\n }\r\n }\r\n var userCtx = theContext.user;\r\n if (userCtx && !userCtx.isUserCookieSet) {\r\n userCtx.update(theContext.user.id);\r\n }\r\n _processTelemetryInternal(event, itemCtx);\r\n if (userCtx && userCtx.isNewUser) {\r\n userCtx.isNewUser = false;\r\n var message = new _InternalLogMessage(72 /* _eInternalMessageId.SendBrowserInfoOnUserInit */, ((getNavigator() || {}).userAgent || \"\"));\r\n _logInternalMessage(itemCtx.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, message);\r\n }\r\n _self.processNext(event, itemCtx);\r\n }\r\n };\r\n _self._doTeardown = function (unloadCtx, unloadState) {\r\n var core = (unloadCtx || {}).core();\r\n if (core && core.getTraceCtx) {\r\n var traceCtx = core.getTraceCtx(false);\r\n if (traceCtx === _distributedTraceCtx) {\r\n core.setTraceCtx(_previousTraceCtx);\r\n }\r\n }\r\n _initDefaults();\r\n };\r\n function _initDefaults() {\r\n _extensionConfig = null;\r\n _distributedTraceCtx = null;\r\n _previousTraceCtx = null;\r\n }\r\n function _processTelemetryInternal(evt, itemCtx) {\r\n // Set Part A fields\r\n getSetValue(evt, \"tags\", []);\r\n getSetValue(evt, \"ext\", {});\r\n var ctx = _self.context;\r\n ctx.applySessionContext(evt, itemCtx);\r\n ctx.applyApplicationContext(evt, itemCtx);\r\n ctx.applyDeviceContext(evt, itemCtx);\r\n ctx.applyOperationContext(evt, itemCtx);\r\n ctx.applyUserContext(evt, itemCtx);\r\n ctx.applyOperatingSystemContxt(evt, itemCtx);\r\n ctx.applyWebContext(evt, itemCtx);\r\n ctx.applyLocationContext(evt, itemCtx); // legacy tags\r\n ctx.applyInternalContext(evt, itemCtx); // legacy tags\r\n ctx.cleanUp(evt, itemCtx);\r\n }\r\n });\r\n return _this;\r\n }\r\n PropertiesPlugin.getDefaultConfig = function () {\r\n var defaultConfig = {\r\n instrumentationKey: function () { return undefined; },\r\n accountId: function () { return null; },\r\n sessionRenewalMs: function () { return 30 * 60 * 1000; },\r\n samplingPercentage: function () { return 100; },\r\n sessionExpirationMs: function () { return 24 * 60 * 60 * 1000; },\r\n cookieDomain: function () { return null; },\r\n sdkExtension: function () { return null; },\r\n isBrowserLinkTrackingEnabled: function () { return false; },\r\n appId: function () { return null; },\r\n getSessionId: function () { return null; },\r\n namePrefix: function () { return undefined; },\r\n sessionCookiePostfix: function () { return undefined; },\r\n userCookiePostfix: function () { return undefined; },\r\n idLength: function () { return 22; },\r\n getNewId: function () { return null; }\r\n };\r\n return defaultConfig;\r\n };\r\n PropertiesPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Add Part A fields to the event\r\n * @param event The event that needs to be processed\r\n */\r\n PropertiesPlugin.prototype.processTelemetry = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return PropertiesPlugin;\r\n}(BaseTelemetryPlugin));\r\nexport default PropertiesPlugin;\r\n//# sourceMappingURL=PropertiesPlugin.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;gEASM;AACN;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  /**
@@ -24,7 +24,7 @@ function _removeEmpty(target, name) {
24
24
  }
25
25
  }
26
26
  var TelemetryContext = /** @class */ (function () {
27
- function TelemetryContext(core, defaultConfig) {
27
+ function TelemetryContext(core, defaultConfig, previousTraceCtx) {
28
28
  var _this = this;
29
29
  var logger = core.logger;
30
30
  this.appId = function () { return null; };
@@ -37,7 +37,15 @@ var TelemetryContext = /** @class */ (function () {
37
37
  _self.device = new Device();
38
38
  _self.location = new Location();
39
39
  _self.user = new User(defaultConfig, core);
40
- _self.telemetryTrace = new TelemetryTrace(undefined, undefined, undefined, logger);
40
+ var traceId = void 0;
41
+ var parentId = void 0;
42
+ var name_1;
43
+ if (previousTraceCtx) {
44
+ traceId = previousTraceCtx.getTraceId();
45
+ parentId = previousTraceCtx.getSpanId();
46
+ name_1 = previousTraceCtx.getName();
47
+ }
48
+ _self.telemetryTrace = new TelemetryTrace(traceId, parentId, name_1, logger);
41
49
  _self.session = new Session();
42
50
  }
43
51
  _self.getSessionId = function () {
@@ -1 +1 @@
1
- {"version":3,"file":"TelemetryContext.js.map","sources":["TelemetryContext.js"],"sourcesContent":["/**\r\n * TelemetryContext.ts\r\n * @copyright Microsoft 2018\r\n */\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { isString, objKeys, hasWindow, _InternalLogMessage, setValue, getSetValue } from \"@microsoft/applicationinsights-core-js\";\r\nimport { Session, _SessionManager } from \"./Context/Session\";\r\nimport { Extensions, CtxTagKeys, PageView } from \"@microsoft/applicationinsights-common\";\r\nimport { Application } from \"./Context/Application\";\r\nimport { Device } from \"./Context/Device\";\r\nimport { Internal } from \"./Context/Internal\";\r\nimport { User } from \"./Context/User\";\r\nimport { Location } from \"./Context/Location\";\r\nimport { TelemetryTrace } from \"./Context/TelemetryTrace\";\r\nvar strExt = \"ext\";\r\nvar strTags = \"tags\";\r\nfunction _removeEmpty(target, name) {\r\n if (target && target[name] && objKeys(target[name]).length === 0) {\r\n delete target[name];\r\n }\r\n}\r\nvar TelemetryContext = /** @class */ (function () {\r\n function TelemetryContext(core, defaultConfig) {\r\n var _this = this;\r\n var logger = core.logger;\r\n this.appId = function () { return null; };\r\n this.getSessionId = function () { return null; };\r\n dynamicProto(TelemetryContext, this, function (_self) {\r\n _self.application = new Application();\r\n _self.internal = new Internal(defaultConfig);\r\n if (hasWindow()) {\r\n _self.sessionManager = new _SessionManager(defaultConfig, core);\r\n _self.device = new Device();\r\n _self.location = new Location();\r\n _self.user = new User(defaultConfig, core);\r\n _self.telemetryTrace = new TelemetryTrace(undefined, undefined, undefined, logger);\r\n _self.session = new Session();\r\n }\r\n _self.getSessionId = function () {\r\n var session = _self.session;\r\n var sesId = null;\r\n // If customer set session info, apply their context; otherwise apply context automatically generated\r\n if (session && isString(session.id)) {\r\n sesId = session.id;\r\n }\r\n else {\r\n // Gets the automatic session if it exists or an empty object\r\n var autoSession = (_self.sessionManager || {}).automaticSession;\r\n sesId = autoSession && isString(autoSession.id) ? autoSession.id : null;\r\n }\r\n return sesId;\r\n };\r\n _self.applySessionContext = function (evt, itemCtx) {\r\n setValue(getSetValue(evt.ext, Extensions.AppExt), \"sesId\", _self.getSessionId(), isString);\r\n };\r\n _self.applyOperatingSystemContxt = function (evt, itemCtx) {\r\n setValue(evt.ext, Extensions.OSExt, _self.os);\r\n };\r\n _self.applyApplicationContext = function (evt, itemCtx) {\r\n var application = _self.application;\r\n if (application) {\r\n // evt.ext.app\r\n var tags = getSetValue(evt, strTags);\r\n setValue(tags, CtxTagKeys.applicationVersion, application.ver, isString);\r\n setValue(tags, CtxTagKeys.applicationBuild, application.build, isString);\r\n }\r\n };\r\n _self.applyDeviceContext = function (evt, itemCtx) {\r\n var device = _self.device;\r\n if (device) {\r\n // evt.ext.device\r\n var extDevice = getSetValue(getSetValue(evt, strExt), Extensions.DeviceExt);\r\n setValue(extDevice, \"localId\", device.id, isString);\r\n setValue(extDevice, \"ip\", device.ip, isString);\r\n setValue(extDevice, \"model\", device.model, isString);\r\n setValue(extDevice, \"deviceClass\", device.deviceClass, isString);\r\n }\r\n };\r\n _self.applyInternalContext = function (evt, itemCtx) {\r\n var internal = _self.internal;\r\n if (internal) {\r\n var tags = getSetValue(evt, strTags);\r\n setValue(tags, CtxTagKeys.internalAgentVersion, internal.agentVersion, isString); // not mapped in CS 4.0\r\n setValue(tags, CtxTagKeys.internalSdkVersion, internal.sdkVersion, isString);\r\n if (evt.baseType === _InternalLogMessage.dataType || evt.baseType === PageView.dataType) {\r\n setValue(tags, CtxTagKeys.internalSnippet, internal.snippetVer, isString);\r\n setValue(tags, CtxTagKeys.internalSdkSrc, internal.sdkSrc, isString);\r\n }\r\n }\r\n };\r\n _self.applyLocationContext = function (evt, itemCtx) {\r\n var location = _this.location;\r\n if (location) {\r\n setValue(getSetValue(evt, strTags, []), CtxTagKeys.locationIp, location.ip, isString);\r\n }\r\n };\r\n _self.applyOperationContext = function (evt, itemCtx) {\r\n var telemetryTrace = _self.telemetryTrace;\r\n if (telemetryTrace) {\r\n var extTrace = getSetValue(getSetValue(evt, strExt), Extensions.TraceExt, { traceID: undefined, parentID: undefined });\r\n setValue(extTrace, \"traceID\", telemetryTrace.traceID, isString);\r\n setValue(extTrace, \"name\", telemetryTrace.name, isString);\r\n setValue(extTrace, \"parentID\", telemetryTrace.parentID, isString);\r\n }\r\n };\r\n _self.applyWebContext = function (evt, itemCtx) {\r\n var web = _this.web;\r\n if (web) {\r\n setValue(getSetValue(evt, strExt), Extensions.WebExt, web);\r\n }\r\n };\r\n _self.applyUserContext = function (evt, itemCtx) {\r\n var user = _self.user;\r\n if (user) {\r\n var tags = getSetValue(evt, strTags, []);\r\n // stays in tags\r\n setValue(tags, CtxTagKeys.userAccountId, user.accountId, isString);\r\n // CS 4.0\r\n var extUser = getSetValue(getSetValue(evt, strExt), Extensions.UserExt);\r\n setValue(extUser, \"id\", user.id, isString);\r\n setValue(extUser, \"authId\", user.authenticatedId, isString);\r\n }\r\n };\r\n _self.cleanUp = function (evt, itemCtx) {\r\n var ext = evt.ext;\r\n if (ext) {\r\n _removeEmpty(ext, Extensions.DeviceExt);\r\n _removeEmpty(ext, Extensions.UserExt);\r\n _removeEmpty(ext, Extensions.WebExt);\r\n _removeEmpty(ext, Extensions.OSExt);\r\n _removeEmpty(ext, Extensions.AppExt);\r\n _removeEmpty(ext, Extensions.TraceExt);\r\n }\r\n };\r\n });\r\n }\r\n TelemetryContext.prototype.applySessionContext = function (evt, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyOperatingSystemContxt = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyApplicationContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyDeviceContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyInternalContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyLocationContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyOperationContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyWebContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyUserContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.cleanUp = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return TelemetryContext;\r\n}());\r\nexport { TelemetryContext };\r\n//# sourceMappingURL=TelemetryContext.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;uDA6BM;AACN;AACA;AACA;AACA"}
1
+ {"version":3,"file":"TelemetryContext.js.map","sources":["TelemetryContext.js"],"sourcesContent":["/**\r\n * TelemetryContext.ts\r\n * @copyright Microsoft 2018\r\n */\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { isString, objKeys, hasWindow, _InternalLogMessage, setValue, getSetValue } from \"@microsoft/applicationinsights-core-js\";\r\nimport { Session, _SessionManager } from \"./Context/Session\";\r\nimport { Extensions, CtxTagKeys, PageView } from \"@microsoft/applicationinsights-common\";\r\nimport { Application } from \"./Context/Application\";\r\nimport { Device } from \"./Context/Device\";\r\nimport { Internal } from \"./Context/Internal\";\r\nimport { User } from \"./Context/User\";\r\nimport { Location } from \"./Context/Location\";\r\nimport { TelemetryTrace } from \"./Context/TelemetryTrace\";\r\nvar strExt = \"ext\";\r\nvar strTags = \"tags\";\r\nfunction _removeEmpty(target, name) {\r\n if (target && target[name] && objKeys(target[name]).length === 0) {\r\n delete target[name];\r\n }\r\n}\r\nvar TelemetryContext = /** @class */ (function () {\r\n function TelemetryContext(core, defaultConfig, previousTraceCtx) {\r\n var _this = this;\r\n var logger = core.logger;\r\n this.appId = function () { return null; };\r\n this.getSessionId = function () { return null; };\r\n dynamicProto(TelemetryContext, this, function (_self) {\r\n _self.application = new Application();\r\n _self.internal = new Internal(defaultConfig);\r\n if (hasWindow()) {\r\n _self.sessionManager = new _SessionManager(defaultConfig, core);\r\n _self.device = new Device();\r\n _self.location = new Location();\r\n _self.user = new User(defaultConfig, core);\r\n var traceId = void 0;\r\n var parentId = void 0;\r\n var name_1;\r\n if (previousTraceCtx) {\r\n traceId = previousTraceCtx.getTraceId();\r\n parentId = previousTraceCtx.getSpanId();\r\n name_1 = previousTraceCtx.getName();\r\n }\r\n _self.telemetryTrace = new TelemetryTrace(traceId, parentId, name_1, logger);\r\n _self.session = new Session();\r\n }\r\n _self.getSessionId = function () {\r\n var session = _self.session;\r\n var sesId = null;\r\n // If customer set session info, apply their context; otherwise apply context automatically generated\r\n if (session && isString(session.id)) {\r\n sesId = session.id;\r\n }\r\n else {\r\n // Gets the automatic session if it exists or an empty object\r\n var autoSession = (_self.sessionManager || {}).automaticSession;\r\n sesId = autoSession && isString(autoSession.id) ? autoSession.id : null;\r\n }\r\n return sesId;\r\n };\r\n _self.applySessionContext = function (evt, itemCtx) {\r\n setValue(getSetValue(evt.ext, Extensions.AppExt), \"sesId\", _self.getSessionId(), isString);\r\n };\r\n _self.applyOperatingSystemContxt = function (evt, itemCtx) {\r\n setValue(evt.ext, Extensions.OSExt, _self.os);\r\n };\r\n _self.applyApplicationContext = function (evt, itemCtx) {\r\n var application = _self.application;\r\n if (application) {\r\n // evt.ext.app\r\n var tags = getSetValue(evt, strTags);\r\n setValue(tags, CtxTagKeys.applicationVersion, application.ver, isString);\r\n setValue(tags, CtxTagKeys.applicationBuild, application.build, isString);\r\n }\r\n };\r\n _self.applyDeviceContext = function (evt, itemCtx) {\r\n var device = _self.device;\r\n if (device) {\r\n // evt.ext.device\r\n var extDevice = getSetValue(getSetValue(evt, strExt), Extensions.DeviceExt);\r\n setValue(extDevice, \"localId\", device.id, isString);\r\n setValue(extDevice, \"ip\", device.ip, isString);\r\n setValue(extDevice, \"model\", device.model, isString);\r\n setValue(extDevice, \"deviceClass\", device.deviceClass, isString);\r\n }\r\n };\r\n _self.applyInternalContext = function (evt, itemCtx) {\r\n var internal = _self.internal;\r\n if (internal) {\r\n var tags = getSetValue(evt, strTags);\r\n setValue(tags, CtxTagKeys.internalAgentVersion, internal.agentVersion, isString); // not mapped in CS 4.0\r\n setValue(tags, CtxTagKeys.internalSdkVersion, internal.sdkVersion, isString);\r\n if (evt.baseType === _InternalLogMessage.dataType || evt.baseType === PageView.dataType) {\r\n setValue(tags, CtxTagKeys.internalSnippet, internal.snippetVer, isString);\r\n setValue(tags, CtxTagKeys.internalSdkSrc, internal.sdkSrc, isString);\r\n }\r\n }\r\n };\r\n _self.applyLocationContext = function (evt, itemCtx) {\r\n var location = _this.location;\r\n if (location) {\r\n setValue(getSetValue(evt, strTags, []), CtxTagKeys.locationIp, location.ip, isString);\r\n }\r\n };\r\n _self.applyOperationContext = function (evt, itemCtx) {\r\n var telemetryTrace = _self.telemetryTrace;\r\n if (telemetryTrace) {\r\n var extTrace = getSetValue(getSetValue(evt, strExt), Extensions.TraceExt, { traceID: undefined, parentID: undefined });\r\n setValue(extTrace, \"traceID\", telemetryTrace.traceID, isString);\r\n setValue(extTrace, \"name\", telemetryTrace.name, isString);\r\n setValue(extTrace, \"parentID\", telemetryTrace.parentID, isString);\r\n }\r\n };\r\n _self.applyWebContext = function (evt, itemCtx) {\r\n var web = _this.web;\r\n if (web) {\r\n setValue(getSetValue(evt, strExt), Extensions.WebExt, web);\r\n }\r\n };\r\n _self.applyUserContext = function (evt, itemCtx) {\r\n var user = _self.user;\r\n if (user) {\r\n var tags = getSetValue(evt, strTags, []);\r\n // stays in tags\r\n setValue(tags, CtxTagKeys.userAccountId, user.accountId, isString);\r\n // CS 4.0\r\n var extUser = getSetValue(getSetValue(evt, strExt), Extensions.UserExt);\r\n setValue(extUser, \"id\", user.id, isString);\r\n setValue(extUser, \"authId\", user.authenticatedId, isString);\r\n }\r\n };\r\n _self.cleanUp = function (evt, itemCtx) {\r\n var ext = evt.ext;\r\n if (ext) {\r\n _removeEmpty(ext, Extensions.DeviceExt);\r\n _removeEmpty(ext, Extensions.UserExt);\r\n _removeEmpty(ext, Extensions.WebExt);\r\n _removeEmpty(ext, Extensions.OSExt);\r\n _removeEmpty(ext, Extensions.AppExt);\r\n _removeEmpty(ext, Extensions.TraceExt);\r\n }\r\n };\r\n });\r\n }\r\n TelemetryContext.prototype.applySessionContext = function (evt, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyOperatingSystemContxt = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyApplicationContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyDeviceContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyInternalContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyLocationContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyOperationContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyWebContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyUserContext = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.cleanUp = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return TelemetryContext;\r\n}());\r\nexport { TelemetryContext };\r\n//# sourceMappingURL=TelemetryContext.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;uDA6BM;AACN;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.4-nightly.2205-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.5-nightly.2206-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/applicationinsights-properties-js",
3
- "version": "2.8.4-nightly.2205-09",
3
+ "version": "2.8.5-nightly.2206-02",
4
4
  "description": "Microsoft Application Insights properties (Part A) plugin",
5
5
  "homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
6
6
  "author": "Microsoft Application Insights Team",
@@ -51,8 +51,8 @@
51
51
  "dependencies": {
52
52
  "@microsoft/dynamicproto-js": "^1.1.6",
53
53
  "@microsoft/applicationinsights-shims": "2.0.1",
54
- "@microsoft/applicationinsights-core-js": "2.8.4-nightly.2205-09",
55
- "@microsoft/applicationinsights-common": "2.8.4-nightly.2205-09"
54
+ "@microsoft/applicationinsights-core-js": "2.8.5-nightly.2206-02",
55
+ "@microsoft/applicationinsights-common": "2.8.5-nightly.2206-02"
56
56
  },
57
57
  "license": "MIT",
58
58
  "publishConfig": {
@@ -4,7 +4,7 @@
4
4
  import { IInternal } from "@microsoft/applicationinsights-common";
5
5
  import { ITelemetryConfig } from "../Interfaces/ITelemetryConfig";
6
6
 
7
- const Version = "2.8.4-nightly.2205-09";
7
+ const Version = "2.8.5-nightly.2206-02";
8
8
 
9
9
  export class Internal implements IInternal {
10
10
 
@@ -9,18 +9,18 @@ export class TelemetryTrace implements ITelemetryTrace {
9
9
  public traceID: string;
10
10
  public parentID: string;
11
11
  public traceState: ITraceState;
12
+ public traceFlags: number;
12
13
  public name: string;
13
14
 
14
15
  constructor(id?: string, parentId?: string, name?: string, logger?: IDiagnosticLogger) {
15
16
  const _self = this;
16
17
  _self.traceID = id || generateW3CId();
17
18
  _self.parentID = parentId;
18
- _self.name = name;
19
19
  let location = getLocation();
20
20
  if (!name && location && location.pathname) {
21
- _self.name = location.pathname;
21
+ name = location.pathname;
22
22
  }
23
23
 
24
- _self.name = dataSanitizeString(logger, _self.name);
24
+ _self.name = dataSanitizeString(logger, name);
25
25
  }
26
26
  }
@@ -7,10 +7,10 @@ import dynamicProto from "@microsoft/dynamicproto-js";
7
7
  import {
8
8
  BaseTelemetryPlugin, IConfiguration, isNullOrUndefined,
9
9
  IAppInsightsCore, IPlugin, ITelemetryItem, IProcessTelemetryContext, _InternalLogMessage, eLoggingSeverity, _eInternalMessageId, getNavigator,
10
- ITelemetryPluginChain, objForEachKey, getSetValue, _logInternalMessage
10
+ ITelemetryPluginChain, objForEachKey, getSetValue, _logInternalMessage, IProcessTelemetryUnloadContext, ITelemetryUnloadState, IDistributedTraceContext
11
11
  } from "@microsoft/applicationinsights-core-js";
12
12
  import { TelemetryContext } from "./TelemetryContext";
13
- import { PageView, IConfig, BreezeChannelIdentifier, PropertiesPluginIdentifier, IPropertiesPlugin, getExtensionByName } from "@microsoft/applicationinsights-common";
13
+ import { PageView, IConfig, BreezeChannelIdentifier, PropertiesPluginIdentifier, IPropertiesPlugin, createDistributedTraceContextFromTrace } from "@microsoft/applicationinsights-common";
14
14
  import { ITelemetryConfig } from "./Interfaces/ITelemetryConfig";
15
15
  import { IPropTelemetryContext } from "./Interfaces/IPropTelemetryContext";
16
16
 
@@ -46,11 +46,14 @@ export default class PropertiesPlugin extends BaseTelemetryPlugin implements IPr
46
46
  constructor() {
47
47
  super();
48
48
 
49
- let _breezeChannel: IPlugin; // optional. If exists, grab appId from it
50
49
  let _extensionConfig: ITelemetryConfig;
50
+ let _distributedTraceCtx: IDistributedTraceContext;
51
+ let _previousTraceCtx: IDistributedTraceContext;
51
52
 
52
53
  dynamicProto(PropertiesPlugin, this, (_self, _base) => {
53
54
 
55
+ _initDefaults();
56
+
54
57
  _self.initialize = (config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain) => {
55
58
  _base.initialize(config, core, extensions, pluginChain);
56
59
  let ctx = _self._getTelCtx();
@@ -58,12 +61,17 @@ export default class PropertiesPlugin extends BaseTelemetryPlugin implements IPr
58
61
  const defaultConfig: ITelemetryConfig = PropertiesPlugin.getDefaultConfig();
59
62
  _extensionConfig = _extensionConfig || {} as ITelemetryConfig;
60
63
  objForEachKey(defaultConfig, (field, value) => {
61
- _extensionConfig[field] = () => ctx.getConfig(identifier, field, value());
64
+ _extensionConfig[field] = () => ctx.getConfig(identifier, field, value() as any);
62
65
  });
63
66
 
64
- _self.context = new TelemetryContext(core, _extensionConfig);
65
- _breezeChannel = getExtensionByName(extensions, BreezeChannelIdentifier);
66
- _self.context.appId = () => _breezeChannel ? _breezeChannel["_appId"] : null;
67
+ _previousTraceCtx = core.getTraceCtx(false);
68
+ _self.context = new TelemetryContext(core, _extensionConfig, _previousTraceCtx);
69
+ _distributedTraceCtx = createDistributedTraceContextFromTrace(_self.context.telemetryTrace, _previousTraceCtx);
70
+ core.setTraceCtx(_distributedTraceCtx);
71
+ _self.context.appId = () => {
72
+ let breezeChannel = core.getPlugin<IPlugin>(BreezeChannelIdentifier);
73
+ return breezeChannel ? breezeChannel.plugin["_appId"] : null;
74
+ };
67
75
 
68
76
  // Test hook to allow accessing the internal values -- explicitly not defined as an available property on the class
69
77
  _self["_extConfig"] = _extensionConfig;
@@ -108,7 +116,25 @@ export default class PropertiesPlugin extends BaseTelemetryPlugin implements IPr
108
116
  _self.processNext(event, itemCtx);
109
117
  }
110
118
  };
119
+
120
+ _self._doTeardown = (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => {
121
+ let core = (unloadCtx || {} as any).core();
122
+ if (core && core.getTraceCtx) {
123
+ let traceCtx = core.getTraceCtx(false);
124
+ if (traceCtx === _distributedTraceCtx) {
125
+ core.setTraceCtx(_previousTraceCtx);
126
+ }
127
+ }
128
+
129
+ _initDefaults();
130
+ };
111
131
 
132
+ function _initDefaults() {
133
+ _extensionConfig = null;
134
+ _distributedTraceCtx = null;
135
+ _previousTraceCtx = null;
136
+ }
137
+
112
138
  function _processTelemetryInternal(evt: ITelemetryItem, itemCtx: IProcessTelemetryContext) {
113
139
  // Set Part A fields
114
140
  getSetValue(evt, "tags", []);
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import dynamicProto from "@microsoft/dynamicproto-js";
7
- import { ITelemetryItem, IProcessTelemetryContext, IAppInsightsCore, isString, objKeys, hasWindow, _InternalLogMessage, setValue, getSetValue } from "@microsoft/applicationinsights-core-js";
7
+ import { ITelemetryItem, IProcessTelemetryContext, IAppInsightsCore, isString, objKeys, hasWindow, _InternalLogMessage, setValue, getSetValue, IDistributedTraceContext } from "@microsoft/applicationinsights-core-js";
8
8
  import { Session, _SessionManager } from "./Context/Session";
9
9
  import { Extensions, IOperatingSystem, ITelemetryTrace, IWeb, CtxTagKeys, PageView, IApplication, IDevice, ILocation, IUserContext, IInternal, ISession } from "@microsoft/applicationinsights-common";
10
10
  import { Application } from "./Context/Application";
@@ -40,7 +40,7 @@ export class TelemetryContext implements IPropTelemetryContext {
40
40
  public appId: () => string;
41
41
  public getSessionId: () => string;
42
42
 
43
- constructor(core: IAppInsightsCore, defaultConfig: ITelemetryConfig) {
43
+ constructor(core: IAppInsightsCore, defaultConfig: ITelemetryConfig, previousTraceCtx?: IDistributedTraceContext) {
44
44
  let logger = core.logger
45
45
  this.appId = () => null;
46
46
  this.getSessionId = () => null;
@@ -53,7 +53,16 @@ export class TelemetryContext implements IPropTelemetryContext {
53
53
  _self.device = new Device();
54
54
  _self.location = new Location();
55
55
  _self.user = new User(defaultConfig, core);
56
- _self.telemetryTrace = new TelemetryTrace(undefined, undefined, undefined, logger);
56
+
57
+ let traceId: string;
58
+ let parentId: string;
59
+ let name: string;
60
+ if (previousTraceCtx) {
61
+ traceId = previousTraceCtx.getTraceId();
62
+ parentId = previousTraceCtx.getSpanId();
63
+ name = previousTraceCtx.getName();
64
+ }
65
+ _self.telemetryTrace = new TelemetryTrace(traceId, parentId, name, logger);
57
66
  _self.session = new Session();
58
67
  }
59
68
 
@@ -4,6 +4,7 @@ export declare class TelemetryTrace implements ITelemetryTrace {
4
4
  traceID: string;
5
5
  parentID: string;
6
6
  traceState: ITraceState;
7
+ traceFlags: number;
7
8
  name: string;
8
9
  constructor(id?: string, parentId?: string, name?: string, logger?: IDiagnosticLogger);
9
10
  }
@@ -2,7 +2,7 @@
2
2
  * TelemetryContext.ts
3
3
  * @copyright Microsoft 2018
4
4
  */
5
- import { ITelemetryItem, IProcessTelemetryContext, IAppInsightsCore } from "@microsoft/applicationinsights-core-js";
5
+ import { ITelemetryItem, IProcessTelemetryContext, IAppInsightsCore, IDistributedTraceContext } from "@microsoft/applicationinsights-core-js";
6
6
  import { _SessionManager } from "./Context/Session";
7
7
  import { IOperatingSystem, ITelemetryTrace, IWeb, IApplication, IDevice, ILocation, IUserContext, IInternal, ISession } from "@microsoft/applicationinsights-common";
8
8
  import { ITelemetryConfig } from "./Interfaces/ITelemetryConfig";
@@ -20,7 +20,7 @@ export declare class TelemetryContext implements IPropTelemetryContext {
20
20
  web: IWeb;
21
21
  appId: () => string;
22
22
  getSessionId: () => string;
23
- constructor(core: IAppInsightsCore, defaultConfig: ITelemetryConfig);
23
+ constructor(core: IAppInsightsCore, defaultConfig: ITelemetryConfig, previousTraceCtx?: IDistributedTraceContext);
24
24
  applySessionContext(evt: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
25
25
  applyOperatingSystemContxt(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
26
26
  applyApplicationContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.24.0"
8
+ "packageVersion": "7.24.2"
9
9
  }
10
10
  ]
11
11
  }