@microsoft/applicationinsights-react-js 3.3.0-beta.2203-10 → 3.3.0-beta.2203-13

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "metadata": {
3
3
  "toolPackage": "@microsoft/api-extractor",
4
- "toolVersion": "7.19.4",
4
+ "toolVersion": "7.19.5",
5
5
  "schemaVersion": 1004,
6
6
  "oldestForwardsCompatibleVersion": 1001,
7
7
  "tsdocConfig": {
@@ -422,6 +422,20 @@
422
422
  "releaseTag": "Public",
423
423
  "name": "ReactPlugin",
424
424
  "members": [
425
+ {
426
+ "kind": "Constructor",
427
+ "canonicalReference": "@microsoft/applicationinsights-react-js!ReactPlugin:constructor(1)",
428
+ "docComment": "/**\n * Constructs a new instance of the `ReactPlugin` class\n */\n",
429
+ "excerptTokens": [
430
+ {
431
+ "kind": "Content",
432
+ "text": "constructor();"
433
+ }
434
+ ],
435
+ "releaseTag": "Public",
436
+ "overloadIndex": 1,
437
+ "parameters": []
438
+ },
425
439
  {
426
440
  "kind": "Method",
427
441
  "canonicalReference": "@microsoft/applicationinsights-react-js!ReactPlugin#getAppInsights:member(1)",
@@ -786,8 +800,9 @@
786
800
  "text": ", customProperties?: "
787
801
  },
788
802
  {
789
- "kind": "Content",
790
- "text": "{\n [key: string]: any;\n }"
803
+ "kind": "Reference",
804
+ "text": "ICustomProperties",
805
+ "canonicalReference": "@microsoft/applicationinsights-core-js!ICustomProperties:interface"
791
806
  },
792
807
  {
793
808
  "kind": "Content",
@@ -955,8 +970,9 @@
955
970
  "text": ", customProperties?: "
956
971
  },
957
972
  {
958
- "kind": "Content",
959
- "text": "{\n [key: string]: any;\n }"
973
+ "kind": "Reference",
974
+ "text": "ICustomProperties",
975
+ "canonicalReference": "@microsoft/applicationinsights-core-js!ICustomProperties:interface"
960
976
  },
961
977
  {
962
978
  "kind": "Content",
@@ -1157,14 +1173,23 @@
1157
1173
  },
1158
1174
  {
1159
1175
  "kind": "Content",
1160
- "text": ", componentName: string) => () => void"
1176
+ "text": ", componentName: string, customProperties?: "
1177
+ },
1178
+ {
1179
+ "kind": "Reference",
1180
+ "text": "ICustomProperties",
1181
+ "canonicalReference": "@microsoft/applicationinsights-core-js!ICustomProperties:interface"
1182
+ },
1183
+ {
1184
+ "kind": "Content",
1185
+ "text": ") => () => void"
1161
1186
  }
1162
1187
  ],
1163
1188
  "releaseTag": "Public",
1164
1189
  "name": "useTrackMetric",
1165
1190
  "variableTypeTokenRange": {
1166
1191
  "startIndex": 1,
1167
- "endIndex": 4
1192
+ "endIndex": 6
1168
1193
  }
1169
1194
  },
1170
1195
  {
@@ -54,6 +54,7 @@ export interface IReactExtensionConfig {
54
54
 
55
55
  // @public (undocumented)
56
56
  export class ReactPlugin extends BaseTelemetryPlugin {
57
+ constructor();
57
58
  getAppInsights(): IAppInsights;
58
59
  getCookieMgr(): ICookieMgr;
59
60
  // (undocumented)
@@ -66,17 +67,13 @@ export class ReactPlugin extends BaseTelemetryPlugin {
66
67
  // (undocumented)
67
68
  trackEvent(event: IEventTelemetry, customProperties?: ICustomProperties): void;
68
69
  // (undocumented)
69
- trackException(exception: IExceptionTelemetry, customProperties?: {
70
- [key: string]: any;
71
- }): void;
70
+ trackException(exception: IExceptionTelemetry, customProperties?: ICustomProperties): void;
72
71
  // (undocumented)
73
72
  trackMetric(metric: IMetricTelemetry, customProperties: ICustomProperties): void;
74
73
  // (undocumented)
75
74
  trackPageView(pageView: IPageViewTelemetry): void;
76
75
  // (undocumented)
77
- trackTrace(trace: ITraceTelemetry, customProperties?: {
78
- [key: string]: any;
79
- }): void;
76
+ trackTrace(trace: ITraceTelemetry, customProperties?: ICustomProperties): void;
80
77
  }
81
78
 
82
79
  // @public (undocumented)
@@ -88,7 +85,7 @@ export const useAppInsightsContext: () => ReactPlugin;
88
85
  export function useTrackEvent<T>(reactPlugin: ReactPlugin, eventName: string, eventData: T, skipFirstRun?: boolean): AIReactCustomEvent<T>;
89
86
 
90
87
  // @public (undocumented)
91
- export const useTrackMetric: (reactPlugin: ReactPlugin, componentName: string) => () => void;
88
+ export const useTrackMetric: (reactPlugin: ReactPlugin, componentName: string, customProperties?: ICustomProperties) => () => void;
92
89
 
93
90
  // @public
94
91
  export function withAITracking<P>(reactPlugin: ReactPlugin, Component: React_2.ComponentType<P>, componentName?: string, className?: string): React_2.ComponentClass<P>;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights react plugin, 3.3.0-beta.2203-10
2
+ * Microsoft Application Insights react plugin, 3.3.0-beta.2203-13
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  *
@@ -69,8 +69,7 @@ declare namespace ApplicationInsights {
69
69
  class ReactPlugin extends BaseTelemetryPlugin {
70
70
  priority: number;
71
71
  identifier: string;
72
- private _analyticsPlugin;
73
- private _extensionConfig;
72
+ constructor();
74
73
  initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
75
74
  /**
76
75
  * Get the current cookie manager for this instance
@@ -88,20 +87,15 @@ declare namespace ApplicationInsights {
88
87
  trackMetric(metric: IMetricTelemetry, customProperties: ICustomProperties): void;
89
88
  trackPageView(pageView: IPageViewTelemetry): void;
90
89
  trackEvent(event: IEventTelemetry, customProperties?: ICustomProperties): void;
91
- trackException(exception: IExceptionTelemetry, customProperties?: {
92
- [key: string]: any;
93
- }): void;
94
- trackTrace(trace: ITraceTelemetry, customProperties?: {
95
- [key: string]: any;
96
- }): void;
97
- private addHistoryListener;
90
+ trackException(exception: IExceptionTelemetry, customProperties?: ICustomProperties): void;
91
+ trackTrace(trace: ITraceTelemetry, customProperties?: ICustomProperties): void;
98
92
  }
99
93
 
100
94
  const useAppInsightsContext: () => ReactPlugin;
101
95
 
102
96
  function useTrackEvent<T>(reactPlugin: ReactPlugin, eventName: string, eventData: T, skipFirstRun?: boolean): AIReactCustomEvent<T>;
103
97
 
104
- const useTrackMetric: (reactPlugin: ReactPlugin, componentName: string) => () => void;
98
+ const useTrackMetric: (reactPlugin: ReactPlugin, componentName: string, customProperties?: ICustomProperties) => () => void;
105
99
 
106
100
  /**
107
101
  * Higher-order component function to hook Application Insights tracking
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-10
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-13
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -738,6 +738,17 @@
738
738
  }
739
739
  }
740
740
  }
741
+ function proxyFunctions(target, source, functionsToProxy, overwriteTarget) {
742
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
743
+ if (target && source && isObject(target) && isArray(functionsToProxy)) {
744
+ arrForEach(functionsToProxy, function (theFuncName) {
745
+ if (isString(theFuncName)) {
746
+ proxyFunctionAs(target, theFuncName, source, theFuncName, overwriteTarget);
747
+ }
748
+ });
749
+ }
750
+ return target;
751
+ }
741
752
  function createEnumStyle(values) {
742
753
  var enumClass = {};
743
754
  objForEachKey(values, function (field, value) {
@@ -1269,7 +1280,7 @@
1269
1280
  }
1270
1281
 
1271
1282
  var _objDefineProperty = ObjDefineProperty;
1272
- var version = "2.7.3";
1283
+ var version = "2.8.0-beta.2203-13";
1273
1284
  var instanceName = "." + newId(6);
1274
1285
  var _dataUid = 0;
1275
1286
  function _createAccessor(target, prop, value) {
@@ -2148,7 +2159,7 @@
2148
2159
  eventName = (eventName || "") + theNamespace_1;
2149
2160
  }
2150
2161
  }
2151
- var parsedEvent = (eventNamespace.exec(eventName) || []);
2162
+ var parsedEvent = (eventNamespace.exec(eventName || "") || []);
2152
2163
  return {
2153
2164
  type: parsedEvent[1],
2154
2165
  ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
@@ -2408,98 +2419,91 @@
2408
2419
  var ReactPlugin = /** @class */ (function (_super) {
2409
2420
  __extendsFn(ReactPlugin, _super);
2410
2421
  function ReactPlugin() {
2411
- var _this = _super !== null && _super.apply(this, arguments) || this;
2422
+ var _this = _super.call(this) || this;
2412
2423
  _this.priority = 185;
2413
2424
  _this.identifier = 'ReactPlugin';
2414
- return _this;
2415
- }
2416
- ReactPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
2417
- var _this = this;
2418
- _super.prototype.initialize.call(this, config, core, extensions, pluginChain);
2419
- this._extensionConfig =
2420
- config.extensionConfig && config.extensionConfig[this.identifier]
2421
- ? config.extensionConfig[this.identifier]
2422
- : { history: null };
2423
- arrForEach(extensions, function (ext) {
2424
- var identifier = ext.identifier;
2425
- if (identifier === 'ApplicationInsightsAnalytics') {
2426
- _this._analyticsPlugin = ext;
2425
+ var _analyticsPlugin;
2426
+ var _extensionConfig;
2427
+ var _unlisten;
2428
+ var _pageViewTimer;
2429
+ dynamicProto(ReactPlugin, _this, function (_self, _base) {
2430
+ _initDefaults();
2431
+ _self.initialize = function (config, core, extensions, pluginChain) {
2432
+ _super.prototype.initialize.call(_this, config, core, extensions, pluginChain);
2433
+ _extensionConfig =
2434
+ config.extensionConfig && config.extensionConfig[_self.identifier]
2435
+ ? config.extensionConfig[_self.identifier]
2436
+ : { history: null };
2437
+ arrForEach(extensions, function (ext) {
2438
+ var identifier = ext.identifier;
2439
+ if (identifier === 'ApplicationInsightsAnalytics') {
2440
+ _analyticsPlugin = ext;
2441
+ }
2442
+ });
2443
+ if (_extensionConfig.history) {
2444
+ _addHistoryListener(_extensionConfig.history);
2445
+ var pageViewTelemetry = {
2446
+ uri: _extensionConfig.history.location.pathname
2447
+ };
2448
+ _self.trackPageView(pageViewTelemetry);
2449
+ }
2450
+ };
2451
+ _self.getCookieMgr = function () {
2452
+ return safeGetCookieMgr(_self.core);
2453
+ };
2454
+ _self.getAppInsights = _getAnalytics;
2455
+ _self.processTelemetry = function (event, itemCtx) {
2456
+ _self.processNext(event, itemCtx);
2457
+ };
2458
+ _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {
2459
+ if (isFunction(_unlisten)) {
2460
+ _unlisten();
2461
+ }
2462
+ if (_pageViewTimer) {
2463
+ clearTimeout(_pageViewTimer);
2464
+ }
2465
+ _initDefaults();
2466
+ };
2467
+ proxyFunctions(_self, _getAnalytics, [
2468
+ "trackMetric",
2469
+ "trackPageView",
2470
+ "trackEvent",
2471
+ "trackException",
2472
+ "trackTrace",
2473
+ ]);
2474
+ function _initDefaults() {
2475
+ _analyticsPlugin = null;
2476
+ _extensionConfig = null;
2477
+ _unlisten = null;
2478
+ _pageViewTimer = null;
2479
+ }
2480
+ function _getAnalytics() {
2481
+ if (!_analyticsPlugin) {
2482
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2483
+ }
2484
+ return _analyticsPlugin;
2427
2485
  }
2486
+ function _addHistoryListener(history) {
2487
+ var locationListener = function (arg) {
2488
+ var locn = null;
2489
+ if ("location" in arg) {
2490
+ locn = arg["location"];
2491
+ }
2492
+ else {
2493
+ locn = arg;
2494
+ }
2495
+ _pageViewTimer = setTimeout(function () {
2496
+ _pageViewTimer = null;
2497
+ var pageViewTelemetry = { uri: locn.pathname };
2498
+ _self.trackPageView(pageViewTelemetry);
2499
+ }, 500);
2500
+ };
2501
+ _unlisten = history.listen(locationListener);
2502
+ }
2503
+ objDefineAccessors(_self, "_extensionConfig", function () { return _extensionConfig; });
2428
2504
  });
2429
- if (this._extensionConfig.history) {
2430
- this.addHistoryListener(this._extensionConfig.history);
2431
- var pageViewTelemetry = {
2432
- uri: this._extensionConfig.history.location.pathname
2433
- };
2434
- this.trackPageView(pageViewTelemetry);
2435
- }
2436
- };
2437
- ReactPlugin.prototype.getCookieMgr = function () {
2438
- return safeGetCookieMgr(this.core);
2439
- };
2440
- ReactPlugin.prototype.getAppInsights = function () {
2441
- return this._analyticsPlugin;
2442
- };
2443
- ReactPlugin.prototype.processTelemetry = function (event, itemCtx) {
2444
- this.processNext(event, itemCtx);
2445
- };
2446
- ReactPlugin.prototype.trackMetric = function (metric, customProperties) {
2447
- if (this._analyticsPlugin) {
2448
- this._analyticsPlugin.trackMetric(metric, customProperties);
2449
- }
2450
- else {
2451
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2452
- }
2453
- };
2454
- ReactPlugin.prototype.trackPageView = function (pageView) {
2455
- if (this._analyticsPlugin) {
2456
- this._analyticsPlugin.trackPageView(pageView);
2457
- }
2458
- else {
2459
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2460
- }
2461
- };
2462
- ReactPlugin.prototype.trackEvent = function (event, customProperties) {
2463
- if (this._analyticsPlugin) {
2464
- this._analyticsPlugin.trackEvent(event, customProperties);
2465
- }
2466
- else {
2467
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2468
- }
2469
- };
2470
- ReactPlugin.prototype.trackException = function (exception, customProperties) {
2471
- if (this._analyticsPlugin) {
2472
- this._analyticsPlugin.trackException(exception, customProperties);
2473
- }
2474
- else {
2475
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2476
- }
2477
- };
2478
- ReactPlugin.prototype.trackTrace = function (trace, customProperties) {
2479
- if (this._analyticsPlugin) {
2480
- this._analyticsPlugin.trackTrace(trace, customProperties);
2481
- }
2482
- else {
2483
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2484
- }
2485
- };
2486
- ReactPlugin.prototype.addHistoryListener = function (history) {
2487
- var _this = this;
2488
- var locationListener = function (arg) {
2489
- var locn = null;
2490
- if ("location" in arg) {
2491
- locn = arg["location"];
2492
- }
2493
- else {
2494
- locn = arg;
2495
- }
2496
- setTimeout(function () {
2497
- var pageViewTelemetry = { uri: locn.pathname };
2498
- _this.trackPageView(pageViewTelemetry);
2499
- }, 500);
2500
- };
2501
- history.listen(locationListener);
2502
- };
2505
+ return _this;
2506
+ }
2503
2507
  return ReactPlugin;
2504
2508
  }(BaseTelemetryPlugin));
2505
2509
  var ReactPlugin$1 = ReactPlugin;
@@ -2646,7 +2650,7 @@
2646
2650
  trackedData.idleCount * trackedData.idleTimeout) /
2647
2651
  1000);
2648
2652
  }
2649
- var useComponentTracking = function (reactPlugin, componentName) {
2653
+ var useComponentTracking = function (reactPlugin, componentName, customProperties) {
2650
2654
  var tracking = React.useRef({
2651
2655
  hookTimestamp: dateNow(),
2652
2656
  firstActiveTimestamp: 0,
@@ -2685,7 +2689,7 @@
2685
2689
  name: "React Component Engaged Time (seconds)",
2686
2690
  sampleCount: 1
2687
2691
  };
2688
- var additionalProperties = { "Component Name": componentName };
2692
+ var additionalProperties = __assignFn({ "Component Name": componentName }, customProperties);
2689
2693
  reactPlugin.trackMetric(metricData, additionalProperties);
2690
2694
  };
2691
2695
  }, []);