@domandigital/sentry 0.0.0-stage → 0.1.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/CHANGELOG.md +7 -0
- package/LICENSE +202 -0
- package/README.md +229 -2
- package/dist/browser.cjs +365 -0
- package/dist/browser.d.cts +25 -0
- package/dist/browser.d.ts +25 -0
- package/dist/browser.js +13 -0
- package/dist/chunk-6BR5I252.js +14 -0
- package/dist/chunk-BICH2PO4.js +339 -0
- package/dist/chunk-TD2AK75E.js +15 -0
- package/dist/chunk-ZIWYCDHF.js +14 -0
- package/dist/cli.js +236 -0
- package/dist/cloudflare.cjs +352 -0
- package/dist/cloudflare.d.cts +27 -0
- package/dist/cloudflare.d.ts +27 -0
- package/dist/cloudflare.js +9 -0
- package/dist/index.cjs +399 -0
- package/dist/index.d.cts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +50 -0
- package/dist/next.cjs +422 -0
- package/dist/next.d.cts +78 -0
- package/dist/next.d.ts +78 -0
- package/dist/next.js +63 -0
- package/dist/preset-D2peo0uv.d.cts +208 -0
- package/dist/preset-D2peo0uv.d.ts +208 -0
- package/dist/third-party-LjX9unFo.d.cts +21 -0
- package/dist/third-party-LjX9unFo.d.ts +21 -0
- package/package.json +110 -4
package/dist/next.cjs
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/next.ts
|
|
31
|
+
var next_exports = {};
|
|
32
|
+
__export(next_exports, {
|
|
33
|
+
captureGlobalError: () => captureGlobalError,
|
|
34
|
+
nextBuildOptions: () => nextBuildOptions,
|
|
35
|
+
nextClientOptions: () => nextClientOptions,
|
|
36
|
+
nextEdgeOptions: () => nextEdgeOptions,
|
|
37
|
+
nextServerOptions: () => nextServerOptions,
|
|
38
|
+
onRequestError: () => onRequestError,
|
|
39
|
+
thirdPartyFilterOptions: () => thirdPartyFilterOptions
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(next_exports);
|
|
42
|
+
|
|
43
|
+
// src/env.ts
|
|
44
|
+
var SENTRY_ORG = "domandigital";
|
|
45
|
+
var INGEST_HOST = "o4510784554991616.ingest.de.sentry.io";
|
|
46
|
+
var ENVIRONMENT_VARS = [
|
|
47
|
+
"SENTRY_ENVIRONMENT",
|
|
48
|
+
"PUBLIC_SENTRY_ENVIRONMENT",
|
|
49
|
+
"NEXT_PUBLIC_SENTRY_ENVIRONMENT",
|
|
50
|
+
// Vercel sets these itself, so a Vercel project is right without any setup.
|
|
51
|
+
"VERCEL_ENV",
|
|
52
|
+
"NEXT_PUBLIC_VERCEL_ENV"
|
|
53
|
+
];
|
|
54
|
+
var RELEASE_VARS = [
|
|
55
|
+
"SENTRY_RELEASE",
|
|
56
|
+
"PUBLIC_SENTRY_RELEASE",
|
|
57
|
+
"NEXT_PUBLIC_SENTRY_RELEASE",
|
|
58
|
+
"CF_PAGES_COMMIT_SHA",
|
|
59
|
+
"WORKERS_CI_COMMIT_SHA",
|
|
60
|
+
"VERCEL_GIT_COMMIT_SHA",
|
|
61
|
+
"NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA",
|
|
62
|
+
"GITHUB_SHA"
|
|
63
|
+
];
|
|
64
|
+
var DSN_VARS = ["SENTRY_DSN", "PUBLIC_SENTRY_DSN", "NEXT_PUBLIC_SENTRY_DSN"];
|
|
65
|
+
function text(value) {
|
|
66
|
+
if (typeof value !== "string") return void 0;
|
|
67
|
+
const trimmed = value.trim();
|
|
68
|
+
return trimmed === "" ? void 0 : trimmed;
|
|
69
|
+
}
|
|
70
|
+
function firstOf(env, names) {
|
|
71
|
+
if (!env) return void 0;
|
|
72
|
+
for (const name of names) {
|
|
73
|
+
const value = text(env[name]);
|
|
74
|
+
if (value) return { value, from: name };
|
|
75
|
+
}
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
var ALIASES = {
|
|
79
|
+
production: "production",
|
|
80
|
+
prod: "production",
|
|
81
|
+
live: "production",
|
|
82
|
+
staging: "staging",
|
|
83
|
+
stage: "staging",
|
|
84
|
+
stg: "staging",
|
|
85
|
+
preview: "preview"
|
|
86
|
+
};
|
|
87
|
+
var LOCAL = /* @__PURE__ */ new Set(["development", "dev", "local", "test"]);
|
|
88
|
+
function resolveEnvironment(input = {}) {
|
|
89
|
+
const explicit = text(input.environment);
|
|
90
|
+
const found = explicit ? { value: explicit, from: "explicit" } : firstOf(input.env, ENVIRONMENT_VARS);
|
|
91
|
+
if (!found) return { environment: "preview", enabled: true, from: null };
|
|
92
|
+
const key = found.value.toLowerCase();
|
|
93
|
+
if (LOCAL.has(key)) return { environment: "preview", enabled: false, from: found.from };
|
|
94
|
+
return { environment: ALIASES[key] ?? "preview", enabled: true, from: found.from };
|
|
95
|
+
}
|
|
96
|
+
function resolveRelease(input = {}) {
|
|
97
|
+
return text(input.release) ?? firstOf(input.env, RELEASE_VARS)?.value;
|
|
98
|
+
}
|
|
99
|
+
var OLD_INGEST = /^(https?:\/\/[^@/]+@)(o\d+\.ingest\.de\.sentry\.io)(\/.*)$/i;
|
|
100
|
+
function normaliseDsn(dsn) {
|
|
101
|
+
const value = text(dsn);
|
|
102
|
+
if (!value) return void 0;
|
|
103
|
+
const match = OLD_INGEST.exec(value);
|
|
104
|
+
return match ? `${match[1]}${INGEST_HOST}${match[3]}` : value;
|
|
105
|
+
}
|
|
106
|
+
function resolveDsn(input = {}) {
|
|
107
|
+
return normaliseDsn(text(input.dsn) ?? firstOf(input.env, DSN_VARS)?.value);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/filters.ts
|
|
111
|
+
var IGNORE_ERRORS = [
|
|
112
|
+
// In-app browsers and wallet extensions poking at objects they injected.
|
|
113
|
+
/\bethereum\b/i,
|
|
114
|
+
"__firefox__",
|
|
115
|
+
"webkit.messageHandlers",
|
|
116
|
+
"Java object is gone",
|
|
117
|
+
// Globals that tag managers, extensions and injected bars expect to exist.
|
|
118
|
+
/\b(?:googletag|jQuery|zaius|eventTracker) is not defined\b/,
|
|
119
|
+
/(?:^|[^\w$])\$ is not defined\b/,
|
|
120
|
+
/Can't find variable: (?:googletag|jQuery|zaius|eventTracker|\$)(?![\w$])/,
|
|
121
|
+
// Next.js after a deploy: an open tab posts to a server action the new build no longer has.
|
|
122
|
+
"Failed to find Server Action",
|
|
123
|
+
// The browser skipped a view transition (a second navigation, a hidden tab). Nothing broke.
|
|
124
|
+
"Skipping view transition",
|
|
125
|
+
"Transition was skipped"
|
|
126
|
+
];
|
|
127
|
+
var DENY_URLS = [
|
|
128
|
+
// Errors whose top frame is in a browser extension, or Safari's mask for one.
|
|
129
|
+
/^(?:chrome|moz|safari|safari-web|ms-browser)-extension:\/\//i,
|
|
130
|
+
/^webkit-masked-url:/i,
|
|
131
|
+
// Third-party scripts a site embeds and cannot fix.
|
|
132
|
+
/googletagmanager\.com/i,
|
|
133
|
+
/google-analytics\.com/i,
|
|
134
|
+
/googlesyndication\.com/i,
|
|
135
|
+
/connect\.facebook\.net/i,
|
|
136
|
+
/static\.hotjar\.com/i,
|
|
137
|
+
/clarity\.ms/i
|
|
138
|
+
];
|
|
139
|
+
var NETWORK_FAILURE = /^(?:Failed to fetch|Load failed|NetworkError when attempting to fetch resource\.)(?: \(([^)\s]+)\))?$/;
|
|
140
|
+
var isRec = (value) => typeof value === "object" && value !== null;
|
|
141
|
+
function bareHost(host) {
|
|
142
|
+
return host.toLowerCase().replace(/:\d+$/, "").replace(/^www\./, "");
|
|
143
|
+
}
|
|
144
|
+
function hostOf(url) {
|
|
145
|
+
if (typeof url !== "string") return void 0;
|
|
146
|
+
try {
|
|
147
|
+
return new URL(url).host;
|
|
148
|
+
} catch {
|
|
149
|
+
return void 0;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function sameSite(a, b) {
|
|
153
|
+
const x = bareHost(a);
|
|
154
|
+
const y = bareHost(b);
|
|
155
|
+
return x === y || x.endsWith(`.${y}`) || y.endsWith(`.${x}`);
|
|
156
|
+
}
|
|
157
|
+
function isThirdPartyNetworkError(event, hint, firstPartyHosts = []) {
|
|
158
|
+
if (!isRec(event) || !isRec(event.exception) || !Array.isArray(event.exception.values)) return false;
|
|
159
|
+
const values = event.exception.values.filter(isRec);
|
|
160
|
+
const last = values[values.length - 1];
|
|
161
|
+
if (!last || last.type !== "TypeError" || typeof last.value !== "string") return false;
|
|
162
|
+
const match = NETWORK_FAILURE.exec(last.value);
|
|
163
|
+
if (!match) return false;
|
|
164
|
+
const original = isRec(hint) && isRec(hint.originalException) ? hint.originalException : void 0;
|
|
165
|
+
const target = match[1] ?? (typeof original?.__sentry_fetch_url_host__ === "string" ? original.__sentry_fetch_url_host__ : void 0);
|
|
166
|
+
if (!target) return false;
|
|
167
|
+
const page = isRec(event.request) ? hostOf(event.request.url) : void 0;
|
|
168
|
+
const ours = [...firstPartyHosts, ...page ? [page] : []];
|
|
169
|
+
if (ours.length === 0) return false;
|
|
170
|
+
return !ours.some((host) => sameSite(host, target));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// src/scrub.ts
|
|
174
|
+
var import_synthetic = require("@domandigital/synthetic");
|
|
175
|
+
var REDACTED = "[REDACTED]";
|
|
176
|
+
var REDACT_KEYS = /email|token|cookie|authori[sz]ation|^auth$|password|passwd|secret|session|signature|api[-_]?key|phone/i;
|
|
177
|
+
var EMAIL = /[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}/gi;
|
|
178
|
+
var BEARER = /bearer\s+[a-z0-9._\-~+/]+=*/gi;
|
|
179
|
+
var PHONE = /(?<![\w.+])(?:\+44\s?(?:\(0\)\s?)?|0)\d(?:[\s-]?\d){8,9}(?![\w.])/g;
|
|
180
|
+
var MAX_DEPTH = 8;
|
|
181
|
+
var MAX_ITEMS = 100;
|
|
182
|
+
function scrubString(input) {
|
|
183
|
+
return input.replace(EMAIL, "[REDACTED_EMAIL]").replace(BEARER, "Bearer [REDACTED_TOKEN]").replace(PHONE, "[REDACTED_PHONE]");
|
|
184
|
+
}
|
|
185
|
+
function scrubValue(value, depth = 0) {
|
|
186
|
+
if (depth > MAX_DEPTH) return "[TRUNCATED_DEPTH]";
|
|
187
|
+
if (value == null) return value;
|
|
188
|
+
if (typeof value === "string") return scrubString(value);
|
|
189
|
+
if (typeof value === "number" || typeof value === "boolean") return value;
|
|
190
|
+
if (typeof value === "bigint") return value.toString();
|
|
191
|
+
if (value instanceof Error) return { name: value.name, message: scrubString(value.message) };
|
|
192
|
+
if (Array.isArray(value)) return value.slice(0, MAX_ITEMS).map((item) => scrubValue(item, depth + 1));
|
|
193
|
+
if (typeof value === "object") {
|
|
194
|
+
const out = {};
|
|
195
|
+
for (const [key, item] of Object.entries(value)) {
|
|
196
|
+
out[key] = REDACT_KEYS.test(key) ? REDACTED : scrubValue(item, depth + 1);
|
|
197
|
+
}
|
|
198
|
+
return out;
|
|
199
|
+
}
|
|
200
|
+
return String(value);
|
|
201
|
+
}
|
|
202
|
+
var isRec2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
203
|
+
function scrubRequest(request) {
|
|
204
|
+
const out = { ...request };
|
|
205
|
+
if ("headers" in out) out.headers = scrubValue(out.headers);
|
|
206
|
+
if ("cookies" in out && out.cookies) out.cookies = REDACTED;
|
|
207
|
+
if ("data" in out) out.data = scrubValue(out.data);
|
|
208
|
+
if (typeof out.query_string === "string") out.query_string = scrubString(out.query_string);
|
|
209
|
+
else if ("query_string" in out) out.query_string = scrubValue(out.query_string);
|
|
210
|
+
if (typeof out.url === "string") out.url = scrubString(out.url);
|
|
211
|
+
return out;
|
|
212
|
+
}
|
|
213
|
+
function scrubException(exception) {
|
|
214
|
+
if (!Array.isArray(exception.values)) return exception;
|
|
215
|
+
return {
|
|
216
|
+
...exception,
|
|
217
|
+
// Only the message: stack frames, types and mechanisms are code, not customer data.
|
|
218
|
+
values: exception.values.map((v) => isRec2(v) && typeof v.value === "string" ? { ...v, value: scrubString(v.value) } : v)
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function scrubBreadcrumb(crumb) {
|
|
222
|
+
if (!isRec2(crumb)) return crumb;
|
|
223
|
+
const out = { ...crumb };
|
|
224
|
+
if (typeof out.message === "string") out.message = scrubString(out.message);
|
|
225
|
+
if ("data" in out) out.data = scrubValue(out.data);
|
|
226
|
+
return out;
|
|
227
|
+
}
|
|
228
|
+
function scrubPii(event) {
|
|
229
|
+
const out = { ...event };
|
|
230
|
+
if (isRec2(out.request)) out.request = scrubRequest(out.request);
|
|
231
|
+
for (const key of ["user", "extra", "contexts", "tags"]) {
|
|
232
|
+
if (key in out) out[key] = scrubValue(out[key]);
|
|
233
|
+
}
|
|
234
|
+
if (typeof out.message === "string") out.message = scrubString(out.message);
|
|
235
|
+
if (isRec2(out.logentry) && typeof out.logentry.message === "string") {
|
|
236
|
+
out.logentry = { ...out.logentry, message: scrubString(out.logentry.message) };
|
|
237
|
+
}
|
|
238
|
+
if (isRec2(out.exception)) out.exception = scrubException(out.exception);
|
|
239
|
+
if (Array.isArray(out.breadcrumbs)) out.breadcrumbs = out.breadcrumbs.map(scrubBreadcrumb);
|
|
240
|
+
return out;
|
|
241
|
+
}
|
|
242
|
+
var SPAN_REDACT_KEYS = /x-dd-synth|cookie|authori[sz]ation|token|secret|password|email|phone/i;
|
|
243
|
+
function scrubAttributes(attributes) {
|
|
244
|
+
const out = {};
|
|
245
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
246
|
+
if (SPAN_REDACT_KEYS.test(key)) out[key] = REDACTED;
|
|
247
|
+
else if (typeof value === "string") out[key] = scrubString(value);
|
|
248
|
+
else if (Array.isArray(value)) out[key] = value.map((v) => typeof v === "string" ? scrubString(v) : v);
|
|
249
|
+
else out[key] = value;
|
|
250
|
+
}
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
253
|
+
function scrubSpan(span) {
|
|
254
|
+
try {
|
|
255
|
+
const out = { ...span };
|
|
256
|
+
if (typeof out.name === "string") out.name = scrubString(out.name);
|
|
257
|
+
if (typeof out.description === "string") out.description = scrubString(out.description);
|
|
258
|
+
if (isRec2(out.attributes)) out.attributes = scrubAttributes(out.attributes);
|
|
259
|
+
if (isRec2(out.data)) out.data = scrubAttributes(out.data);
|
|
260
|
+
return out;
|
|
261
|
+
} catch {
|
|
262
|
+
return span;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function scrubEvent(event) {
|
|
266
|
+
try {
|
|
267
|
+
return (0, import_synthetic.scrubSentryEvent)(scrubPii(event));
|
|
268
|
+
} catch {
|
|
269
|
+
const { request: _request, user: _user, extra: _extra, breadcrumbs: _breadcrumbs, ...rest } = event;
|
|
270
|
+
return rest;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// src/preset.ts
|
|
275
|
+
var DATA_COLLECTION = {
|
|
276
|
+
userInfo: false,
|
|
277
|
+
cookies: false,
|
|
278
|
+
httpHeaders: { request: true, response: false },
|
|
279
|
+
httpBodies: [],
|
|
280
|
+
urlQueryParams: true,
|
|
281
|
+
graphQL: { document: true, variables: false },
|
|
282
|
+
genAI: { inputs: false, outputs: false },
|
|
283
|
+
databaseQueryData: false,
|
|
284
|
+
queues: false,
|
|
285
|
+
stackFrameVariables: false
|
|
286
|
+
};
|
|
287
|
+
function isThenable(value) {
|
|
288
|
+
return typeof value === "object" && value !== null && typeof value.then === "function";
|
|
289
|
+
}
|
|
290
|
+
function scrubbingHook(user, drop) {
|
|
291
|
+
return ((event, hint) => {
|
|
292
|
+
if (drop?.(event, hint)) return null;
|
|
293
|
+
const out = user ? user(event, hint) : event;
|
|
294
|
+
if (isThenable(out)) return Promise.resolve(out).then((e) => e ? scrubEvent(e) : null);
|
|
295
|
+
return out ? scrubEvent(out) : null;
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
var SCRUB_TRANSACTIONS = {
|
|
299
|
+
name: "DomanDigitalScrubTransactions",
|
|
300
|
+
processEvent: (event) => event.type === "transaction" ? scrubEvent(event) : event
|
|
301
|
+
};
|
|
302
|
+
function withScrubber(integrations) {
|
|
303
|
+
if (typeof integrations === "function") {
|
|
304
|
+
return (defaults) => [...integrations(defaults), SCRUB_TRANSACTIONS];
|
|
305
|
+
}
|
|
306
|
+
return [...Array.isArray(integrations) ? integrations : [], SCRUB_TRANSACTIONS];
|
|
307
|
+
}
|
|
308
|
+
function hasReplay(integrations) {
|
|
309
|
+
return Array.isArray(integrations) && integrations.some((i) => typeof i === "object" && i !== null && i.name === "Replay");
|
|
310
|
+
}
|
|
311
|
+
function buildPreset(input, runtime) {
|
|
312
|
+
const {
|
|
313
|
+
dsn: dsnIn,
|
|
314
|
+
env,
|
|
315
|
+
environment: environmentIn,
|
|
316
|
+
release: releaseIn,
|
|
317
|
+
firstPartyHosts = [],
|
|
318
|
+
ignoreErrors = [],
|
|
319
|
+
denyUrls = [],
|
|
320
|
+
integrations,
|
|
321
|
+
beforeSend,
|
|
322
|
+
beforeSendSpan,
|
|
323
|
+
dataCollection,
|
|
324
|
+
tracesSampleRate,
|
|
325
|
+
replaysSessionSampleRate,
|
|
326
|
+
replaysOnErrorSampleRate,
|
|
327
|
+
sendDefaultPii: _sendDefaultPii,
|
|
328
|
+
...rest
|
|
329
|
+
} = input;
|
|
330
|
+
const { environment, enabled } = resolveEnvironment({ environment: environmentIn, env });
|
|
331
|
+
const dsn = resolveDsn({ dsn: dsnIn, env });
|
|
332
|
+
const release = resolveRelease({ release: releaseIn, env });
|
|
333
|
+
const out = {
|
|
334
|
+
...rest,
|
|
335
|
+
environment,
|
|
336
|
+
dataCollection: { ...DATA_COLLECTION, ...dataCollection },
|
|
337
|
+
ignoreErrors: [...IGNORE_ERRORS, ...ignoreErrors],
|
|
338
|
+
denyUrls: [...DENY_URLS, ...denyUrls],
|
|
339
|
+
integrations: withScrubber(integrations),
|
|
340
|
+
beforeSend: scrubbingHook(
|
|
341
|
+
beforeSend,
|
|
342
|
+
runtime.browser ? (event, hint) => isThirdPartyNetworkError(event, hint, firstPartyHosts) : void 0
|
|
343
|
+
),
|
|
344
|
+
// A site's own hook replaces this one rather than being wrapped: v11 marks
|
|
345
|
+
// a static-span hook (`withStaticSpan`), and a wrapper would lose the mark.
|
|
346
|
+
beforeSendSpan: beforeSendSpan ?? scrubSpan,
|
|
347
|
+
tracesSampleRate: tracesSampleRate ?? runtime.tracesSampleRate
|
|
348
|
+
};
|
|
349
|
+
if (dsn) out.dsn = dsn;
|
|
350
|
+
if (release) out.release = release;
|
|
351
|
+
if (!enabled) out.enabled = false;
|
|
352
|
+
if (runtime.browser && hasReplay(integrations)) {
|
|
353
|
+
out.replaysSessionSampleRate = replaysSessionSampleRate ?? 0;
|
|
354
|
+
out.replaysOnErrorSampleRate = replaysOnErrorSampleRate ?? 1;
|
|
355
|
+
}
|
|
356
|
+
return out;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// src/third-party.ts
|
|
360
|
+
function applicationKey(project) {
|
|
361
|
+
return `dd-${project}`;
|
|
362
|
+
}
|
|
363
|
+
function thirdPartyFilterOptions(project) {
|
|
364
|
+
return {
|
|
365
|
+
filterKeys: [applicationKey(project)],
|
|
366
|
+
behaviour: "drop-error-if-exclusively-contains-third-party-frames"
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// src/browser.ts
|
|
371
|
+
var BROWSER_TRACES_SAMPLE_RATE = 0.05;
|
|
372
|
+
|
|
373
|
+
// src/cloudflare.ts
|
|
374
|
+
var SERVER_TRACES_SAMPLE_RATE = 0.1;
|
|
375
|
+
|
|
376
|
+
// src/next.ts
|
|
377
|
+
function nextClientOptions(input = {}) {
|
|
378
|
+
return buildPreset(input, { tracesSampleRate: BROWSER_TRACES_SAMPLE_RATE, browser: true });
|
|
379
|
+
}
|
|
380
|
+
function nextServerOptions(input = {}) {
|
|
381
|
+
return buildPreset(input, { tracesSampleRate: SERVER_TRACES_SAMPLE_RATE, browser: false });
|
|
382
|
+
}
|
|
383
|
+
function nextEdgeOptions(input = {}) {
|
|
384
|
+
return buildPreset(input, { tracesSampleRate: SERVER_TRACES_SAMPLE_RATE, browser: false });
|
|
385
|
+
}
|
|
386
|
+
function nextBuildOptions({ project, env }) {
|
|
387
|
+
const release = resolveRelease({ env });
|
|
388
|
+
const { environment, enabled } = resolveEnvironment({ env });
|
|
389
|
+
const token = typeof env?.SENTRY_AUTH_TOKEN === "string" && env.SENTRY_AUTH_TOKEN ? env.SENTRY_AUTH_TOKEN : void 0;
|
|
390
|
+
return {
|
|
391
|
+
org: SENTRY_ORG,
|
|
392
|
+
project,
|
|
393
|
+
...token ? { authToken: token } : {},
|
|
394
|
+
applicationKey: applicationKey(project),
|
|
395
|
+
silent: !env?.CI,
|
|
396
|
+
widenClientFileUpload: true,
|
|
397
|
+
sourcemaps: { deleteSourcemapsAfterUpload: true },
|
|
398
|
+
...release ? { release: { name: release, ...enabled ? { deploy: { env: environment } } : {} } } : {}
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
async function sdk() {
|
|
402
|
+
return await import("@sentry/nextjs");
|
|
403
|
+
}
|
|
404
|
+
async function onRequestError(error, request, context) {
|
|
405
|
+
(await sdk()).captureRequestError(error, request, context);
|
|
406
|
+
}
|
|
407
|
+
async function captureGlobalError(error) {
|
|
408
|
+
(await sdk()).captureException(error, {
|
|
409
|
+
tags: { boundary: "global-error" },
|
|
410
|
+
...error.digest ? { extra: { digest: error.digest } } : {}
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
414
|
+
0 && (module.exports = {
|
|
415
|
+
captureGlobalError,
|
|
416
|
+
nextBuildOptions,
|
|
417
|
+
nextClientOptions,
|
|
418
|
+
nextEdgeOptions,
|
|
419
|
+
nextServerOptions,
|
|
420
|
+
onRequestError,
|
|
421
|
+
thirdPartyFilterOptions
|
|
422
|
+
});
|
package/dist/next.d.cts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { h as EnvSource, P as PresetInput, B as BrowserPreset, c as Preset } from './preset-D2peo0uv.cjs';
|
|
2
|
+
export { a as BrowserPresetDefaults, d as PresetDefaults, S as ScrubbingHook, b as SpanScrubbingHook } from './preset-D2peo0uv.cjs';
|
|
3
|
+
export { t as thirdPartyFilterOptions } from './third-party-LjX9unFo.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Next.js: init options for the client, Node server and edge runtimes, the
|
|
7
|
+
* `withSentryConfig` build options, and the two capture hooks Next needs.
|
|
8
|
+
*
|
|
9
|
+
* Next 16 with Turbopack loads only `instrumentation-client.ts` in the
|
|
10
|
+
* browser. A `sentry.client.config.ts` is never read, and a site that keeps
|
|
11
|
+
* its client init there reports nothing from the browser (HJ-Beauty and the
|
|
12
|
+
* DD portal, 2026-10-08 audit).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* For `instrumentation-client.ts`. Pass the public variables written out in
|
|
17
|
+
* full: Next inlines `process.env.NEXT_PUBLIC_*` only where it sees the whole
|
|
18
|
+
* name. The release comes from `withSentryConfig`, which injects it.
|
|
19
|
+
*/
|
|
20
|
+
declare function nextClientOptions<I extends PresetInput>(input?: I): BrowserPreset<I>;
|
|
21
|
+
/** For `instrumentation.ts` when `NEXT_RUNTIME === "nodejs"`. Pass `env: process.env`. */
|
|
22
|
+
declare function nextServerOptions<I extends PresetInput>(input?: I): Preset<I>;
|
|
23
|
+
/** For `instrumentation.ts` when `NEXT_RUNTIME === "edge"`. Pass `env: process.env`. */
|
|
24
|
+
declare function nextEdgeOptions<I extends PresetInput>(input?: I): Preset<I>;
|
|
25
|
+
interface NextBuildInput {
|
|
26
|
+
/** The Sentry project slug. */
|
|
27
|
+
project: string;
|
|
28
|
+
/** Build-time variables, normally `process.env`. */
|
|
29
|
+
env?: EnvSource;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The second argument to `withSentryConfig`: org, project, token, the release
|
|
33
|
+
* named after the commit with a deploy record for its environment, maps
|
|
34
|
+
* uploaded then deleted, and the application key `thirdPartyFilterOptions`
|
|
35
|
+
* matches. Spread it and add anything site-specific after.
|
|
36
|
+
*/
|
|
37
|
+
declare function nextBuildOptions({ project, env }: NextBuildInput): {
|
|
38
|
+
release?: {
|
|
39
|
+
deploy?: {
|
|
40
|
+
env: "production" | "staging" | "preview";
|
|
41
|
+
} | undefined;
|
|
42
|
+
name: string;
|
|
43
|
+
} | undefined;
|
|
44
|
+
applicationKey: string;
|
|
45
|
+
silent: boolean;
|
|
46
|
+
widenClientFileUpload: boolean;
|
|
47
|
+
sourcemaps: {
|
|
48
|
+
deleteSourcemapsAfterUpload: boolean;
|
|
49
|
+
};
|
|
50
|
+
authToken?: string | undefined;
|
|
51
|
+
org: string;
|
|
52
|
+
project: string;
|
|
53
|
+
};
|
|
54
|
+
/** What Next passes to `onRequestError`, loosely enough to accept every Next version's type. */
|
|
55
|
+
type NextRequestInfo = Readonly<{
|
|
56
|
+
path: string;
|
|
57
|
+
method: string;
|
|
58
|
+
headers: Readonly<Record<string, string | string[] | undefined>>;
|
|
59
|
+
}>;
|
|
60
|
+
type NextErrorContext = Readonly<{
|
|
61
|
+
routerKind: string;
|
|
62
|
+
routePath: string;
|
|
63
|
+
routeType: string;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Server errors from rendering, route handlers, server actions and the proxy.
|
|
67
|
+
* In `instrumentation.ts`: `export { onRequestError } from "@domandigital/sentry/next";`
|
|
68
|
+
*/
|
|
69
|
+
declare function onRequestError(error: unknown, request: NextRequestInfo, context: NextErrorContext): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* For `app/global-error.tsx`, which replaces the root layout when it throws,
|
|
72
|
+
* so nothing else reports it: `useEffect(() => { captureGlobalError(error); }, [error]);`
|
|
73
|
+
*/
|
|
74
|
+
declare function captureGlobalError(error: Error & {
|
|
75
|
+
digest?: string;
|
|
76
|
+
}): Promise<void>;
|
|
77
|
+
|
|
78
|
+
export { BrowserPreset, type NextBuildInput, type NextErrorContext, type NextRequestInfo, Preset, PresetInput, captureGlobalError, nextBuildOptions, nextClientOptions, nextEdgeOptions, nextServerOptions, onRequestError };
|
package/dist/next.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { h as EnvSource, P as PresetInput, B as BrowserPreset, c as Preset } from './preset-D2peo0uv.js';
|
|
2
|
+
export { a as BrowserPresetDefaults, d as PresetDefaults, S as ScrubbingHook, b as SpanScrubbingHook } from './preset-D2peo0uv.js';
|
|
3
|
+
export { t as thirdPartyFilterOptions } from './third-party-LjX9unFo.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Next.js: init options for the client, Node server and edge runtimes, the
|
|
7
|
+
* `withSentryConfig` build options, and the two capture hooks Next needs.
|
|
8
|
+
*
|
|
9
|
+
* Next 16 with Turbopack loads only `instrumentation-client.ts` in the
|
|
10
|
+
* browser. A `sentry.client.config.ts` is never read, and a site that keeps
|
|
11
|
+
* its client init there reports nothing from the browser (HJ-Beauty and the
|
|
12
|
+
* DD portal, 2026-10-08 audit).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* For `instrumentation-client.ts`. Pass the public variables written out in
|
|
17
|
+
* full: Next inlines `process.env.NEXT_PUBLIC_*` only where it sees the whole
|
|
18
|
+
* name. The release comes from `withSentryConfig`, which injects it.
|
|
19
|
+
*/
|
|
20
|
+
declare function nextClientOptions<I extends PresetInput>(input?: I): BrowserPreset<I>;
|
|
21
|
+
/** For `instrumentation.ts` when `NEXT_RUNTIME === "nodejs"`. Pass `env: process.env`. */
|
|
22
|
+
declare function nextServerOptions<I extends PresetInput>(input?: I): Preset<I>;
|
|
23
|
+
/** For `instrumentation.ts` when `NEXT_RUNTIME === "edge"`. Pass `env: process.env`. */
|
|
24
|
+
declare function nextEdgeOptions<I extends PresetInput>(input?: I): Preset<I>;
|
|
25
|
+
interface NextBuildInput {
|
|
26
|
+
/** The Sentry project slug. */
|
|
27
|
+
project: string;
|
|
28
|
+
/** Build-time variables, normally `process.env`. */
|
|
29
|
+
env?: EnvSource;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The second argument to `withSentryConfig`: org, project, token, the release
|
|
33
|
+
* named after the commit with a deploy record for its environment, maps
|
|
34
|
+
* uploaded then deleted, and the application key `thirdPartyFilterOptions`
|
|
35
|
+
* matches. Spread it and add anything site-specific after.
|
|
36
|
+
*/
|
|
37
|
+
declare function nextBuildOptions({ project, env }: NextBuildInput): {
|
|
38
|
+
release?: {
|
|
39
|
+
deploy?: {
|
|
40
|
+
env: "production" | "staging" | "preview";
|
|
41
|
+
} | undefined;
|
|
42
|
+
name: string;
|
|
43
|
+
} | undefined;
|
|
44
|
+
applicationKey: string;
|
|
45
|
+
silent: boolean;
|
|
46
|
+
widenClientFileUpload: boolean;
|
|
47
|
+
sourcemaps: {
|
|
48
|
+
deleteSourcemapsAfterUpload: boolean;
|
|
49
|
+
};
|
|
50
|
+
authToken?: string | undefined;
|
|
51
|
+
org: string;
|
|
52
|
+
project: string;
|
|
53
|
+
};
|
|
54
|
+
/** What Next passes to `onRequestError`, loosely enough to accept every Next version's type. */
|
|
55
|
+
type NextRequestInfo = Readonly<{
|
|
56
|
+
path: string;
|
|
57
|
+
method: string;
|
|
58
|
+
headers: Readonly<Record<string, string | string[] | undefined>>;
|
|
59
|
+
}>;
|
|
60
|
+
type NextErrorContext = Readonly<{
|
|
61
|
+
routerKind: string;
|
|
62
|
+
routePath: string;
|
|
63
|
+
routeType: string;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Server errors from rendering, route handlers, server actions and the proxy.
|
|
67
|
+
* In `instrumentation.ts`: `export { onRequestError } from "@domandigital/sentry/next";`
|
|
68
|
+
*/
|
|
69
|
+
declare function onRequestError(error: unknown, request: NextRequestInfo, context: NextErrorContext): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* For `app/global-error.tsx`, which replaces the root layout when it throws,
|
|
72
|
+
* so nothing else reports it: `useEffect(() => { captureGlobalError(error); }, [error]);`
|
|
73
|
+
*/
|
|
74
|
+
declare function captureGlobalError(error: Error & {
|
|
75
|
+
digest?: string;
|
|
76
|
+
}): Promise<void>;
|
|
77
|
+
|
|
78
|
+
export { BrowserPreset, type NextBuildInput, type NextErrorContext, type NextRequestInfo, Preset, PresetInput, captureGlobalError, nextBuildOptions, nextClientOptions, nextEdgeOptions, nextServerOptions, onRequestError };
|
package/dist/next.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BROWSER_TRACES_SAMPLE_RATE
|
|
3
|
+
} from "./chunk-6BR5I252.js";
|
|
4
|
+
import {
|
|
5
|
+
SERVER_TRACES_SAMPLE_RATE
|
|
6
|
+
} from "./chunk-ZIWYCDHF.js";
|
|
7
|
+
import {
|
|
8
|
+
applicationKey,
|
|
9
|
+
thirdPartyFilterOptions
|
|
10
|
+
} from "./chunk-TD2AK75E.js";
|
|
11
|
+
import {
|
|
12
|
+
SENTRY_ORG,
|
|
13
|
+
buildPreset,
|
|
14
|
+
resolveEnvironment,
|
|
15
|
+
resolveRelease
|
|
16
|
+
} from "./chunk-BICH2PO4.js";
|
|
17
|
+
|
|
18
|
+
// src/next.ts
|
|
19
|
+
function nextClientOptions(input = {}) {
|
|
20
|
+
return buildPreset(input, { tracesSampleRate: BROWSER_TRACES_SAMPLE_RATE, browser: true });
|
|
21
|
+
}
|
|
22
|
+
function nextServerOptions(input = {}) {
|
|
23
|
+
return buildPreset(input, { tracesSampleRate: SERVER_TRACES_SAMPLE_RATE, browser: false });
|
|
24
|
+
}
|
|
25
|
+
function nextEdgeOptions(input = {}) {
|
|
26
|
+
return buildPreset(input, { tracesSampleRate: SERVER_TRACES_SAMPLE_RATE, browser: false });
|
|
27
|
+
}
|
|
28
|
+
function nextBuildOptions({ project, env }) {
|
|
29
|
+
const release = resolveRelease({ env });
|
|
30
|
+
const { environment, enabled } = resolveEnvironment({ env });
|
|
31
|
+
const token = typeof env?.SENTRY_AUTH_TOKEN === "string" && env.SENTRY_AUTH_TOKEN ? env.SENTRY_AUTH_TOKEN : void 0;
|
|
32
|
+
return {
|
|
33
|
+
org: SENTRY_ORG,
|
|
34
|
+
project,
|
|
35
|
+
...token ? { authToken: token } : {},
|
|
36
|
+
applicationKey: applicationKey(project),
|
|
37
|
+
silent: !env?.CI,
|
|
38
|
+
widenClientFileUpload: true,
|
|
39
|
+
sourcemaps: { deleteSourcemapsAfterUpload: true },
|
|
40
|
+
...release ? { release: { name: release, ...enabled ? { deploy: { env: environment } } : {} } } : {}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async function sdk() {
|
|
44
|
+
return await import("@sentry/nextjs");
|
|
45
|
+
}
|
|
46
|
+
async function onRequestError(error, request, context) {
|
|
47
|
+
(await sdk()).captureRequestError(error, request, context);
|
|
48
|
+
}
|
|
49
|
+
async function captureGlobalError(error) {
|
|
50
|
+
(await sdk()).captureException(error, {
|
|
51
|
+
tags: { boundary: "global-error" },
|
|
52
|
+
...error.digest ? { extra: { digest: error.digest } } : {}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
captureGlobalError,
|
|
57
|
+
nextBuildOptions,
|
|
58
|
+
nextClientOptions,
|
|
59
|
+
nextEdgeOptions,
|
|
60
|
+
nextServerOptions,
|
|
61
|
+
onRequestError,
|
|
62
|
+
thirdPartyFilterOptions
|
|
63
|
+
};
|