@microsoft/applicationinsights-react-js 3.2.2-nightly.2111-09 → 3.2.2-nightly.2111-10

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 (32) hide show
  1. package/browser/applicationinsights-react-js.js +1 -1
  2. package/browser/applicationinsights-react-js.js.map +1 -1
  3. package/browser/applicationinsights-react-js.min.js +1 -1
  4. package/browser/applicationinsights-react-js.min.js.map +1 -1
  5. package/dist/applicationinsights-react-js.d.ts +1 -1
  6. package/dist/applicationinsights-react-js.js +1 -1
  7. package/dist/applicationinsights-react-js.js.map +1 -1
  8. package/dist/applicationinsights-react-js.min.js +1 -1
  9. package/dist/applicationinsights-react-js.min.js.map +1 -1
  10. package/dist/applicationinsights-react-js.rollup.d.ts +1 -1
  11. package/dist-esm/AppInsightsContext.js +1 -1
  12. package/dist-esm/AppInsightsErrorBoundary.js +1 -1
  13. package/dist-esm/Interfaces/IReactExtensionConfig.js +1 -1
  14. package/dist-esm/ReactPlugin.js +1 -1
  15. package/dist-esm/applicationinsights-react-js.js +1 -1
  16. package/dist-esm/useTrackEvent.js +1 -1
  17. package/dist-esm/useTrackMetric.js +1 -1
  18. package/dist-esm/withAITracking.js +1 -1
  19. package/package.json +3 -3
  20. package/api-extractor.json +0 -361
  21. package/applicationinsights-react-js.build.error.log +0 -40
  22. package/applicationinsights-react-js.build.log +0 -93
  23. package/microsoft-applicationinsights-react-js-3.2.2-nightly.2111-09.tgz +0 -0
  24. package/rollup.config.js +0 -148
  25. package/temp/applicationinsights-react-js.api.md +0 -98
  26. package/test/AppInsightsErrorBoundary.test.tsx +0 -88
  27. package/test/ReactAI.test.ts +0 -158
  28. package/test/TestComponent.tsx +0 -31
  29. package/test/jestconfig.json +0 -21
  30. package/test/tsconfig.json +0 -16
  31. package/test/withAITracking.test.tsx +0 -72
  32. package/tslint.json +0 -5
package/rollup.config.js DELETED
@@ -1,148 +0,0 @@
1
- import nodeResolve from "@rollup/plugin-node-resolve";
2
- import commonjs from "@rollup/plugin-commonjs";
3
- import replace from "@rollup/plugin-replace";
4
- import cleanup from "rollup-plugin-cleanup";
5
- import peerDepsExternal from 'rollup-plugin-peer-deps-external';
6
- import { uglify } from "../../tools/rollup-plugin-uglify3-js/dist/esm/rollup-plugin-uglify3-js";
7
- import { es3Poly, importCheck } from "@microsoft/applicationinsights-rollup-es3";
8
- import dynamicRemove from "@microsoft/dynamicproto-js/tools/rollup/node/removedynamic";
9
- import { updateDistEsmFiles } from "../../tools/updateDistEsm/updateDistEsm";
10
-
11
- const version = require("./package.json").version;
12
- const outputName = "applicationinsights-react-js";
13
- const banner = [
14
- "/*!",
15
- ` * Application Insights JavaScript SDK - React Plugin, ${version}`,
16
- " * Copyright (c) Microsoft and contributors. All rights reserved.",
17
- " */"
18
- ].join("\n");
19
-
20
- const replaceValues = {
21
- "// Copyright (c) Microsoft Corporation. All rights reserved.": "",
22
- "// Licensed under the MIT License.": ""
23
- };
24
-
25
- function doCleanup() {
26
- return cleanup({
27
- comments: [
28
- 'some',
29
- /^.\s*@DynamicProtoStub/i,
30
- /^\*\*\s*@class\s*$/
31
- ]
32
- })
33
- }
34
-
35
- const browserRollupConfigFactory = isProduction => {
36
- const browserRollupConfig = {
37
- input: `dist-esm/${outputName}.js`,
38
- output: {
39
- file: `browser/${outputName}.js`,
40
- banner: banner,
41
- format: "umd",
42
- name: "Microsoft.ApplicationInsights",
43
- extend: true,
44
- freeze: false,
45
- sourcemap: true
46
- },
47
- plugins: [
48
- dynamicRemove(),
49
- replace({
50
- preventAssignment: true,
51
- delimiters: ["", ""],
52
- values: replaceValues
53
- }),
54
- importCheck({ exclude: [ "applicationinsights-react-js" ] }),
55
- peerDepsExternal(),
56
- nodeResolve({
57
- browser: true,
58
- preferBuiltins: true,
59
- dedupe: [ "react", "react-dom" ]
60
- }),
61
- commonjs(),
62
- doCleanup(),
63
- es3Poly()
64
- ]
65
- };
66
-
67
- if (isProduction) {
68
- browserRollupConfig.output.file = `browser/${outputName}.min.js`;
69
- browserRollupConfig.plugins.push(
70
- uglify({
71
- ie8: true,
72
- toplevel: true,
73
- compress: {
74
- passes:3,
75
- unsafe: true
76
- },
77
- output: {
78
- preamble: banner,
79
- webkit:true
80
- }
81
- })
82
- );
83
- }
84
-
85
- return browserRollupConfig;
86
- };
87
-
88
- const nodeUmdRollupConfigFactory = (isProduction) => {
89
- const nodeRollupConfig = {
90
- input: `dist-esm/${outputName}.js`,
91
- output: {
92
- file: `dist/${outputName}.js`,
93
- banner: banner,
94
- format: "umd",
95
- name: "Microsoft.ApplicationInsights",
96
- extend: true,
97
- freeze: false,
98
- sourcemap: true
99
- },
100
- plugins: [
101
- dynamicRemove(),
102
- replace({
103
- preventAssignment: true,
104
- delimiters: ["", ""],
105
- values: replaceValues
106
- }),
107
- importCheck({ exclude: [ "applicationinsights-react-js" ] }),
108
- peerDepsExternal(),
109
- nodeResolve({
110
- browser: true,
111
- preferBuiltins: true,
112
- dedupe: [ "react", "react-dom" ]
113
- }),
114
- commonjs(),
115
- doCleanup(),
116
- es3Poly()
117
- ]
118
- };
119
-
120
- if (isProduction) {
121
- nodeRollupConfig.output.file = `dist/${outputName}.min.js`;
122
- nodeRollupConfig.plugins.push(
123
- uglify({
124
- ie8: true,
125
- toplevel: true,
126
- compress: {
127
- passes:3,
128
- unsafe: true
129
- },
130
- output: {
131
- preamble: banner,
132
- webkit:true
133
- }
134
- })
135
- );
136
- }
137
-
138
- return nodeRollupConfig;
139
- };
140
-
141
- updateDistEsmFiles(replaceValues, banner);
142
-
143
- export default [
144
- browserRollupConfigFactory(true),
145
- browserRollupConfigFactory(false),
146
- nodeUmdRollupConfigFactory(true),
147
- nodeUmdRollupConfigFactory(false)
148
- ];
@@ -1,98 +0,0 @@
1
- ## API Report File for "@microsoft/applicationinsights-react-js"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- import { BaseTelemetryPlugin } from '@microsoft/applicationinsights-core-js';
8
- import { Context } from 'react';
9
- import { Dispatch } from 'react';
10
- import { History as History_2 } from 'history';
11
- import { IAppInsights } from '@microsoft/applicationinsights-common';
12
- import { IAppInsightsCore } from '@microsoft/applicationinsights-core-js';
13
- import { IConfig } from '@microsoft/applicationinsights-common';
14
- import { IConfiguration } from '@microsoft/applicationinsights-core-js';
15
- import { ICookieMgr } from '@microsoft/applicationinsights-core-js';
16
- import { ICustomProperties } from '@microsoft/applicationinsights-core-js';
17
- import { IEventTelemetry } from '@microsoft/applicationinsights-common';
18
- import { IExceptionTelemetry } from '@microsoft/applicationinsights-common';
19
- import { IMetricTelemetry } from '@microsoft/applicationinsights-common';
20
- import { IPageViewTelemetry } from '@microsoft/applicationinsights-common';
21
- import { IPlugin } from '@microsoft/applicationinsights-core-js';
22
- import { IProcessTelemetryContext } from '@microsoft/applicationinsights-core-js';
23
- import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
24
- import { ITelemetryPluginChain } from '@microsoft/applicationinsights-core-js';
25
- import { ITraceTelemetry } from '@microsoft/applicationinsights-common';
26
- import * as React_2 from 'react';
27
- import { default as React_3 } from 'react';
28
- import { SetStateAction } from 'react';
29
-
30
- // Warning: (ae-forgotten-export) The symbol "AppInsightsReactContext" needs to be exported by the entry point applicationinsights-react-js.d.ts
31
- //
32
- // @public (undocumented)
33
- export const AppInsightsContext: AppInsightsReactContext;
34
-
35
- // Warning: (ae-forgotten-export) The symbol "IAppInsightsErrorBoundaryProps" needs to be exported by the entry point applicationinsights-react-js.d.ts
36
- // Warning: (ae-forgotten-export) The symbol "IAppInsightsErrorBoundaryState" needs to be exported by the entry point applicationinsights-react-js.d.ts
37
- //
38
- // @public (undocumented)
39
- export class AppInsightsErrorBoundary extends React_3.Component<IAppInsightsErrorBoundaryProps, IAppInsightsErrorBoundaryState> {
40
- // (undocumented)
41
- componentDidCatch(error: Error, errorInfo: React_3.ErrorInfo): void;
42
- // (undocumented)
43
- render(): React_3.ReactNode;
44
- // (undocumented)
45
- state: {
46
- hasError: boolean;
47
- };
48
- }
49
-
50
- // @public
51
- export interface IReactExtensionConfig {
52
- readonly history?: History_2;
53
- }
54
-
55
- // @public (undocumented)
56
- export class ReactPlugin extends BaseTelemetryPlugin {
57
- getAppInsights(): IAppInsights;
58
- getCookieMgr(): ICookieMgr;
59
- // (undocumented)
60
- identifier: string;
61
- // (undocumented)
62
- initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
63
- // (undocumented)
64
- priority: number;
65
- processTelemetry(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
66
- // (undocumented)
67
- trackEvent(event: IEventTelemetry, customProperties?: ICustomProperties): void;
68
- // (undocumented)
69
- trackException(exception: IExceptionTelemetry, customProperties?: {
70
- [key: string]: any;
71
- }): void;
72
- // (undocumented)
73
- trackMetric(metric: IMetricTelemetry, customProperties: ICustomProperties): void;
74
- // (undocumented)
75
- trackPageView(pageView: IPageViewTelemetry): void;
76
- // (undocumented)
77
- trackTrace(trace: ITraceTelemetry, customProperties?: {
78
- [key: string]: any;
79
- }): void;
80
- }
81
-
82
- // @public (undocumented)
83
- export const useAppInsightsContext: () => ReactPlugin;
84
-
85
- // Warning: (ae-forgotten-export) The symbol "AIReactCustomEvent" needs to be exported by the entry point applicationinsights-react-js.d.ts
86
- //
87
- // @public (undocumented)
88
- export function useTrackEvent<T>(reactPlugin: ReactPlugin, eventName: string, eventData: T, skipFirstRun?: boolean): AIReactCustomEvent<T>;
89
-
90
- // @public (undocumented)
91
- export const useTrackMetric: (reactPlugin: ReactPlugin, componentName: string) => () => void;
92
-
93
- // @public
94
- export function withAITracking<P>(reactPlugin: ReactPlugin, Component: React_2.ComponentType<P>, componentName?: string, className?: string): React_2.ComponentClass<P>;
95
-
96
- // (No @packageDocumentation comment for this package)
97
-
98
- ```
@@ -1,88 +0,0 @@
1
- import React from "react";
2
- import ReactPlugin from "../src/ReactPlugin";
3
- import AppInsightsErrorBoundary from "../src/AppInsightsErrorBoundary";
4
- import { TestComponent, ErrorTestComponent } from "./TestComponent";
5
- import { render} from '@testing-library/react';
6
- import '@testing-library/jest-dom/extend-expect';
7
-
8
- let reactPlugin: ReactPlugin;
9
- let trackExceptionSpy;
10
- let orgWarn = console && console.warn;
11
-
12
- describe("<AppInsightsErrorBoundary />", () => {
13
- beforeEach(() => {
14
- if (orgWarn) {
15
- console.warn = (msg) => { /* Swallow */ }
16
- }
17
- reactPlugin = new ReactPlugin();
18
- trackExceptionSpy = reactPlugin.trackException = jest.fn();
19
- });
20
-
21
- afterEach(() => {
22
- if (orgWarn) {
23
- console.warn = orgWarn;
24
- }
25
- });
26
-
27
- it("should render a non-erroring component", () => {
28
- const aiErrorBoundry = render(
29
- <AppInsightsErrorBoundary
30
- appInsights={reactPlugin}
31
- onError={() => <div></div>}
32
- >
33
- <TestComponent />
34
- </AppInsightsErrorBoundary>
35
- );
36
- const testComponent = render(<TestComponent />);
37
- expect(aiErrorBoundry.container).toEqual(testComponent.container);
38
- });
39
-
40
- it("should catch the error and render the alternative component", async () => {
41
- const orgError = console && console.error;
42
- if (orgError) {
43
- console.error = msg => { /* Do Nothing */ };
44
- }
45
-
46
- try {
47
- const ErrorDisplay = () => <div>Error</div>;
48
- const aiErrorBoundry = render(
49
- <AppInsightsErrorBoundary
50
- appInsights={reactPlugin}
51
- onError={ErrorDisplay}
52
- >
53
- <ErrorTestComponent />
54
- </AppInsightsErrorBoundary>
55
- );
56
- const errorDisplay = render(<ErrorDisplay />);
57
- expect(aiErrorBoundry.container).toEqual(errorDisplay.container);
58
- } finally {
59
- if (orgError) {
60
- console.error = orgError;
61
- }
62
- }
63
- });
64
-
65
- it("should catch the error and track exception", async () => {
66
- const orgError = console && console.error;
67
- if (orgError) {
68
- console.error = msg => { /* Do Nothing */ };
69
- }
70
-
71
- try {
72
- const ErrorDisplay = () => <div>Error</div>;
73
- const aiErrorBoundry = render(
74
- <AppInsightsErrorBoundary
75
- appInsights={reactPlugin}
76
- onError={ErrorDisplay}
77
- >
78
- <ErrorTestComponent />
79
- </AppInsightsErrorBoundary>
80
- );
81
- expect(trackExceptionSpy).toHaveBeenCalledTimes(1);
82
- } finally {
83
- if (orgError) {
84
- console.error = orgError;
85
- }
86
- }
87
- });
88
- });
@@ -1,158 +0,0 @@
1
- import { AppInsightsCore, IConfiguration, DiagnosticLogger, ITelemetryItem, IPlugin } from "@microsoft/applicationinsights-core-js";
2
- import { IPageViewTelemetry } from "@microsoft/applicationinsights-common";
3
- import ReactPlugin from "../src/ReactPlugin";
4
- import { IReactExtensionConfig } from "../src/Interfaces/IReactExtensionConfig";
5
- import { createBrowserHistory } from "history";
6
-
7
- let reactPlugin: ReactPlugin;
8
- let core: AppInsightsCore;
9
- let orgWarn = console && console.warn;
10
-
11
- describe("ReactAI", () => {
12
-
13
- beforeEach(() => {
14
- if (orgWarn) {
15
- console.warn = (msg) => { /* Swallow */ }
16
- }
17
- });
18
-
19
- afterEach(() => {
20
- if (orgWarn) {
21
- console.warn = orgWarn;
22
- }
23
- });
24
-
25
- function init() {
26
- core = new AppInsightsCore();
27
- core.logger = new DiagnosticLogger();
28
- reactPlugin = new ReactPlugin();
29
- }
30
-
31
- it("React Configuration: Config options can be passed from root config", () => {
32
- const history = createBrowserHistory();
33
- init();
34
- reactPlugin.initialize({
35
- instrumentationKey: 'instrumentation_key',
36
- extensionConfig: {
37
- [reactPlugin.identifier]: {
38
- history
39
- }
40
- }
41
- }, core, []);
42
- const reactConfig: IReactExtensionConfig = reactPlugin['_extensionConfig'];
43
- expect(reactConfig.history).toEqual(history);
44
- });
45
-
46
- it("React PageView using Analytics plugin", () => {
47
- const history = createBrowserHistory();
48
- jest.useFakeTimers();
49
- init();
50
- const analyticsExtension = {
51
- initialize: (config, core, extensions) => { },
52
- trackEvent: (event, customProperties) => { },
53
- trackPageView: (pageView, customProperties) => { },
54
- trackException: (exception, customProperties) => { },
55
- trackTrace: (trace, customProperties) => { },
56
- trackMetric: (metric, customProperties) => { },
57
- _onerror: (exception) => { },
58
- startTrackPage: (name) => { },
59
- stopTrackPage: (name, properties, measurements) => { },
60
- startTrackEvent: (name) => { },
61
- stopTrackEvent: (name, properties, measurements) => { },
62
- addTelemetryInitializer: (telemetryInitializer) => { },
63
- trackPageViewPerformance: (pageViewPerformance, customProperties) => { },
64
- processTelemetry: (env) => { },
65
- setNextPlugin: (next) => { },
66
- identifier: "ApplicationInsightsAnalytics"
67
- };
68
- const channel = new ChannelPlugin();
69
- const config: IConfiguration = {
70
- instrumentationKey: 'instrumentation_key',
71
- extensionConfig: {
72
- [reactPlugin.identifier]: {
73
- history
74
- },
75
- }
76
- };
77
- core.initialize(config, [reactPlugin, analyticsExtension, channel]);
78
- // Mock Analytics track
79
- const analyticsMock = analyticsExtension.trackPageView = jest.fn();
80
-
81
- // Emulate navigation to different URL-addressed pages
82
- history.push("/home", { some: "state" });
83
- history.push("/new-fancy-page");
84
- jest.runOnlyPendingTimers();
85
- expect(analyticsExtension.trackPageView).toHaveBeenCalledTimes(2);
86
- let event: IPageViewTelemetry = analyticsMock.mock.calls[0][0]
87
- expect(event.uri).toBe("/home");
88
- event = analyticsMock.mock.calls[1][0]
89
- expect(event.uri).toBe("/new-fancy-page");
90
- });
91
-
92
- it("React plugin with Analytics not available", () => {
93
- const history = createBrowserHistory();
94
- jest.useFakeTimers();
95
- init();
96
- const channel = new ChannelPlugin();
97
- const config: IConfiguration = {
98
- instrumentationKey: 'instrumentation_key',
99
- extensionConfig: {
100
- [reactPlugin.identifier]: {
101
- history
102
- }
103
- }
104
- };
105
- core.initialize(config, [reactPlugin, channel]);
106
- // Mock logger
107
- const loggerMock = core["logger"].throwInternal = jest.fn();
108
- history.push("/home");
109
- jest.runOnlyPendingTimers();
110
- expect(loggerMock).toHaveBeenCalledTimes(1);
111
- });
112
- });
113
-
114
- class ChannelPlugin implements IPlugin {
115
- public isFlushInvoked = false;
116
- public isTearDownInvoked = false;
117
- public isResumeInvoked = false;
118
- public isPauseInvoked = false;
119
-
120
- public identifier = "Sender";
121
-
122
- public priority: number = 1001;
123
-
124
- constructor() {
125
- this.processTelemetry = this._processTelemetry.bind(this);
126
- }
127
- public pause(): void {
128
- this.isPauseInvoked = true;
129
- }
130
-
131
- public resume(): void {
132
- this.isResumeInvoked = true;
133
- }
134
-
135
- public teardown(): void {
136
- this.isTearDownInvoked = true;
137
- }
138
-
139
- flush(async?: boolean, callBack?: () => void): void {
140
- this.isFlushInvoked = true;
141
- if (callBack) {
142
- callBack();
143
- }
144
- }
145
-
146
- public processTelemetry(env: ITelemetryItem) { }
147
-
148
- setNextPlugin(next: any) {
149
- // no next setup
150
- }
151
-
152
- public initialize = (config: IConfiguration, core: AppInsightsCore, plugin: IPlugin[]) => {
153
- }
154
-
155
- private _processTelemetry(env: ITelemetryItem) {
156
-
157
- }
158
- }
@@ -1,31 +0,0 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // Licensed under the MIT License.
3
-
4
- import * as React from "react";
5
-
6
- export interface ITestComponentProps {
7
- prop1?: number;
8
- prop2?: string;
9
- }
10
-
11
- export class TestComponent extends React.Component<ITestComponentProps> {
12
- public render() {
13
- const { prop1, prop2 } = this.props;
14
- return (
15
- <div>
16
- <h1>TestComponent</h1>
17
- prop1: {prop1}, prop2: {prop2}
18
- </div>
19
- );
20
- }
21
- }
22
-
23
- export default TestComponent;
24
-
25
- export class ErrorTestComponent extends React.Component {
26
- public render(): React.ReactNode {
27
- if (true) {
28
- throw new Error("Error");
29
- }
30
- }
31
- }
@@ -1,21 +0,0 @@
1
- {
2
- "transform": {
3
- "^.+\\.(t|j)sx?$": "ts-jest"
4
- },
5
- "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
6
- "testEnvironment": "jsdom",
7
- "moduleFileExtensions": [
8
- "ts",
9
- "tsx",
10
- "js",
11
- "jsx",
12
- "json",
13
- "node"
14
- ],
15
- "testPathIgnorePatterns": [
16
- "node_modules",
17
- "legacy",
18
- "dist",
19
- "dist-esm"
20
- ]
21
- }
@@ -1,16 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "sourceMap": true,
4
- "inlineSources": true,
5
- "noImplicitAny": false,
6
- "module": "amd",
7
- "moduleResolution": "Node",
8
- "target": "es5",
9
- "alwaysStrict": true,
10
- "declaration": true,
11
- "jsx": "react",
12
- "esModuleInterop": true,
13
- "allowJs": true
14
- },
15
- "files": []
16
- }
@@ -1,72 +0,0 @@
1
- import { IPageViewTelemetry, IMetricTelemetry } from "@microsoft/applicationinsights-common";
2
- import * as React from "react";
3
- import ReactPlugin from "../src/ReactPlugin";
4
- import withAITracking from "../src/withAITracking";
5
- import { TestComponent } from "./TestComponent";
6
- import { render, screen } from '@testing-library/react';
7
- import userEvent from '@testing-library/user-event';
8
- import '@testing-library/jest-dom/extend-expect';
9
-
10
- let reactPlugin: ReactPlugin;
11
- let TestComponentWithTracking;
12
- let trackedTestComponentUnmount;
13
- let trackMetricSpy;
14
- let orgWarn = console && console.warn;
15
-
16
- describe("withAITracking(TestComponent)", () => {
17
-
18
- beforeEach(() => {
19
- if (orgWarn) {
20
- console.warn = (msg) => { /* Swallow */ }
21
- }
22
- reactPlugin = new ReactPlugin();
23
- TestComponentWithTracking = withAITracking(reactPlugin, TestComponent);
24
- const testComponentWithTracking = render(<TestComponentWithTracking />);
25
- trackedTestComponentUnmount = testComponentWithTracking.unmount;
26
- trackMetricSpy = reactPlugin.trackMetric = jest.fn();
27
- });
28
-
29
- afterEach(() => {
30
- if (orgWarn) {
31
- console.warn = orgWarn;
32
- }
33
- });
34
-
35
- it("should wrap <TestComponent />", () => {
36
- expect(screen.getByText('TestComponent')).toBeInTheDocument();
37
- });
38
-
39
- it("shouldn't call trackMetric if there's no user interaction", () => {
40
- trackedTestComponentUnmount();
41
- expect(trackMetricSpy).toHaveBeenCalledTimes(0);
42
- });
43
-
44
-
45
- it("should call trackMetric if there is user interaction", () => {
46
- userEvent.click(screen.getByText('TestComponent'));
47
- trackedTestComponentUnmount();
48
- expect(trackMetricSpy).toHaveBeenCalledTimes(1);
49
- const metricTelemetry: IMetricTelemetry & IPageViewTelemetry = {
50
- average: expect.any(Number),
51
- name: "React Component Engaged Time (seconds)",
52
- sampleCount: 1
53
- };
54
- expect(trackMetricSpy).toHaveBeenCalledWith(metricTelemetry, { "Component Name": "TestComponent" });
55
- });
56
-
57
- it("should use the passed component name in trackMetric", () => {
58
- trackedTestComponentUnmount();
59
- const TestComponentWithTrackingCustomName = withAITracking(reactPlugin, TestComponent, "MyCustomName");
60
- const { container, unmount } = render(<TestComponentWithTrackingCustomName />);
61
- userEvent.click(screen.getByText('TestComponent'));
62
- unmount();
63
-
64
- expect(trackMetricSpy).toHaveBeenCalledTimes(1);
65
- const metricTelemetry: IMetricTelemetry & IPageViewTelemetry = {
66
- average: expect.any(Number),
67
- name: "React Component Engaged Time (seconds)",
68
- sampleCount: 1
69
- };
70
- expect(trackMetricSpy).toHaveBeenCalledWith(metricTelemetry, { "Component Name": "MyCustomName" });
71
- });
72
- });
package/tslint.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "extends": [
3
- "../../tslint-base.json"
4
- ]
5
- }