Skip to content

Commit 345b256

Browse files
authored
feat: Enable Sentry error tracking by environment (#1642)
* wip * feat: Simplify navigation hub data product links and descriptions * feat: enable Sentry error tracking based on environment configuration * feat: centralize Sentry initialization options across applications * refactor: remove unused DPI logic from components and simplify imports
1 parent 89f8e69 commit 345b256

42 files changed

Lines changed: 987 additions & 365 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
import * as Sentry from "@sentry/nextjs";
2-
import {
3-
sentryBeforeSend,
4-
sentryBeforeSendTransaction,
5-
sentryDenyUrls,
6-
sentryIgnoreErrors,
7-
sentryTracesSampler,
8-
} from "@workspace/sentry";
2+
import { sentryOptions } from "@workspace/sentry";
93

10-
Sentry.init({
11-
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
12-
tracesSampler: sentryTracesSampler,
13-
beforeSendTransaction: sentryBeforeSendTransaction,
14-
beforeSend: sentryBeforeSend,
15-
ignoreErrors: sentryIgnoreErrors,
16-
denyUrls: sentryDenyUrls,
17-
});
4+
Sentry.init(sentryOptions);
Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
import * as Sentry from "@sentry/nextjs";
2-
import {
3-
sentryBeforeSend,
4-
sentryBeforeSendTransaction,
5-
sentryDenyUrls,
6-
sentryIgnoreErrors,
7-
sentryTracesSampler,
8-
} from "@workspace/sentry";
2+
import { sentryOptions } from "@workspace/sentry";
93

10-
Sentry.init({
11-
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
12-
tracesSampler: sentryTracesSampler,
13-
beforeSendTransaction: sentryBeforeSendTransaction,
14-
beforeSend: sentryBeforeSend,
15-
ignoreErrors: sentryIgnoreErrors,
16-
denyUrls: sentryDenyUrls,
17-
});
4+
Sentry.init(sentryOptions);

apps/accelerate/src/instrumentation-client.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,8 @@
33
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
44

55
import * as Sentry from "@sentry/nextjs";
6-
import {
7-
sentryBeforeSend,
8-
sentryBeforeSendTransaction,
9-
sentryDenyUrls,
10-
sentryIgnoreErrors,
11-
sentryTracesSampler,
12-
} from "@workspace/sentry";
6+
import { sentryOptions } from "@workspace/sentry";
137

14-
Sentry.init({
15-
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
16-
tracesSampler: sentryTracesSampler,
17-
debug: false,
18-
beforeSend: sentryBeforeSend,
19-
beforeSendTransaction: sentryBeforeSendTransaction,
20-
ignoreErrors: sentryIgnoreErrors,
21-
denyUrls: sentryDenyUrls,
22-
});
8+
Sentry.init(sentryOptions);
239

2410
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
import * as Sentry from "@sentry/nextjs";
2-
import {
3-
sentryBeforeSend,
4-
sentryBeforeSendTransaction,
5-
sentryDenyUrls,
6-
sentryIgnoreErrors,
7-
sentryTracesSampler,
8-
} from "@workspace/sentry";
2+
import { sentryOptions } from "@workspace/sentry";
93

10-
Sentry.init({
11-
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
12-
tracesSampler: sentryTracesSampler,
13-
beforeSendTransaction: sentryBeforeSendTransaction,
14-
beforeSend: sentryBeforeSend,
15-
ignoreErrors: sentryIgnoreErrors,
16-
denyUrls: sentryDenyUrls,
17-
});
4+
Sentry.init(sentryOptions);
Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
import * as Sentry from "@sentry/nextjs";
2-
import {
3-
sentryBeforeSend,
4-
sentryBeforeSendTransaction,
5-
sentryDenyUrls,
6-
sentryIgnoreErrors,
7-
sentryTracesSampler,
8-
} from "@workspace/sentry";
2+
import { sentryOptions } from "@workspace/sentry";
93

10-
Sentry.init({
11-
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
12-
tracesSampler: sentryTracesSampler,
13-
beforeSendTransaction: sentryBeforeSendTransaction,
14-
beforeSend: sentryBeforeSend,
15-
ignoreErrors: sentryIgnoreErrors,
16-
denyUrls: sentryDenyUrls,
17-
});
4+
Sentry.init(sentryOptions);

apps/breakpoint/src/instrumentation-client.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,10 @@
33
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
44

55
import * as Sentry from "@sentry/nextjs";
6-
import {
7-
sentryBeforeSend,
8-
sentryBeforeSendTransaction,
9-
sentryDenyUrls,
10-
sentryIgnoreErrors,
11-
sentryTracesSampler,
12-
} from "@workspace/sentry";
6+
import { sentryOptions } from "@workspace/sentry";
137

148
const initSentry = () => {
15-
Sentry.init({
16-
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
17-
tracesSampler: sentryTracesSampler,
18-
debug: false,
19-
beforeSend: sentryBeforeSend,
20-
beforeSendTransaction: sentryBeforeSendTransaction,
21-
ignoreErrors: sentryIgnoreErrors,
22-
denyUrls: sentryDenyUrls,
23-
});
9+
Sentry.init(sentryOptions);
2410
};
2511

2612
if (typeof window !== "undefined") {

apps/docs/sentry.edge.config.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
import * as Sentry from "@sentry/nextjs";
2-
import {
3-
sentryBeforeSend,
4-
sentryBeforeSendTransaction,
5-
sentryDenyUrls,
6-
sentryIgnoreErrors,
7-
sentryTracesSampler,
8-
} from "@workspace/sentry";
2+
import { sentryOptions } from "@workspace/sentry";
93

10-
Sentry.init({
11-
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
12-
tracesSampler: sentryTracesSampler,
13-
beforeSendTransaction: sentryBeforeSendTransaction,
14-
beforeSend: sentryBeforeSend,
15-
ignoreErrors: sentryIgnoreErrors,
16-
denyUrls: sentryDenyUrls,
17-
});
4+
Sentry.init(sentryOptions);

apps/docs/sentry.server.config.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
import * as Sentry from "@sentry/nextjs";
2-
import {
3-
sentryBeforeSend,
4-
sentryBeforeSendTransaction,
5-
sentryDenyUrls,
6-
sentryIgnoreErrors,
7-
sentryTracesSampler,
8-
} from "@workspace/sentry";
2+
import { sentryOptions } from "@workspace/sentry";
93

10-
Sentry.init({
11-
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
12-
tracesSampler: sentryTracesSampler,
13-
beforeSendTransaction: sentryBeforeSendTransaction,
14-
beforeSend: sentryBeforeSend,
15-
ignoreErrors: sentryIgnoreErrors,
16-
denyUrls: sentryDenyUrls,
17-
});
4+
Sentry.init(sentryOptions);

apps/docs/src/app/components/posthog/PostHogProvider.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Suspense, useEffect, useRef, useState } from "react";
55
import { usePathname, useSearchParams } from "next/navigation";
66
import {
77
COOKIE_CONSENT_EVENT,
8+
getBrowserStorage,
89
readCookieConsent,
910
type CookieConsentValue,
1011
} from "@solana-com/ui-chrome";
@@ -51,22 +52,19 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
5152
setIsEnabled(false);
5253
};
5354

54-
syncPostHogConsent(
55+
const readConsent = () =>
5556
readCookieConsent({
56-
storage: window.localStorage,
57-
}),
58-
);
57+
storage: getBrowserStorage("localStorage"),
58+
});
59+
60+
syncPostHogConsent(readConsent());
5961

6062
const handleConsentChange = (
6163
event: Event | CustomEvent<{ value?: boolean }>,
6264
) => {
6365
const consent = "detail" in event ? event.detail?.value : undefined;
6466
syncPostHogConsent(
65-
typeof consent === "boolean"
66-
? consent
67-
: readCookieConsent({
68-
storage: window.localStorage,
69-
}),
67+
typeof consent === "boolean" ? consent : readConsent(),
7068
);
7169
};
7270

apps/docs/src/hooks/useDevelopersLearnProgress.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
import { useCallback, useEffect, useMemo, useState } from "react";
44
import { getDevelopersLearnDependentLessonKeys } from "@/utils/developers-learn-curriculum";
5+
import {
6+
getBrowserStorage,
7+
safeStorageGetItem,
8+
safeStorageSetItem,
9+
} from "@solana-com/ui-chrome";
510

611
type StoredProgress = {
712
completedLessons: string[];
@@ -16,7 +21,10 @@ function readProgressFromStorage(): StoredProgress {
1621
return { completedLessons: [], updatedAt: "" };
1722
}
1823

19-
const rawProgress = window.localStorage.getItem(STORAGE_KEY);
24+
const rawProgress = safeStorageGetItem(
25+
getBrowserStorage("localStorage"),
26+
STORAGE_KEY,
27+
);
2028
if (!rawProgress) {
2129
return { completedLessons: [], updatedAt: "" };
2230
}
@@ -45,7 +53,11 @@ function writeProgressToStorage(completedLessons: string[]) {
4553
updatedAt: new Date().toISOString(),
4654
};
4755

48-
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(nextProgress));
56+
safeStorageSetItem(
57+
getBrowserStorage("localStorage"),
58+
STORAGE_KEY,
59+
JSON.stringify(nextProgress),
60+
);
4961
window.dispatchEvent(new Event(PROGRESS_UPDATED_EVENT));
5062
}
5163

0 commit comments

Comments
 (0)