@microsoft/applicationinsights-properties-js 2.8.4-nightly.2205-07 → 2.8.4-nightly.2205-10

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 (39) 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 +5 -5
  20. package/dist-esm/Context/Session.js.map +1 -1
  21. package/dist-esm/Context/TelemetryTrace.js +3 -4
  22. package/dist-esm/Context/TelemetryTrace.js.map +1 -1
  23. package/dist-esm/Context/User.js +2 -2
  24. package/dist-esm/Context/User.js.map +1 -1
  25. package/dist-esm/Interfaces/IPropTelemetryContext.js +1 -1
  26. package/dist-esm/Interfaces/ITelemetryConfig.js +1 -1
  27. package/dist-esm/PropertiesPlugin.js +30 -8
  28. package/dist-esm/PropertiesPlugin.js.map +1 -1
  29. package/dist-esm/TelemetryContext.js +11 -3
  30. package/dist-esm/TelemetryContext.js.map +1 -1
  31. package/dist-esm/applicationinsights-properties-js.js +1 -1
  32. package/package.json +4 -4
  33. package/src/Context/Internal.ts +1 -1
  34. package/src/Context/TelemetryTrace.ts +3 -3
  35. package/src/PropertiesPlugin.ts +33 -7
  36. package/src/TelemetryContext.ts +12 -3
  37. package/types/Context/TelemetryTrace.d.ts +1 -0
  38. package/types/TelemetryContext.d.ts +2 -2
  39. package/types/tsdoc-metadata.json +1 -1
@@ -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.23.2"
8
+ "packageVersion": "7.24.2"
9
9
  }
10
10
  ]
11
11
  }