Skip to content

Commit b3605d6

Browse files
flakey5MattIPv4
andauthored
src: migrate from toucan-js to sentry sdk (#833)
Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com> Co-authored-by: Matt Cowley <me@mattcowley.co.uk>
1 parent 34c4e98 commit b3605d6

19 files changed

+232
-236
lines changed

.github/workflows/deploy.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ jobs:
4444
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
4545
with:
4646
apiToken: ${{ secrets.CF_API_TOKEN }}
47-
command: deploy --env staging --outdir=./dist
48-
49-
- name: Upload sourcemaps for dist-worker-staging
50-
if: github.event_name == 'push'
51-
env:
52-
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
53-
run: |
54-
npx sentry-cli sourcemaps inject --org nodejs --project dist-worker-staging ./dist && npx sentry-cli sourcemaps upload --org nodejs --project dist-worker-staging ./dist
47+
command: deploy --env staging --outdir=./dist --upload-source-maps --var SENTRY_RELEASE:$(npx sentry-cli releases propose-version)
5548

5649
- name: Deploy to Production
5750
if: github.event_name == 'workflow_dispatch'
5851
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
5952
with:
6053
apiToken: ${{ secrets.CF_API_TOKEN }}
61-
command: deploy --env prod --outdir=./dist
54+
command: deploy --env prod --outdir=./dist --upload-source-maps --var SENTRY_RELEASE:$(npx sentry-cli releases propose-version)
55+
56+
- name: Upload Source Maps to Sentry
57+
env:
58+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
59+
SENTRY_ORG: nodejs-org
60+
SENTRY_PROJECT: ${{ (github.event_name == 'workflow_dispatch' && 'dist-worker-prod') || 'dist-worker-staging' }}
61+
run: ./scripts/upload-sourcemaps.sh
6262

6363
- name: Alert on Failure
6464
if: failure() && github.repository == 'nodejs/release-cloudflare-worker'

package-lock.json

Lines changed: 76 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@eslint/eslintrc": "^3.3.3",
1919
"@eslint/js": "^9.39.1",
2020
"@reporters/github": "^1.7.2",
21-
"@sentry/cli": "^2.58.2",
21+
"@sentry/cli": "^2.58.4",
2222
"@types/mustache": "^4.2.6",
2323
"@types/node": "^25.0.3",
2424
"@typescript-eslint/eslint-plugin": "^8.54.0",
@@ -38,8 +38,8 @@
3838
},
3939
"dependencies": {
4040
"@aws-sdk/client-s3": "^3.859.0",
41+
"@sentry/cloudflare": "^10.37.0",
4142
"itty-router": "^5.0.22",
42-
"mustache": "^4.2.0",
43-
"toucan-js": "^4.1.1"
43+
"mustache": "^4.2.0"
4444
}
4545
}

scripts/upload-sourcemaps.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# Uploads a build's sourcemaps to Sentry so we can get a usable stacktrace when
4+
# errors happen.
5+
6+
if [ -z "$SENTRY_ORG" ]; then
7+
echo "SENTRY_ORG missing"
8+
exit 1
9+
fi
10+
11+
if [ -z "$SENTRY_PROJECT" ]; then
12+
echo "SENTRY_PROJECT missing"
13+
exit 1
14+
fi
15+
16+
SENTRY_RELEASE=$(npx sentry-cli releases propose-version)
17+
18+
echo Creating release $SENTRY_RELEASE
19+
20+
npx sentry-cli releases new $SENTRY_RELEASE
21+
--org=$SENTRY_ORG
22+
--project=$SENTRY_PROJECT
23+
24+
# Associate the commits since last release with this release
25+
npx sentry-cli releases set-commits --auto $SENTRY_RELEASE
26+
27+
npx sentry-cli sourcemaps upload \
28+
--org=$SENTRY_ORG \
29+
--project=$SENTRY_PROJECT \
30+
--release=$SENTRY_RELEASE \
31+
--strip-prefix 'dist/..' dist

src/context.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import type { Toucan } from 'toucan-js';
21
import type { Env } from './env';
32

43
export interface Context {
54
env: Env;
65
execution: ExecutionContext;
7-
sentry?: Toucan;
86
}

0 commit comments

Comments
 (0)