Skip to content

Commit a66fda2

Browse files
authored
feat(dd): add RUM + trace on studio (#818)
* feat: add dd rum * chore: add tracer * feat: add env to front * fix: env and version * feat: update tag * chore: add vapt * fix: deps * chore: add env
1 parent 817c56a commit a66fda2

File tree

11 files changed

+540
-23
lines changed

11 files changed

+540
-23
lines changed

.github/workflows/aws_deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jobs:
158158
tags: |
159159
${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
160160
build-args: |
161-
ENV=${{env.ENV}}
161+
NEXT_PUBLIC_APP_ENV=${{ inputs.environment }}
162162
NEXT_PUBLIC_APP_URL=${{ inputs.app-url }}
163163
NEXT_PUBLIC_APP_NAME=${{ inputs.app-name }}
164164
NEXT_PUBLIC_APP_VERSION=${{ inputs.app-version }}
@@ -243,7 +243,7 @@ jobs:
243243
codedeploy-deployment-group: ${{ inputs.codedeploy-deployment-group }}
244244

245245
# - name: Upload sourcemaps to Datadog
246-
# if: ${{ env.DATADOG_API_KEY != '' }}
246+
# if: ${{ env.DD_API_KEY != '' }}
247247
# env:
248248
# IMAGE_TAG: ${{ env.LOCAL_IMAGE_TAG }}
249249
# shell: bash

.github/workflows/deploy_production.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
ecs-task-exec-role: studio-production-ecs-task-exec-role
3535
app-url: "https://studio.isomer.gov.sg"
3636
app-name: "Isomer Studio"
37-
app-version: ${{ github.sha }}
37+
app-version: ${{ github.event.release.tag_name }}
3838
app-enable-sgid: false
3939
app-s3-region: "ap-southeast-1"
4040
app-s3-assets-bucket-name: "isomer-next-infra-prod-assets-private-a319984"

apps/studio/.env.test

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ SESSION_SECRET=random_session_secret_that_is_at_least_32_characters
66
NEXT_PUBLIC_APP_NAME="Isomer Studio (TEST)"
77
NEXT_PUBLIC_S3_ASSETS_DOMAIN_NAME=user-content.example.com
88
NEXT_PUBLIC_S3_ASSETS_BUCKET_NAME=assets-bucket
9+
NEXT_PUBLIC_APP_ENV='test'
910

1011
# Used for E2E testing
1112
DATABASE_URL=postgres://root:root@localhost:5432/test
1213

13-
PINO_LOG_LEVEL=silent
14+
PINO_LOG_LEVEL=silent
15+

apps/studio/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM node:22-alpine AS base
22

3+
ARG NEXT_PUBLIC_APP_ENV
4+
ENV NEXT_PUBLIC_APP_ENV=$NEXT_PUBLIC_APP_ENV
5+
36
ARG NEXT_PUBLIC_APP_URL
47
ENV NEXT_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL
58

apps/studio/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@chakra-ui/styled-system": "^2.9.2",
5858
"@chakra-ui/theme-tools": "^2.1.2",
5959
"@chakra-ui/utils": "^2.0.15",
60+
"@datadog/browser-rum": "^5.29.1",
6061
"@fontsource/ibm-plex-mono": "^5.0.13",
6162
"@formkit/auto-animate": "^0.8.2",
6263
"@growthbook/growthbook": "^1.2.0",
@@ -112,6 +113,7 @@
112113
"ajv": "^8.16.0",
113114
"date-fns": "^4.1.0",
114115
"date-fns-tz": "^3.1.3",
116+
"dd-trace": "^5.24.0",
115117
"flat": "^6.0.1",
116118
"fuzzysort": "^2.0.4",
117119
"inter-ui": "^4.0.2",

apps/studio/src/env.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ const s3Schema = z.object({
2222
*/
2323
const client = z
2424
.object({
25+
NEXT_PUBLIC_APP_ENV: z.enum([
26+
"development",
27+
"staging",
28+
"production",
29+
"vapt",
30+
"test",
31+
]),
2532
NEXT_PUBLIC_ENABLE_SGID: coerceBoolean.default("false"),
2633
NEXT_PUBLIC_APP_URL: z.string().url().optional(),
2734
NEXT_PUBLIC_APP_NAME: z.string().default("Isomer Studio"),
@@ -124,6 +131,7 @@ const processEnv = {
124131
SGID_PRIVATE_KEY: process.env.SGID_PRIVATE_KEY,
125132
SGID_REDIRECT_URI: process.env.SGID_REDIRECT_URI,
126133
// Client-side env vars
134+
NEXT_PUBLIC_APP_ENV: process.env.NEXT_PUBLIC_APP_ENV,
127135
NEXT_PUBLIC_APP_NAME: process.env.NEXT_PUBLIC_APP_NAME,
128136
NEXT_PUBLIC_APP_VERSION:
129137
process.env.NEXT_PUBLIC_APP_VERSION ??

apps/studio/src/pages/_app.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import "../styles/editor/editorStyles.scss"
55

66
import type { AppProps, AppType } from "next/app"
77
import { Skeleton, Stack } from "@chakra-ui/react"
8+
import { datadogRum } from "@datadog/browser-rum"
89
import { GrowthBook } from "@growthbook/growthbook"
910
import { GrowthBookProvider } from "@growthbook/growthbook-react"
1011
import Intercom from "@intercom/messenger-js-sdk"
@@ -28,6 +29,23 @@ type AppPropsWithAuthAndLayout = AppProps & {
2829
Component: NextPageWithLayout
2930
}
3031

32+
datadogRum.init({
33+
applicationId: "32c64617-51e3-4a6e-a977-ad113021ffae",
34+
clientToken: "pub89baaf356268edcb9ed95847d7c5d679",
35+
// `site` refers to the Datadog site parameter of your organization
36+
// see https://docs.datadoghq.com/getting_started/site/
37+
site: "datadoghq.com",
38+
service: "isomer-next",
39+
env: env.NEXT_PUBLIC_APP_ENV,
40+
version: env.NEXT_PUBLIC_APP_VERSION,
41+
sessionSampleRate: 100,
42+
sessionReplaySampleRate: 100,
43+
trackUserInteractions: true,
44+
trackResources: true,
45+
trackLongTasks: true,
46+
defaultPrivacyLevel: "mask-user-input",
47+
})
48+
3149
// Create a GrowthBook instance
3250
const gb = new GrowthBook({
3351
apiHost: "https://cdn.growthbook.io",

apps/studio/src/server/modules/_app.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**
22
* This file contains the root router of your tRPC-backend
33
*/
4+
import "./tracer"
5+
46
import { publicProcedure, router } from "../trpc"
57
import { assetRouter } from "./asset/asset.router"
68
import { authRouter } from "./auth/auth.router"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import tracer from "dd-trace"
2+
3+
tracer.init() // initialized in a different file to avoid hoisting.
4+
export default tracer

0 commit comments

Comments
 (0)