Skip to content

Commit

Permalink
fix(docs): stop instrumenting csp errors (#1315)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Aug 19, 2024
1 parent def40ba commit d415ad1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/ui/docs-bundle/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Sentry.init({
sendDefaultPii: true,

beforeSend: (event: Sentry.Event, _: Sentry.EventHint): Sentry.Event | null => {
if ((event.type as string) === "csp" || (event as any)?.csp != null) {
return null;
}
// Filter out events from privategpt
if (event.request?.url?.includes("privategpt")) {
return null;
Expand Down
20 changes: 20 additions & 0 deletions packages/ui/docs-bundle/sentry.edge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,24 @@ Sentry.init({
environment: process?.env.NEXT_PUBLIC_APPLICATION_ENVIRONMENT ?? "dev",

spotlight: process.env.NODE_ENV === "development",

beforeSend: (event: Sentry.Event, _: Sentry.EventHint): Sentry.Event | null => {
if ((event.type as string) === "csp" || (event as any)?.csp != null) {
return null;
}
// Filter out events from privategpt
if (event.request?.url?.includes("privategpt")) {
return null;
}
if (
event.tags != null &&
event.tags["url"] != null &&
typeof event.tags["url"] === "string" &&
event.tags["url"].includes("privategpt")
) {
return null;
}

return event;
},
});
20 changes: 20 additions & 0 deletions packages/ui/docs-bundle/sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,24 @@ Sentry.init({
environment: sentryEnv,

spotlight: process.env.NODE_ENV === "development",

beforeSend: (event: Sentry.Event, _: Sentry.EventHint): Sentry.Event | null => {
if ((event.type as string) === "csp" || (event as any)?.csp != null) {
return null;
}
// Filter out events from privategpt
if (event.request?.url?.includes("privategpt")) {
return null;
}
if (
event.tags != null &&
event.tags["url"] != null &&
typeof event.tags["url"] === "string" &&
event.tags["url"].includes("privategpt")
) {
return null;
}

return event;
},
});

0 comments on commit d415ad1

Please sign in to comment.