@microsoft/applicationinsights-react-js 3.2.4 → 3.2.5-nightly.2203-02

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.4
2
+ * Microsoft Application Insights react plugin, 3.2.5-nightly.2203-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  *
@@ -107,7 +107,7 @@ export declare const useAppInsightsContext: () => ReactPlugin;
107
107
 
108
108
  export declare function useTrackEvent<T>(reactPlugin: ReactPlugin, eventName: string, eventData: T, skipFirstRun?: boolean): AIReactCustomEvent<T>;
109
109
 
110
- export declare const useTrackMetric: (reactPlugin: ReactPlugin, componentName: string) => () => void;
110
+ export declare const useTrackMetric: (reactPlugin: ReactPlugin, componentName: string, customProperties?: ICustomProperties) => () => void;
111
111
 
112
112
  /**
113
113
  * Higher-order component function to hook Application Insights tracking
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - React Plugin, 3.2.4
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.5-nightly.2203-02
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.4
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.5-nightly.2203-02
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.4
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.5-nightly.2203-02
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.4
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.5-nightly.2203-02
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.4
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.5-nightly.2203-02
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.4
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.5-nightly.2203-02
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.2.4
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.5-nightly.2203-02
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.2.4
2
+ * Application Insights JavaScript SDK - React Plugin, 3.2.5-nightly.2203-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,71 +1,74 @@
1
- {
2
- "name": "@microsoft/applicationinsights-react-js",
3
- "version": "3.2.4",
4
- "description": "Microsoft Application Insights React plugin",
5
- "main": "dist/applicationinsights-react-js.js",
6
- "module": "dist-esm/applicationinsights-react-js.js",
7
- "types": "types/applicationinsights-react-js.d.ts",
8
- "sideEffects": false,
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/microsoft/ApplicationInsights-JS/tree/master/extensions/applicationinsights-react-js"
12
- },
13
- "scripts": {
14
- "build": "npm run build:esm && npm run build:package && npm run dtsgen",
15
- "build:esm": "tsc -p tsconfig.json",
16
- "build:package": "rollup -c",
17
- "rebuild": "npm run build",
18
- "testx": "grunt reacttests",
19
- "test": "jest --config test/jestconfig.json",
20
- "test-watch": "jest --config test/jestconfig.json --watch",
21
- "lint": "tslint -p tsconfig.json",
22
- "dtsgen": "api-extractor run --local && node ../../scripts/dtsgen.js \"Microsoft Application Insights react plugin\""
23
- },
24
- "devDependencies": {
25
- "@microsoft/ai-test-framework": "0.0.1",
26
- "@microsoft/applicationinsights-rollup-es3": "1.1.3",
27
- "@microsoft/api-extractor": "^7.18.1",
28
- "@testing-library/dom": "^7.29.6",
29
- "@testing-library/jest-dom": "^5.11.9",
30
- "@testing-library/react": "^11.2.5",
31
- "@testing-library/user-event": "^12.8.1",
32
- "@types/cheerio": "0.22.13",
33
- "@types/history": "^4.7.9",
34
- "@types/jest": "^27.0.2",
35
- "@types/node": "11.13.2",
36
- "@types/prop-types": "^15.7.3",
37
- "@types/react": "^16.9.11",
38
- "@types/react-dom": "^16.9.4",
39
- "csstype": "~2.6.7",
40
- "grunt": "^1.4.1",
41
- "grunt-cli": "^1.4.3",
42
- "jest": "^27.3.1",
43
- "react": "^17.0.2",
44
- "react-dom": "^17.0.2",
45
- "globby": "^11.0.0",
46
- "magic-string": "^0.25.7",
47
- "@rollup/plugin-commonjs": "^18.0.0",
48
- "@rollup/plugin-node-resolve": "^11.2.1",
49
- "@rollup/plugin-replace": "^2.3.3",
50
- "rollup-plugin-cleanup": "3.2.1",
51
- "rollup-plugin-peer-deps-external": "^2.2.4",
52
- "rollup": "^2.32.0",
53
- "ts-jest": "^27.0.7",
54
- "typescript": "^4.3.4",
55
- "tslib": "^2.0.0",
56
- "uglify-js": "^3.11.0",
57
- "history": "^5.1.0"
58
- },
59
- "dependencies": {
60
- "@microsoft/applicationinsights-shims": "2.0.1",
61
- "@microsoft/applicationinsights-core-js": "2.7.4",
62
- "@microsoft/applicationinsights-common": "2.7.4",
63
- "@microsoft/dynamicproto-js": "^1.1.4"
64
- },
65
- "peerDependencies": {
66
- "tslib": "*",
67
- "react": "^17.0.1",
68
- "history": ">= 4.10.1"
69
- },
70
- "license": "MIT"
71
- }
1
+ {
2
+ "name": "@microsoft/applicationinsights-react-js",
3
+ "version": "3.2.5-nightly.2203-02",
4
+ "description": "Microsoft Application Insights React plugin",
5
+ "main": "dist/applicationinsights-react-js.js",
6
+ "module": "dist-esm/applicationinsights-react-js.js",
7
+ "types": "types/applicationinsights-react-js.d.ts",
8
+ "sideEffects": false,
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/microsoft/ApplicationInsights-JS/tree/master/extensions/applicationinsights-react-js"
12
+ },
13
+ "scripts": {
14
+ "build": "npm run build:esm && npm run build:package && npm run dtsgen",
15
+ "build:esm": "tsc -p tsconfig.json",
16
+ "build:package": "rollup -c",
17
+ "rebuild": "npm run build",
18
+ "testx": "grunt reacttests",
19
+ "test": "jest --config test/jestconfig.json",
20
+ "test-watch": "jest --config test/jestconfig.json --watch",
21
+ "lint": "tslint -p tsconfig.json",
22
+ "dtsgen": "api-extractor run --local && node ../../scripts/dtsgen.js \"Microsoft Application Insights react plugin\""
23
+ },
24
+ "devDependencies": {
25
+ "@microsoft/ai-test-framework": "0.0.1",
26
+ "@microsoft/applicationinsights-rollup-es3": "1.1.3",
27
+ "@microsoft/api-extractor": "^7.18.1",
28
+ "@testing-library/dom": "^7.29.6",
29
+ "@testing-library/jest-dom": "^5.11.9",
30
+ "@testing-library/react": "^11.2.5",
31
+ "@testing-library/user-event": "^12.8.1",
32
+ "@types/cheerio": "0.22.13",
33
+ "@types/history": "^4.7.9",
34
+ "@types/jest": "^27.0.2",
35
+ "@types/node": "11.13.2",
36
+ "@types/prop-types": "^15.7.3",
37
+ "@types/react": "^16.9.11",
38
+ "@types/react-dom": "^16.9.4",
39
+ "csstype": "~2.6.7",
40
+ "grunt": "^1.4.1",
41
+ "grunt-cli": "^1.4.3",
42
+ "jest": "^27.3.1",
43
+ "react": "^17.0.2",
44
+ "react-dom": "^17.0.2",
45
+ "globby": "^11.0.0",
46
+ "magic-string": "^0.25.7",
47
+ "@rollup/plugin-commonjs": "^18.0.0",
48
+ "@rollup/plugin-node-resolve": "^11.2.1",
49
+ "@rollup/plugin-replace": "^2.3.3",
50
+ "rollup-plugin-cleanup": "3.2.1",
51
+ "rollup-plugin-peer-deps-external": "^2.2.4",
52
+ "rollup": "^2.32.0",
53
+ "ts-jest": "^27.0.7",
54
+ "typescript": "^4.3.4",
55
+ "tslib": "^2.0.0",
56
+ "uglify-js": "^3.11.0",
57
+ "history": "^5.1.0"
58
+ },
59
+ "dependencies": {
60
+ "@microsoft/applicationinsights-shims": "2.0.1",
61
+ "@microsoft/applicationinsights-core-js": "2.7.5-nightly.2203-02",
62
+ "@microsoft/applicationinsights-common": "2.7.5-nightly.2203-02",
63
+ "@microsoft/dynamicproto-js": "^1.1.4"
64
+ },
65
+ "peerDependencies": {
66
+ "tslib": "*",
67
+ "react": "^17.0.1",
68
+ "history": ">= 4.10.1"
69
+ },
70
+ "license": "MIT",
71
+ "publishConfig": {
72
+ "tag": "nightly"
73
+ }
74
+ }
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useRef } from "react";
2
- import { dateNow } from "@microsoft/applicationinsights-core-js";
2
+ import { dateNow, ICustomProperties } from "@microsoft/applicationinsights-core-js";
3
3
  import ReactPlugin from "./ReactPlugin";
4
4
 
5
5
  interface ITrackedData {
@@ -24,7 +24,8 @@ function getEngagementTimeSeconds(trackedData: ITrackedData) {
24
24
 
25
25
  const useComponentTracking = (
26
26
  reactPlugin: ReactPlugin,
27
- componentName: string
27
+ componentName: string,
28
+ customProperties?: ICustomProperties
28
29
  ) => {
29
30
  const tracking = useRef<ITrackedData>({
30
31
  hookTimestamp: dateNow(),
@@ -76,7 +77,7 @@ const useComponentTracking = (
76
77
  sampleCount: 1
77
78
  };
78
79
 
79
- const additionalProperties = { "Component Name": componentName };
80
+ const additionalProperties = { "Component Name": componentName, ...customProperties };
80
81
  reactPlugin.trackMetric(metricData, additionalProperties);
81
82
  };
82
83
  }, []);
@@ -1,3 +1,4 @@
1
+ import { ICustomProperties } from "@microsoft/applicationinsights-core-js";
1
2
  import ReactPlugin from "./ReactPlugin";
2
- declare const useComponentTracking: (reactPlugin: ReactPlugin, componentName: string) => () => void;
3
+ declare const useComponentTracking: (reactPlugin: ReactPlugin, componentName: string, customProperties?: ICustomProperties) => () => void;
3
4
  export default useComponentTracking;