@microsoft/applicationinsights-react-js 3.3.0-beta.2203-08 → 3.3.0-beta.2203-11

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,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights react plugin, 3.3.0-beta.2203-08
2
+ * Microsoft Application Insights react plugin, 3.3.0-beta.2203-11
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  *
@@ -75,8 +75,7 @@ export declare interface IReactExtensionConfig {
75
75
  export declare class ReactPlugin extends BaseTelemetryPlugin {
76
76
  priority: number;
77
77
  identifier: string;
78
- private _analyticsPlugin;
79
- private _extensionConfig;
78
+ constructor();
80
79
  initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
81
80
  /**
82
81
  * Get the current cookie manager for this instance
@@ -94,20 +93,15 @@ export declare class ReactPlugin extends BaseTelemetryPlugin {
94
93
  trackMetric(metric: IMetricTelemetry, customProperties: ICustomProperties): void;
95
94
  trackPageView(pageView: IPageViewTelemetry): void;
96
95
  trackEvent(event: IEventTelemetry, customProperties?: ICustomProperties): void;
97
- trackException(exception: IExceptionTelemetry, customProperties?: {
98
- [key: string]: any;
99
- }): void;
100
- trackTrace(trace: ITraceTelemetry, customProperties?: {
101
- [key: string]: any;
102
- }): void;
103
- private addHistoryListener;
96
+ trackException(exception: IExceptionTelemetry, customProperties?: ICustomProperties): void;
97
+ trackTrace(trace: ITraceTelemetry, customProperties?: ICustomProperties): void;
104
98
  }
105
99
 
106
100
  export declare const useAppInsightsContext: () => ReactPlugin;
107
101
 
108
102
  export declare function useTrackEvent<T>(reactPlugin: ReactPlugin, eventName: string, eventData: T, skipFirstRun?: boolean): AIReactCustomEvent<T>;
109
103
 
110
- export declare const useTrackMetric: (reactPlugin: ReactPlugin, componentName: string) => () => void;
104
+ export declare const useTrackMetric: (reactPlugin: ReactPlugin, componentName: string, customProperties?: ICustomProperties) => () => void;
111
105
 
112
106
  /**
113
107
  * 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-08
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-11
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  import { createContext, useContext } from "react";
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-08
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-11
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 - React Plugin, 3.3.0-beta.2203-08
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-11
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 - React Plugin, 3.3.0-beta.2203-08
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-11
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  /**
@@ -7,115 +7,109 @@
7
7
  * @copyright Microsoft 2019
8
8
  */
9
9
  import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
10
- import { BaseTelemetryPlugin, _InternalMessageId, LoggingSeverity, safeGetCookieMgr, arrForEach } from "@microsoft/applicationinsights-core-js";
10
+ import dynamicProto from "@microsoft/dynamicproto-js";
11
+ import { BaseTelemetryPlugin, _InternalMessageId, LoggingSeverity, safeGetCookieMgr, arrForEach, proxyFunctions, isFunction, objDefineAccessors } from "@microsoft/applicationinsights-core-js";
11
12
  var ReactPlugin = /** @class */ (function (_super) {
12
13
  __extends(ReactPlugin, _super);
13
14
  function ReactPlugin() {
14
- var _this = _super !== null && _super.apply(this, arguments) || this;
15
+ var _this = _super.call(this) || this;
15
16
  _this.priority = 185;
16
17
  _this.identifier = 'ReactPlugin';
17
- return _this;
18
- }
19
- ReactPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
20
- var _this = this;
21
- _super.prototype.initialize.call(this, config, core, extensions, pluginChain);
22
- this._extensionConfig =
23
- config.extensionConfig && config.extensionConfig[this.identifier]
24
- ? config.extensionConfig[this.identifier]
25
- : { history: null };
26
- arrForEach(extensions, function (ext) {
27
- var identifier = ext.identifier;
28
- if (identifier === 'ApplicationInsightsAnalytics') {
29
- _this._analyticsPlugin = ext;
30
- }
31
- });
32
- if (this._extensionConfig.history) {
33
- this.addHistoryListener(this._extensionConfig.history);
34
- var pageViewTelemetry = {
35
- uri: this._extensionConfig.history.location.pathname
18
+ var _analyticsPlugin;
19
+ var _extensionConfig;
20
+ var _unlisten;
21
+ var _pageViewTimer;
22
+ dynamicProto(ReactPlugin, _this, function (_self, _base) {
23
+ _initDefaults();
24
+ _self.initialize = function (config, core, extensions, pluginChain) {
25
+ _super.prototype.initialize.call(_this, config, core, extensions, pluginChain);
26
+ _extensionConfig =
27
+ config.extensionConfig && config.extensionConfig[_self.identifier]
28
+ ? config.extensionConfig[_self.identifier]
29
+ : { history: null };
30
+ arrForEach(extensions, function (ext) {
31
+ var identifier = ext.identifier;
32
+ if (identifier === 'ApplicationInsightsAnalytics') {
33
+ _analyticsPlugin = ext;
34
+ }
35
+ });
36
+ if (_extensionConfig.history) {
37
+ _addHistoryListener(_extensionConfig.history);
38
+ var pageViewTelemetry = {
39
+ uri: _extensionConfig.history.location.pathname
40
+ };
41
+ _self.trackPageView(pageViewTelemetry);
42
+ }
43
+ };
44
+ _self.getCookieMgr = function () {
45
+ return safeGetCookieMgr(_self.core);
46
+ };
47
+ _self.getAppInsights = _getAnalytics;
48
+ _self.processTelemetry = function (event, itemCtx) {
49
+ _self.processNext(event, itemCtx);
36
50
  };
37
- this.trackPageView(pageViewTelemetry);
38
- }
39
- };
40
- /**
41
- * Get the current cookie manager for this instance
42
- */
43
- ReactPlugin.prototype.getCookieMgr = function () {
44
- return safeGetCookieMgr(this.core);
45
- };
46
- /**
47
- * Get application insights instance.
48
- */
49
- ReactPlugin.prototype.getAppInsights = function () {
50
- return this._analyticsPlugin;
51
- };
52
- /**
53
- * Add Part A fields to the event
54
- * @param event The event that needs to be processed
55
- */
56
- ReactPlugin.prototype.processTelemetry = function (event, itemCtx) {
57
- this.processNext(event, itemCtx);
58
- };
59
- ReactPlugin.prototype.trackMetric = function (metric, customProperties) {
60
- if (this._analyticsPlugin) {
61
- this._analyticsPlugin.trackMetric(metric, customProperties);
62
- }
63
- else {
64
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
65
- }
66
- };
67
- ReactPlugin.prototype.trackPageView = function (pageView) {
68
- if (this._analyticsPlugin) {
69
- this._analyticsPlugin.trackPageView(pageView);
70
- }
71
- else {
72
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
73
- }
74
- };
75
- ReactPlugin.prototype.trackEvent = function (event, customProperties) {
76
- if (this._analyticsPlugin) {
77
- this._analyticsPlugin.trackEvent(event, customProperties);
78
- }
79
- else {
80
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
81
- }
82
- };
83
- ReactPlugin.prototype.trackException = function (exception, customProperties) {
84
- if (this._analyticsPlugin) {
85
- this._analyticsPlugin.trackException(exception, customProperties);
86
- }
87
- else {
88
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
89
- }
90
- };
91
- ReactPlugin.prototype.trackTrace = function (trace, customProperties) {
92
- if (this._analyticsPlugin) {
93
- this._analyticsPlugin.trackTrace(trace, customProperties);
94
- }
95
- else {
96
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
97
- }
98
- };
99
- ReactPlugin.prototype.addHistoryListener = function (history) {
100
- var _this = this;
101
- var locationListener = function (arg) {
102
- // v4 of the history API passes "location" as the first argument, while v5 passes an object that contains location and action
103
- var locn = null;
104
- if ("location" in arg) {
105
- // Looks like v5
106
- locn = arg["location"];
51
+ _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {
52
+ if (isFunction(_unlisten)) {
53
+ _unlisten();
54
+ }
55
+ if (_pageViewTimer) {
56
+ clearTimeout(_pageViewTimer);
57
+ }
58
+ _initDefaults();
59
+ };
60
+ // Proxy the analytics functions
61
+ proxyFunctions(_self, _getAnalytics, [
62
+ "trackMetric",
63
+ "trackPageView",
64
+ "trackEvent",
65
+ "trackException",
66
+ "trackTrace",
67
+ ]);
68
+ function _initDefaults() {
69
+ _analyticsPlugin = null;
70
+ _extensionConfig = null;
71
+ _unlisten = null;
72
+ _pageViewTimer = null;
73
+ }
74
+ function _getAnalytics() {
75
+ if (!_analyticsPlugin) {
76
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
77
+ }
78
+ return _analyticsPlugin;
107
79
  }
108
- else {
109
- locn = arg;
80
+ function _addHistoryListener(history) {
81
+ var locationListener = function (arg) {
82
+ // v4 of the history API passes "location" as the first argument, while v5 passes an object that contains location and action
83
+ var locn = null;
84
+ if ("location" in arg) {
85
+ // Looks like v5
86
+ locn = arg["location"];
87
+ }
88
+ else {
89
+ locn = arg;
90
+ }
91
+ // Timeout to ensure any changes to the DOM made by route changes get included in pageView telemetry
92
+ _pageViewTimer = setTimeout(function () {
93
+ _pageViewTimer = null;
94
+ var pageViewTelemetry = { uri: locn.pathname };
95
+ _self.trackPageView(pageViewTelemetry);
96
+ }, 500);
97
+ };
98
+ _unlisten = history.listen(locationListener);
110
99
  }
111
- // Timeout to ensure any changes to the DOM made by route changes get included in pageView telemetry
112
- setTimeout(function () {
113
- var pageViewTelemetry = { uri: locn.pathname };
114
- _this.trackPageView(pageViewTelemetry);
115
- }, 500);
116
- };
117
- history.listen(locationListener);
118
- };
100
+ objDefineAccessors(_self, "_extensionConfig", function () { return _extensionConfig; });
101
+ });
102
+ return _this;
103
+ }
104
+ // Removed Stub for ReactPlugin.prototype.initialize.
105
+ // Removed Stub for ReactPlugin.prototype.getCookieMgr.
106
+ // Removed Stub for ReactPlugin.prototype.getAppInsights.
107
+ // Removed Stub for ReactPlugin.prototype.processTelemetry.
108
+ // Removed Stub for ReactPlugin.prototype.trackMetric.
109
+ // Removed Stub for ReactPlugin.prototype.trackPageView.
110
+ // Removed Stub for ReactPlugin.prototype.trackEvent.
111
+ // Removed Stub for ReactPlugin.prototype.trackException.
112
+ // Removed Stub for ReactPlugin.prototype.trackTrace.
119
113
  return ReactPlugin;
120
114
  }(BaseTelemetryPlugin));
121
115
  export default ReactPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"ReactPlugin.js.map","sources":["ReactPlugin.js"],"sourcesContent":["/**\r\n * ReactPlugin.ts\r\n * @copyright Microsoft 2019\r\n */\r\nimport { __extends } from \"tslib\";\r\nimport { BaseTelemetryPlugin, _InternalMessageId, LoggingSeverity, safeGetCookieMgr, arrForEach } from \"@microsoft/applicationinsights-core-js\";\r\nvar ReactPlugin = /** @class */ (function (_super) {\r\n __extends(ReactPlugin, _super);\r\n function ReactPlugin() {\r\n var _this = _super !== null && _super.apply(this, arguments) || this;\r\n _this.priority = 185;\r\n _this.identifier = 'ReactPlugin';\r\n return _this;\r\n }\r\n ReactPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {\r\n var _this = this;\r\n _super.prototype.initialize.call(this, config, core, extensions, pluginChain);\r\n this._extensionConfig =\r\n config.extensionConfig && config.extensionConfig[this.identifier]\r\n ? config.extensionConfig[this.identifier]\r\n : { history: null };\r\n arrForEach(extensions, function (ext) {\r\n var identifier = ext.identifier;\r\n if (identifier === 'ApplicationInsightsAnalytics') {\r\n _this._analyticsPlugin = ext;\r\n }\r\n });\r\n if (this._extensionConfig.history) {\r\n this.addHistoryListener(this._extensionConfig.history);\r\n var pageViewTelemetry = {\r\n uri: this._extensionConfig.history.location.pathname\r\n };\r\n this.trackPageView(pageViewTelemetry);\r\n }\r\n };\r\n /**\r\n * Get the current cookie manager for this instance\r\n */\r\n ReactPlugin.prototype.getCookieMgr = function () {\r\n return safeGetCookieMgr(this.core);\r\n };\r\n /**\r\n * Get application insights instance.\r\n */\r\n ReactPlugin.prototype.getAppInsights = function () {\r\n return this._analyticsPlugin;\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 ReactPlugin.prototype.processTelemetry = function (event, itemCtx) {\r\n this.processNext(event, itemCtx);\r\n };\r\n ReactPlugin.prototype.trackMetric = function (metric, customProperties) {\r\n if (this._analyticsPlugin) {\r\n this._analyticsPlugin.trackMetric(metric, customProperties);\r\n }\r\n else {\r\n this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, \"Analytics plugin is not available, React plugin telemetry will not be sent: \");\r\n }\r\n };\r\n ReactPlugin.prototype.trackPageView = function (pageView) {\r\n if (this._analyticsPlugin) {\r\n this._analyticsPlugin.trackPageView(pageView);\r\n }\r\n else {\r\n this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, \"Analytics plugin is not available, React plugin telemetry will not be sent: \");\r\n }\r\n };\r\n ReactPlugin.prototype.trackEvent = function (event, customProperties) {\r\n if (this._analyticsPlugin) {\r\n this._analyticsPlugin.trackEvent(event, customProperties);\r\n }\r\n else {\r\n this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, \"Analytics plugin is not available, React plugin telemetry will not be sent: \");\r\n }\r\n };\r\n ReactPlugin.prototype.trackException = function (exception, customProperties) {\r\n if (this._analyticsPlugin) {\r\n this._analyticsPlugin.trackException(exception, customProperties);\r\n }\r\n else {\r\n this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, \"Analytics plugin is not available, React plugin telemetry will not be sent: \");\r\n }\r\n };\r\n ReactPlugin.prototype.trackTrace = function (trace, customProperties) {\r\n if (this._analyticsPlugin) {\r\n this._analyticsPlugin.trackTrace(trace, customProperties);\r\n }\r\n else {\r\n this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, \"Analytics plugin is not available, React plugin telemetry will not be sent: \");\r\n }\r\n };\r\n ReactPlugin.prototype.addHistoryListener = function (history) {\r\n var _this = this;\r\n var locationListener = function (arg) {\r\n // v4 of the history API passes \"location\" as the first argument, while v5 passes an object that contains location and action \r\n var locn = null;\r\n if (\"location\" in arg) {\r\n // Looks like v5\r\n locn = arg[\"location\"];\r\n }\r\n else {\r\n locn = arg;\r\n }\r\n // Timeout to ensure any changes to the DOM made by route changes get included in pageView telemetry\r\n setTimeout(function () {\r\n var pageViewTelemetry = { uri: locn.pathname };\r\n _this.trackPageView(pageViewTelemetry);\r\n }, 500);\r\n };\r\n history.listen(locationListener);\r\n };\r\n return ReactPlugin;\r\n}(BaseTelemetryPlugin));\r\nexport default ReactPlugin;\r\n//# sourceMappingURL=ReactPlugin.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"}
1
+ {"version":3,"file":"ReactPlugin.js.map","sources":["ReactPlugin.js"],"sourcesContent":["/**\r\n * ReactPlugin.ts\r\n * @copyright Microsoft 2019\r\n */\r\nimport { __extends } from \"tslib\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { BaseTelemetryPlugin, _InternalMessageId, LoggingSeverity, safeGetCookieMgr, arrForEach, proxyFunctions, isFunction, objDefineAccessors } from \"@microsoft/applicationinsights-core-js\";\r\nvar ReactPlugin = /** @class */ (function (_super) {\r\n __extends(ReactPlugin, _super);\r\n function ReactPlugin() {\r\n var _this = _super.call(this) || this;\r\n _this.priority = 185;\r\n _this.identifier = 'ReactPlugin';\r\n var _analyticsPlugin;\r\n var _extensionConfig;\r\n var _unlisten;\r\n var _pageViewTimer;\r\n dynamicProto(ReactPlugin, _this, function (_self, _base) {\r\n _initDefaults();\r\n _self.initialize = function (config, core, extensions, pluginChain) {\r\n _super.prototype.initialize.call(_this, config, core, extensions, pluginChain);\r\n _extensionConfig =\r\n config.extensionConfig && config.extensionConfig[_self.identifier]\r\n ? config.extensionConfig[_self.identifier]\r\n : { history: null };\r\n arrForEach(extensions, function (ext) {\r\n var identifier = ext.identifier;\r\n if (identifier === 'ApplicationInsightsAnalytics') {\r\n _analyticsPlugin = ext;\r\n }\r\n });\r\n if (_extensionConfig.history) {\r\n _addHistoryListener(_extensionConfig.history);\r\n var pageViewTelemetry = {\r\n uri: _extensionConfig.history.location.pathname\r\n };\r\n _self.trackPageView(pageViewTelemetry);\r\n }\r\n };\r\n _self.getCookieMgr = function () {\r\n return safeGetCookieMgr(_self.core);\r\n };\r\n _self.getAppInsights = _getAnalytics;\r\n _self.processTelemetry = function (event, itemCtx) {\r\n _self.processNext(event, itemCtx);\r\n };\r\n _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {\r\n if (isFunction(_unlisten)) {\r\n _unlisten();\r\n }\r\n if (_pageViewTimer) {\r\n clearTimeout(_pageViewTimer);\r\n }\r\n _initDefaults();\r\n };\r\n // Proxy the analytics functions\r\n proxyFunctions(_self, _getAnalytics, [\r\n \"trackMetric\",\r\n \"trackPageView\",\r\n \"trackEvent\",\r\n \"trackException\",\r\n \"trackTrace\",\r\n ]);\r\n function _initDefaults() {\r\n _analyticsPlugin = null;\r\n _extensionConfig = null;\r\n _unlisten = null;\r\n _pageViewTimer = null;\r\n }\r\n function _getAnalytics() {\r\n if (!_analyticsPlugin) {\r\n _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, \"Analytics plugin is not available, React plugin telemetry will not be sent: \");\r\n }\r\n return _analyticsPlugin;\r\n }\r\n function _addHistoryListener(history) {\r\n var locationListener = function (arg) {\r\n // v4 of the history API passes \"location\" as the first argument, while v5 passes an object that contains location and action \r\n var locn = null;\r\n if (\"location\" in arg) {\r\n // Looks like v5\r\n locn = arg[\"location\"];\r\n }\r\n else {\r\n locn = arg;\r\n }\r\n // Timeout to ensure any changes to the DOM made by route changes get included in pageView telemetry\r\n _pageViewTimer = setTimeout(function () {\r\n _pageViewTimer = null;\r\n var pageViewTelemetry = { uri: locn.pathname };\r\n _self.trackPageView(pageViewTelemetry);\r\n }, 500);\r\n };\r\n _unlisten = history.listen(locationListener);\r\n }\r\n objDefineAccessors(_self, \"_extensionConfig\", function () { return _extensionConfig; });\r\n });\r\n return _this;\r\n }\r\n ReactPlugin.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 * Get the current cookie manager for this instance\r\n */\r\n ReactPlugin.prototype.getCookieMgr = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Get application insights instance.\r\n */\r\n ReactPlugin.prototype.getAppInsights = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\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 ReactPlugin.prototype.processTelemetry = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactPlugin.prototype.trackMetric = function (metric, customProperties) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactPlugin.prototype.trackPageView = function (pageView) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactPlugin.prototype.trackEvent = function (event, customProperties) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactPlugin.prototype.trackException = function (exception, customProperties) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ReactPlugin.prototype.trackTrace = function (trace, customProperties) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return ReactPlugin;\r\n}(BaseTelemetryPlugin));\r\nexport default ReactPlugin;\r\n//# sourceMappingURL=ReactPlugin.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;;;;;;;;qDAsCM;AACN;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-08
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-11
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 - React Plugin, 3.3.0-beta.2203-08
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-11
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  /**
@@ -1,7 +1,8 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-08
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-11
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
+ import { __assignFn as __assign } from "@microsoft/applicationinsights-shims";
5
6
  import { useEffect, useRef } from "react";
6
7
  import { dateNow } from "@microsoft/applicationinsights-core-js";
7
8
  function getEngagementTimeSeconds(trackedData) {
@@ -11,7 +12,7 @@ function getEngagementTimeSeconds(trackedData) {
11
12
  trackedData.idleCount * trackedData.idleTimeout) /
12
13
  1000);
13
14
  }
14
- var useComponentTracking = function (reactPlugin, componentName) {
15
+ var useComponentTracking = function (reactPlugin, componentName, customProperties) {
15
16
  var tracking = useRef({
16
17
  hookTimestamp: dateNow(),
17
18
  firstActiveTimestamp: 0,
@@ -51,7 +52,7 @@ var useComponentTracking = function (reactPlugin, componentName) {
51
52
  name: "React Component Engaged Time (seconds)",
52
53
  sampleCount: 1
53
54
  };
54
- var additionalProperties = { "Component Name": componentName };
55
+ var additionalProperties = __assign({ "Component Name": componentName }, customProperties);
55
56
  reactPlugin.trackMetric(metricData, additionalProperties);
56
57
  };
57
58
  }, []);
@@ -1 +1 @@
1
- {"version":3,"file":"useTrackMetric.js.map","sources":["useTrackMetric.js"],"sourcesContent":["import { useEffect, useRef } from \"react\";\r\nimport { dateNow } from \"@microsoft/applicationinsights-core-js\";\r\nfunction getEngagementTimeSeconds(trackedData) {\r\n return ((dateNow() -\r\n trackedData.firstActiveTimestamp -\r\n trackedData.totalIdleTime -\r\n trackedData.idleCount * trackedData.idleTimeout) /\r\n 1000);\r\n}\r\nvar useComponentTracking = function (reactPlugin, componentName) {\r\n var tracking = useRef({\r\n hookTimestamp: dateNow(),\r\n firstActiveTimestamp: 0,\r\n totalIdleTime: 0,\r\n lastActiveTimestamp: 0,\r\n idleStartTimestamp: 0,\r\n idleCount: 0,\r\n idleTimeout: 5000\r\n });\r\n var savedCallback = useRef();\r\n var callback = function () {\r\n var trackedData = tracking.current;\r\n if (trackedData.lastActiveTimestamp > 0 &&\r\n trackedData.idleStartTimestamp === 0 &&\r\n dateNow() - trackedData.lastActiveTimestamp >= trackedData.idleTimeout) {\r\n trackedData.idleStartTimestamp = dateNow();\r\n trackedData.idleCount++;\r\n }\r\n };\r\n var delay = 100;\r\n savedCallback.current = callback;\r\n // Set up the interval.\r\n useEffect(function () {\r\n var id = setInterval(savedCallback.current, delay);\r\n return function () {\r\n clearInterval(id);\r\n var trackedData = tracking.current;\r\n if (trackedData.hookTimestamp === 0) {\r\n throw new Error(\"useAppInsights:unload hook: hookTimestamp is not initialized.\");\r\n }\r\n if (trackedData.firstActiveTimestamp === 0) {\r\n return;\r\n }\r\n var engagementTime = getEngagementTimeSeconds(trackedData);\r\n var metricData = {\r\n average: engagementTime,\r\n name: \"React Component Engaged Time (seconds)\",\r\n sampleCount: 1\r\n };\r\n var additionalProperties = { \"Component Name\": componentName };\r\n reactPlugin.trackMetric(metricData, additionalProperties);\r\n };\r\n }, []);\r\n var trackActivity = function () {\r\n var trackedData = tracking.current;\r\n if (trackedData.firstActiveTimestamp === 0) {\r\n trackedData.firstActiveTimestamp = dateNow();\r\n trackedData.lastActiveTimestamp = trackedData.firstActiveTimestamp;\r\n }\r\n else {\r\n trackedData.lastActiveTimestamp = dateNow();\r\n }\r\n if (trackedData.idleStartTimestamp > 0) {\r\n var lastIdleTime = trackedData.lastActiveTimestamp - trackedData.idleStartTimestamp;\r\n trackedData.totalIdleTime += lastIdleTime;\r\n trackedData.idleStartTimestamp = 0;\r\n }\r\n };\r\n return trackActivity;\r\n};\r\nexport default useComponentTracking;\r\n//# sourceMappingURL=useTrackMetric.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"}
1
+ {"version":3,"file":"useTrackMetric.js.map","sources":["useTrackMetric.js"],"sourcesContent":["import { __assign } from \"tslib\";\r\nimport { useEffect, useRef } from \"react\";\r\nimport { dateNow } from \"@microsoft/applicationinsights-core-js\";\r\nfunction getEngagementTimeSeconds(trackedData) {\r\n return ((dateNow() -\r\n trackedData.firstActiveTimestamp -\r\n trackedData.totalIdleTime -\r\n trackedData.idleCount * trackedData.idleTimeout) /\r\n 1000);\r\n}\r\nvar useComponentTracking = function (reactPlugin, componentName, customProperties) {\r\n var tracking = useRef({\r\n hookTimestamp: dateNow(),\r\n firstActiveTimestamp: 0,\r\n totalIdleTime: 0,\r\n lastActiveTimestamp: 0,\r\n idleStartTimestamp: 0,\r\n idleCount: 0,\r\n idleTimeout: 5000\r\n });\r\n var savedCallback = useRef();\r\n var callback = function () {\r\n var trackedData = tracking.current;\r\n if (trackedData.lastActiveTimestamp > 0 &&\r\n trackedData.idleStartTimestamp === 0 &&\r\n dateNow() - trackedData.lastActiveTimestamp >= trackedData.idleTimeout) {\r\n trackedData.idleStartTimestamp = dateNow();\r\n trackedData.idleCount++;\r\n }\r\n };\r\n var delay = 100;\r\n savedCallback.current = callback;\r\n // Set up the interval.\r\n useEffect(function () {\r\n var id = setInterval(savedCallback.current, delay);\r\n return function () {\r\n clearInterval(id);\r\n var trackedData = tracking.current;\r\n if (trackedData.hookTimestamp === 0) {\r\n throw new Error(\"useAppInsights:unload hook: hookTimestamp is not initialized.\");\r\n }\r\n if (trackedData.firstActiveTimestamp === 0) {\r\n return;\r\n }\r\n var engagementTime = getEngagementTimeSeconds(trackedData);\r\n var metricData = {\r\n average: engagementTime,\r\n name: \"React Component Engaged Time (seconds)\",\r\n sampleCount: 1\r\n };\r\n var additionalProperties = __assign({ \"Component Name\": componentName }, customProperties);\r\n reactPlugin.trackMetric(metricData, additionalProperties);\r\n };\r\n }, []);\r\n var trackActivity = function () {\r\n var trackedData = tracking.current;\r\n if (trackedData.firstActiveTimestamp === 0) {\r\n trackedData.firstActiveTimestamp = dateNow();\r\n trackedData.lastActiveTimestamp = trackedData.firstActiveTimestamp;\r\n }\r\n else {\r\n trackedData.lastActiveTimestamp = dateNow();\r\n }\r\n if (trackedData.idleStartTimestamp > 0) {\r\n var lastIdleTime = trackedData.lastActiveTimestamp - trackedData.idleStartTimestamp;\r\n trackedData.totalIdleTime += lastIdleTime;\r\n trackedData.idleStartTimestamp = 0;\r\n }\r\n };\r\n return trackActivity;\r\n};\r\nexport default useComponentTracking;\r\n//# sourceMappingURL=useTrackMetric.js.map"],"names":[],"mappings":";;;;AAAA,8EAAiC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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 - React Plugin, 3.3.0-beta.2203-08
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-11
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-react-js",
3
- "version": "3.3.0-beta.2203-08",
3
+ "version": "3.3.0-beta.2203-11",
4
4
  "description": "Microsoft Application Insights React plugin",
5
5
  "main": "dist/applicationinsights-react-js.js",
6
6
  "module": "dist-esm/applicationinsights-react-js.js",
@@ -47,7 +47,7 @@
47
47
  "@rollup/plugin-commonjs": "^18.0.0",
48
48
  "@rollup/plugin-node-resolve": "^11.2.1",
49
49
  "@rollup/plugin-replace": "^2.3.3",
50
- "rollup-plugin-cleanup": "3.2.1",
50
+ "rollup-plugin-cleanup": "^3.2.1",
51
51
  "rollup-plugin-peer-deps-external": "^2.2.4",
52
52
  "rollup": "^2.32.0",
53
53
  "ts-jest": "^27.0.7",
@@ -58,8 +58,8 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@microsoft/applicationinsights-shims": "2.0.1",
61
- "@microsoft/applicationinsights-core-js": "2.8.0-beta.2203-08",
62
- "@microsoft/applicationinsights-common": "2.8.0-beta.2203-08",
61
+ "@microsoft/applicationinsights-core-js": "2.8.0-beta.2203-11",
62
+ "@microsoft/applicationinsights-common": "2.8.0-beta.2203-11",
63
63
  "@microsoft/dynamicproto-js": "^1.1.4"
64
64
  },
65
65
  "peerDependencies": {