Skip to content

Commit 6649622

Browse files
geclosclaude
andauthored
feat: replace Sentry with DataDog tracer in web app (#1737)
* feat: replace Sentry with DataDog tracer in web app - Remove Sentry dependencies and configuration files - Install and configure dd-trace for server-side tracing - Install @datadog/browser-rum for client-side RUM monitoring - Update all error capture calls to use DataDog equivalents - Replace Sentry environment variables with DataDog ones - Update Dockerfile and CI/CD workflow for DataDog integration - Add DatadogProvider to app layout for proper initialization 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix lint and tc * fix edge incompats --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent b6ac8a6 commit 6649622

File tree

24 files changed

+605
-1532
lines changed

24 files changed

+605
-1532
lines changed

.github/workflows/build-and-push.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
strategy:
6262
matrix:
6363
include:
64-
# Public images on GitHub Container Registry (without Sentry)
64+
# Public images on GitHub Container Registry (without DataDog secrets)
6565
# Multi-platform builds (AMD64)
6666
- app: web
6767
dockerfile: apps/web/docker/Dockerfile
@@ -151,7 +151,7 @@ jobs:
151151
strategy:
152152
matrix:
153153
include:
154-
# Private images on AWS ECR (with Sentry)
154+
# Private images on AWS ECR (with DataDog)
155155
- app: web
156156
dockerfile: apps/web/docker/Dockerfile
157157
repo_name: latitude-llm-app-repo-43d71dc
@@ -225,7 +225,6 @@ jobs:
225225
cache-from: type=registry,ref=${{ format('{0}/{1}', env.ECR_REGISTRY, matrix.repo_name) }}:latest
226226
cache-to: type=inline
227227
secrets: |
228-
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
229228
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY=${{ secrets.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY }}
230229
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}
231230
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}
@@ -236,10 +235,10 @@ jobs:
236235
NEXT_PUBLIC_LATITUDE_CLOUD_PAYMENT_URL=${{ vars.NEXT_PUBLIC_LATITUDE_CLOUD_PAYMENT_URL }}
237236
NEXT_PUBLIC_POSTHOG_HOST=${{ secrets.NEXT_PUBLIC_POSTHOG_HOST }}
238237
NEXT_PUBLIC_POSTHOG_KEY=${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }}
239-
NEXT_PUBLIC_SENTRY_WEB_DSN=${{ vars.SENTRY_WEB_DSN }}
238+
NEXT_PUBLIC_DATADOG_APPLICATION_ID=${{ secrets.NEXT_PUBLIC_DATADOG_APPLICATION_ID }}
239+
NEXT_PUBLIC_DATADOG_CLIENT_TOKEN=${{ secrets.NEXT_PUBLIC_DATADOG_CLIENT_TOKEN }}
240+
NEXT_PUBLIC_DATADOG_SITE=${{ secrets.NEXT_PUBLIC_DATADOG_SITE }}
240241
S3_BUCKET=${{ vars.STATIC_ASSETS_S3_BUCKET }}
241-
SENTRY_ORG=${{ secrets.SENTRY_ORG }}
242-
SENTRY_PROJECT=${{ secrets.SENTRY_PROJECT }}
243242
STATIC_ASSETS_HOST=${{ vars.STATIC_ASSETS_HOST }}
244243
245244
run-migrations:

apps/web/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
public/workers/**/*
2-
# Sentry Config File
3-
.env.sentry-build-plugin

apps/web/docker/Dockerfile

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
ARG PROJECT="@latitude-data/web"
22
ARG PROJECT_PATH="apps/web"
3-
ARG NEXT_PUBLIC_SENTRY_WEB_DSN
43
ARG NEXT_PUBLIC_DOCS_URL
5-
ARG SENTRY_ORG
6-
ARG SENTRY_PROJECT
4+
ARG NEXT_PUBLIC_DATADOG_APPLICATION_ID
5+
ARG NEXT_PUBLIC_DATADOG_CLIENT_TOKEN
6+
ARG NEXT_PUBLIC_DATADOG_SITE
77
ARG AWS_REGION
88
ARG S3_BUCKET
99
ARG BUILD_ID
@@ -65,21 +65,21 @@ RUN turbo prune "${PROJECT}" --docker
6565
FROM base AS builder
6666

6767
ARG PROJECT
68-
ARG NEXT_PUBLIC_SENTRY_WEB_DSN
69-
ARG SENTRY_ORG
70-
ARG SENTRY_PROJECT
68+
ARG NEXT_PUBLIC_DATADOG_APPLICATION_ID
69+
ARG NEXT_PUBLIC_DATADOG_CLIENT_TOKEN
70+
ARG NEXT_PUBLIC_DATADOG_SITE
7171
ARG NEXT_PUBLIC_POSTHOG_KEY
7272
ARG NEXT_PUBLIC_POSTHOG_HOST
7373
ARG NEXT_PUBLIC_LATITUDE_CLOUD_PAYMENT_URL
7474

7575
ARG NEXT_PUBLIC_DOCS_URL
7676

77-
ENV SENTRY_ORG=$SENTRY_ORG
78-
ENV SENTRY_PROJECT=$SENTRY_PROJECT
77+
ENV NEXT_PUBLIC_DATADOG_APPLICATION_ID=$NEXT_PUBLIC_DATADOG_APPLICATION_ID
78+
ENV NEXT_PUBLIC_DATADOG_CLIENT_TOKEN=$NEXT_PUBLIC_DATADOG_CLIENT_TOKEN
79+
ENV NEXT_PUBLIC_DATADOG_SITE=$NEXT_PUBLIC_DATADOG_SITE
7980
ENV NEXT_PUBLIC_POSTHOG_KEY=$NEXT_PUBLIC_POSTHOG_KEY
8081
ENV NEXT_PUBLIC_POSTHOG_HOST=$NEXT_PUBLIC_POSTHOG_HOST
8182
ENV NEXT_PUBLIC_LATITUDE_CLOUD_PAYMENT_URL=$NEXT_PUBLIC_LATITUDE_CLOUD_PAYMENT_URL
82-
ENV NEXT_PUBLIC_SENTRY_WEB_DSN=$NEXT_PUBLIC_SENTRY_WEB_DSN
8383

8484
ENV NEXT_PUBLIC_DOCS_URL=$NEXT_PUBLIC_DOCS_URL
8585

@@ -107,18 +107,17 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install \
107107
--filter "${PROJECT}..."
108108

109109
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
110-
--mount=type=secret,id=SENTRY_AUTH_TOKEN \
111110
--mount=type=secret,id=NEXT_SERVER_ACTIONS_ENCRYPTION_KEY \
112111
set -a && \
113112
BUILDING_CONTAINER=true && \
114113
NEXT_TELEMETRY_DISABLED=1 && \
115-
SENTRY_ORG=$SENTRY_ORG && \
116-
SENTRY_PROJECT=$SENTRY_PROJECT && \
117-
SENTRY_AUTH_TOKEN="$(cat /run/secrets/SENTRY_AUTH_TOKEN 2>/dev/null || echo '')" && \
114+
NEXT_PUBLIC_NODE_ENV=production && \
115+
NEXT_PUBLIC_DATADOG_APPLICATION_ID=$NEXT_PUBLIC_DATADOG_APPLICATION_ID && \
116+
NEXT_PUBLIC_DATADOG_CLIENT_TOKEN=$NEXT_PUBLIC_DATADOG_CLIENT_TOKEN && \
117+
NEXT_PUBLIC_DATADOG_SITE=$NEXT_PUBLIC_DATADOG_SITE && \
118118
NEXT_PUBLIC_POSTHOG_KEY=$NEXT_PUBLIC_POSTHOG_KEY && \
119119
NEXT_PUBLIC_POSTHOG_HOST=$NEXT_PUBLIC_POSTHOG_HOST && \
120120
NEXT_PUBLIC_LATITUDE_CLOUD_PAYMENT_URL=$NEXT_PUBLIC_LATITUDE_CLOUD_PAYMENT_URL && \
121-
NEXT_PUBLIC_SENTRY_WEB_DSN=$NEXT_PUBLIC_SENTRY_WEB_DSN && \
122121
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY="$(cat /run/secrets/NEXT_SERVER_ACTIONS_ENCRYPTION_KEY 2>/dev/null || echo '')" && \
123122
NEXT_PUBLIC_DOCS_URL=$NEXT_PUBLIC_DOCS_URL && \
124123
AWS_REGION=$AWS_REGION && \

apps/web/next.config.mjs

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { withSentryConfig } from '@sentry/nextjs'
2-
31
const INTERNAL_PACKAGES = [
42
'@latitude-data/web-ui',
53
'@latitude-data/env',
@@ -29,8 +27,6 @@ const nextConfig = {
2927
ignoreBuildErrors: true,
3028
},
3129
experimental: {
32-
// TODO: Review this decision. It would be more performant to use
33-
// direct uploads.
3430
serverActions: {
3531
bodySizeLimit: '25mb',
3632
},
@@ -42,49 +38,4 @@ const nextConfig = {
4238
assetPrefix: process.env.NEXT_PUBLIC_STATIC_ASSETS_URL,
4339
}
4440

45-
let config
46-
if (process.env.SENTRY_ORG && process.env.SENTRY_PROJECT) {
47-
config = withSentryConfig(nextConfig, {
48-
// For all available options, see:
49-
// https://github.com/getsentry/sentry-webpack-plugin#options
50-
51-
org: process.env.SENTRY_ORG,
52-
project: process.env.SENTRY_PROJECT,
53-
54-
// Only print logs for uploading source maps in CI
55-
silent: !process.env.CI,
56-
57-
// For all available options, see:
58-
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
59-
60-
// Upload a larger set of source maps for prettier stack traces (increases build time)
61-
widenClientFileUpload: true,
62-
63-
// Automatically annotate React components to show their full name in breadcrumbs and session replay
64-
reactComponentAnnotation: {
65-
enabled: true,
66-
},
67-
68-
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
69-
// This can increase your server load as well as your hosting bill.
70-
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
71-
// side errors will fail.
72-
tunnelRoute: '/monitoring',
73-
74-
// Hides source maps from generated client bundles
75-
hideSourceMaps: false,
76-
77-
// Automatically tree-shake Sentry logger statements to reduce bundle size
78-
disableLogger: true,
79-
80-
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
81-
// See the following for more information:
82-
// https://docs.sentry.io/product/crons/
83-
// https://vercel.com/docs/cron-jobs
84-
automaticVercelMonitors: false,
85-
})
86-
} else {
87-
config = nextConfig
88-
}
89-
90-
export default config
41+
export default nextConfig

apps/web/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919
"dependencies": {
2020
"@aws-sdk/client-s3": "3.850.0",
21+
"@datadog/browser-rum": "^6.21.1",
2122
"@intercom/messenger-js-sdk": "0.0.14",
2223
"@latitude-data/constants": "workspace:*",
2324
"@latitude-data/core": "workspace:*",
@@ -36,7 +37,6 @@
3637
"@napi-rs/canvas": "0.1.68",
3738
"@pilcrowjs/object-parser": "0.0.4",
3839
"@pipedream/sdk": "^2.0.0",
39-
"@sentry/nextjs": "9.10.1",
4040
"@sindresorhus/slugify": "2.2.1",
4141
"@t3-oss/env-nextjs": "0.10.1",
4242
"@types/diff-match-patch": "1.0.36",
@@ -46,6 +46,7 @@
4646
"argon2": "0.41.0",
4747
"bullmq": "5.44.4",
4848
"date-fns": "3.6.0",
49+
"dd-trace": "^5.67.0",
4950
"diff-match-patch": "1.0.5",
5051
"drizzle-orm": "catalog:",
5152
"eventsource-parser": "2.0.1",

apps/web/sentry.edge.config.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

apps/web/sentry.server.config.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

apps/web/src/actions/procedures/index.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
EvaluationsV2Repository,
1515
ProjectsRepository,
1616
} from '@latitude-data/core/repositories'
17-
import * as Sentry from '@sentry/nextjs'
17+
import { captureException } from '$/helpers/captureException'
1818
import { ReplyError } from 'ioredis'
1919
import { headers } from 'next/headers'
2020
import { RateLimiterRedis, RateLimiterRes } from 'rate-limiter-flexible'
@@ -32,15 +32,14 @@ export const errorHandlingProcedure = createServerActionProcedure()
3232
try {
3333
const data = await getCurrentUserOrRedirect()
3434

35-
Sentry.captureException(error, {
36-
user: {
37-
id: data.user.id,
38-
name: data.user.name,
39-
email: data.user.email,
40-
},
35+
captureException(error as Error, {
36+
component: 'serverAction',
37+
userId: data.user.id,
38+
userName: data.user.name,
39+
userEmail: data.user.email,
4140
})
4241
} catch (_) {
43-
Sentry.captureException(error)
42+
captureException(error as Error, { component: 'serverAction' })
4443
}
4544
})
4645
.handler((ctx) => ({ ...ctx }))

apps/web/src/app/(onboarding)/onboarding/_components/Navbar/NocodersNavbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useMemo, Fragment, useCallback } from 'react'
2-
import { NavbarItem } from './navbarItem'
2+
import { NavbarItem } from './NavbarItem'
33
import { Separator } from '@latitude-data/web-ui/atoms/Separator'
44
import { Text } from '@latitude-data/web-ui/atoms/Text'
55
import { Button } from '@latitude-data/web-ui/atoms/Button'

apps/web/src/app/(onboarding)/onboarding/_components/Navbar/navbarItem.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)