Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sentry source maps #174

Closed
wants to merge 10 commits into from
3 changes: 3 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- name: Set up QEMU
if: startsWith(github.ref, 'refs/tags/')
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand Down Expand Up @@ -65,3 +66,5 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
env:
SENTRY_AUTH_TOKEN: ${{ github.ref == 'refs/tags/*' && secrets.SENTRY_AUTH_TOKEN || '' }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ test/build

.nx/cache
.vscode/
.sentryclirc

# Sentry Config File
.sentryclirc
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# production ready dockerfile that runs pnpm start
FROM node:20-alpine

ARG SENTRY_AUTH_TOKEN

# set working directory
WORKDIR /app

Expand All @@ -22,7 +24,7 @@ RUN pnpm fetch
RUN pnpm install -r

# copy source code
RUN pnpm build
RUN SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN} pnpm build

# remove dev dependencies
# RUN pnpm clean-modules
Expand Down
146 changes: 144 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if [ -n "$SENTRY_AUTH_TOKEN" ]; then
# Run your script or command here
echo "Running script because SENTRY_AUTH_TOKEN is set and not empty"
pnpm run compile-tsc
pnpm run sentry:sourcemaps
# Example: ./your_script.sh
else
echo "SENTRY_AUTH_TOKEN is not set or empty"
pnpm run compile-tsc
fi

7 changes: 5 additions & 2 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"*.js"
],
"scripts": {
"build": "tsc -p ./tsconfig.json && tsc-alias -p tsconfig.json",
"compile-tsc": "tsc -p ./tsconfig.json && tsc-alias -p tsconfig.json",
"build": "./build.sh",
"dev": "nodemon --exec DOTENV_CONFIG_PATH=$(pwd)/../.env ts-node -r tsconfig-paths/register cli/alto.ts run",
"test": "test -d test && mocha test/**/*.test.ts --exit || echo 'No test folder found. Skipping tests.'",
"lint": "eslint src/**/*.ts",
"lint:fix": "eslint src/**/*.ts --fix"
"lint:fix": "eslint src/**/*.ts --fix",
"sentry:sourcemaps": "sentry-cli sourcemaps inject --org pimlico --project alto ./lib && sentry-cli sourcemaps upload --org pimlico --project alto ./lib"
},
"dependencies": {
"@fastify/websocket": "^10.0.1",
Expand All @@ -33,6 +35,7 @@
"@opentelemetry/sdk-node": "^0.46.0",
"@opentelemetry/sdk-trace-base": "^1.19.0",
"@opentelemetry/semantic-conventions": "^1.19.0",
"@sentry/cli": "^2.30.4",
"@sentry/node": "^7.83.0",
"@types/node": "^18.16.3",
"@types/ws": "^8.5.10",
Expand Down
10 changes: 9 additions & 1 deletion src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"declaration": true,
"declarationMap": true,
"moduleResolution": "node",

"paths": {
"@alto/cli": [
"./cli"
Expand All @@ -35,7 +36,14 @@
"@alto/utils": [
"./utils"
]
}
},

"inlineSources": true,

// Set `sourceRoot` to "/" to strip the build path prefix
// from generated source code references.
// This improves issue grouping in Sentry.
"sourceRoot": "/"
},
"ts-node": {
"swc": true
Expand Down
Loading