Skip to content

Commit de1d611

Browse files
committed
refactor: clean up
1 parent ab8b184 commit de1d611

30 files changed

Lines changed: 2121 additions & 169 deletions

.env.sample

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ STRIPE_SECRET_KEY=xxxx
3838
STRIPE_WEBHOOK_SECRET=xxxx
3939
STRIPE_PRICE_ID=xxxx
4040
# end: stripe #
41+
42+
SENTRY_ORG=
43+
SENTRY_PROJECT=
44+
SENTRY_AUTH_TOKEN=
45+
NEXT_PUBLIC_SENTRY_DSN=

.internal/setup/db.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { spawn } from "node:child_process";
33
export async function generateMigrationFiles() {
44
const commands = [
55
"pnpm db:up",
6-
"pnpm db:migrate --name initial-migration",
6+
"pnpm db:migrate --name initial",
77
"pnpm generate:client",
88
"docker compose down",
99
];

.internal/setup/questions/otel.mjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import {
77
removeWords,
88
} from "../utils.mjs";
99

10-
export const removedFiles = /** @type {const} */ ([
11-
"otel-collector-config.yml",
12-
"./src/instrumentation.ts",
13-
]);
10+
export const removedFiles = /** @type {const} */ (["./src/instrumentation.ts"]);
1411

1512
export const removedDirs = /** @type {const} */ (["./src/otel"]);
1613

.internal/tests/common.test.mjs.snapshot

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ exports[`common > should put files 1`] = `
2222
"internal-tests-output-common/knip.config.ts",
2323
"internal-tests-output-common/lefthook.yml",
2424
"internal-tests-output-common/next.config.ts",
25-
"internal-tests-output-common/otel-collector-config.yml",
2625
"internal-tests-output-common/package.json",
2726
"internal-tests-output-common/playwright.config.ts",
2827
"internal-tests-output-common/pnpm-lock.yaml",
@@ -82,6 +81,11 @@ exports[`common > should update .env.sample 1`] = `
8281
"STRIPE_SECRET_KEY=xxxx",
8382
"STRIPE_WEBHOOK_SECRET=xxxx",
8483
"STRIPE_PRICE_ID=xxxx",
84+
"",
85+
"SENTRY_ORG=",
86+
"SENTRY_PROJECT=",
87+
"SENTRY_AUTH_TOKEN=",
88+
"NEXT_PUBLIC_SENTRY_DSN=",
8589
""
8690
]
8791
`;
@@ -429,30 +433,6 @@ exports[`common > should update compose.yml 1`] = `
429433
" interval: 1s",
430434
" timeout: 5s",
431435
" retries: 10",
432-
" jaeger:",
433-
" image: jaegertracing/all-in-one",
434-
" ports:",
435-
" # https://www.jaegertracing.io/docs/1.6/getting-started/#all-in-one-docker-image",
436-
" # frontend",
437-
" - 16686:16686",
438-
" - 14268",
439-
" - 14250",
440-
" environment:",
441-
" - METRICS_STORAGE_TYPE=prometheus",
442-
" - PROMETHEUS_QUERY_SUPPORT_SPANMETRICS_CONNECTOR=true",
443-
" - COLLECTOR_OTLP_ENABLED=true",
444-
" # don't use contrib on prod",
445-
" # https://opentelemetry.io/blog/2024/otel-collector-anti-patterns/#3--not-using-the-right-collector-distribution-or-not-building-your-own-distribution",
446-
" otel-collector:",
447-
" image: otel/opentelemetry-collector-contrib",
448-
" command: [\\"--config=/conf/otel-collector-config.yml\\"]",
449-
" volumes:",
450-
" - ./otel-collector-config.yml:/conf/otel-collector-config.yml",
451-
" ports:",
452-
" - 13133:13133 # health_check extension",
453-
" - 4317:4317 # OTLP gRPC receiver",
454-
" depends_on:",
455-
" - jaeger",
456436
""
457437
]
458438
`;
@@ -473,6 +453,8 @@ exports[`common > should update dependencies 1`] = `
473453
"@opentelemetry/semantic-conventions",
474454
"@prisma/client",
475455
"@prisma/instrumentation",
456+
"@sentry/nextjs",
457+
"@sentry/profiling-node",
476458
"clsx",
477459
"next",
478460
"next-auth",
@@ -798,6 +780,11 @@ exports[`common > should update env.ts 1`] = `
798780
" STRIPE_PRICE_ID: z.string().min(1),",
799781
" STRIPE_SECRET_KEY: z.string().min(1),",
800782
" STRIPE_WEBHOOK_SECRET: z.string().min(1),",
783+
"",
784+
" SENTRY_ORG: z.string().min(1).optional().or(z.literal(\\"\\")),",
785+
" SENTRY_PROJECT: z.string().min(1).optional().or(z.literal(\\"\\")),",
786+
" SENTRY_AUTH_TOKEN: z.string().min(1).optional().or(z.literal(\\"\\")),",
787+
" NEXT_PUBLIC_SENTRY_DSN: z.string().min(1).optional().or(z.literal(\\"\\")),",
801788
"});",
802789
"",
803790
"const runtimeEnv = z.object({});",
@@ -847,6 +834,7 @@ exports[`common > should update knip.config.ts 1`] = `
847834

848835
exports[`common > should update next.config.ts 1`] = `
849836
[
837+
"import { withSentryConfig } from \\"@sentry/nextjs\\";",
850838
"import type { NextConfig } from \\"next\\";",
851839
"import { config } from \\"./env\\";",
852840
"",
@@ -880,6 +868,15 @@ exports[`common > should update next.config.ts 1`] = `
880868
" },",
881869
" ],",
882870
" },",
871+
" {",
872+
" source: \\"/:path*\\",",
873+
" headers: [",
874+
" {",
875+
" key: \\"Document-Policy\\",",
876+
" value: \\"js-profiling\\",",
877+
" },",
878+
" ],",
879+
" },",
883880
" ];",
884881
" },",
885882
" images: {",
@@ -910,7 +907,17 @@ exports[`common > should update next.config.ts 1`] = `
910907
" ],",
911908
"};",
912909
"",
913-
"export default nextConfig;",
910+
"export default withSentryConfig(nextConfig, {",
911+
" org: process.env.SENTRY_ORG,",
912+
" project: process.env.SENTRY_PROJECT,",
913+
" silent: !process.env.CI,",
914+
" widenClientFileUpload: true,",
915+
" authToken: process.env.SENTRY_AUTH_TOKEN,",
916+
" disableLogger: true,",
917+
" reactComponentAnnotation: {",
918+
" enabled: true,",
919+
" },",
920+
"});",
914921
""
915922
]
916923
`;
@@ -1068,6 +1075,7 @@ exports[`common > should update src/app/layout.tsx 1`] = `
10681075
"import { Inter } from \\"next/font/google\\";",
10691076
"import { Footer } from \\"./_components/Footer\\";",
10701077
"import { Header } from \\"./_components/Header\\";",
1078+
"import { SentryProvider } from \\"./_providers/Sentry\\";",
10711079
"import \\"./globals.css\\";",
10721080
"",
10731081
"const inter = Inter({",
@@ -1090,16 +1098,20 @@ exports[`common > should update src/app/layout.tsx 1`] = `
10901098
"",
10911099
"export default function Layout({ children }: LayoutProps<\\"/\\">) {",
10921100
" return (",
1093-
" <html lang=\\"en\\">",
1101+
" <html lang=\\"en\\" suppressHydrationWarning>",
10941102
" <body",
1103+
" // Extensions like Grammarly mutate <body> attributes before hydration.",
1104+
" suppressHydrationWarning",
10951105
" className={clsx(",
10961106
" inter.className,",
10971107
" \\"bg-gray-700 text-gray-200 min-h-screen flex flex-col\\",",
10981108
" )}",
10991109
" >",
1100-
" <Header />",
1101-
" <main className=\\"flex-1\\">{children}</main>",
1102-
" <Footer />",
1110+
" <SentryProvider>",
1111+
" <Header />",
1112+
" <main className=\\"flex-1\\">{children}</main>",
1113+
" <Footer />",
1114+
" </SentryProvider>",
11031115
" </body>",
11041116
" </html>",
11051117
" );",

.internal/tests/no-docker.test.mjs.snapshot

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ exports[`no-docker > should put files 1`] = `
2020
"internal-tests-output-no-docker/knip.config.ts",
2121
"internal-tests-output-no-docker/lefthook.yml",
2222
"internal-tests-output-no-docker/next.config.ts",
23-
"internal-tests-output-no-docker/otel-collector-config.yml",
2423
"internal-tests-output-no-docker/package.json",
2524
"internal-tests-output-no-docker/playwright.config.ts",
2625
"internal-tests-output-no-docker/pnpm-lock.yaml",

.internal/tests/no-e2e.test.mjs.snapshot

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ exports[`no-e2e > should put files 1`] = `
2222
"internal-tests-output-no-e2e/knip.config.ts",
2323
"internal-tests-output-no-e2e/lefthook.yml",
2424
"internal-tests-output-no-e2e/next.config.ts",
25-
"internal-tests-output-no-e2e/otel-collector-config.yml",
2625
"internal-tests-output-no-e2e/package.json",
2726
"internal-tests-output-no-e2e/pnpm-lock.yaml",
2827
"internal-tests-output-no-e2e/pnpm-workspace.yaml",
@@ -271,6 +270,8 @@ exports[`no-e2e > should update dependencies 1`] = `
271270
"@opentelemetry/semantic-conventions",
272271
"@prisma/client",
273272
"@prisma/instrumentation",
273+
"@sentry/nextjs",
274+
"@sentry/profiling-node",
274275
"clsx",
275276
"next",
276277
"next-auth",

.internal/tests/no-otel.test.mjs.snapshot

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ exports[`no-otel > should update .env.sample 1`] = `
7979
"STRIPE_SECRET_KEY=xxxx",
8080
"STRIPE_WEBHOOK_SECRET=xxxx",
8181
"STRIPE_PRICE_ID=xxxx",
82+
"",
83+
"SENTRY_ORG=",
84+
"SENTRY_PROJECT=",
85+
"SENTRY_AUTH_TOKEN=",
86+
"NEXT_PUBLIC_SENTRY_DSN=",
8287
""
8388
]
8489
`;
@@ -394,6 +399,8 @@ exports[`no-otel > should update dependencies 1`] = `
394399
"@hookform/resolvers",
395400
"@next/env",
396401
"@prisma/client",
402+
"@sentry/nextjs",
403+
"@sentry/profiling-node",
397404
"clsx",
398405
"next",
399406
"next-auth",
@@ -460,6 +467,11 @@ exports[`no-otel > should update env.ts 1`] = `
460467
" STRIPE_PRICE_ID: z.string().min(1),",
461468
" STRIPE_SECRET_KEY: z.string().min(1),",
462469
" STRIPE_WEBHOOK_SECRET: z.string().min(1),",
470+
"",
471+
" SENTRY_ORG: z.string().min(1).optional().or(z.literal(\\"\\")),",
472+
" SENTRY_PROJECT: z.string().min(1).optional().or(z.literal(\\"\\")),",
473+
" SENTRY_AUTH_TOKEN: z.string().min(1).optional().or(z.literal(\\"\\")),",
474+
" NEXT_PUBLIC_SENTRY_DSN: z.string().min(1).optional().or(z.literal(\\"\\")),",
463475
"});",
464476
"",
465477
"const runtimeEnv = z.object({});",
@@ -487,6 +499,7 @@ exports[`no-otel > should update env.ts 1`] = `
487499

488500
exports[`no-otel > should update next.config.ts 1`] = `
489501
[
502+
"import { withSentryConfig } from \\"@sentry/nextjs\\";",
490503
"import type { NextConfig } from \\"next\\";",
491504
"import { config } from \\"./env\\";",
492505
"",
@@ -520,6 +533,15 @@ exports[`no-otel > should update next.config.ts 1`] = `
520533
" },",
521534
" ],",
522535
" },",
536+
" {",
537+
" source: \\"/:path*\\",",
538+
" headers: [",
539+
" {",
540+
" key: \\"Document-Policy\\",",
541+
" value: \\"js-profiling\\",",
542+
" },",
543+
" ],",
544+
" },",
523545
" ];",
524546
" },",
525547
" images: {",
@@ -539,7 +561,17 @@ exports[`no-otel > should update next.config.ts 1`] = `
539561
" },",
540562
"};",
541563
"",
542-
"export default nextConfig;",
564+
"export default withSentryConfig(nextConfig, {",
565+
" org: process.env.SENTRY_ORG,",
566+
" project: process.env.SENTRY_PROJECT,",
567+
" silent: !process.env.CI,",
568+
" widenClientFileUpload: true,",
569+
" authToken: process.env.SENTRY_AUTH_TOKEN,",
570+
" disableLogger: true,",
571+
" reactComponentAnnotation: {",
572+
" enabled: true,",
573+
" },",
574+
"});",
543575
""
544576
]
545577
`;

.internal/tests/no-sample-code.test.mjs.snapshot

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ exports[`no-sample-code > should put files 1`] = `
4141
"internal-tests-output-no-sample-code/knip.config.ts",
4242
"internal-tests-output-no-sample-code/lefthook.yml",
4343
"internal-tests-output-no-sample-code/next.config.ts",
44-
"internal-tests-output-no-sample-code/otel-collector-config.yml",
4544
"internal-tests-output-no-sample-code/package.json",
4645
"internal-tests-output-no-sample-code/playwright.config.ts",
4746
"internal-tests-output-no-sample-code/pnpm-lock.yaml",
@@ -68,6 +67,7 @@ exports[`no-sample-code > should put files 1`] = `
6867
"internal-tests-output-no-sample-code/src/app/_clients/nextAuth.ts",
6968
"internal-tests-output-no-sample-code/src/app/_clients/nextAuthConfig.ts",
7069
"internal-tests-output-no-sample-code/src/app/_clients/prisma.ts",
70+
"internal-tests-output-no-sample-code/src/app/_clients/sentry.ts",
7171
"internal-tests-output-no-sample-code/src/app/_clients/stripe.ts",
7272
"internal-tests-output-no-sample-code/src/app/_components/AuthButtons.tsx",
7373
"internal-tests-output-no-sample-code/src/app/_components/Button.tsx",
@@ -79,6 +79,7 @@ exports[`no-sample-code > should put files 1`] = `
7979
"internal-tests-output-no-sample-code/src/app/_components/Input.tsx",
8080
"internal-tests-output-no-sample-code/src/app/_hooks/useFormId.test.ts",
8181
"internal-tests-output-no-sample-code/src/app/_hooks/useFormId.ts",
82+
"internal-tests-output-no-sample-code/src/app/_providers/Sentry.tsx",
8283
"internal-tests-output-no-sample-code/src/app/_schemas/users.test.ts",
8384
"internal-tests-output-no-sample-code/src/app/_schemas/users.ts",
8485
"internal-tests-output-no-sample-code/src/app/_types/result.ts",
@@ -90,6 +91,7 @@ exports[`no-sample-code > should put files 1`] = `
9091
"internal-tests-output-no-sample-code/src/app/_utils/db.ts",
9192
"internal-tests-output-no-sample-code/src/app/_utils/payment.test.ts",
9293
"internal-tests-output-no-sample-code/src/app/_utils/payment.ts",
94+
"internal-tests-output-no-sample-code/src/app/_utils/sentry.ts",
9395
"internal-tests-output-no-sample-code/src/app/_utils/zod.test.ts",
9496
"internal-tests-output-no-sample-code/src/app/_utils/zod.ts",
9597
"internal-tests-output-no-sample-code/src/app/api/auth/[...nextauth]/route.ts",
@@ -105,10 +107,14 @@ exports[`no-sample-code > should put files 1`] = `
105107
"internal-tests-output-no-sample-code/src/app/layout.tsx",
106108
"internal-tests-output-no-sample-code/src/app/not-found.tsx",
107109
"internal-tests-output-no-sample-code/src/app/robots.txt",
110+
"internal-tests-output-no-sample-code/src/instrumentation-client.ts",
108111
"internal-tests-output-no-sample-code/src/instrumentation.ts",
109112
"internal-tests-output-no-sample-code/src/middleware.test.ts",
110113
"internal-tests-output-no-sample-code/src/middleware.ts",
114+
"internal-tests-output-no-sample-code/src/otel/instrumentations.ts",
111115
"internal-tests-output-no-sample-code/src/otel/node.ts",
116+
"internal-tests-output-no-sample-code/src/sentry.edge.config.ts",
117+
"internal-tests-output-no-sample-code/src/sentry.server.config.ts",
112118
"internal-tests-output-no-sample-code/tests/db.setup.ts",
113119
"internal-tests-output-no-sample-code/tests/vitest.helper.ts",
114120
"internal-tests-output-no-sample-code/tests/vitest.setup.ts",
@@ -298,6 +304,7 @@ exports[`no-sample-code > should update e2e/models/TopPage.ts 1`] = `
298304

299305
exports[`no-sample-code > should update next.config.ts 1`] = `
300306
[
307+
"import { withSentryConfig } from \\"@sentry/nextjs\\";",
301308
"import type { NextConfig } from \\"next\\";",
302309
"import { config } from \\"./env\\";",
303310
"",
@@ -331,6 +338,15 @@ exports[`no-sample-code > should update next.config.ts 1`] = `
331338
" },",
332339
" ],",
333340
" },",
341+
" {",
342+
" source: \\"/:path*\\",",
343+
" headers: [",
344+
" {",
345+
" key: \\"Document-Policy\\",",
346+
" value: \\"js-profiling\\",",
347+
" },",
348+
" ],",
349+
" },",
334350
" ];",
335351
" },",
336352
" typedRoutes: true,",
@@ -353,7 +369,17 @@ exports[`no-sample-code > should update next.config.ts 1`] = `
353369
" ],",
354370
"};",
355371
"",
356-
"export default nextConfig;",
372+
"export default withSentryConfig(nextConfig, {",
373+
" org: process.env.SENTRY_ORG,",
374+
" project: process.env.SENTRY_PROJECT,",
375+
" silent: !process.env.CI,",
376+
" widenClientFileUpload: true,",
377+
" authToken: process.env.SENTRY_AUTH_TOKEN,",
378+
" disableLogger: true,",
379+
" reactComponentAnnotation: {",
380+
" enabled: true,",
381+
" },",
382+
"});",
357383
""
358384
]
359385
`;

0 commit comments

Comments
 (0)