@microsoft/applicationinsights-react-js 19.3.7-nightly.2507-03 → 19.3.7-nightly.2507-04

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 (30) hide show
  1. package/dist-esm/AppInsightsContext.js +0 -4
  2. package/dist-esm/AppInsightsContext.js.map +1 -1
  3. package/dist-esm/AppInsightsErrorBoundary.js +3 -7
  4. package/dist-esm/AppInsightsErrorBoundary.js.map +1 -1
  5. package/dist-esm/Interfaces/IReactExtensionConfig.js +2 -6
  6. package/dist-esm/Interfaces/IReactExtensionConfig.js.map +1 -1
  7. package/dist-esm/ReactPlugin.js +40 -19
  8. package/dist-esm/ReactPlugin.js.map +1 -1
  9. package/dist-esm/applicationinsights-react-js.js +2 -6
  10. package/dist-esm/applicationinsights-react-js.js.map +1 -1
  11. package/dist-esm/useTrackEvent.js +0 -4
  12. package/dist-esm/useTrackEvent.js.map +1 -1
  13. package/dist-esm/useTrackMetric.js +1 -5
  14. package/dist-esm/useTrackMetric.js.map +1 -1
  15. package/dist-esm/withAITracking.js +3 -7
  16. package/dist-esm/withAITracking.js.map +1 -1
  17. package/package.json +1 -1
  18. package/browser/applicationinsights-react-js.js +0 -3863
  19. package/browser/applicationinsights-react-js.js.map +0 -1
  20. package/browser/applicationinsights-react-js.min.js +0 -6
  21. package/browser/applicationinsights-react-js.min.js.map +0 -1
  22. package/dist/applicationinsights-react-js.api.json +0 -1982
  23. package/dist/applicationinsights-react-js.api.md +0 -129
  24. package/dist/applicationinsights-react-js.d.ts +0 -137
  25. package/dist/applicationinsights-react-js.js +0 -3863
  26. package/dist/applicationinsights-react-js.js.map +0 -1
  27. package/dist/applicationinsights-react-js.min.js +0 -6
  28. package/dist/applicationinsights-react-js.min.js.map +0 -1
  29. package/dist/applicationinsights-react-js.rollup.d.ts +0 -142
  30. package/types/tsdoc-metadata.json +0 -11
@@ -1,7 +1,3 @@
1
- /*
2
- * Application Insights JavaScript SDK - React Plugin, 19.3.7-nightly.2507-03
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- */
5
1
  import { createContext, useContext } from "react";
6
2
  var AppInsightsContext = createContext(undefined);
7
3
  var useAppInsightsContext = function () { return useContext(AppInsightsContext); };
@@ -1 +1 @@
1
- {"version":3,"file":"AppInsightsContext.js.map","sources":["AppInsightsContext.js"],"sourcesContent":["import { createContext, useContext } from \"react\";\r\nvar AppInsightsContext = createContext(undefined);\r\nvar useAppInsightsContext = function () { return useContext(AppInsightsContext); };\r\nexport { AppInsightsContext, useAppInsightsContext };\r\n//# sourceMappingURL=AppInsightsContext.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"AppInsightsContext.js","sourceRoot":"","sources":["../src/AppInsightsContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAW,MAAM,OAAO,CAAC;AAI3D,IAAM,kBAAkB,GAAG,aAAa,CAAc,SAAS,CAA4B,CAAC;AAE5F,IAAM,qBAAqB,GAAG,cAAM,OAAA,UAAU,CAAC,kBAAkB,CAAC,EAA9B,CAA8B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["import { createContext, useContext, Context } from \"react\";\r\nimport ReactPlugin from \"./ReactPlugin\";\r\n\r\nexport declare type AppInsightsReactContext = Context<ReactPlugin>\r\nconst AppInsightsContext = createContext<ReactPlugin>(undefined) as AppInsightsReactContext;\r\n\r\nconst useAppInsightsContext = () => useContext(AppInsightsContext);\r\n\r\nexport { AppInsightsContext, useAppInsightsContext };\r\n"]}
@@ -1,10 +1,6 @@
1
- /*
2
- * Application Insights JavaScript SDK - React Plugin, 19.3.7-nightly.2507-03
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- */
5
-
6
-
7
- import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+ import { __extends } from "tslib";
8
4
  import React from "react";
9
5
  import { SeverityLevel } from "@microsoft/applicationinsights-common";
10
6
  var AppInsightsErrorBoundary = /** @class */ (function (_super) {
@@ -1 +1 @@
1
- {"version":3,"file":"AppInsightsErrorBoundary.js.map","sources":["AppInsightsErrorBoundary.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { __extends } from \"tslib\";\r\nimport React from \"react\";\r\nimport { SeverityLevel } from \"@microsoft/applicationinsights-common\";\r\nvar AppInsightsErrorBoundary = /** @class */ (function (_super) {\r\n __extends(AppInsightsErrorBoundary, _super);\r\n function AppInsightsErrorBoundary() {\r\n var _this = _super !== null && _super.apply(this, arguments) || this;\r\n _this.state = { hasError: false };\r\n return _this;\r\n }\r\n AppInsightsErrorBoundary.prototype.componentDidCatch = function (error, errorInfo) {\r\n this.setState({ hasError: true });\r\n this.props.appInsights.trackException({\r\n error: error,\r\n exception: error,\r\n severityLevel: SeverityLevel.Error,\r\n properties: errorInfo\r\n });\r\n };\r\n AppInsightsErrorBoundary.prototype.render = function () {\r\n if (this.state.hasError) {\r\n var onError = this.props.onError;\r\n return React.createElement(onError);\r\n }\r\n return this.props.children;\r\n };\r\n return AppInsightsErrorBoundary;\r\n}(React.Component));\r\nexport default AppInsightsErrorBoundary;\r\n//# sourceMappingURL=AppInsightsErrorBoundary.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC,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"}
1
+ {"version":3,"file":"AppInsightsErrorBoundary.js","sourceRoot":"","sources":["../src/AppInsightsErrorBoundary.tsx"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAatE;IAAsD,4CAA+E;IAArI;QAAA,qEAqBC;QApBG,WAAK,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;IAoBhC,CAAC;IAlBG,oDAAiB,GAAjB,UAAkB,KAAY,EAAE,SAA0B;QACtD,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,cAAc,CAAC;YAClC,KAAK,EAAE,KAAK;YACZ,SAAS,EAAE,KAAK;YAChB,aAAa,EAAE,aAAa,CAAC,KAAK;YAClC,UAAU,EAAE,SAAS;SACxB,CAAC,CAAC;IACP,CAAC;IAED,yCAAM,GAAN;QACI,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACb,IAAA,OAAO,GAAK,IAAI,CAAC,KAAK,QAAf,CAAgB;YAC/B,OAAO,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;SACvC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC/B,CAAC;IACL,+BAAC;AAAD,CAAC,AArBD,CAAsD,KAAK,CAAC,SAAS,GAqBpE","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\nimport React from \"react\";\r\nimport { SeverityLevel } from \"@microsoft/applicationinsights-common\";\r\nimport ReactPlugin from \"./ReactPlugin\";\r\n\r\nexport interface IAppInsightsErrorBoundaryProps {\r\n appInsights: ReactPlugin\r\n onError: React.ComponentType<any>\r\n children: React.ReactElement\r\n}\r\n\r\nexport interface IAppInsightsErrorBoundaryState {\r\n hasError: boolean\r\n}\r\n\r\nexport default class AppInsightsErrorBoundary extends React.Component<IAppInsightsErrorBoundaryProps, IAppInsightsErrorBoundaryState> {\r\n state = { hasError: false };\r\n\r\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\r\n this.setState({ hasError: true });\r\n this.props.appInsights.trackException({\r\n error: error,\r\n exception: error,\r\n severityLevel: SeverityLevel.Error,\r\n properties: errorInfo\r\n });\r\n }\r\n\r\n render() {\r\n if (this.state.hasError) {\r\n const { onError } = this.props;\r\n return React.createElement(onError);\r\n }\r\n\r\n return this.props.children;\r\n }\r\n}\r\n"]}
@@ -1,8 +1,4 @@
1
- /*
2
- * Application Insights JavaScript SDK - React Plugin, 19.3.7-nightly.2507-03
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- */
5
-
6
-
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
7
3
  export {};
8
4
  //# sourceMappingURL=IReactExtensionConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IReactExtensionConfig.js.map","sources":["IReactExtensionConfig.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nexport {};\r\n//# sourceMappingURL=IReactExtensionConfig.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA"}
1
+ {"version":3,"file":"IReactExtensionConfig.js","sourceRoot":"","sources":["../../src/Interfaces/IReactExtensionConfig.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\nimport { History } from \"history\";\r\n\r\n/**\r\n * Settings to initialize a ReactAI instance.\r\n */\r\nexport interface IReactExtensionConfig {\r\n /**\r\n * React router history for enabling Application Insights PageView tracking.\r\n *\r\n * @type {History}\r\n * @memberof IReactAISettings\r\n */\r\n readonly history?: History;\r\n}\r\n"]}
@@ -1,12 +1,8 @@
1
- /*
2
- * Application Insights JavaScript SDK - React Plugin, 19.3.7-nightly.2507-03
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- */
5
1
  /**
6
2
  * ReactPlugin.ts
7
3
  * @copyright Microsoft 2019
8
4
  */
9
- import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
5
+ import { __extends } from "tslib";
10
6
  import dynamicProto from "@microsoft/dynamicproto-js";
11
7
  import { AnalyticsPluginIdentifier, PropertiesPluginIdentifier } from "@microsoft/applicationinsights-common";
12
8
  import { BaseTelemetryPlugin, _throwInternal, isFunction, proxyFunctions, safeGetCookieMgr, onConfigChange, objDefineAccessors } from "@microsoft/applicationinsights-core-js";
@@ -120,20 +116,45 @@ var ReactPlugin = /** @class */ (function (_super) {
120
116
  });
121
117
  return _this;
122
118
  }
123
- // Removed Stub for ReactPlugin.prototype.initialize.
124
- // Removed Stub for ReactPlugin.prototype.getCookieMgr.
125
- // Removed Stub for ReactPlugin.prototype.getAppInsights.
126
- // Removed Stub for ReactPlugin.prototype.processTelemetry.
127
- // Removed Stub for ReactPlugin.prototype.trackMetric.
128
- // Removed Stub for ReactPlugin.prototype.trackPageView.
129
- // Removed Stub for ReactPlugin.prototype.trackEvent.
130
- // Removed Stub for ReactPlugin.prototype.trackException.
131
- // Removed Stub for ReactPlugin.prototype.trackTrace.
132
- // This is a workaround for an IE8 bug when using dynamicProto() with classes that don't have any
133
- // non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
134
- // this will be removed when ES3 support is dropped.
135
- ReactPlugin.__ieDyn=1;
136
-
119
+ ReactPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
120
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
121
+ };
122
+ /**
123
+ * Get the current cookie manager for this instance
124
+ */
125
+ ReactPlugin.prototype.getCookieMgr = function () {
126
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
127
+ return null;
128
+ };
129
+ /**
130
+ * Get application insights instance.
131
+ */
132
+ ReactPlugin.prototype.getAppInsights = function () {
133
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
134
+ return null;
135
+ };
136
+ /**
137
+ * Add Part A fields to the event
138
+ * @param event The event that needs to be processed
139
+ */
140
+ ReactPlugin.prototype.processTelemetry = function (event, itemCtx) {
141
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
142
+ };
143
+ ReactPlugin.prototype.trackMetric = function (metric, customProperties) {
144
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
145
+ };
146
+ ReactPlugin.prototype.trackPageView = function (pageView) {
147
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
148
+ };
149
+ ReactPlugin.prototype.trackEvent = function (event, customProperties) {
150
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
151
+ };
152
+ ReactPlugin.prototype.trackException = function (exception, customProperties) {
153
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
154
+ };
155
+ ReactPlugin.prototype.trackTrace = function (trace, customProperties) {
156
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
157
+ };
137
158
  return ReactPlugin;
138
159
  }(BaseTelemetryPlugin));
139
160
  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 dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { AnalyticsPluginIdentifier, PropertiesPluginIdentifier } from \"@microsoft/applicationinsights-common\";\r\nimport { BaseTelemetryPlugin, _throwInternal, isFunction, proxyFunctions, safeGetCookieMgr, onConfigChange, objDefineAccessors } from \"@microsoft/applicationinsights-core-js\";\r\nimport { objDeepFreeze, objDefine } from \"@nevware21/ts-utils\";\r\nvar defaultReactExtensionConfig = objDeepFreeze({\r\n history: { blkVal: true, v: undefined }\r\n});\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 var _pageViewTracked;\r\n var properties;\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 var thePlugin = core.getPlugin(PropertiesPluginIdentifier);\r\n if (thePlugin) {\r\n properties = thePlugin.plugin;\r\n }\r\n objDefine(_self, \"context\", {\r\n g: function () { return properties ? properties.context : null; }\r\n });\r\n _self._addHook(onConfigChange(config, function (details) {\r\n var _a;\r\n var ctx = _self._getTelCtx();\r\n _extensionConfig = ctx.getExtCfg(_this.identifier, defaultReactExtensionConfig);\r\n _analyticsPlugin = (_a = core.getPlugin(AnalyticsPluginIdentifier)) === null || _a === void 0 ? void 0 : _a.plugin;\r\n if (isFunction(_unlisten)) {\r\n _unlisten();\r\n _unlisten = null;\r\n }\r\n if (_extensionConfig.history) {\r\n _addHistoryListener(_extensionConfig.history);\r\n if (!_pageViewTracked) {\r\n var pageViewTelemetry = {\r\n uri: _extensionConfig.history.location.pathname\r\n };\r\n _self.trackPageView(pageViewTelemetry);\r\n _pageViewTracked = true;\r\n }\r\n }\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 _pageViewTracked = false;\r\n properties = null;\r\n }\r\n function _getAnalytics() {\r\n if (!_analyticsPlugin) {\r\n _throwInternal(_self.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, 64 /* _eInternalMessageId.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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;qDAsCM,CAAC;;;;;;uBACgB;AACvB;AACA;AACA"}
1
+ {"version":3,"file":"ReactPlugin.js","sourceRoot":"","sources":["../src/ReactPlugin.ts"],"names":[],"mappings":"AAAA;;;EAGE;;AAEF,OAAO,YAAY,MAAM,4BAA4B,CAAC;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AO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;YACjD,CAAC;YAED,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,EAAE,cAAM,OAAA,gBAAgB,EAAhB,CAAgB,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;;IACP,CAAC;IAED,gCAAU,GAAV,UAAW,MAAgC,EAAE,IAAsB,EAAE,UAAqB,EAAE,WAAkC;QAC1H,oFAAoF;IACxF,CAAC;IAED;;OAEG;IACH,kCAAY,GAAZ;QACI,oFAAoF;QACpF,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,oCAAc,GAAd;QACI,oFAAoF;QACpF,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,sCAAgB,GAAhB,UAAiB,KAAqB,EAAE,OAAkC;QACtE,oFAAoF;IACxF,CAAC;IAED,iCAAW,GAAX,UAAY,MAAwB,EAAE,gBAAmC;QACrE,oFAAoF;IACxF,CAAC;IAED,mCAAa,GAAb,UAAc,QAA4B;QACtC,oFAAoF;IACxF,CAAC;IAED,gCAAU,GAAV,UAAW,KAAsB,EAAE,gBAAoC;QACnE,oFAAoF;IACxF,CAAC;IAED,oCAAc,GAAd,UAAe,SAA8B,EAAE,gBAAoC;QAC/E,oFAAoF;IACxF,CAAC;IAED,gCAAU,GAAV,UAAW,KAAsB,EAAE,gBAAoC;QACnE,oFAAoF;IACxF,CAAC;IACL,kBAAC;AAAD,CAAC,AA9KD,CAAyC,mBAAmB,GA8K3D","sourcesContent":["/**\r\n* ReactPlugin.ts\r\n* @copyright Microsoft 2019\r\n*/\r\n\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport {\r\n AnalyticsPluginIdentifier,\r\n IAppInsights, IConfig, IEventTelemetry, IExceptionTelemetry, IMetricTelemetry, IPageViewTelemetry, ITraceTelemetry, ITelemetryContext as Common_ITelemetryContext, PropertiesPluginIdentifier\r\n} from \"@microsoft/applicationinsights-common\";\r\nimport {\r\n BaseTelemetryPlugin, IAppInsightsCore, IConfiguration, ICookieMgr, ICustomProperties, IPlugin, IProcessTelemetryContext,\r\n IProcessTelemetryUnloadContext, ITelemetryItem, ITelemetryPlugin, ITelemetryPluginChain, ITelemetryUnloadState, _eInternalMessageId,\r\n _throwInternal, arrForEach, eLoggingSeverity, isFunction, proxyFunctions, safeGetCookieMgr, IConfigDefaults, onConfigChange, objDefineAccessors\r\n} from \"@microsoft/applicationinsights-core-js\";\r\nimport {objDeepFreeze, objDefine} from \"@nevware21/ts-utils\";\r\n\r\nimport { History, Location, Update } from \"history\";\r\n\r\nimport { IReactExtensionConfig } from './Interfaces/IReactExtensionConfig';\r\nconst defaultReactExtensionConfig: IConfigDefaults<IReactExtensionConfig> = objDeepFreeze({\r\n history: { blkVal: true, v: undefined }\r\n});\r\nimport { PropertiesPlugin } from \"@microsoft/applicationinsights-properties-js\";\r\n\r\nexport default class ReactPlugin extends BaseTelemetryPlugin {\r\n public priority = 185;\r\n public identifier = 'ReactPlugin';\r\n public readonly context: Common_ITelemetryContext;\r\n\r\n\r\n constructor() {\r\n super();\r\n let _analyticsPlugin: IAppInsights;\r\n let _extensionConfig: IReactExtensionConfig;\r\n let _unlisten: any;\r\n let _pageViewTimer: any;\r\n let _pageViewTracked:boolean;\r\n let properties: PropertiesPlugin;\r\n\r\n\r\n dynamicProto(ReactPlugin, this, (_self, _base) => {\r\n _initDefaults();\r\n\r\n _self.initialize = (config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain) => {\r\n super.initialize(config, core, extensions, pluginChain);\r\n \r\n let thePlugin = core.getPlugin<PropertiesPlugin>(PropertiesPluginIdentifier);\r\n if (thePlugin) {\r\n properties = thePlugin.plugin;\r\n }\r\n objDefine(_self, \"context\", {\r\n g: () => properties ? properties.context : null\r\n });\r\n\r\n _self._addHook(onConfigChange(config, (details) => {\r\n let ctx = _self._getTelCtx();\r\n _extensionConfig = ctx.getExtCfg<IReactExtensionConfig>(this.identifier, defaultReactExtensionConfig);\r\n _analyticsPlugin = core.getPlugin<any>(AnalyticsPluginIdentifier)?.plugin as IAppInsights;\r\n \r\n if (isFunction(_unlisten)) {\r\n _unlisten();\r\n _unlisten = null;\r\n }\r\n if (_extensionConfig.history) {\r\n _addHistoryListener(_extensionConfig.history);\r\n if (!_pageViewTracked){\r\n const pageViewTelemetry: IPageViewTelemetry = {\r\n uri: _extensionConfig.history.location.pathname\r\n };\r\n _self.trackPageView(pageViewTelemetry);\r\n _pageViewTracked = true;\r\n }\r\n }\r\n }));\r\n };\r\n\r\n _self.getCookieMgr = (): ICookieMgr => {\r\n return safeGetCookieMgr(_self.core);\r\n };\r\n \r\n _self.getAppInsights = _getAnalytics;\r\n \r\n _self.processTelemetry = (event: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => {\r\n _self.processNext(event, itemCtx);\r\n };\r\n \r\n _self._doTeardown = (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void): void | boolean => {\r\n if (isFunction(_unlisten)) {\r\n _unlisten();\r\n }\r\n\r\n if (_pageViewTimer) {\r\n clearTimeout(_pageViewTimer);\r\n }\r\n\r\n _initDefaults();\r\n };\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 \r\n function _initDefaults() {\r\n _analyticsPlugin = null;\r\n _extensionConfig = null;\r\n _unlisten = null;\r\n _pageViewTimer = null;\r\n _pageViewTracked = false;\r\n properties = null;\r\n }\r\n\r\n function _getAnalytics() {\r\n if (!_analyticsPlugin) {\r\n _throwInternal(_self.diagLog(),\r\n eLoggingSeverity.CRITICAL, _eInternalMessageId.TelemetryInitializerFailed, \"Analytics plugin is not available, React plugin telemetry will not be sent: \");\r\n }\r\n\r\n return _analyticsPlugin;\r\n }\r\n\r\n function _addHistoryListener(history: History): void {\r\n const locationListener = (arg: Location | Update): void => {\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 let locn: Location = null;\r\n if (\"location\" in arg) {\r\n // Looks like v5\r\n locn = arg[\"location\"];\r\n } else {\r\n locn = arg as Location;\r\n }\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(() => {\r\n _pageViewTimer = null;\r\n const pageViewTelemetry: IPageViewTelemetry = { uri: locn.pathname };\r\n _self.trackPageView(pageViewTelemetry);\r\n }, 500);\r\n };\r\n\r\n _unlisten = history.listen(locationListener);\r\n }\r\n \r\n objDefineAccessors(_self, \"_extensionConfig\", () => _extensionConfig);\r\n });\r\n }\r\n\r\n initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n }\r\n\r\n /**\r\n * Get the current cookie manager for this instance\r\n */\r\n getCookieMgr(): ICookieMgr {\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 /**\r\n * Get application insights instance.\r\n */\r\n getAppInsights(): IAppInsights {\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 /**\r\n * Add Part A fields to the event\r\n * @param event The event that needs to be processed\r\n */\r\n processTelemetry(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n }\r\n\r\n trackMetric(metric: IMetricTelemetry, customProperties: ICustomProperties) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n }\r\n\r\n trackPageView(pageView: IPageViewTelemetry) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n }\r\n\r\n trackEvent(event: IEventTelemetry, customProperties?: ICustomProperties) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n }\r\n\r\n trackException(exception: IExceptionTelemetry, customProperties?: ICustomProperties) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n }\r\n\r\n trackTrace(trace: ITraceTelemetry, customProperties?: ICustomProperties) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n }\r\n}\r\n"]}
@@ -1,9 +1,5 @@
1
- /*
2
- * Application Insights JavaScript SDK - React Plugin, 19.3.7-nightly.2507-03
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- */
5
-
6
-
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
7
3
  import ReactPlugin from "./ReactPlugin";
8
4
  import withAITracking, { AITrackedComponentBase } from "./withAITracking";
9
5
  import AppInsightsErrorBoundary from "./AppInsightsErrorBoundary";
@@ -1 +1 @@
1
- {"version":3,"file":"applicationinsights-react-js.js.map","sources":["applicationinsights-react-js.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport ReactPlugin from \"./ReactPlugin\";\r\nimport withAITracking, { AITrackedComponentBase } from \"./withAITracking\";\r\nimport AppInsightsErrorBoundary from \"./AppInsightsErrorBoundary\";\r\nimport { AppInsightsContext, useAppInsightsContext } from \"./AppInsightsContext\";\r\nimport useTrackEvent from \"./useTrackEvent\";\r\nimport useTrackMetric from \"./useTrackMetric\";\r\nexport { ReactPlugin, withAITracking, AppInsightsErrorBoundary, AppInsightsContext, useAppInsightsContext, useTrackEvent, useTrackMetric, AITrackedComponentBase };\r\n//# sourceMappingURL=applicationinsights-react-js.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"applicationinsights-react-js.js","sourceRoot":"","sources":["../src/applicationinsights-react-js.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;AAGlC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,cAAc,EAAE,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,wBAAwB,MAAM,4BAA4B,CAAA;AACjE,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EACL,WAAW,EAEX,cAAc,EACd,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,sBAAsB,EACvB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\nimport { IReactExtensionConfig } from \"./Interfaces/IReactExtensionConfig\";\r\nimport ReactPlugin from \"./ReactPlugin\";\r\nimport withAITracking, { AITrackedComponentBase } from \"./withAITracking\";\r\nimport AppInsightsErrorBoundary from \"./AppInsightsErrorBoundary\"\r\nimport {\r\n AppInsightsContext,\r\n useAppInsightsContext\r\n} from \"./AppInsightsContext\";\r\nimport useTrackEvent from \"./useTrackEvent\";\r\nimport useTrackMetric from \"./useTrackMetric\";\r\n\r\nexport {\r\n ReactPlugin,\r\n IReactExtensionConfig,\r\n withAITracking,\r\n AppInsightsErrorBoundary,\r\n AppInsightsContext,\r\n useAppInsightsContext,\r\n useTrackEvent,\r\n useTrackMetric,\r\n AITrackedComponentBase\r\n};\r\n"]}
@@ -1,7 +1,3 @@
1
- /*
2
- * Application Insights JavaScript SDK - React Plugin, 19.3.7-nightly.2507-03
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- */
5
1
  import { useEffect, useRef, useState } from "react";
6
2
  export default function useCustomEvent(reactPlugin, eventName, eventData, skipFirstRun) {
7
3
  if (skipFirstRun === void 0) { skipFirstRun = true; }
@@ -1 +1 @@
1
- {"version":3,"file":"useTrackEvent.js.map","sources":["useTrackEvent.js"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\r\nexport default function useCustomEvent(reactPlugin, eventName, eventData, skipFirstRun) {\r\n if (skipFirstRun === void 0) { skipFirstRun = true; }\r\n var _a = useState(eventData), data = _a[0], setData = _a[1];\r\n var firstRun = useRef(skipFirstRun);\r\n var savedSkipFirstRun = useRef(skipFirstRun);\r\n useEffect(function () {\r\n if (firstRun.current) {\r\n firstRun.current = false;\r\n return;\r\n }\r\n reactPlugin.trackEvent({ name: eventName }, data);\r\n }, [reactPlugin, data, eventName]);\r\n useEffect(function () {\r\n return function () {\r\n firstRun.current = savedSkipFirstRun.current;\r\n };\r\n }, []);\r\n return setData;\r\n}\r\n//# sourceMappingURL=useTrackEvent.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"}
1
+ {"version":3,"file":"useTrackEvent.js","sourceRoot":"","sources":["../src/useTrackEvent.ts"],"names":[],"mappings":"AAKA,OAAO,EAA4B,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAI9E,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,WAAwB,EACxB,SAAiB,EACjB,SAAY,EACZ,YAAmB;IAAnB,6BAAA,EAAA,mBAAmB;IAEb,IAAA,KAAkB,QAAQ,CAAC,SAAS,CAAC,EAApC,IAAI,QAAA,EAAE,OAAO,QAAuB,CAAC;IAC5C,IAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IACtC,IAAM,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IAE/C,SAAS,CAAC;QACR,IAAI,QAAQ,CAAC,OAAO,EAAE;YACpB,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;YACzB,OAAO;SACR;QACD,WAAW,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;IAEnC,SAAS,CAAC;QACR,OAAO;YACL,QAAQ,CAAC,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC;QAC/C,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,OAAgC,CAAC;AAC1C,CAAC","sourcesContent":["/**\r\n * ReactPlugin.ts\r\n * @copyright Microsoft 2019\r\n */\r\nimport ReactPlugin from \"./ReactPlugin\";\r\nimport { Dispatch, SetStateAction, useEffect, useRef, useState } from \"react\";\r\n\r\nexport type AIReactCustomEvent<T> = Dispatch<SetStateAction<T>>;\r\n\r\nexport default function useCustomEvent<T>(\r\n reactPlugin: ReactPlugin,\r\n eventName: string,\r\n eventData: T,\r\n skipFirstRun = true\r\n): AIReactCustomEvent<T> {\r\n const [data, setData] = useState(eventData);\r\n const firstRun = useRef(skipFirstRun);\r\n const savedSkipFirstRun = useRef(skipFirstRun);\r\n\r\n useEffect(() => {\r\n if (firstRun.current) {\r\n firstRun.current = false;\r\n return;\r\n }\r\n reactPlugin.trackEvent({ name: eventName }, data);\r\n }, [reactPlugin, data, eventName]);\r\n\r\n useEffect(() => {\r\n return () => {\r\n firstRun.current = savedSkipFirstRun.current;\r\n };\r\n }, []);\r\n\r\n return setData as AIReactCustomEvent<T>;\r\n}\r\n"]}
@@ -1,8 +1,4 @@
1
- /*
2
- * Application Insights JavaScript SDK - React Plugin, 19.3.7-nightly.2507-03
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- */
5
- import { __assignFn as __assign } from "@microsoft/applicationinsights-shims";
1
+ import { __assign } from "tslib";
6
2
  import { dateNow } from "@microsoft/applicationinsights-core-js";
7
3
  import { useEffect, useRef } from "react";
8
4
  function getEngagementTimeSeconds(trackedData) {
@@ -1 +1 @@
1
- {"version":3,"file":"useTrackMetric.js.map","sources":["useTrackMetric.js"],"sourcesContent":["import { __assign } from \"tslib\";\r\nimport { dateNow } from \"@microsoft/applicationinsights-core-js\";\r\nimport { useEffect, useRef } from \"react\";\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(null);\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
+ {"version":3,"file":"useTrackMetric.js","sourceRoot":"","sources":["../src/useTrackMetric.ts"],"names":[],"mappings":";AACA,OAAO,EAAqB,OAAO,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAY1C,SAAS,wBAAwB,CAAC,WAAyB;IACzD,OAAO,CACL,CAAC,OAAO,EAAE;QACR,WAAW,CAAC,oBAAoB;QAChC,WAAW,CAAC,aAAa;QACzB,WAAW,CAAC,SAAS,GAAG,WAAW,CAAC,WAAW,CAAC;QAClD,IAAI,CACL,CAAC;AACJ,CAAC;AAED,IAAM,oBAAoB,GAAG,UAC3B,WAAwB,EACxB,aAAqB,EACrB,gBAAoC;IAEpC,IAAM,QAAQ,GAAG,MAAM,CAAe;QACpC,aAAa,EAAE,OAAO,EAAE;QACxB,oBAAoB,EAAE,CAAC;QACvB,aAAa,EAAE,CAAC;QAChB,m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AAC,UAAU,EAAE,oBAAoB,CAAC,CAAC;QAC5D,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAM,aAAa,GAAG;QACpB,IAAI,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC;QACnC,IAAI,WAAW,CAAC,oBAAoB,KAAK,CAAC,EAAE;YAC1C,WAAW,CAAC,oBAAoB,GAAG,OAAO,EAAE,CAAC;YAC7C,WAAW,CAAC,mBAAmB,GAAG,WAAW,CAAC,oBAAoB,CAAC;SACpE;aAAM;YACL,WAAW,CAAC,mBAAmB,GAAG,OAAO,EAAE,CAAC;SAC7C;QAED,IAAI,WAAW,CAAC,kBAAkB,GAAG,CAAC,EAAE;YACtC,IAAM,YAAY,GAChB,WAAW,CAAC,mBAAmB,GAAG,WAAW,CAAC,kBAAkB,CAAC;YACnE,WAAW,CAAC,aAAa,IAAI,YAAY,CAAC;YAC1C,WAAW,CAAC,kBAAkB,GAAG,CAAC,CAAC;SACpC;IACH,CAAC,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["import ReactPlugin from \"./ReactPlugin\";\r\nimport { ICustomProperties, dateNow } from \"@microsoft/applicationinsights-core-js\";\r\nimport { useEffect, useRef } from \"react\";\r\n\r\ninterface ITrackedData {\r\n hookTimestamp: number;\r\n firstActiveTimestamp: number;\r\n totalIdleTime: number;\r\n lastActiveTimestamp: number;\r\n idleStartTimestamp: number;\r\n idleCount: number;\r\n idleTimeout: number;\r\n}\r\n\r\nfunction getEngagementTimeSeconds(trackedData: ITrackedData) {\r\n return (\r\n (dateNow() -\r\n trackedData.firstActiveTimestamp -\r\n trackedData.totalIdleTime -\r\n trackedData.idleCount * trackedData.idleTimeout) /\r\n 1000\r\n );\r\n}\r\n\r\nconst useComponentTracking = (\r\n reactPlugin: ReactPlugin,\r\n componentName: string,\r\n customProperties?: ICustomProperties\r\n) => {\r\n const tracking = useRef<ITrackedData>({\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 const savedCallback = useRef<() => void>(null);\r\n\r\n const callback = () => {\r\n let trackedData = tracking.current;\r\n if (\r\n trackedData.lastActiveTimestamp > 0 &&\r\n trackedData.idleStartTimestamp === 0 &&\r\n dateNow() - trackedData.lastActiveTimestamp >= trackedData.idleTimeout\r\n ) {\r\n trackedData.idleStartTimestamp = dateNow();\r\n trackedData.idleCount++;\r\n }\r\n };\r\n const delay = 100;\r\n\r\n savedCallback.current = callback;\r\n\r\n // Set up the interval.\r\n useEffect(() => {\r\n let id = setInterval(savedCallback.current, delay);\r\n return () => {\r\n clearInterval(id);\r\n\r\n let trackedData = tracking.current;\r\n if (trackedData.hookTimestamp === 0) {\r\n throw new Error(\r\n \"useAppInsights:unload hook: hookTimestamp is not initialized.\"\r\n );\r\n }\r\n\r\n if (trackedData.firstActiveTimestamp === 0) {\r\n return;\r\n }\r\n\r\n const engagementTime = getEngagementTimeSeconds(trackedData);\r\n const metricData = {\r\n average: engagementTime,\r\n name: \"React Component Engaged Time (seconds)\",\r\n sampleCount: 1\r\n };\r\n\r\n const additionalProperties = { \"Component Name\": componentName, ...customProperties };\r\n reactPlugin.trackMetric(metricData, additionalProperties);\r\n };\r\n }, []);\r\n\r\n const trackActivity = () => {\r\n let trackedData = tracking.current;\r\n if (trackedData.firstActiveTimestamp === 0) {\r\n trackedData.firstActiveTimestamp = dateNow();\r\n trackedData.lastActiveTimestamp = trackedData.firstActiveTimestamp;\r\n } else {\r\n trackedData.lastActiveTimestamp = dateNow();\r\n }\r\n\r\n if (trackedData.idleStartTimestamp > 0) {\r\n const lastIdleTime =\r\n trackedData.lastActiveTimestamp - trackedData.idleStartTimestamp;\r\n trackedData.totalIdleTime += lastIdleTime;\r\n trackedData.idleStartTimestamp = 0;\r\n }\r\n };\r\n\r\n return trackActivity;\r\n};\r\n\r\nexport default useComponentTracking;\r\n"]}
@@ -1,10 +1,6 @@
1
- /*
2
- * Application Insights JavaScript SDK - React Plugin, 19.3.7-nightly.2507-03
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- */
5
-
6
-
7
- import { __assignFn as __assign, __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+ import { __assign, __extends } from "tslib";
8
4
  import { dateNow } from '@microsoft/applicationinsights-core-js';
9
5
  import * as React from 'react';
10
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"withAITracking.js.map","sources":["withAITracking.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { __assign, __extends } from \"tslib\";\r\nimport { dateNow } from '@microsoft/applicationinsights-core-js';\r\nimport * as React from 'react';\r\n/**\r\n * Higher-order component base class to hook Application Insights tracking\r\n * in a React component's lifecycle.\r\n */\r\nvar AITrackedComponentBase = /** @class */ (function (_super) {\r\n __extends(AITrackedComponentBase, _super);\r\n function AITrackedComponentBase(props, reactPlugin, componentName) {\r\n var _this = _super.call(this, props) || this;\r\n _this._mountTimestamp = 0;\r\n _this._firstActiveTimestamp = 0;\r\n _this._idleStartTimestamp = 0;\r\n _this._lastActiveTimestamp = 0;\r\n _this._totalIdleTime = 0;\r\n _this._idleCount = 0;\r\n _this._idleTimeout = 5000;\r\n _this.trackActivity = function (e) {\r\n if (_this._firstActiveTimestamp === 0) {\r\n _this._firstActiveTimestamp = dateNow();\r\n _this._lastActiveTimestamp = _this._firstActiveTimestamp;\r\n }\r\n else {\r\n _this._lastActiveTimestamp = dateNow();\r\n }\r\n if (_this._idleStartTimestamp > 0) {\r\n var lastIdleTime = _this._lastActiveTimestamp - _this._idleStartTimestamp;\r\n _this._totalIdleTime += lastIdleTime;\r\n _this._idleStartTimestamp = 0;\r\n }\r\n };\r\n _this._reactPlugin = reactPlugin;\r\n _this._componentName = componentName;\r\n return _this;\r\n }\r\n AITrackedComponentBase.prototype.componentDidMount = function () {\r\n var _this = this;\r\n this._mountTimestamp = dateNow();\r\n this._firstActiveTimestamp = 0;\r\n this._totalIdleTime = 0;\r\n this._lastActiveTimestamp = 0;\r\n this._idleStartTimestamp = 0;\r\n this._idleCount = 0;\r\n this._intervalId = setInterval(function () {\r\n if (_this._lastActiveTimestamp > 0 && _this._idleStartTimestamp === 0 && dateNow() - _this._lastActiveTimestamp >= _this._idleTimeout) {\r\n _this._idleStartTimestamp = dateNow();\r\n _this._idleCount++;\r\n }\r\n }, 100);\r\n };\r\n AITrackedComponentBase.prototype.componentWillUnmount = function () {\r\n if (this._mountTimestamp === 0) {\r\n throw new Error('withAITracking:componentWillUnmount: mountTimestamp is not initialized.');\r\n }\r\n if (this._intervalId) {\r\n clearInterval(this._intervalId);\r\n }\r\n if (this._firstActiveTimestamp === 0) {\r\n return;\r\n }\r\n var engagementTime = this.getEngagementTimeSeconds();\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': this._componentName };\r\n this._reactPlugin.trackMetric(metricData, additionalProperties);\r\n };\r\n AITrackedComponentBase.prototype.getEngagementTimeSeconds = function () {\r\n return (dateNow() - this._firstActiveTimestamp - this._totalIdleTime - this._idleCount * this._idleTimeout) / 1000;\r\n };\r\n return AITrackedComponentBase;\r\n}(React.Component));\r\nexport { AITrackedComponentBase };\r\n/**\r\n * Higher-order component function to hook Application Insights tracking\r\n * in a React component's lifecycle.\r\n *\r\n * @param reactPlugin ReactPlugin instance\r\n * @param Component the React component to be instrumented\r\n * @param componentName (optional) component name\r\n * @param className (optional) className of the HOC div\r\n */\r\nexport default function withAITracking(reactPlugin, Component, componentName, className) {\r\n if (componentName === undefined || componentName === null || typeof componentName !== 'string') {\r\n componentName = Component.prototype &&\r\n Component.prototype.constructor &&\r\n Component.prototype.constructor.name ||\r\n 'Unknown';\r\n }\r\n if (className === undefined || className === null || typeof className !== 'string') {\r\n className = '';\r\n }\r\n return /** @class */ (function (_super) {\r\n __extends(class_1, _super);\r\n function class_1(props) {\r\n return _super.call(this, props, reactPlugin, componentName) || this;\r\n }\r\n class_1.prototype.render = function () {\r\n return (React.createElement(\"div\", { onKeyDown: this.trackActivity, onMouseMove: this.trackActivity, onScroll: this.trackActivity, onMouseDown: this.trackActivity, onTouchStart: this.trackActivity, onTouchMove: this.trackActivity, className: className },\r\n React.createElement(Component, __assign({}, this.props))));\r\n };\r\n return class_1;\r\n }(AITrackedComponentBase));\r\n}\r\n//# sourceMappingURL=withAITracking.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC,wGAA4C;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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":"withAITracking.js","sourceRoot":"","sources":["../src/withAITracking.tsx"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;;AAGlC,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AACjE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B;;;GAGG;AACH;IAAwD,0C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H,MAAM,CAAC,OAAO,UAAU,cAAc,CAAI,WAAwB,EAAE,SAAiC,EAAE,aAAsB,EAAE,SAAkB;IAE/I,IAAI,aAAa,KAAK,SAAS,IAAI,aAAa,KAAK,IAAI,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;QAC9F,aAAa,GAAG,SAAS,CAAC,SAAS;YACjC,SAAS,CAAC,SAAS,CAAC,WAAW;YAC/B,SAAS,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI;YACpC,SAAS,CAAC;KACb;IAED,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,IAAI,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;QAClF,SAAS,GAAG,EAAE,CAAC;KAChB;IAED;QAAqB,2BAAyB;QAE5C,iBAAmB,KAAQ;mBACzB,kBAAM,KAAK,EAAE,WAAW,EAAE,aAAa,CAAC;QAC1C,CAAC;QAEM,wBAAM,GAAb;YACE,OAAO,CACL,6BACE,SAAS,EAAE,IAAI,CAAC,aAAa,EAC7B,WAAW,EAAE,IAAI,CAAC,aAAa,EAC/B,QAAQ,EAAE,IAAI,CAAC,aAAa,EAC5B,WAAW,EAAE,IAAI,CAAC,aAAa,EAC/B,YAAY,EAAE,IAAI,CAAC,aAAa,EAChC,WAAW,EAAE,IAAI,CAAC,aAAa,EAC/B,SAAS,EAAE,SAAS;gBAEpB,oBAAC,SAAS,eAAK,IAAI,CAAC,KAAK,EAAI,CACzB,CACP,CAAC;QACJ,CAAC;QACH,cAAC;IAAD,CAAC,AArBM,CAAc,sBAAsB,GAqB1C;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\r\nimport { IMetricTelemetry } from '@microsoft/applicationinsights-common';\r\nimport { dateNow } from '@microsoft/applicationinsights-core-js';\r\nimport * as React from 'react';\r\nimport ReactPlugin from './ReactPlugin';\r\n\r\n/**\r\n * Higher-order component base class to hook Application Insights tracking \r\n * in a React component's lifecycle.\r\n */\r\nexport abstract class AITrackedComponentBase<P> extends React.Component<P> {\r\n protected _mountTimestamp: number = 0;\r\n protected _firstActiveTimestamp: number = 0;\r\n protected _idleStartTimestamp: number = 0;\r\n protected _lastActiveTimestamp: number = 0;\r\n protected _totalIdleTime: number = 0;\r\n protected _idleCount: number = 0;\r\n protected _idleTimeout: number = 5000;\r\n protected _intervalId?: any;\r\n protected _componentName: string;\r\n protected _reactPlugin: ReactPlugin;\r\n\r\n public constructor(props: P, reactPlugin: ReactPlugin, componentName: string) {\r\n super(props);\r\n\r\n this._reactPlugin = reactPlugin;\r\n this._componentName = componentName;\r\n }\r\n\r\n public componentDidMount() {\r\n this._mountTimestamp = dateNow();\r\n this._firstActiveTimestamp = 0;\r\n this._totalIdleTime = 0;\r\n this._lastActiveTimestamp = 0;\r\n this._idleStartTimestamp = 0;\r\n this._idleCount = 0;\r\n\r\n this._intervalId = setInterval(() => {\r\n if (this._lastActiveTimestamp > 0 && this._idleStartTimestamp === 0 && dateNow() - this._lastActiveTimestamp >= this._idleTimeout) {\r\n this._idleStartTimestamp = dateNow();\r\n this._idleCount++;\r\n }\r\n }, 100);\r\n }\r\n\r\n public componentWillUnmount() {\r\n if (this._mountTimestamp === 0) {\r\n throw new Error('withAITracking:componentWillUnmount: mountTimestamp is not initialized.');\r\n }\r\n if (this._intervalId) {\r\n clearInterval(this._intervalId);\r\n }\r\n\r\n if (this._firstActiveTimestamp === 0) {\r\n return;\r\n }\r\n\r\n const engagementTime = this.getEngagementTimeSeconds();\r\n const metricData: IMetricTelemetry = {\r\n average: engagementTime,\r\n name: 'React Component Engaged Time (seconds)',\r\n sampleCount: 1\r\n };\r\n\r\n const additionalProperties: { [key: string]: any } = { 'Component Name': this._componentName };\r\n this._reactPlugin.trackMetric(metricData, additionalProperties);\r\n }\r\n\r\n protected trackActivity = (e: React.SyntheticEvent<any>): void => {\r\n if (this._firstActiveTimestamp === 0) {\r\n this._firstActiveTimestamp = dateNow();\r\n this._lastActiveTimestamp = this._firstActiveTimestamp;\r\n } else {\r\n this._lastActiveTimestamp = dateNow();\r\n }\r\n\r\n if (this._idleStartTimestamp > 0) {\r\n const lastIdleTime = this._lastActiveTimestamp - this._idleStartTimestamp;\r\n this._totalIdleTime += lastIdleTime;\r\n this._idleStartTimestamp = 0;\r\n }\r\n }\r\n\r\n private getEngagementTimeSeconds(): number {\r\n return (dateNow() - this._firstActiveTimestamp - this._totalIdleTime - this._idleCount * this._idleTimeout) / 1000;\r\n }\r\n}\r\n\r\n/**\r\n * Higher-order component function to hook Application Insights tracking \r\n * in a React component's lifecycle.\r\n * \r\n * @param reactPlugin ReactPlugin instance\r\n * @param Component the React component to be instrumented \r\n * @param componentName (optional) component name\r\n * @param className (optional) className of the HOC div\r\n */\r\nexport default function withAITracking<P>(reactPlugin: ReactPlugin, Component: React.ComponentType<P>, componentName?: string, className?: string): React.ComponentClass<P> {\r\n\r\n if (componentName === undefined || componentName === null || typeof componentName !== 'string') {\r\n componentName = Component.prototype &&\r\n Component.prototype.constructor &&\r\n Component.prototype.constructor.name ||\r\n 'Unknown';\r\n }\r\n\r\n if (className === undefined || className === null || typeof className !== 'string') {\r\n className = '';\r\n }\r\n\r\n return class extends AITrackedComponentBase<P> {\r\n\r\n public constructor(props: P) {\r\n super(props, reactPlugin, componentName);\r\n }\r\n\r\n public render() {\r\n return (\r\n <div\r\n onKeyDown={this.trackActivity}\r\n onMouseMove={this.trackActivity}\r\n onScroll={this.trackActivity}\r\n onMouseDown={this.trackActivity}\r\n onTouchStart={this.trackActivity}\r\n onTouchMove={this.trackActivity}\r\n className={className}\r\n >\r\n <Component {...this.props} />\r\n </div>\r\n );\r\n }\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/applicationinsights-react-js",
3
- "version": "19.3.7-nightly.2507-03",
3
+ "version": "19.3.7-nightly.2507-04",
4
4
  "description": "Microsoft Application Insights React plugin",
5
5
  "author": "Microsoft Application Insights Team",
6
6
  "license": "MIT",