How to Setup Sentry Integration for SyRF Services¶
Overview¶
The SyRF CI/CD pipeline is configured to automatically:
- Web Service: Upload sourcemaps and create releases in Sentry
- .NET Services (API, Project Management, Quartz): Create releases with commit association
This enables:
- Readable stack traces for minified JavaScript errors
- "Suspect Commits" feature to identify which commit introduced a bug
- Release tracking and health monitoring
Prerequisites¶
- Admin access to the GitHub repository
- Admin access to the Sentry organization (camarades)
Sentry Projects¶
| Service | Sentry Project | Release Format |
|---|---|---|
| Web | syrf-web |
syrf-web@{version} |
| API | syrf-api |
syrf-api@{version} |
| Project Management | syrf-project-management |
syrf-projectmanagement@{version} |
| Quartz | syrf-quartz |
syrf-quartz@{version} |
Setup Steps¶
1. Generate Sentry Auth Token¶
- Log into Sentry at https://sentry.io
- Navigate to Settings → Auth Tokens
- Click Create New Token
- Configure the token:
- Name:
syrf-ci-cd - Scopes (required):
project:releases- Create and finalize releasesproject:write- Upload sourcemapsorg:read- Read organization details
- Click Create Token
- Copy the generated token (you won't be able to see it again)
2. Add Token to GitHub Repository Secrets¶
- Navigate to the GitHub repository: https://github.com/camaradesuk/syrf
- Go to Settings → Secrets and variables → Actions
- Click New repository secret
- Create the secret:
- Name:
SENTRY_AUTH_TOKEN - Value: Paste the token from step 1.6
- Click Add secret
How It Works¶
Web Service (Angular)¶
The build-web-artifacts job in CI/CD:
- name: Upload sourcemaps to Sentry
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: camarades
SENTRY_PROJECT: syrf-web
run: |
# Release name must match Angular SDK: syrf-web@{version}
RELEASE="syrf-web@${VERSION}"
# Create release and associate commits
pnpm exec sentry-cli releases new "${RELEASE}"
pnpm exec sentry-cli releases set-commits "${RELEASE}" --auto
# Inject debug IDs and upload sourcemaps
pnpm exec sentry-cli sourcemaps inject ./dist/browser/
pnpm exec sentry-cli sourcemaps upload --release "${RELEASE}" ./dist/browser/
# Finalize release
pnpm exec sentry-cli releases finalize "${RELEASE}"
The Angular app initializes Sentry in main.ts with:
- DSN from configuration
- Release version matching CI/CD release name
- Browser tracing integration
- Environment-specific settings
.NET Services¶
The create-sentry-releases job creates releases after Docker builds:
- name: Create Sentry releases for .NET services
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: camarades
run: |
sentry-cli releases new "syrf-api@${VERSION}" --project syrf-api
sentry-cli releases set-commits "syrf-api@${VERSION}" --auto --project syrf-api
sentry-cli releases finalize "syrf-api@${VERSION}" --project syrf-api
.NET services configure Sentry in HostExtensions.cs:
o.Release = gitVersion.ReleaseName; // Format: servicename@semver
o.Environment = runtimeEnvironment;
o.TracesSampleRate = customSentryConfig.TracingSampleRate;
Verification¶
After setting up the token:
- Push a change that triggers a service build
- Check the GitHub Actions logs:
- Web: Look for "Upload sourcemaps to Sentry" step in
build-web-artifacts - .NET: Look for "Create Sentry releases" step in
create-sentry-releases - Check Sentry dashboard:
- Navigate to Releases in each project
- Verify the new release appears with associated commits
Troubleshooting¶
Token Not Working¶
- Verify the token has the correct scopes (
project:releases,project:write,org:read) - Check the token hasn't expired
- Ensure the secret name is exactly
SENTRY_AUTH_TOKEN
Sourcemaps Not Uploading (Web)¶
- Check the Sentry organization name matches (
camarades) - Check the Sentry project name matches (
syrf-web) - Verify the dist folder structure (
dist/browser/) - Check that debug IDs are being injected (look for
sentry-cli sourcemaps injectoutput)
Commits Not Associating¶
- Ensure
fetch-depth: 0is set in the checkout step - Verify the repository has proper git history
- Check that the release name matches what the SDK sends
Runtime Sourcemap Removal (Web)¶
Sourcemaps are included in the Docker image but removed at runtime in production:
- The
remove-sourcemaps.shscript checksSPA__RuntimeEnvironment - If set to
production, all.mapfiles are deleted at container startup - In dev/staging environments, sourcemaps remain for debugging
.NET Release Names Not Matching¶
The .NET SDK gets the release name from GitVersion.ReleaseName:
Ensure the CI/CD release creation uses the same format.
Configuration Reference¶
Web Service (main.ts)¶
Sentry.init({
dsn: config.sentryDsn,
environment: config.runtimeEnvironment,
release: config.releaseVersion,
integrations: [Sentry.browserTracingIntegration()],
tracesSampleRate: 1.0,
tracePropagationTargets: [...config.protectedUrls],
});
.NET Services (appsettings.json)¶
{
"Sentry": {
"Dsn": "CHANGEME",
"IncludeRequestPayload": true,
"SendDefaultPii": true,
"MinimumBreadcrumbLevel": "Debug",
"MinimumEventLevel": "Warning",
"AttachStackTrace": true
},
"CustomSentryConfig": {
"Enabled": true,
"OpenTelemetryTracing": false,
"TracingSampleRate": 1.0
}
}