@microsoft/applicationinsights-react-js 3.2.2-nightly.2111-07 → 3.2.2-nightly.2111-12

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.2.2-nightly.2111-07
2
+ * Microsoft Application Insights react plugin, 3.2.2-nightly.2111-12
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.2.2-nightly.2111-07
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.2-nightly.2111-12
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.2.2-nightly.2111-07
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.2-nightly.2111-12
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.2.2-nightly.2111-07
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.2-nightly.2111-12
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.2.2-nightly.2111-07
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.2-nightly.2111-12
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  /**
@@ -98,10 +98,19 @@ var ReactPlugin = /** @class */ (function (_super) {
98
98
  };
99
99
  ReactPlugin.prototype.addHistoryListener = function (history) {
100
100
  var _this = this;
101
- var locationListener = function (location, action) {
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"];
107
+ }
108
+ else {
109
+ locn = arg;
110
+ }
102
111
  // Timeout to ensure any changes to the DOM made by route changes get included in pageView telemetry
103
112
  setTimeout(function () {
104
- var pageViewTelemetry = { uri: location.pathname };
113
+ var pageViewTelemetry = { uri: locn.pathname };
105
114
  _this.trackPageView(pageViewTelemetry);
106
115
  }, 500);
107
116
  };
@@ -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 (location, action) {\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: location.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"}
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,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - React Plugin, 3.2.2-nightly.2111-07
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.2-nightly.2111-12
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.2.2-nightly.2111-07
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.2-nightly.2111-12
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.2.2-nightly.2111-07
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.2-nightly.2111-12
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  import { useEffect, useRef } from "react";
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - React Plugin, 3.2.2-nightly.2111-07
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.2-nightly.2111-12
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.2.2-nightly.2111-07",
3
+ "version": "3.2.2-nightly.2111-12",
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",
@@ -30,8 +30,8 @@
30
30
  "@testing-library/react": "^11.2.5",
31
31
  "@testing-library/user-event": "^12.8.1",
32
32
  "@types/cheerio": "0.22.13",
33
- "@types/history": "4.7.2",
34
- "@types/jest": "^24.0.11",
33
+ "@types/history": "^4.7.9",
34
+ "@types/jest": "^27.0.2",
35
35
  "@types/node": "11.13.2",
36
36
  "@types/prop-types": "^15.7.3",
37
37
  "@types/react": "^16.9.11",
@@ -39,9 +39,9 @@
39
39
  "csstype": "~2.6.7",
40
40
  "grunt": "^1.4.1",
41
41
  "grunt-cli": "^1.4.3",
42
- "jest": "^24.7.1",
43
- "react": "^17.0.1",
44
- "react-dom": "^17.0.1",
42
+ "jest": "^27.3.1",
43
+ "react": "^17.0.2",
44
+ "react-dom": "^17.0.2",
45
45
  "globby": "^11.0.0",
46
46
  "magic-string": "^0.25.7",
47
47
  "@rollup/plugin-commonjs": "^18.0.0",
@@ -50,21 +50,22 @@
50
50
  "rollup-plugin-cleanup": "3.2.1",
51
51
  "rollup-plugin-peer-deps-external": "^2.2.4",
52
52
  "rollup": "^2.32.0",
53
- "ts-jest": "^24.0.2",
53
+ "ts-jest": "^27.0.7",
54
54
  "typescript": "^4.3.4",
55
55
  "tslib": "^2.0.0",
56
- "uglify-js": "^3.11.0"
56
+ "uglify-js": "^3.11.0",
57
+ "history": "^5.1.0"
57
58
  },
58
59
  "dependencies": {
59
60
  "@microsoft/applicationinsights-shims": "2.0.0",
60
- "@microsoft/applicationinsights-core-js": "2.7.2-nightly.2111-07",
61
- "@microsoft/applicationinsights-common": "2.7.2-nightly.2111-07",
62
- "@microsoft/dynamicproto-js": "^1.1.4",
63
- "history": "^4.10.1"
61
+ "@microsoft/applicationinsights-core-js": "2.7.2-nightly.2111-12",
62
+ "@microsoft/applicationinsights-common": "2.7.2-nightly.2111-12",
63
+ "@microsoft/dynamicproto-js": "^1.1.4"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "tslib": "*",
67
- "react": "^17.0.1"
67
+ "react": "^17.0.1",
68
+ "history": ">= 4.10.1"
68
69
  },
69
70
  "license": "MIT",
70
71
  "publishConfig": {
@@ -12,7 +12,7 @@ import {
12
12
  ITelemetryPluginChain, _InternalMessageId, LoggingSeverity, ICustomProperties, safeGetCookieMgr, ICookieMgr, arrForEach
13
13
  } from "@microsoft/applicationinsights-core-js";
14
14
  import { IReactExtensionConfig } from './Interfaces/IReactExtensionConfig';
15
- import { History, LocationListener, Location, Action } from "history";
15
+ import { History, Location, Action, Update } from "history";
16
16
 
17
17
  export default class ReactPlugin extends BaseTelemetryPlugin {
18
18
  public priority = 185;
@@ -116,10 +116,19 @@ export default class ReactPlugin extends BaseTelemetryPlugin {
116
116
 
117
117
 
118
118
  private addHistoryListener(history: History): void {
119
- const locationListener: LocationListener = (location: Location, action: Action): void => {
119
+ const locationListener = (arg: Location | Update): void => {
120
+ // v4 of the history API passes "location" as the first argument, while v5 passes an object that contains location and action
121
+ let locn: Location = null;
122
+ if ("location" in arg) {
123
+ // Looks like v5
124
+ locn = arg["location"];
125
+ } else {
126
+ locn = arg as Location;
127
+ }
128
+
120
129
  // Timeout to ensure any changes to the DOM made by route changes get included in pageView telemetry
121
130
  setTimeout(() => {
122
- const pageViewTelemetry: IPageViewTelemetry = { uri: location.pathname };
131
+ const pageViewTelemetry: IPageViewTelemetry = { uri: locn.pathname };
123
132
  this.trackPageView(pageViewTelemetry);
124
133
  }, 500);
125
134
  };
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.18.17"
8
+ "packageVersion": "7.18.19"
9
9
  }
10
10
  ]
11
11
  }