securenow 5.18.0 → 6.0.0
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/LICENSE +15 -0
- package/README.md +40 -239
- package/cli.js +455 -415
- package/console-instrumentation.js +136 -147
- package/docs/ALL-FRAMEWORKS-QUICKSTART.md +455 -1339
- package/docs/ARCHITECTURE.md +3 -3
- package/docs/AUTO-BODY-CAPTURE.md +1 -1
- package/docs/AUTO-SETUP.md +4 -4
- package/docs/AUTOMATIC-IP-CAPTURE.md +5 -5
- package/docs/BODY-CAPTURE-QUICKSTART.md +2 -2
- package/docs/CHANGELOG-NEXTJS.md +1 -1
- package/docs/CUSTOMER-GUIDE.md +16 -16
- package/docs/EASIEST-SETUP.md +5 -5
- package/docs/ENVIRONMENT-VARIABLES.md +652 -880
- package/docs/EXPRESS-BODY-CAPTURE.md +12 -13
- package/docs/EXPRESS-SETUP-GUIDE.md +720 -719
- package/docs/INDEX.md +4 -22
- package/docs/LOGGING-GUIDE.md +708 -701
- package/docs/LOGGING-QUICKSTART.md +239 -234
- package/docs/NEXTJS-BODY-CAPTURE.md +2 -2
- package/docs/NEXTJS-GUIDE.md +14 -14
- package/docs/NEXTJS-QUICKSTART.md +1 -1
- package/docs/NEXTJS-WRAPPER-APPROACH.md +1 -1
- package/docs/QUICKSTART-BODY-CAPTURE.md +2 -2
- package/docs/REDACTION-EXAMPLES.md +1 -1
- package/docs/REQUEST-BODY-CAPTURE.md +10 -19
- package/docs/VERCEL-OTEL-MIGRATION.md +3 -3
- package/examples/README.md +6 -6
- package/examples/instrumentation-with-auto-capture.ts +1 -1
- package/examples/nextjs-env-example.txt +2 -2
- package/examples/nextjs-instrumentation.js +1 -1
- package/examples/nextjs-instrumentation.ts +1 -1
- package/examples/nextjs-with-logging-example.md +6 -6
- package/examples/nextjs-with-options.ts +1 -1
- package/examples/test-nextjs-setup.js +1 -1
- package/nextjs-auto-capture.js +207 -199
- package/nextjs-middleware.js +181 -186
- package/nextjs-webpack-config.js +53 -88
- package/nextjs-wrapper.js +158 -158
- package/nextjs.d.ts +1 -1
- package/nextjs.js +135 -190
- package/package.json +45 -67
- package/postinstall.js +6 -6
- package/register.d.ts +1 -1
- package/register.js +4 -39
- package/tracing.d.ts +1 -2
- package/tracing.js +22 -287
- package/web-vite.mjs +156 -239
- package/CONSUMING-APPS-GUIDE.md +0 -455
- package/NPM_README.md +0 -1933
- package/SKILL-API.md +0 -600
- package/SKILL-CLI.md +0 -409
- package/cidr.js +0 -83
- package/cli/apps.js +0 -585
- package/cli/auth.js +0 -280
- package/cli/client.js +0 -115
- package/cli/config.js +0 -173
- package/cli/firewall.js +0 -100
- package/cli/fp.js +0 -638
- package/cli/init.js +0 -201
- package/cli/monitor.js +0 -440
- package/cli/run.js +0 -133
- package/cli/security.js +0 -1064
- package/cli/ui.js +0 -386
- package/docs/API-KEYS-GUIDE.md +0 -233
- package/docs/AUTO-SETUP-SUMMARY.md +0 -331
- package/docs/BODY-CAPTURE-FIX.md +0 -261
- package/docs/COMPLETION-REPORT.md +0 -408
- package/docs/FINAL-SOLUTION.md +0 -335
- package/docs/FIREWALL-GUIDE.md +0 -426
- package/docs/IMPLEMENTATION-SUMMARY.md +0 -410
- package/docs/NEXTJS-BODY-CAPTURE-COMPARISON.md +0 -323
- package/docs/NEXTJS-SETUP-COMPLETE.md +0 -795
- package/docs/NUXT-GUIDE.md +0 -166
- package/docs/SOLUTION-SUMMARY.md +0 -312
- package/firewall-cloud.js +0 -212
- package/firewall-iptables.js +0 -139
- package/firewall-only.js +0 -38
- package/firewall-tcp.js +0 -74
- package/firewall.js +0 -720
- package/free-trial-banner.js +0 -174
- package/nuxt-server-plugin.mjs +0 -423
- package/nuxt.d.ts +0 -60
- package/nuxt.mjs +0 -75
- package/resolve-ip.js +0 -77
package/web-vite.mjs
CHANGED
|
@@ -1,239 +1,156 @@
|
|
|
1
|
-
// web-vite.ts — Browser OTel for Vite (ESM)
|
|
2
|
-
// Defaults & naming rules match your Node tracing.js
|
|
3
|
-
|
|
4
|
-
import { WebTracerProvider, BatchSpanProcessor } from '@opentelemetry/sdk-trace-web';
|
|
5
|
-
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
6
|
-
import { Resource } from '@opentelemetry/resources';
|
|
7
|
-
import { SemanticResourceAttributes as S } from '@opentelemetry/semantic-conventions';
|
|
8
|
-
import { registerInstrumentations } from '@opentelemetry/instrumentation';
|
|
9
|
-
import { DocumentLoadInstrumentation } from '@opentelemetry/instrumentation-document-load';
|
|
10
|
-
import { UserInteractionInstrumentation } from '@opentelemetry/instrumentation-user-interaction';
|
|
11
|
-
import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';
|
|
12
|
-
import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request';
|
|
13
|
-
|
|
14
|
-
// ---- helpers / env ----
|
|
15
|
-
const viteEnv: any = (import.meta as any).env || {};
|
|
16
|
-
|
|
17
|
-
function env(k: string): string | undefined {
|
|
18
|
-
// Accept both Vite envs (VITE_*) and raw names for window.__SECURENOW__
|
|
19
|
-
const direct =
|
|
20
|
-
viteEnv[k] ??
|
|
21
|
-
viteEnv[k.toUpperCase()] ??
|
|
22
|
-
viteEnv[k.toLowerCase()];
|
|
23
|
-
if (direct != null) return String(direct);
|
|
24
|
-
|
|
25
|
-
// Optionally support runtime overrides via window.__SECURENOW__
|
|
26
|
-
const w = (globalThis as any).window as any;
|
|
27
|
-
if (w && w.__SECURENOW__ && k in w.__SECURENOW__) return String(w.__SECURENOW__[k]);
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function parseHeaders(str?: string) {
|
|
32
|
-
const out: Record<string, string> = {};
|
|
33
|
-
if (!str) return out;
|
|
34
|
-
String(str).split(',').forEach(raw => {
|
|
35
|
-
const s = raw.trim();
|
|
36
|
-
if (!s) return;
|
|
37
|
-
const i = s.indexOf('=');
|
|
38
|
-
if (i === -1) return;
|
|
39
|
-
out[s.slice(0, i).trim().toLowerCase()] = s.slice(i + 1).trim();
|
|
40
|
-
});
|
|
41
|
-
return out;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// ---- endpoints (same defaults as tracing.js) ----
|
|
45
|
-
const endpointBase =
|
|
46
|
-
(env('SECURENOW_INSTANCE') || env('OTEL_EXPORTER_OTLP_ENDPOINT') || 'https://freetrial.securenow.ai:4318')
|
|
47
|
-
.replace(/\/$/, '');
|
|
48
|
-
const tracesUrl =
|
|
49
|
-
env('OTEL_EXPORTER_OTLP_TRACES_ENDPOINT') || `${endpointBase}/v1/traces`;
|
|
50
|
-
const headers = parseHeaders(env('OTEL_EXPORTER_OTLP_HEADERS'));
|
|
51
|
-
|
|
52
|
-
// ---- naming rules (mirrors tracing.js) ----
|
|
53
|
-
const rawBase = (env('OTEL_SERVICE_NAME') || env('SECURENOW_APPID') || '').trim().replace(/^['"]|['"]$/g, '');
|
|
54
|
-
const baseName = rawBase || null;
|
|
55
|
-
const noUuid = String(env('SECURENOW_NO_UUID')) === '1' || String(env('SECURENOW_NO_UUID')).toLowerCase() === 'true';
|
|
56
|
-
const strict = String(env('SECURENOW_STRICT')) === '1' || String(env('SECURENOW_STRICT')).toLowerCase() === 'true';
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
// ---- Free trial banner (browser DOM injection) ----
|
|
158
|
-
function injectFreeTrialBanner(): void {
|
|
159
|
-
const FREETRIAL_HOST = 'freetrial.securenow.ai';
|
|
160
|
-
const hideBanner = String(env('SECURENOW_HIDE_BANNER')) === '1';
|
|
161
|
-
if (hideBanner || !endpointBase.includes(FREETRIAL_HOST)) return;
|
|
162
|
-
if (typeof document === 'undefined') return;
|
|
163
|
-
|
|
164
|
-
function create(): void {
|
|
165
|
-
if (document.getElementById('sn-ft-banner')) return;
|
|
166
|
-
|
|
167
|
-
const d = document.createElement('div');
|
|
168
|
-
d.id = 'sn-ft-banner';
|
|
169
|
-
d.style.cssText =
|
|
170
|
-
'position:fixed;top:0;left:0;right:0;z-index:2147483647;' +
|
|
171
|
-
'background:#FEF3CD;color:#856404;padding:10px 16px;' +
|
|
172
|
-
'font-family:system-ui,-apple-system,sans-serif;font-size:13px;' +
|
|
173
|
-
'text-align:center;border-bottom:2px solid #FFE69C;' +
|
|
174
|
-
'display:flex;align-items:center;justify-content:center;gap:6px;' +
|
|
175
|
-
'box-shadow:0 2px 8px rgba(0,0,0,0.12)';
|
|
176
|
-
|
|
177
|
-
const icon = document.createElement('span');
|
|
178
|
-
icon.textContent = '\u26a0\ufe0f';
|
|
179
|
-
d.appendChild(icon);
|
|
180
|
-
|
|
181
|
-
const msg = document.createElement('span');
|
|
182
|
-
const strong = document.createElement('strong');
|
|
183
|
-
strong.textContent = 'Testing Environment:';
|
|
184
|
-
msg.appendChild(strong);
|
|
185
|
-
msg.appendChild(document.createTextNode(
|
|
186
|
-
' Only add test applications. For production usage, '
|
|
187
|
-
));
|
|
188
|
-
|
|
189
|
-
const link = document.createElement('a');
|
|
190
|
-
link.href = 'https://app.securenow.ai/dashboard/settings/instances';
|
|
191
|
-
link.target = '_blank';
|
|
192
|
-
link.rel = 'noopener';
|
|
193
|
-
link.style.cssText = 'color:#664D03;font-weight:600;text-decoration:underline';
|
|
194
|
-
link.textContent = 'create a new production instance';
|
|
195
|
-
msg.appendChild(link);
|
|
196
|
-
msg.appendChild(document.createTextNode('.'));
|
|
197
|
-
d.appendChild(msg);
|
|
198
|
-
|
|
199
|
-
const upgradeBtn = document.createElement('a');
|
|
200
|
-
upgradeBtn.href = 'https://app.securenow.ai/dashboard/settings/instances';
|
|
201
|
-
upgradeBtn.target = '_blank';
|
|
202
|
-
upgradeBtn.rel = 'noopener';
|
|
203
|
-
upgradeBtn.textContent = '\u26a1 Upgrade';
|
|
204
|
-
upgradeBtn.style.cssText =
|
|
205
|
-
'display:inline-flex;align-items:center;gap:4px;' +
|
|
206
|
-
'background:#D97706;color:#fff;padding:4px 12px;border-radius:4px;' +
|
|
207
|
-
'font-size:12px;font-weight:600;text-decoration:none;margin-left:10px;' +
|
|
208
|
-
'white-space:nowrap;transition:background 0.15s';
|
|
209
|
-
upgradeBtn.onmouseover = () => { upgradeBtn.style.background = '#B45309'; };
|
|
210
|
-
upgradeBtn.onmouseout = () => { upgradeBtn.style.background = '#D97706'; };
|
|
211
|
-
d.appendChild(upgradeBtn);
|
|
212
|
-
|
|
213
|
-
const close = document.createElement('button');
|
|
214
|
-
close.textContent = '\u00d7';
|
|
215
|
-
close.style.cssText =
|
|
216
|
-
'background:none;border:none;color:#856404;font-size:18px;' +
|
|
217
|
-
'cursor:pointer;margin-left:12px;padding:0 4px;line-height:1';
|
|
218
|
-
close.onclick = () => { d.style.display = 'none'; };
|
|
219
|
-
d.appendChild(close);
|
|
220
|
-
|
|
221
|
-
document.body.prepend(d);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (document.readyState === 'loading') {
|
|
225
|
-
document.addEventListener('DOMContentLoaded', create);
|
|
226
|
-
} else {
|
|
227
|
-
create();
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Auto-start
|
|
232
|
-
try {
|
|
233
|
-
startSecurenowWeb();
|
|
234
|
-
injectFreeTrialBanner();
|
|
235
|
-
} catch (e: any) {
|
|
236
|
-
console.error('[securenow/web-vite] failed to start:', e);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export default startSecurenowWeb;
|
|
1
|
+
// web-vite.ts — Browser OTel for Vite (ESM)
|
|
2
|
+
// Defaults & naming rules match your Node tracing.js
|
|
3
|
+
|
|
4
|
+
import { WebTracerProvider, BatchSpanProcessor } from '@opentelemetry/sdk-trace-web';
|
|
5
|
+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
6
|
+
import { Resource } from '@opentelemetry/resources';
|
|
7
|
+
import { SemanticResourceAttributes as S } from '@opentelemetry/semantic-conventions';
|
|
8
|
+
import { registerInstrumentations } from '@opentelemetry/instrumentation';
|
|
9
|
+
import { DocumentLoadInstrumentation } from '@opentelemetry/instrumentation-document-load';
|
|
10
|
+
import { UserInteractionInstrumentation } from '@opentelemetry/instrumentation-user-interaction';
|
|
11
|
+
import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';
|
|
12
|
+
import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request';
|
|
13
|
+
|
|
14
|
+
// ---- helpers / env ----
|
|
15
|
+
const viteEnv: any = (import.meta as any).env || {};
|
|
16
|
+
|
|
17
|
+
function env(k: string): string | undefined {
|
|
18
|
+
// Accept both Vite envs (VITE_*) and raw names for window.__SECURENOW__
|
|
19
|
+
const direct =
|
|
20
|
+
viteEnv[k] ??
|
|
21
|
+
viteEnv[k.toUpperCase()] ??
|
|
22
|
+
viteEnv[k.toLowerCase()];
|
|
23
|
+
if (direct != null) return String(direct);
|
|
24
|
+
|
|
25
|
+
// Optionally support runtime overrides via window.__SECURENOW__
|
|
26
|
+
const w = (globalThis as any).window as any;
|
|
27
|
+
if (w && w.__SECURENOW__ && k in w.__SECURENOW__) return String(w.__SECURENOW__[k]);
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parseHeaders(str?: string) {
|
|
32
|
+
const out: Record<string, string> = {};
|
|
33
|
+
if (!str) return out;
|
|
34
|
+
String(str).split(',').forEach(raw => {
|
|
35
|
+
const s = raw.trim();
|
|
36
|
+
if (!s) return;
|
|
37
|
+
const i = s.indexOf('=');
|
|
38
|
+
if (i === -1) return;
|
|
39
|
+
out[s.slice(0, i).trim().toLowerCase()] = s.slice(i + 1).trim();
|
|
40
|
+
});
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ---- endpoints (same defaults as tracing.js) ----
|
|
45
|
+
const endpointBase =
|
|
46
|
+
(env('SECURENOW_INSTANCE') || env('OTEL_EXPORTER_OTLP_ENDPOINT') || 'https://freetrial.securenow.ai:4318')
|
|
47
|
+
.replace(/\/$/, '');
|
|
48
|
+
const tracesUrl =
|
|
49
|
+
env('OTEL_EXPORTER_OTLP_TRACES_ENDPOINT') || `${endpointBase}/v1/traces`;
|
|
50
|
+
const headers = parseHeaders(env('OTEL_EXPORTER_OTLP_HEADERS'));
|
|
51
|
+
|
|
52
|
+
// ---- naming rules (mirrors tracing.js) ----
|
|
53
|
+
const rawBase = (env('OTEL_SERVICE_NAME') || env('SECURENOW_APPID') || '').trim().replace(/^['"]|['"]$/g, '');
|
|
54
|
+
const baseName = rawBase || null;
|
|
55
|
+
const noUuid = String(env('SECURENOW_NO_UUID')) === '1' || String(env('SECURENOW_NO_UUID')).toLowerCase() === 'true';
|
|
56
|
+
const strict = String(env('SECURENOW_STRICT')) === '1' || String(env('SECURENOW_STRICT')).toLowerCase() === 'true';
|
|
57
|
+
|
|
58
|
+
// Simple UUID v4 (no crypto dependency needed)
|
|
59
|
+
function uuidv4(): string {
|
|
60
|
+
const rnd = (n = 16) => Array.from({ length: n }, () => Math.floor(Math.random() * 16).toString(16)).join('');
|
|
61
|
+
return `${rnd(8)}-${rnd(4)}-4${rnd(3)}-${((8 + Math.random()*4)|0).toString(16)}${rnd(3)}-${rnd(12)}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let serviceName: string;
|
|
65
|
+
if (baseName) {
|
|
66
|
+
serviceName = noUuid ? baseName : `${baseName}-${uuidv4()}`;
|
|
67
|
+
} else {
|
|
68
|
+
if (strict) {
|
|
69
|
+
console.error('[securenow/web-vite] FATAL: SECURENOW_APPID/OTEL_SERVICE_NAME missing and SECURENOW_STRICT=1. Tracing disabled.');
|
|
70
|
+
// Do not start tracing
|
|
71
|
+
// @ts-expect-error
|
|
72
|
+
window.__SECURENOW_DISABLED__ = true;
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
74
|
+
const _noop = true;
|
|
75
|
+
// early return by throwing a no-op error caught below:
|
|
76
|
+
throw new Error('__SECURENOW_NO_START__');
|
|
77
|
+
}
|
|
78
|
+
serviceName = `securenow-free-${uuidv4()}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const instancePrefix = baseName || 'securenow';
|
|
82
|
+
const serviceInstanceId = `${instancePrefix}-${uuidv4()}`;
|
|
83
|
+
|
|
84
|
+
// Loud line
|
|
85
|
+
try {
|
|
86
|
+
// eslint-disable-next-line no-console
|
|
87
|
+
console.log(
|
|
88
|
+
'[securenow] web preload loaded SECURENOW_APPID=%s OTEL_SERVICE_NAME=%s SECURENOW_NO_UUID=%s SECURENOW_STRICT=%s → service.name=%s instance.id=%s',
|
|
89
|
+
JSON.stringify(env('SECURENOW_APPID')),
|
|
90
|
+
JSON.stringify(env('OTEL_SERVICE_NAME')),
|
|
91
|
+
JSON.stringify(env('SECURENOW_NO_UUID')),
|
|
92
|
+
JSON.stringify(env('SECURENOW_STRICT')),
|
|
93
|
+
serviceName,
|
|
94
|
+
serviceInstanceId
|
|
95
|
+
);
|
|
96
|
+
} catch {}
|
|
97
|
+
|
|
98
|
+
// ---- Provider / Exporter ----
|
|
99
|
+
let started = false;
|
|
100
|
+
|
|
101
|
+
export function startSecurenowWeb() {
|
|
102
|
+
if (started) return;
|
|
103
|
+
started = true;
|
|
104
|
+
|
|
105
|
+
const exporter = new OTLPTraceExporter({
|
|
106
|
+
url: tracesUrl,
|
|
107
|
+
headers,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const provider = new WebTracerProvider({
|
|
111
|
+
resource: new Resource({
|
|
112
|
+
[S.SERVICE_NAME]: serviceName,
|
|
113
|
+
[S.SERVICE_INSTANCE_ID]: serviceInstanceId,
|
|
114
|
+
[S.DEPLOYMENT_ENVIRONMENT]: viteEnv.MODE || 'production',
|
|
115
|
+
[S.SERVICE_VERSION]: viteEnv.VITE_APP_VERSION || undefined,
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
provider.addSpanProcessor(new BatchSpanProcessor(exporter));
|
|
120
|
+
provider.register();
|
|
121
|
+
|
|
122
|
+
registerInstrumentations({
|
|
123
|
+
instrumentations: [
|
|
124
|
+
new DocumentLoadInstrumentation(),
|
|
125
|
+
new UserInteractionInstrumentation(),
|
|
126
|
+
new FetchInstrumentation({
|
|
127
|
+
propagateTraceHeaderCorsUrls: [/.*/],
|
|
128
|
+
ignoreUrls: [/\/vite\/hmr/, /^chrome-extension:\/\//, /sockjs/],
|
|
129
|
+
}),
|
|
130
|
+
new XMLHttpRequestInstrumentation({
|
|
131
|
+
propagateTraceHeaderCorsUrls: [/.*/],
|
|
132
|
+
}),
|
|
133
|
+
],
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// Optional smoke span (same flag name)
|
|
137
|
+
if (String(env('SECURENOW_TEST_SPAN')) === '1') {
|
|
138
|
+
const api = await import('@opentelemetry/api');
|
|
139
|
+
const tracer = api.trace.getTracer('securenow-smoke');
|
|
140
|
+
const span = tracer.startSpan('securenow.startup.smoke.web'); span.end();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// eslint-disable-next-line no-console
|
|
144
|
+
console.log('[securenow] Web OTel started → %s', tracesUrl);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Auto-start
|
|
148
|
+
try {
|
|
149
|
+
startSecurenowWeb();
|
|
150
|
+
} catch (e: any) {
|
|
151
|
+
if (String(e?.message) !== '__SECURENOW_NO_START__') {
|
|
152
|
+
console.error('[securenow/web-vite] failed to start:', e);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export default startSecurenowWeb;
|