@snokam/application-insights 1.2.19 → 1.3.1

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/CHANGELOG.md CHANGED
@@ -3,169 +3,124 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [1.2.19](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.19-alpha.0...@snokam/application-insights@1.2.19) (2025-06-02)
7
-
8
- **Note:** Version bump only for package @snokam/application-insights
9
-
10
-
6
+ ## [1.3.1](https://github.com/snokam/components/compare/%40snokam%2Fapplication-insights%401.3.0...%40snokam%2Fapplication-insights%401.3.1) (2026-11-09)
11
7
 
8
+ ### Bug Fixes
12
9
 
10
+ - **deps:** close all open npm Dependabot alerts and bump deps within major ([#3364](https://github.com/snokam/components/issues/3364)) ([1372dbb](https://github.com/snokam/components/commit/1372dbbed19d6d6c93c357f3543f4c8db01bfb43))
11
+ - **observability:** always record 5xx and exceptions, report web server errors to App Insights ([#3298](https://github.com/snokam/components/issues/3298)) ([246229d](https://github.com/snokam/components/commit/246229d4774378c591155a145e4b9b5f64e0e708))
12
+ - **web:** never send the server token to an unknown host; dates in Europe/Oslo everywhere ([#3334](https://github.com/snokam/components/issues/3334)) ([a17581a](https://github.com/snokam/components/commit/a17581a457f91de68e646958509b490e39763b32)), closes [#3318](https://github.com/snokam/components/issues/3318) [#418](https://github.com/snokam/components/issues/418) [#3322](https://github.com/snokam/components/issues/3322) [#3328](https://github.com/snokam/components/issues/3328)
13
13
 
14
- ## [1.2.19-alpha.0](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.18...@snokam/application-insights@1.2.19-alpha.0) (2025-05-31)
14
+ ### Performance Improvements
15
15
 
16
- **Note:** Version bump only for package @snokam/application-insights
16
+ - **web:** cache public pages per host and speed up every app (Lighthouse round 2) ([#3279](https://github.com/snokam/components/issues/3279)) ([4ab508b](https://github.com/snokam/components/commit/4ab508ba90289a5d1bd28e7b843f9069dae5cc44))
17
+ - **web:** faster and more accessible public pages (Lighthouse) ([#3273](https://github.com/snokam/components/issues/3273)) ([0501fea](https://github.com/snokam/components/commit/0501feaeb803dec1c0a2993726a65f10a986f803)), closes [#1976d2](https://github.com/snokam/components/issues/1976d2) [#1565c0](https://github.com/snokam/components/issues/1565c0)
18
+ - **web:** halve the JavaScript on the signed-in apps ([#3281](https://github.com/snokam/components/issues/3281)) ([c248da6](https://github.com/snokam/components/commit/c248da646f6a9b457278042890b92976b07a8d16))
17
19
 
20
+ # 1.3.0 (2026-08-18)
18
21
 
22
+ ### Bug Fixes
19
23
 
24
+ - **deps:** close all 128 Dependabot alerts, upgrade across majors, consolidate the catalog ([#2028](https://github.com/snokam/components/issues/2028)) ([1b16dd5](https://github.com/snokam/components/commit/1b16dd5370f5685d290aa72b45bcbe81baa122c9)), closes [#816](https://github.com/snokam/components/issues/816)
25
+ - **security:** upgrade all dependencies and fix Dependabot alerts ([c462d7f](https://github.com/snokam/components/commit/c462d7f975451c490726177e0fd9c588a90953bd))
26
+ - update all dependencies to latest ([8aff44e](https://github.com/snokam/components/commit/8aff44ec72f8a17f2f9d1f527f5c3ae89c3ccaef))
20
27
 
28
+ ### Features
21
29
 
22
- ## [1.2.18](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.17...@snokam/application-insights@1.2.18) (2025-05-30)
30
+ - migrate all 16 frontend apps from Pages Router to App Router ([#681](https://github.com/snokam/components/issues/681)) ([3b0cd1c](https://github.com/snokam/components/commit/3b0cd1c0c28abc2684e9c07d42264afe3d19cc8c))
31
+ - monomono repo ([b1dec79](https://github.com/snokam/components/commit/b1dec79c4a96f51150398da11b69c0e397c1aec1))
32
+ - multi-business platform — secret persistence, integration checks, feature flags ([#1556](https://github.com/snokam/components/issues/1556)) ([990de8f](https://github.com/snokam/components/commit/990de8f2044a619de641d8066d40d503ab390070)), closes [#70](https://github.com/snokam/components/issues/70) [#71](https://github.com/snokam/components/issues/71) [#69](https://github.com/snokam/components/issues/69)
23
33
 
34
+ ## [1.2.19](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.19-alpha.0...@snokam/application-insights@1.2.19) (2025-06-02)
24
35
 
25
- ### Bug Fixes
36
+ **Note:** Version bump only for package @snokam/application-insights
26
37
 
27
- * update all deps ([d3183ec](https://github.com/snokam/components/commit/d3183eca3678a2b9f7df52a6e91e7e6ea7e27967))
28
- * update storybook and all texts ([7158e03](https://github.com/snokam/components/commit/7158e03996e82cb95aac309663bbdd5c331c5579))
38
+ ## [1.2.19-alpha.0](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.18...@snokam/application-insights@1.2.19-alpha.0) (2025-05-31)
29
39
 
40
+ **Note:** Version bump only for package @snokam/application-insights
30
41
 
42
+ ## [1.2.18](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.17...@snokam/application-insights@1.2.18) (2025-05-30)
31
43
 
44
+ ### Bug Fixes
32
45
 
46
+ - update all deps ([d3183ec](https://github.com/snokam/components/commit/d3183eca3678a2b9f7df52a6e91e7e6ea7e27967))
47
+ - update storybook and all texts ([7158e03](https://github.com/snokam/components/commit/7158e03996e82cb95aac309663bbdd5c331c5579))
33
48
 
34
49
  ## [1.2.17](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.16...@snokam/application-insights@1.2.17) (2025-03-10)
35
50
 
36
-
37
51
  ### Bug Fixes
38
52
 
39
- * upgrade all deps ([dfe05ac](https://github.com/snokam/components/commit/dfe05acb1ff7564e050405d4ee01dd12a7237641))
40
-
41
-
42
-
43
-
53
+ - upgrade all deps ([dfe05ac](https://github.com/snokam/components/commit/dfe05acb1ff7564e050405d4ee01dd12a7237641))
44
54
 
45
55
  ## [1.2.16](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.15...@snokam/application-insights@1.2.16) (2025-02-28)
46
56
 
47
-
48
57
  ### Bug Fixes
49
58
 
50
- * revert to use router ([fe1c008](https://github.com/snokam/components/commit/fe1c008f81c75c95a5a761d37e1012184e355716))
51
-
52
-
53
-
54
-
59
+ - revert to use router ([fe1c008](https://github.com/snokam/components/commit/fe1c008f81c75c95a5a761d37e1012184e355716))
55
60
 
56
61
  ## [1.2.15](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.14...@snokam/application-insights@1.2.15) (2025-02-28)
57
62
 
58
-
59
63
  ### Bug Fixes
60
64
 
61
- * add null check on router ([f0378b1](https://github.com/snokam/components/commit/f0378b15c7ee9ca9bc3623830a09ce9c26c60de7))
62
- * null check ([6eca652](https://github.com/snokam/components/commit/6eca652608206287b4d3888241437a36fa41f40c))
63
-
64
-
65
-
66
-
65
+ - add null check on router ([f0378b1](https://github.com/snokam/components/commit/f0378b15c7ee9ca9bc3623830a09ce9c26c60de7))
66
+ - null check ([6eca652](https://github.com/snokam/components/commit/6eca652608206287b4d3888241437a36fa41f40c))
67
67
 
68
68
  ## [1.2.14](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.13...@snokam/application-insights@1.2.14) (2025-02-28)
69
69
 
70
-
71
70
  ### Bug Fixes
72
71
 
73
- * add null check ([aefdf5f](https://github.com/snokam/components/commit/aefdf5fa39abcc3ff7a0301b6755181c0ffe344c))
74
-
75
-
76
-
77
-
72
+ - add null check ([aefdf5f](https://github.com/snokam/components/commit/aefdf5fa39abcc3ff7a0301b6755181c0ffe344c))
78
73
 
79
74
  ## [1.2.13](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.12...@snokam/application-insights@1.2.13) (2025-02-28)
80
75
 
81
-
82
76
  ### Bug Fixes
83
77
 
84
- * use compat router ([517435f](https://github.com/snokam/components/commit/517435f5dc0549ec52ff85af813fc8863c231f3f))
85
-
86
-
87
-
88
-
78
+ - use compat router ([517435f](https://github.com/snokam/components/commit/517435f5dc0549ec52ff85af813fc8863c231f3f))
89
79
 
90
80
  ## [1.2.12](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.11...@snokam/application-insights@1.2.12) (2025-02-15)
91
81
 
92
82
  **Note:** Version bump only for package @snokam/application-insights
93
83
 
94
-
95
-
96
-
97
-
98
84
  ## [1.2.11](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.10...@snokam/application-insights@1.2.11) (2025-02-15)
99
85
 
100
-
101
86
  ### Bug Fixes
102
87
 
103
- * remove rootDir concept ([c7e1cc4](https://github.com/snokam/components/commit/c7e1cc456965a50592044e3150b2a4daec551083))
104
- * update deps ([caa80b4](https://github.com/snokam/components/commit/caa80b42e50c20f936bbfc29f05b0ba9a17e9b0e))
105
-
106
-
107
-
108
-
88
+ - remove rootDir concept ([c7e1cc4](https://github.com/snokam/components/commit/c7e1cc456965a50592044e3150b2a4daec551083))
89
+ - update deps ([caa80b4](https://github.com/snokam/components/commit/caa80b42e50c20f936bbfc29f05b0ba9a17e9b0e))
109
90
 
110
91
  ## [1.2.10](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.9...@snokam/application-insights@1.2.10) (2025-02-03)
111
92
 
112
-
113
93
  ### Bug Fixes
114
94
 
115
- * restructure whole project ([225825e](https://github.com/snokam/components/commit/225825e4a0447131c7ceebb65cd92b69f33aab2b))
116
-
117
-
118
-
119
-
95
+ - restructure whole project ([225825e](https://github.com/snokam/components/commit/225825e4a0447131c7ceebb65cd92b69f33aab2b))
120
96
 
121
97
  ## [1.2.9](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.8...@snokam/application-insights@1.2.9) (2024-12-04)
122
98
 
123
-
124
99
  ### Bug Fixes
125
100
 
126
- * allow any next version ([a185787](https://github.com/snokam/components/commit/a185787786cd8a2564d0c7170008911f61415fa4))
127
- * deploy new packages with peer dep update ([290a502](https://github.com/snokam/components/commit/290a5028930327c27cce670f75d4db09e5673323))
128
-
129
-
130
-
131
-
101
+ - allow any next version ([a185787](https://github.com/snokam/components/commit/a185787786cd8a2564d0c7170008911f61415fa4))
102
+ - deploy new packages with peer dep update ([290a502](https://github.com/snokam/components/commit/290a5028930327c27cce670f75d4db09e5673323))
132
103
 
133
104
  ## [1.2.8](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.7...@snokam/application-insights@1.2.8) (2024-10-31)
134
105
 
135
-
136
106
  ### Bug Fixes
137
107
 
138
- * simplify check ([271ca71](https://github.com/snokam/components/commit/271ca71c27be891a76a553e7315629add3618700))
139
-
140
-
141
-
142
-
108
+ - simplify check ([271ca71](https://github.com/snokam/components/commit/271ca71c27be891a76a553e7315629add3618700))
143
109
 
144
110
  ## [1.2.7](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.6...@snokam/application-insights@1.2.7) (2024-10-31)
145
111
 
146
-
147
112
  ### Bug Fixes
148
113
 
149
- * filter out video telemetry ([b8f4db1](https://github.com/snokam/components/commit/b8f4db15505f1d4eaa5fd7cdbde6a38bba1bf9fd))
150
-
151
-
152
-
153
-
114
+ - filter out video telemetry ([b8f4db1](https://github.com/snokam/components/commit/b8f4db15505f1d4eaa5fd7cdbde6a38bba1bf9fd))
154
115
 
155
116
  ## [1.2.6](https://github.com/snokam/components/compare/@snokam/application-insights@1.2.5...@snokam/application-insights@1.2.6) (2024-10-31)
156
117
 
157
-
158
118
  ### Bug Fixes
159
119
 
160
- * adjust insights ([0c82e75](https://github.com/snokam/components/commit/0c82e75d8b9485aa1b2a5c995a62ac5216a8fb9d))
161
-
162
-
163
-
164
-
120
+ - adjust insights ([0c82e75](https://github.com/snokam/components/commit/0c82e75d8b9485aa1b2a5c995a62ac5216a8fb9d))
165
121
 
166
122
  ## 1.2.5 (2024-10-31)
167
123
 
168
-
169
124
  ### Bug Fixes
170
125
 
171
- * initial commit for @snokam/application-insights ([335ec5f](https://github.com/snokam/components/commit/335ec5f58092291138e687b03d87543c3b844c9f))
126
+ - initial commit for @snokam/application-insights ([335ec5f](https://github.com/snokam/components/commit/335ec5f58092291138e687b03d87543c3b844c9f))
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@snokam/application-insights",
3
3
  "description": "Snøkam core components",
4
- "version": "1.2.19",
5
- "main": "lib/index.js",
6
- "typings": "lib/index.d.ts",
4
+ "version": "1.3.1",
5
+ "main": "src/index.tsx",
6
+ "sideEffects": false,
7
+ "types": "src/index.tsx",
7
8
  "files": [
8
- "lib",
9
+ "src",
9
10
  "package.json",
10
11
  "CHANGELOG.md"
11
12
  ],
@@ -14,24 +15,31 @@
14
15
  "url": "ssh://git@github.com:snokam/components.git",
15
16
  "directory": "@snokam/core"
16
17
  },
17
- "scripts": {
18
- "start": "webpack --watch --config=../../../webpack/webpack.dev.js",
19
- "build": "webpack --config=../../../webpack/webpack.prod.js",
20
- "build:doc": "webpack --config=../../../webpack/webpack.dev.js",
21
- "clean": "rm -rf lib"
22
- },
23
18
  "publishConfig": {
24
19
  "access": "public"
25
20
  },
26
21
  "dependencies": {
27
- "@microsoft/applicationinsights-react-js": "^19.3.6",
28
- "@microsoft/applicationinsights-web": "^3.3.8",
22
+ "@microsoft/applicationinsights-react-js": "^19.4.2",
23
+ "@microsoft/applicationinsights-web": "^3.4.6",
29
24
  "history": "^5.3.0"
30
25
  },
31
26
  "peerDependencies": {
32
- "next": "*",
33
- "react": "*",
34
- "react-dom": "*"
27
+ "next": "16.4.5",
28
+ "react": "19.3.1",
29
+ "react-dom": "19.3.1"
30
+ },
31
+ "devDependencies": {
32
+ "@types/react": "^19.3.0",
33
+ "@types/react-dom": "^19.3.0"
35
34
  },
36
- "gitHead": "7004483db39956d04699334b9bfa587e5337f313"
37
- }
35
+ "exports": {
36
+ ".": "./src/index.tsx",
37
+ "./page-router": "./src/page-router.tsx",
38
+ "./app-router": "./src/app-router.tsx",
39
+ "./server": "./src/server.ts"
40
+ },
41
+ "scripts": {
42
+ "lint": "eslint .",
43
+ "test": "node --test \"src/**/*.test.ts\""
44
+ }
45
+ }
@@ -0,0 +1,80 @@
1
+ import { useRouter } from "next/router";
2
+ import { ReactNode, useEffect, useRef } from "react";
3
+ import { createBrowserHistory } from "history";
4
+ import {
5
+ AppInsightsContext,
6
+ ReactPlugin,
7
+ } from "@microsoft/applicationinsights-react-js";
8
+ import {
9
+ ApplicationInsights,
10
+ IConfig,
11
+ IConfiguration,
12
+ ITelemetryPlugin,
13
+ } from "@microsoft/applicationinsights-web";
14
+
15
+ export interface ProviderProps {
16
+ children: ReactNode;
17
+ config: IConfiguration & IConfig;
18
+ }
19
+
20
+ export const Provider = ({ children, config }: ProviderProps) => {
21
+ const router = useRouter();
22
+ const reactPluginRef = useRef<ReactPlugin>(new ReactPlugin());
23
+ const appInsightsRef = useRef<ApplicationInsights | null>(null);
24
+
25
+ const events = router?.events;
26
+ const isBrowser = typeof window !== "undefined";
27
+ const browserHistory = isBrowser ? createBrowserHistory() : undefined;
28
+
29
+ useEffect(() => {
30
+ if (!appInsightsRef.current) {
31
+ appInsightsRef.current = new ApplicationInsights({
32
+ config: {
33
+ maxBatchSizeInBytes: 10000,
34
+ maxBatchInterval: 15000,
35
+ enableAutoRouteTracking: true,
36
+ extensions: [reactPluginRef.current as unknown as ITelemetryPlugin],
37
+ extensionConfig: {
38
+ [reactPluginRef.current.identifier]: { history: browserHistory },
39
+ },
40
+ ...config,
41
+ },
42
+ });
43
+
44
+ appInsightsRef.current.loadAppInsights();
45
+
46
+ appInsightsRef.current.addTelemetryInitializer((envelope) => {
47
+ const baseType = envelope.baseType || "";
48
+ const telemetryItem = envelope.baseData || {};
49
+ const target = telemetryItem.target || "";
50
+ const isDependencyData = baseType === "RemoteDependencyData";
51
+
52
+ const isVideo =
53
+ target.includes("mux.com") || target.includes("litix.io");
54
+
55
+ if (isDependencyData && isVideo) {
56
+ return false;
57
+ }
58
+ });
59
+ }
60
+ }, [config]);
61
+
62
+ useEffect(() => {
63
+ const handleRouteChange = (url: string) => {
64
+ appInsightsRef.current?.trackPageView({ name: url });
65
+ };
66
+
67
+ events?.on("routeChangeComplete", handleRouteChange);
68
+ return () => {
69
+ events?.off("routeChangeComplete", handleRouteChange);
70
+ };
71
+ }, [events]);
72
+
73
+ return (
74
+ <AppInsightsContext.Provider value={reactPluginRef.current}>
75
+ {children}
76
+ </AppInsightsContext.Provider>
77
+ );
78
+ };
79
+
80
+ export default Provider;
@@ -0,0 +1,90 @@
1
+ "use client";
2
+
3
+ import { usePathname, useSearchParams } from "next/navigation";
4
+ import { ReactNode, Suspense, useEffect, useRef, useState } from "react";
5
+ import { createBrowserHistory } from "history";
6
+ import {
7
+ AppInsightsContext,
8
+ ReactPlugin,
9
+ } from "@microsoft/applicationinsights-react-js";
10
+ import {
11
+ ApplicationInsights,
12
+ IConfig,
13
+ IConfiguration,
14
+ ITelemetryPlugin,
15
+ } from "@microsoft/applicationinsights-web";
16
+
17
+ export interface ProviderProps {
18
+ children: ReactNode;
19
+ config: IConfiguration & IConfig;
20
+ }
21
+
22
+ function PageViewTracker({
23
+ instance,
24
+ }: {
25
+ instance: ApplicationInsights | null;
26
+ }) {
27
+ const pathname = usePathname();
28
+ const searchParams = useSearchParams();
29
+
30
+ useEffect(() => {
31
+ if (!instance) return;
32
+ const url = pathname + (searchParams?.toString() ? `?${searchParams}` : "");
33
+ instance.trackPageView({ name: url });
34
+ }, [instance, pathname, searchParams]);
35
+
36
+ return null;
37
+ }
38
+
39
+ function AppRouterProvider({ children, config }: ProviderProps) {
40
+ const reactPluginRef = useRef<ReactPlugin>(new ReactPlugin());
41
+ const [instance, setInstance] = useState<ApplicationInsights | null>(null);
42
+ const started = useRef(false);
43
+
44
+ useEffect(() => {
45
+ if (started.current) return;
46
+ started.current = true;
47
+ const browserHistory = createBrowserHistory();
48
+ const appInsights = new ApplicationInsights({
49
+ config: {
50
+ maxBatchSizeInBytes: 10000,
51
+ maxBatchInterval: 15000,
52
+ enableAutoRouteTracking: true,
53
+ disablePageUnloadEvents: ["unload"],
54
+ extensions: [reactPluginRef.current as unknown as ITelemetryPlugin],
55
+ extensionConfig: {
56
+ [reactPluginRef.current.identifier]: { history: browserHistory },
57
+ },
58
+ ...config,
59
+ },
60
+ });
61
+
62
+ appInsights.loadAppInsights();
63
+
64
+ appInsights.addTelemetryInitializer((envelope) => {
65
+ const baseType = envelope.baseType || "";
66
+ const telemetryItem = envelope.baseData || {};
67
+ const target = telemetryItem.target || "";
68
+ const isDependencyData = baseType === "RemoteDependencyData";
69
+
70
+ const isVideo = target.includes("mux.com") || target.includes("litix.io");
71
+
72
+ if (isDependencyData && isVideo) {
73
+ return false;
74
+ }
75
+ });
76
+
77
+ setInstance(appInsights);
78
+ }, [config]);
79
+
80
+ return (
81
+ <AppInsightsContext.Provider value={reactPluginRef.current}>
82
+ {children}
83
+ <Suspense fallback={null}>
84
+ <PageViewTracker instance={instance} />
85
+ </Suspense>
86
+ </AppInsightsContext.Provider>
87
+ );
88
+ }
89
+
90
+ export default { Provider: AppRouterProvider };
package/src/index.tsx ADDED
@@ -0,0 +1,2 @@
1
+ import { Provider } from "./Provider";
2
+ export default { Provider };
@@ -0,0 +1,2 @@
1
+ import { Provider } from "./Provider";
2
+ export default { Provider };
package/src/server.ts ADDED
@@ -0,0 +1,70 @@
1
+ import { parseConnectionString } from "./telemetry/connectionString";
2
+ import {
3
+ exceptionEnvelope,
4
+ type RequestLocation,
5
+ type ServerError,
6
+ } from "./telemetry/exceptionEnvelope";
7
+
8
+ type ErrorRequest = {
9
+ path?: string;
10
+ method?: string;
11
+ headers?: Record<string, string | undefined>;
12
+ };
13
+
14
+ type ErrorContext = {
15
+ routerKind?: string;
16
+ routePath?: string;
17
+ routeType?: string;
18
+ renderSource?: string;
19
+ revalidateReason?: string;
20
+ };
21
+
22
+ async function trackException(serverError: ServerError) {
23
+ const ingestion = parseConnectionString(
24
+ process.env.APPLICATIONINSIGHTS_CONNECTION_STRING
25
+ );
26
+ const site = process.env.WEBSITE_SITE_NAME;
27
+ if (!ingestion || !site) return;
28
+
29
+ const envelope = exceptionEnvelope(
30
+ ingestion.instrumentationKey,
31
+ serverError,
32
+ { name: site, instance: process.env.HOSTNAME },
33
+ new Date()
34
+ );
35
+ try {
36
+ const response = await fetch(ingestion.trackUrl, {
37
+ method: "POST",
38
+ headers: { "content-type": "application/json" },
39
+ body: JSON.stringify([envelope]),
40
+ });
41
+ if (!response.ok)
42
+ console.error("[server-error] telemetry rejected", response.status);
43
+ } catch (failure) {
44
+ console.error("[server-error] telemetry unreachable", failure);
45
+ }
46
+ }
47
+
48
+ export async function onRequestError(
49
+ error: unknown,
50
+ request: ErrorRequest,
51
+ context: ErrorContext
52
+ ) {
53
+ const location: RequestLocation = {
54
+ host: request.headers?.["x-forwarded-host"] ?? request.headers?.["host"],
55
+ method: request.method,
56
+ path: request.path,
57
+ routePath: context.routePath,
58
+ routeType: context.routeType,
59
+ renderSource: context.renderSource,
60
+ };
61
+ console.error(
62
+ "[server-error]",
63
+ JSON.stringify({
64
+ ...location,
65
+ message: error instanceof Error ? error.message : String(error),
66
+ stack: error instanceof Error ? error.stack : undefined,
67
+ })
68
+ );
69
+ await trackException({ error, location });
70
+ }
@@ -0,0 +1,33 @@
1
+ export type Ingestion = {
2
+ instrumentationKey: string;
3
+ trackUrl: string;
4
+ };
5
+
6
+ const TRACK_PATH = "v2.1/track";
7
+
8
+ function settings(connectionString: string) {
9
+ const entries = connectionString.split(";").map((part): [string, string] => {
10
+ const separator = part.indexOf("=");
11
+ return [
12
+ part.slice(0, separator).trim().toLowerCase(),
13
+ part.slice(separator + 1).trim(),
14
+ ];
15
+ });
16
+ return new Map(entries.filter(([key]) => key.length > 0));
17
+ }
18
+
19
+ export function parseConnectionString(
20
+ connectionString: string | undefined
21
+ ): Ingestion | undefined {
22
+ if (!connectionString) return undefined;
23
+
24
+ const values = settings(connectionString);
25
+ const instrumentationKey = values.get("instrumentationkey");
26
+ const endpoint = values.get("ingestionendpoint");
27
+ if (!instrumentationKey || !endpoint) return undefined;
28
+
29
+ return {
30
+ instrumentationKey,
31
+ trackUrl: new URL(TRACK_PATH, endpoint).toString(),
32
+ };
33
+ }
@@ -0,0 +1,108 @@
1
+ export type RequestLocation = {
2
+ host?: string;
3
+ method?: string;
4
+ path?: string;
5
+ routePath?: string;
6
+ routeType?: string;
7
+ renderSource?: string;
8
+ };
9
+
10
+ export type ServerError = {
11
+ error: unknown;
12
+ location: RequestLocation;
13
+ };
14
+
15
+ export type Role = {
16
+ name?: string;
17
+ instance?: string;
18
+ };
19
+
20
+ const ERROR_SEVERITY = 3;
21
+
22
+ type ClientFailure = Error & {
23
+ digest?: string;
24
+ response?: { status?: number; url?: string };
25
+ cause?: unknown;
26
+ };
27
+
28
+ function withoutQuery(url: string | undefined) {
29
+ if (!url) return undefined;
30
+ try {
31
+ const parsed = new URL(url);
32
+ return `${parsed.origin}${parsed.pathname}`;
33
+ } catch {
34
+ return undefined;
35
+ }
36
+ }
37
+
38
+ function causeOf(cause: unknown) {
39
+ if (cause instanceof Error) return `${cause.name}: ${cause.message}`;
40
+ return cause === undefined ? undefined : String(cause);
41
+ }
42
+
43
+ function failedCall(error: ClientFailure) {
44
+ return {
45
+ status: error.response?.status?.toString(),
46
+ url: withoutQuery(error.response?.url),
47
+ cause: causeOf(error.cause),
48
+ };
49
+ }
50
+
51
+ function describe(error: unknown) {
52
+ if (error instanceof Error) {
53
+ const failure = error as ClientFailure;
54
+ return {
55
+ typeName: error.name,
56
+ message: error.message,
57
+ stack: error.stack,
58
+ details: { digest: failure.digest, ...failedCall(failure) },
59
+ };
60
+ }
61
+ return { typeName: "Error", message: String(error), details: {} };
62
+ }
63
+
64
+ function definedOnly(values: Record<string, string | undefined>) {
65
+ return Object.fromEntries(
66
+ Object.entries(values).filter(([, value]) => value !== undefined)
67
+ );
68
+ }
69
+
70
+ export function exceptionEnvelope(
71
+ instrumentationKey: string,
72
+ serverError: ServerError,
73
+ role: Role,
74
+ time: Date
75
+ ) {
76
+ const { typeName, message, stack, details } = describe(serverError.error);
77
+ const { location } = serverError;
78
+ const route = location.routePath ?? location.path;
79
+ const operationName = [location.method, route].filter(Boolean).join(" ");
80
+
81
+ return {
82
+ name: "Microsoft.ApplicationInsights.Exception",
83
+ time: time.toISOString(),
84
+ iKey: instrumentationKey,
85
+ tags: definedOnly({
86
+ "ai.cloud.role": role.name,
87
+ "ai.cloud.roleInstance": role.instance,
88
+ "ai.operation.name": operationName || undefined,
89
+ }),
90
+ data: {
91
+ baseType: "ExceptionData",
92
+ baseData: {
93
+ ver: 2,
94
+ severityLevel: ERROR_SEVERITY,
95
+ problemId: `${typeName} at ${route ?? "unknown route"}`,
96
+ exceptions: [
97
+ {
98
+ typeName,
99
+ message,
100
+ hasFullStack: stack !== undefined,
101
+ stack,
102
+ },
103
+ ],
104
+ properties: definedOnly({ ...location, ...details }),
105
+ },
106
+ },
107
+ };
108
+ }
@@ -0,0 +1,109 @@
1
+ import { test } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { parseConnectionString } from "./connectionString.ts";
4
+ import { exceptionEnvelope } from "./exceptionEnvelope.ts";
5
+
6
+ const connectionString =
7
+ "InstrumentationKey=7e4c6e13-0000-0000-0000-000000000000;IngestionEndpoint=https://norwayeast-0.in.applicationinsights.azure.com/;LiveEndpoint=https://norwayeast.livediagnostics.monitor.azure.com/;ApplicationId=abc";
8
+
9
+ test("the connection string gives the key and the track url", () => {
10
+ assert.deepEqual(parseConnectionString(connectionString), {
11
+ instrumentationKey: "7e4c6e13-0000-0000-0000-000000000000",
12
+ trackUrl:
13
+ "https://norwayeast-0.in.applicationinsights.azure.com/v2.1/track",
14
+ });
15
+ });
16
+
17
+ test("nothing is sent without a usable connection string", () => {
18
+ assert.equal(parseConnectionString(undefined), undefined);
19
+ assert.equal(parseConnectionString(""), undefined);
20
+ assert.equal(parseConnectionString("InstrumentationKey=abc"), undefined);
21
+ });
22
+
23
+ test("a render crash becomes an error-level exception for the site", () => {
24
+ const envelope = exceptionEnvelope(
25
+ "key",
26
+ {
27
+ error: new ReferenceError("localStorage is not defined"),
28
+ location: {
29
+ host: "snokam.test.snosky.no",
30
+ method: "GET",
31
+ path: "/skjer/julebord",
32
+ routePath: "/[host]/skjer/[slug]",
33
+ routeType: "render",
34
+ },
35
+ },
36
+ { name: "app-plfm-web-t", instance: "web-1" },
37
+ new Date("2026-11-08T10:00:00Z")
38
+ );
39
+
40
+ assert.equal(envelope.name, "Microsoft.ApplicationInsights.Exception");
41
+ assert.equal(envelope.iKey, "key");
42
+ assert.equal(envelope.time, "2026-11-08T10:00:00.000Z");
43
+ assert.equal(envelope.tags["ai.cloud.role"], "app-plfm-web-t");
44
+ assert.equal(envelope.tags["ai.operation.name"], "GET /[host]/skjer/[slug]");
45
+ const data = envelope.data.baseData;
46
+ assert.equal(data.severityLevel, 3);
47
+ assert.equal(data.problemId, "ReferenceError at /[host]/skjer/[slug]");
48
+ assert.equal(data.exceptions[0].typeName, "ReferenceError");
49
+ assert.equal(data.exceptions[0].message, "localStorage is not defined");
50
+ assert.equal(data.exceptions[0].hasFullStack, true);
51
+ assert.equal(data.properties.path, "/skjer/julebord");
52
+ });
53
+
54
+ test("a thrown value that is not an Error is still reported", () => {
55
+ const envelope = exceptionEnvelope(
56
+ "key",
57
+ { error: "boom", location: { path: "/blogg/ny" } },
58
+ {},
59
+ new Date("2026-11-08T10:00:00Z")
60
+ );
61
+
62
+ const data = envelope.data.baseData;
63
+ assert.equal(data.exceptions[0].message, "boom");
64
+ assert.equal(data.exceptions[0].hasFullStack, false);
65
+ assert.equal(data.problemId, "Error at /blogg/ny");
66
+ assert.equal("ai.cloud.role" in envelope.tags, false);
67
+ });
68
+
69
+ test("a failed api call names the status and endpoint without its query", () => {
70
+ const failure = Object.assign(new Error("Response returned an error code"), {
71
+ name: "ResponseError",
72
+ response: {
73
+ status: 404,
74
+ url: "https://n8n.snosky.no/api/blog/v1.0/projects?email=a%40b.no",
75
+ },
76
+ });
77
+ const envelope = exceptionEnvelope(
78
+ "key",
79
+ { error: failure, location: { path: "/sider/sitemap.xml" } },
80
+ {},
81
+ new Date("2026-11-08T10:00:00Z")
82
+ );
83
+
84
+ const { properties } = envelope.data.baseData;
85
+ assert.equal(properties.status, "404");
86
+ assert.equal(properties.url, "https://n8n.snosky.no/api/blog/v1.0/projects");
87
+ assert.equal("cause" in properties, false);
88
+ });
89
+
90
+ test("a request that never got a response names its cause", () => {
91
+ const failure = Object.assign(new Error("The request failed"), {
92
+ name: "FetchError",
93
+ cause: new DOMException(
94
+ "The operation was aborted due to timeout",
95
+ "TimeoutError"
96
+ ),
97
+ });
98
+ const envelope = exceptionEnvelope(
99
+ "key",
100
+ { error: failure, location: { path: "/" } },
101
+ {},
102
+ new Date("2026-11-08T10:00:00Z")
103
+ );
104
+
105
+ assert.equal(
106
+ envelope.data.baseData.properties.cause,
107
+ "TimeoutError: The operation was aborted due to timeout"
108
+ );
109
+ });
package/lib/Provider.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { IConfig, IConfiguration } from "@microsoft/applicationinsights-web";
3
- export interface ProviderProps {
4
- children: ReactNode;
5
- config: IConfiguration & IConfig;
6
- }
7
- export declare const Provider: ({ children, config }: ProviderProps) => import("react/jsx-runtime").JSX.Element;
8
- export default Provider;
package/lib/Provider.js DELETED
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.snokam=t():e.snokam=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{Provider:()=>c,default:()=>a});const r=require("react/jsx-runtime"),n=require("next/router"),o=require("react"),i=require("history"),u=require("@microsoft/applicationinsights-react-js"),s=require("@microsoft/applicationinsights-web"),c=({children:e,config:t})=>{const c=(0,n.useRouter)(),a=(0,o.useRef)(!1),l=(0,o.useRef)(new u.ReactPlugin),f=(0,o.useRef)(null),d=null==c?void 0:c.events,p="undefined"!=typeof window?(0,i.createBrowserHistory)():void 0;return(0,o.useEffect)((()=>{f.current||(f.current=new s.ApplicationInsights({config:Object.assign({maxBatchSizeInBytes:1e4,maxBatchInterval:15e3,enableAutoRouteTracking:!0,extensions:[l.current],extensionConfig:{[l.current.identifier]:{history:p}}},t)}),f.current.loadAppInsights(),f.current.addTelemetryInitializer((e=>{const t=e.baseType||"",r=(e.baseData||{}).target||"",n="RemoteDependencyData"===t,o=r.includes("mux.com")||r.includes("litix.io");if(n&&o)return!1})),a.current=!0)}),[t]),(0,o.useEffect)((()=>{const e=e=>{var t;null===(t=f.current)||void 0===t||t.trackPageView({name:e})};return null==d||d.on("routeChangeComplete",e),()=>{null==d||d.off("routeChangeComplete",e)}}),[d]),(0,r.jsx)(u.AppInsightsContext.Provider,{value:l.current,children:e})},a=c;return t})()));
2
- //# sourceMappingURL=Provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Provider.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,GAClB,CATD,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFT,EAAyBL,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,GAAO,G,kDCL9D,MAAM,EAA+BC,QAAQ,qBCAvC,EAA+BA,QAAQ,eCAvC,EAA+BA,QAAQ,SCAvC,EAA+BA,QAAQ,WCAvC,EAA+BA,QAAQ,2CCAvC,EAA+BA,QAAQ,sCCMhCC,EAAW,EAAGC,WAAUC,aACjC,MAAMC,GAAS,IAAAC,aACTC,GAAsB,IAAAC,SAAO,GAC7BC,GAAiB,IAAAD,QAAO,IAAI,EAAAE,aAC5BC,GAAiB,IAAAH,QAAO,MACxBI,EAASP,aAAuC,EAASA,EAAOO,OAEhEC,EAD8B,oBAAXC,QACU,IAAAC,6BAAyBC,EAmC5D,OAlCA,IAAAC,YAAU,KACDN,EAAeO,UAChBP,EAAeO,QAAU,IAAI,EAAAC,oBAAoB,CAC7Cf,OAAQf,OAAO+B,OAAO,CAAEC,oBAAqB,IAAOC,iBAAkB,KAAOC,yBAAyB,EAAMC,WAAY,CAACf,EAAeS,SAAUO,gBAAiB,CAC3J,CAAChB,EAAeS,QAAQQ,YAAa,CAAEC,QAASd,KAC/CT,KAGbO,EAAeO,QAAQU,kBAEvBjB,EAAeO,QAAQW,yBAAyBC,IAC5C,MAAMC,EAAWD,EAASC,UAAY,GAEhCC,GADgBF,EAASG,UAAY,CAAC,GACfD,QAAU,GACjCE,EAAgC,yBAAbH,EAEnBI,EAAUH,EAAOI,SAAS,YAAcJ,EAAOI,SAAS,YAC9D,GAAIF,GAAoBC,EACpB,OAAO,CACX,IAEJ5B,EAAoBW,SAAU,EAClC,GACD,CAACd,KACJ,IAAAa,YAAU,KACN,MAAMoB,EAAqBC,IACvB,IAAIC,EAC8B,QAAjCA,EAAK5B,EAAeO,eAA4B,IAAPqB,GAAyBA,EAAGC,cAAc,CAAEC,KAAMH,GAAM,EAGtG,OADA1B,SAAgDA,EAAO8B,GAAG,sBAAuBL,GAC1E,KACHzB,SAAgDA,EAAO+B,IAAI,sBAAuBN,EAAkB,CACvG,GACF,CAACzB,KACI,SAAK,EAAAgC,mBAAmB1C,SAAU,CAAEF,MAAOS,EAAeS,QAASf,SAAUA,GAAY,EAErG,I","sources":["webpack://snokam/webpack/universalModuleDefinition","webpack://snokam/webpack/bootstrap","webpack://snokam/webpack/runtime/define property getters","webpack://snokam/webpack/runtime/hasOwnProperty shorthand","webpack://snokam/webpack/runtime/make namespace object","webpack://snokam/external commonjs \"react/jsx-runtime\"","webpack://snokam/external commonjs \"next/router\"","webpack://snokam/external commonjs \"react\"","webpack://snokam/external commonjs \"history\"","webpack://snokam/external commonjs \"@microsoft/applicationinsights-react-js\"","webpack://snokam/external commonjs \"@microsoft/applicationinsights-web\"","webpack://snokam/./src/Provider.tsx"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"snokam\"] = factory();\n\telse\n\t\troot[\"snokam\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react/jsx-runtime\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next/router\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"history\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@microsoft/applicationinsights-react-js\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@microsoft/applicationinsights-web\");","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useRouter } from \"next/router\";\nimport { useEffect, useRef } from \"react\";\nimport { createBrowserHistory } from \"history\";\nimport { AppInsightsContext, ReactPlugin, } from \"@microsoft/applicationinsights-react-js\";\nimport { ApplicationInsights, } from \"@microsoft/applicationinsights-web\";\nexport const Provider = ({ children, config }) => {\n const router = useRouter();\n const isAppInsightsLoaded = useRef(false);\n const reactPluginRef = useRef(new ReactPlugin());\n const appInsightsRef = useRef(null);\n const events = router === null || router === void 0 ? void 0 : router.events;\n const isBrowser = typeof window !== \"undefined\";\n const browserHistory = isBrowser ? createBrowserHistory() : undefined;\n useEffect(() => {\n if (!appInsightsRef.current) {\n appInsightsRef.current = new ApplicationInsights({\n config: Object.assign({ maxBatchSizeInBytes: 10000, maxBatchInterval: 15000, enableAutoRouteTracking: true, extensions: [reactPluginRef.current], extensionConfig: {\n [reactPluginRef.current.identifier]: { history: browserHistory },\n } }, config),\n });\n // Load Application Insights\n appInsightsRef.current.loadAppInsights();\n // Filter out telemetry from specific domains\n appInsightsRef.current.addTelemetryInitializer((envelope) => {\n const baseType = envelope.baseType || \"\";\n const telemetryItem = envelope.baseData || {};\n const target = telemetryItem.target || \"\";\n const isDependencyData = baseType === \"RemoteDependencyData\";\n // Video chunk telemetry\n const isVideo = target.includes(\"mux.com\") || target.includes(\"litix.io\");\n if (isDependencyData && isVideo) {\n return false;\n }\n });\n isAppInsightsLoaded.current = true;\n }\n }, [config]);\n useEffect(() => {\n const handleRouteChange = (url) => {\n var _a;\n (_a = appInsightsRef.current) === null || _a === void 0 ? void 0 : _a.trackPageView({ name: url });\n };\n events === null || events === void 0 ? void 0 : events.on(\"routeChangeComplete\", handleRouteChange);\n return () => {\n events === null || events === void 0 ? void 0 : events.off(\"routeChangeComplete\", handleRouteChange);\n };\n }, [events]);\n return (_jsx(AppInsightsContext.Provider, { value: reactPluginRef.current, children: children }));\n};\nexport default Provider;\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","Provider","children","config","router","useRouter","isAppInsightsLoaded","useRef","reactPluginRef","ReactPlugin","appInsightsRef","events","browserHistory","window","createBrowserHistory","undefined","useEffect","current","ApplicationInsights","assign","maxBatchSizeInBytes","maxBatchInterval","enableAutoRouteTracking","extensions","extensionConfig","identifier","history","loadAppInsights","addTelemetryInitializer","envelope","baseType","target","baseData","isDependencyData","isVideo","includes","handleRouteChange","url","_a","trackPageView","name","on","off","AppInsightsContext"],"sourceRoot":""}
package/lib/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- declare const _default: {
2
- Provider: ({ children, config }: import("./Provider").ProviderProps) => import("react/jsx-runtime").JSX.Element;
3
- };
4
- export default _default;
package/lib/index.js DELETED
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.snokam=t():e.snokam=t()}(this,(()=>(()=>{"use strict";var e={172:(e,t,r)=>{r.d(t,{Provider:()=>c});const n=require("react/jsx-runtime"),o=require("next/router"),i=require("react"),u=require("history"),s=require("@microsoft/applicationinsights-react-js"),a=require("@microsoft/applicationinsights-web"),c=({children:e,config:t})=>{const r=(0,o.useRouter)(),c=(0,i.useRef)(!1),l=(0,i.useRef)(new s.ReactPlugin),d=(0,i.useRef)(null),f=null==r?void 0:r.events,p="undefined"!=typeof window?(0,u.createBrowserHistory)():void 0;return(0,i.useEffect)((()=>{d.current||(d.current=new a.ApplicationInsights({config:Object.assign({maxBatchSizeInBytes:1e4,maxBatchInterval:15e3,enableAutoRouteTracking:!0,extensions:[l.current],extensionConfig:{[l.current.identifier]:{history:p}}},t)}),d.current.loadAppInsights(),d.current.addTelemetryInitializer((e=>{const t=e.baseType||"",r=(e.baseData||{}).target||"",n="RemoteDependencyData"===t,o=r.includes("mux.com")||r.includes("litix.io");if(n&&o)return!1})),c.current=!0)}),[t]),(0,i.useEffect)((()=>{const e=e=>{var t;null===(t=d.current)||void 0===t||t.trackPageView({name:e})};return null==f||f.on("routeChangeComplete",e),()=>{null==f||f.off("routeChangeComplete",e)}}),[f]),(0,n.jsx)(s.AppInsightsContext.Provider,{value:l.current,children:e})}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{default:()=>o});const o={Provider:r(172).Provider};return n})()));
2
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,GAClB,CATD,CASGK,MAAM,I,gECTT,MAAM,EAA+BC,QAAQ,qBCAvC,EAA+BA,QAAQ,eCAvC,EAA+BA,QAAQ,SCAvC,EAA+BA,QAAQ,WCAvC,EAA+BA,QAAQ,2CCAvC,EAA+BA,QAAQ,sCCMhCC,EAAW,EAAGC,WAAUC,aACjC,MAAMC,GAAS,IAAAC,aACTC,GAAsB,IAAAC,SAAO,GAC7BC,GAAiB,IAAAD,QAAO,IAAI,EAAAE,aAC5BC,GAAiB,IAAAH,QAAO,MACxBI,EAASP,aAAuC,EAASA,EAAOO,OAEhEC,EAD8B,oBAAXC,QACU,IAAAC,6BAAyBC,EAmC5D,OAlCA,IAAAC,YAAU,KACDN,EAAeO,UAChBP,EAAeO,QAAU,IAAI,EAAAC,oBAAoB,CAC7Cf,OAAQgB,OAAOC,OAAO,CAAEC,oBAAqB,IAAOC,iBAAkB,KAAOC,yBAAyB,EAAMC,WAAY,CAAChB,EAAeS,SAAUQ,gBAAiB,CAC3J,CAACjB,EAAeS,QAAQS,YAAa,CAAEC,QAASf,KAC/CT,KAGbO,EAAeO,QAAQW,kBAEvBlB,EAAeO,QAAQY,yBAAyBC,IAC5C,MAAMC,EAAWD,EAASC,UAAY,GAEhCC,GADgBF,EAASG,UAAY,CAAC,GACfD,QAAU,GACjCE,EAAgC,yBAAbH,EAEnBI,EAAUH,EAAOI,SAAS,YAAcJ,EAAOI,SAAS,YAC9D,GAAIF,GAAoBC,EACpB,OAAO,CACX,IAEJ7B,EAAoBW,SAAU,EAClC,GACD,CAACd,KACJ,IAAAa,YAAU,KACN,MAAMqB,EAAqBC,IACvB,IAAIC,EAC8B,QAAjCA,EAAK7B,EAAeO,eAA4B,IAAPsB,GAAyBA,EAAGC,cAAc,CAAEC,KAAMH,GAAM,EAGtG,OADA3B,SAAgDA,EAAO+B,GAAG,sBAAuBL,GAC1E,KACH1B,SAAgDA,EAAOgC,IAAI,sBAAuBN,EAAkB,CACvG,GACF,CAAC1B,KACI,SAAK,EAAAiC,mBAAmB3C,SAAU,CAAE4C,MAAOrC,EAAeS,QAASf,SAAUA,GAAY,C,GC/CjG4C,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBjC,IAAjBkC,EACH,OAAOA,EAAatD,QAGrB,IAAIC,EAASkD,EAAyBE,GAAY,CAGjDrD,QAAS,CAAC,GAOX,OAHAuD,EAAoBF,GAAUpD,EAAQA,EAAOD,QAASoD,GAG/CnD,EAAOD,OACf,CCrBAoD,EAAoBI,EAAI,CAACxD,EAASyD,KACjC,IAAI,IAAIC,KAAOD,EACXL,EAAoBO,EAAEF,EAAYC,KAASN,EAAoBO,EAAE3D,EAAS0D,IAC5ElC,OAAOoC,eAAe5D,EAAS0D,EAAK,CAAEG,YAAY,EAAMC,IAAKL,EAAWC,IAE1E,ECNDN,EAAoBO,EAAI,CAACI,EAAKC,IAAUxC,OAAOyC,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFZ,EAAoBgB,EAAKpE,IACH,oBAAXqE,QAA0BA,OAAOC,aAC1C9C,OAAOoC,eAAe5D,EAASqE,OAAOC,YAAa,CAAEpB,MAAO,WAE7D1B,OAAOoC,eAAe5D,EAAS,aAAc,CAAEkD,OAAO,GAAO,E,uCCJ9D,SAAiB5C,S,OAAQ,U","sources":["webpack://snokam/webpack/universalModuleDefinition","webpack://snokam/external commonjs \"react/jsx-runtime\"","webpack://snokam/external commonjs \"next/router\"","webpack://snokam/external commonjs \"react\"","webpack://snokam/external commonjs \"history\"","webpack://snokam/external commonjs \"@microsoft/applicationinsights-react-js\"","webpack://snokam/external commonjs \"@microsoft/applicationinsights-web\"","webpack://snokam/./src/Provider.tsx","webpack://snokam/webpack/bootstrap","webpack://snokam/webpack/runtime/define property getters","webpack://snokam/webpack/runtime/hasOwnProperty shorthand","webpack://snokam/webpack/runtime/make namespace object","webpack://snokam/./src/index.tsx"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"snokam\"] = factory();\n\telse\n\t\troot[\"snokam\"] = factory();\n})(this, () => {\nreturn ","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react/jsx-runtime\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next/router\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"history\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@microsoft/applicationinsights-react-js\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@microsoft/applicationinsights-web\");","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useRouter } from \"next/router\";\nimport { useEffect, useRef } from \"react\";\nimport { createBrowserHistory } from \"history\";\nimport { AppInsightsContext, ReactPlugin, } from \"@microsoft/applicationinsights-react-js\";\nimport { ApplicationInsights, } from \"@microsoft/applicationinsights-web\";\nexport const Provider = ({ children, config }) => {\n const router = useRouter();\n const isAppInsightsLoaded = useRef(false);\n const reactPluginRef = useRef(new ReactPlugin());\n const appInsightsRef = useRef(null);\n const events = router === null || router === void 0 ? void 0 : router.events;\n const isBrowser = typeof window !== \"undefined\";\n const browserHistory = isBrowser ? createBrowserHistory() : undefined;\n useEffect(() => {\n if (!appInsightsRef.current) {\n appInsightsRef.current = new ApplicationInsights({\n config: Object.assign({ maxBatchSizeInBytes: 10000, maxBatchInterval: 15000, enableAutoRouteTracking: true, extensions: [reactPluginRef.current], extensionConfig: {\n [reactPluginRef.current.identifier]: { history: browserHistory },\n } }, config),\n });\n // Load Application Insights\n appInsightsRef.current.loadAppInsights();\n // Filter out telemetry from specific domains\n appInsightsRef.current.addTelemetryInitializer((envelope) => {\n const baseType = envelope.baseType || \"\";\n const telemetryItem = envelope.baseData || {};\n const target = telemetryItem.target || \"\";\n const isDependencyData = baseType === \"RemoteDependencyData\";\n // Video chunk telemetry\n const isVideo = target.includes(\"mux.com\") || target.includes(\"litix.io\");\n if (isDependencyData && isVideo) {\n return false;\n }\n });\n isAppInsightsLoaded.current = true;\n }\n }, [config]);\n useEffect(() => {\n const handleRouteChange = (url) => {\n var _a;\n (_a = appInsightsRef.current) === null || _a === void 0 ? void 0 : _a.trackPageView({ name: url });\n };\n events === null || events === void 0 ? void 0 : events.on(\"routeChangeComplete\", handleRouteChange);\n return () => {\n events === null || events === void 0 ? void 0 : events.off(\"routeChangeComplete\", handleRouteChange);\n };\n }, [events]);\n return (_jsx(AppInsightsContext.Provider, { value: reactPluginRef.current, children: children }));\n};\nexport default Provider;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { Provider } from \"./Provider\";\nexport default { Provider };\n"],"names":["root","factory","exports","module","define","amd","this","require","Provider","children","config","router","useRouter","isAppInsightsLoaded","useRef","reactPluginRef","ReactPlugin","appInsightsRef","events","browserHistory","window","createBrowserHistory","undefined","useEffect","current","ApplicationInsights","Object","assign","maxBatchSizeInBytes","maxBatchInterval","enableAutoRouteTracking","extensions","extensionConfig","identifier","history","loadAppInsights","addTelemetryInitializer","envelope","baseType","target","baseData","isDependencyData","isVideo","includes","handleRouteChange","url","_a","trackPageView","name","on","off","AppInsightsContext","value","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","d","definition","key","o","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag"],"sourceRoot":""}