@microsoft/applicationinsights-react-js 3.1.4 → 3.2.1-nightly.202110-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.
- package/browser/applicationinsights-react-js.js +49 -50
- package/browser/applicationinsights-react-js.js.map +1 -1
- package/browser/applicationinsights-react-js.min.js +2 -2
- package/browser/applicationinsights-react-js.min.js.map +1 -1
- package/dist/applicationinsights-react-js.api.json +1194 -0
- package/dist/applicationinsights-react-js.api.md +91 -0
- package/dist/applicationinsights-react-js.d.ts +109 -0
- package/dist/applicationinsights-react-js.js +49 -50
- package/dist/applicationinsights-react-js.js.map +1 -1
- package/dist/applicationinsights-react-js.min.js +2 -2
- package/dist/applicationinsights-react-js.min.js.map +1 -1
- package/dist/applicationinsights-react-js.rollup.d.ts +114 -0
- package/dist-esm/AppInsightsContext.js +1 -1
- package/dist-esm/AppInsightsErrorBoundary.js +1 -1
- package/dist-esm/Interfaces/IReactExtensionConfig.js +2 -1
- package/dist-esm/Interfaces/IReactExtensionConfig.js.map +1 -1
- package/dist-esm/ReactPlugin.js +1 -1
- package/dist-esm/applicationinsights-react-js.js +1 -1
- package/dist-esm/useTrackEvent.js +1 -1
- package/dist-esm/useTrackMetric.js +1 -1
- package/dist-esm/withAITracking.js +1 -1
- package/package.json +73 -67
- package/src/AppInsightsContext.tsx +3 -2
- package/src/useTrackEvent.ts +5 -3
- package/tsconfig.json +1 -1
- package/types/AppInsightsContext.d.ts +3 -2
- package/types/AppInsightsErrorBoundary.d.ts +1 -1
- package/types/tsdoc-metadata.json +11 -0
- package/types/useTrackEvent.d.ts +7 -2
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Microsoft Application Insights react plugin, 3.2.1-nightly.202110-02
|
|
3
|
+
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* ---------------------------------------------------------------------------
|
|
9
|
+
* This is a single combined (rollup) declaration file for the package,
|
|
10
|
+
* use this version if your build environment doesn't support the using the
|
|
11
|
+
* individual *.d.ts files or default namespace wrapped version.
|
|
12
|
+
* - Namespaced version: applicationinsights-react-js.d.ts
|
|
13
|
+
* ---------------------------------------------------------------------------
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { BaseTelemetryPlugin } from '@microsoft/applicationinsights-core-js';
|
|
17
|
+
import { Context } from 'react';
|
|
18
|
+
import { Dispatch } from 'react';
|
|
19
|
+
import { History as History_2 } from 'history';
|
|
20
|
+
import { IAppInsightsCore } from '@microsoft/applicationinsights-core-js';
|
|
21
|
+
import { IConfig } from '@microsoft/applicationinsights-common';
|
|
22
|
+
import { IConfiguration } from '@microsoft/applicationinsights-core-js';
|
|
23
|
+
import { ICookieMgr } from '@microsoft/applicationinsights-core-js';
|
|
24
|
+
import { ICustomProperties } from '@microsoft/applicationinsights-core-js';
|
|
25
|
+
import { IEventTelemetry } from '@microsoft/applicationinsights-common';
|
|
26
|
+
import { IExceptionTelemetry } from '@microsoft/applicationinsights-common';
|
|
27
|
+
import { IMetricTelemetry } from '@microsoft/applicationinsights-common';
|
|
28
|
+
import { IPageViewTelemetry } from '@microsoft/applicationinsights-common';
|
|
29
|
+
import { IPlugin } from '@microsoft/applicationinsights-core-js';
|
|
30
|
+
import { IProcessTelemetryContext } from '@microsoft/applicationinsights-core-js';
|
|
31
|
+
import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
|
|
32
|
+
import { ITelemetryPluginChain } from '@microsoft/applicationinsights-core-js';
|
|
33
|
+
import * as React_2 from 'react';
|
|
34
|
+
import { default as React_3 } from 'react';
|
|
35
|
+
import { SetStateAction } from 'react';
|
|
36
|
+
|
|
37
|
+
declare type AIReactCustomEvent<T> = Dispatch<SetStateAction<T>>;
|
|
38
|
+
|
|
39
|
+
export declare const AppInsightsContext: AppInsightsReactContext;
|
|
40
|
+
|
|
41
|
+
export declare class AppInsightsErrorBoundary extends React_3.Component<IAppInsightsErrorBoundaryProps, IAppInsightsErrorBoundaryState> {
|
|
42
|
+
state: {
|
|
43
|
+
hasError: boolean;
|
|
44
|
+
};
|
|
45
|
+
componentDidCatch(error: Error, errorInfo: React_3.ErrorInfo): void;
|
|
46
|
+
render(): React_3.ReactNode;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare type AppInsightsReactContext = Context<ReactPlugin>;
|
|
50
|
+
|
|
51
|
+
declare interface IAppInsightsErrorBoundaryProps {
|
|
52
|
+
appInsights: ReactPlugin;
|
|
53
|
+
onError: React_3.ComponentType<any>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare interface IAppInsightsErrorBoundaryState {
|
|
57
|
+
hasError: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Settings to initialize a ReactAI instance.
|
|
62
|
+
*/
|
|
63
|
+
export declare interface IReactExtensionConfig {
|
|
64
|
+
/**
|
|
65
|
+
* React router history for enabling Application Insights PageView tracking.
|
|
66
|
+
*
|
|
67
|
+
* @type {History}
|
|
68
|
+
* @memberof IReactAISettings
|
|
69
|
+
*/
|
|
70
|
+
readonly history?: History_2;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export declare class ReactPlugin extends BaseTelemetryPlugin {
|
|
74
|
+
priority: number;
|
|
75
|
+
identifier: string;
|
|
76
|
+
private _analyticsPlugin;
|
|
77
|
+
private _extensionConfig;
|
|
78
|
+
initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
|
|
79
|
+
/**
|
|
80
|
+
* Get the current cookie manager for this instance
|
|
81
|
+
*/
|
|
82
|
+
getCookieMgr(): ICookieMgr;
|
|
83
|
+
/**
|
|
84
|
+
* Add Part A fields to the event
|
|
85
|
+
* @param event The event that needs to be processed
|
|
86
|
+
*/
|
|
87
|
+
processTelemetry(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
88
|
+
trackMetric(metric: IMetricTelemetry, customProperties: ICustomProperties): void;
|
|
89
|
+
trackPageView(pageView: IPageViewTelemetry): void;
|
|
90
|
+
trackEvent(event: IEventTelemetry, customProperties?: ICustomProperties): void;
|
|
91
|
+
trackException(exception: IExceptionTelemetry, customProperties?: {
|
|
92
|
+
[key: string]: any;
|
|
93
|
+
}): void;
|
|
94
|
+
private addHistoryListener;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export declare const useAppInsightsContext: () => ReactPlugin;
|
|
98
|
+
|
|
99
|
+
export declare function useTrackEvent<T>(reactPlugin: ReactPlugin, eventName: string, eventData: T, skipFirstRun?: boolean): AIReactCustomEvent<T>;
|
|
100
|
+
|
|
101
|
+
export declare const useTrackMetric: (reactPlugin: ReactPlugin, componentName: string) => () => void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Higher-order component function to hook Application Insights tracking
|
|
105
|
+
* in a React component's lifecycle.
|
|
106
|
+
*
|
|
107
|
+
* @param reactPlugin ReactPlugin instance
|
|
108
|
+
* @param Component the React component to be instrumented
|
|
109
|
+
* @param componentName (optional) component name
|
|
110
|
+
* @param className (optional) className of the HOC div
|
|
111
|
+
*/
|
|
112
|
+
export declare function withAITracking<P>(reactPlugin: ReactPlugin, Component: React_2.ComponentType<P>, componentName?: string, className?: string): React_2.ComponentClass<P>;
|
|
113
|
+
|
|
114
|
+
export { }
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - React Plugin, 3.1.
|
|
2
|
+
* Application Insights JavaScript SDK - React Plugin, 3.2.1-nightly.202110-02
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
export {};
|
|
7
8
|
//# 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\n//# sourceMappingURL=IReactExtensionConfig.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC"}
|
|
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"}
|
package/dist-esm/ReactPlugin.js
CHANGED
package/package.json
CHANGED
|
@@ -1,67 +1,73 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@microsoft/applicationinsights-react-js",
|
|
3
|
-
"version": "3.1.
|
|
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:
|
|
15
|
-
"build:esm": "tsc -p tsconfig.json",
|
|
16
|
-
"build:
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@types/
|
|
33
|
-
"@types/
|
|
34
|
-
"@types/
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"rollup
|
|
48
|
-
"rollup": "^2.
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"@microsoft/applicationinsights-
|
|
60
|
-
"@microsoft/
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/applicationinsights-react-js",
|
|
3
|
+
"version": "3.2.1-nightly.202110-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.2",
|
|
34
|
+
"@types/jest": "^24.0.11",
|
|
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": "^24.7.1",
|
|
43
|
+
"react": "^17.0.1",
|
|
44
|
+
"react-dom": "^17.0.1",
|
|
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": "^24.0.2",
|
|
54
|
+
"typescript": "^4.3.4",
|
|
55
|
+
"tslib": "^2.0.0",
|
|
56
|
+
"uglify-js": "^3.11.0"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@microsoft/applicationinsights-shims": "2.0.0",
|
|
60
|
+
"@microsoft/applicationinsights-core-js": "2.7.1-nightly.202110-02",
|
|
61
|
+
"@microsoft/applicationinsights-common": "2.7.1-nightly.202110-02",
|
|
62
|
+
"@microsoft/dynamicproto-js": "^1.1.4",
|
|
63
|
+
"history": "^4.10.1"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"tslib": "*",
|
|
67
|
+
"react": "^17.0.1"
|
|
68
|
+
},
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"tag": "nightly"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { createContext, useContext } from "react";
|
|
1
|
+
import { createContext, useContext, Context } from "react";
|
|
2
2
|
import ReactPlugin from "./ReactPlugin";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export declare type AppInsightsReactContext = Context<ReactPlugin>
|
|
5
|
+
const AppInsightsContext = createContext<ReactPlugin>(undefined) as AppInsightsReactContext;
|
|
5
6
|
|
|
6
7
|
const useAppInsightsContext = () => useContext(AppInsightsContext);
|
|
7
8
|
|
package/src/useTrackEvent.ts
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
* ReactPlugin.ts
|
|
3
3
|
* @copyright Microsoft 2019
|
|
4
4
|
*/
|
|
5
|
-
import { useState, useEffect, useRef } from "react";
|
|
5
|
+
import { useState, useEffect, useRef, Dispatch, SetStateAction } from "react";
|
|
6
6
|
import ReactPlugin from "./ReactPlugin";
|
|
7
7
|
|
|
8
|
+
export type AIReactCustomEvent<T> = Dispatch<SetStateAction<T>>;
|
|
9
|
+
|
|
8
10
|
export default function useCustomEvent<T>(
|
|
9
11
|
reactPlugin: ReactPlugin,
|
|
10
12
|
eventName: string,
|
|
11
13
|
eventData: T,
|
|
12
14
|
skipFirstRun = true
|
|
13
|
-
) {
|
|
15
|
+
): AIReactCustomEvent<T> {
|
|
14
16
|
const [data, setData] = useState(eventData);
|
|
15
17
|
const firstRun = useRef(skipFirstRun);
|
|
16
18
|
|
|
@@ -22,5 +24,5 @@ export default function useCustomEvent<T>(
|
|
|
22
24
|
reactPlugin.trackEvent({ name: eventName }, data);
|
|
23
25
|
}, [reactPlugin, data, eventName]);
|
|
24
26
|
|
|
25
|
-
return setData
|
|
27
|
+
return setData as AIReactCustomEvent<T>;
|
|
26
28
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { Context } from "react";
|
|
2
2
|
import ReactPlugin from "./ReactPlugin";
|
|
3
|
-
declare
|
|
3
|
+
export declare type AppInsightsReactContext = Context<ReactPlugin>;
|
|
4
|
+
declare const AppInsightsContext: AppInsightsReactContext;
|
|
4
5
|
declare const useAppInsightsContext: () => ReactPlugin;
|
|
5
6
|
export { AppInsightsContext, useAppInsightsContext };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.18.11"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
package/types/useTrackEvent.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* ReactPlugin.ts
|
|
3
|
+
* @copyright Microsoft 2019
|
|
4
|
+
*/
|
|
5
|
+
import { Dispatch, SetStateAction } from "react";
|
|
2
6
|
import ReactPlugin from "./ReactPlugin";
|
|
3
|
-
export
|
|
7
|
+
export declare type AIReactCustomEvent<T> = Dispatch<SetStateAction<T>>;
|
|
8
|
+
export default function useCustomEvent<T>(reactPlugin: ReactPlugin, eventName: string, eventData: T, skipFirstRun?: boolean): AIReactCustomEvent<T>;
|