-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathsentry.client.config.ts
99 lines (78 loc) · 3.11 KB
/
sentry.client.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
// This file configures the initialization of Sentry on the client.
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: "https://9c7422fbfed53fb87f55bc455bb22a83@o95426.ingest.us.sentry.io/4507630267400192",
enabled: process.env.IS_DEV_ENV !== "true",
tracePropagationTargets: ["localhost", /^https:\/\/genshin-builds\.com\/api/],
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,
sampleRate: 0.25,
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
replaysOnErrorSampleRate: 1,
// This sets the sample rate to be 10%. You may want this to be 100% while
// in development and sample at a lower rate in production
replaysSessionSampleRate: 0.1,
// You can remove this option if you're not planning to use the Sentry Session Replay feature:
integrations: [
Sentry.replayIntegration({
// Additional Replay configuration goes in here, for example:
maskAllText: true,
blockAllMedia: true,
}),
],
ignoreErrors: [
"Script error.",
"ResizeObserver loop limit exceeded",
"Uncaught Error: unreachable: e.data !== MessagePort",
"Object captured as promise rejection with keys: [object has no keys]",
"HierarchyRequestError: The operation would yield an incorrect node tree."
],
denyUrls: [
/pagead\/managed\/js\/gpt\//i,
/googlesyndication\.com/i,
/googletagservices\.com/i,
/pubads\.g\.doubleclick\.net/i,
/securepubads\.g\.doubleclick\.net/i,
/adservice\.google\.com/i,
],
beforeSend(event) {
const hasAdsStackFrame = (frames: Sentry.StackFrame[]) => {
// Sometimes the last frame is not the one we want, like: "\u003Canonymous\u003E"
// So we need to find the last frame that is not from Sentry or pubfig.engine.js
const adsFilenames =
/.*(bao-csm|tag\/js\/gpt\.js|hadron\.js|inpage\.js|pubfig\.engine|prebid-analytics|app:\/\/\/ym\.[0-9]\.js|app:\/\/\/pageFold\/ftpagefold_v|uv\.handler\.js|pubads_impl\.js|pubfig\.min\.js).*/;
for (let i = frames.length - 1; i >= 0; i--) {
const frame = frames[i];
if (adsFilenames.test(frame.filename ?? "")) {
return true;
}
}
return false;
};
if (
hasAdsStackFrame(event.exception?.values?.[0]?.stacktrace?.frames ?? [])
) {
return null;
}
const hasAdsBreadcrumb = (
breadcrumbs: IterableIterator<Sentry.Breadcrumb>
) => {
// Define a regex pattern to match the desired domains
const domainPattern =
/.*([a-z]\.pub\.network|googleads\.g\.doubleclick|ib\.adnxs.com|hadron\.ad|ups\.analytics\.yahoo\.com).*/;
for (const breadcrumb of breadcrumbs) {
if (domainPattern.test(breadcrumb.data?.url)) {
return true;
}
}
return false;
};
if (hasAdsBreadcrumb(event.breadcrumbs?.values() ?? ([] as any))) {
return null;
}
return event;
},
});