This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

further configuring of sentry

+53 -17
+1 -1
.github/workflows/fly-dev-deploy.yml
··· 11 11 steps: 12 12 - uses: actions/checkout@v4 13 13 - uses: superfly/flyctl-actions/setup-flyctl@master 14 - - run: flyctl deploy --remote-only -c fly.development.toml 14 + - run: flyctl deploy --remote-only -c fly.development.toml --build-arg GIT_SHA=${{ github.sha }} 15 15 env: 16 16 FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
+1 -1
.github/workflows/fly-prod-deploy.yml
··· 11 11 steps: 12 12 - uses: actions/checkout@v4 13 13 - uses: superfly/flyctl-actions/setup-flyctl@master 14 - - run: flyctl deploy --remote-only -c fly.production.toml 14 + - run: flyctl deploy --remote-only -c fly.production.toml --build-arg GIT_SHA=${{ github.sha }} 15 15 env: 16 16 FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
+9
Dockerfile
··· 16 16 # Throw-away build stage to reduce size of final image 17 17 FROM base AS build 18 18 19 + # Accept build argument for git SHA (for Sentry release tracking) 20 + ARG GIT_SHA 21 + 19 22 # Install packages needed to build node modules 20 23 RUN apt-get update -qq && \ 21 24 apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 ··· 36 39 37 40 # Final stage for app image 38 41 FROM base 42 + 43 + # Accept build argument for git SHA (needs to be declared in each stage) 44 + ARG GIT_SHA 45 + 46 + # Set as environment variable for runtime access (Sentry release tracking) 47 + ENV GIT_SHA=${GIT_SHA} 39 48 40 49 # Copy built application 41 50 COPY --from=build /app /app
+6 -6
fly.development.toml
··· 4 4 [build] 5 5 6 6 [processes] 7 - web = "npm start" 8 - feed-worker = "npm run worker:feeds" 9 - search-worker = "npm run worker:search" 10 - firehose-worker = "npm run worker:firehose" 11 - notification-worker = "npm run worker:notifications" 12 - sync-worker = "npm run worker:sync" 7 + web = "PROCESS_TYPE=web npm start" 8 + feed-worker = "PROCESS_TYPE=feed-worker npm run worker:feeds" 9 + search-worker = "PROCESS_TYPE=search-worker npm run worker:search" 10 + firehose-worker = "PROCESS_TYPE=firehose-worker npm run worker:firehose" 11 + notification-worker = "PROCESS_TYPE=notification-worker npm run worker:notifications" 12 + sync-worker = "PROCESS_TYPE=sync-worker npm run worker:sync" 13 13 14 14 [http_service] 15 15 internal_port = 3000
+6 -6
fly.production.toml
··· 4 4 [build] 5 5 6 6 [processes] 7 - web = "npm start" 8 - feed-worker = "npm run worker:feeds" 9 - search-worker = "npm run worker:search" 10 - firehose-worker = "npm run worker:firehose" 11 - notification-worker = "npm run worker:notifications" 12 - sync-worker = "npm run worker:sync" 7 + web = "PROCESS_TYPE=web npm start" 8 + feed-worker = "PROCESS_TYPE=feed-worker npm run worker:feeds" 9 + search-worker = "PROCESS_TYPE=search-worker npm run worker:search" 10 + firehose-worker = "PROCESS_TYPE=firehose-worker npm run worker:firehose" 11 + notification-worker = "PROCESS_TYPE=notification-worker npm run worker:notifications" 12 + sync-worker = "PROCESS_TYPE=sync-worker npm run worker:sync" 13 13 14 14 [http_service] 15 15 internal_port = 3000
+15 -3
src/instrument.ts
··· 5 5 6 6 // Only initialize Sentry if DSN is provided 7 7 if (sentryConfig.dsn) { 8 + // Determine release from environment (git SHA injected during deployment) 9 + const release = 10 + process.env.SENTRY_RELEASE || process.env.GIT_SHA || undefined; 11 + 8 12 Sentry.init({ 9 13 dsn: sentryConfig.dsn, 10 14 environment: sentryConfig.environment, 11 - // Performance Monitoring 12 - tracesSampleRate: 1.0, // Capture 100% of transactions for performance monitoring 15 + release: release, 16 + // Performance Monitoring - Start at 10% to manage costs (Fly.io recommendation) 17 + tracesSampleRate: 1.0, 13 18 // Send default PII (includes IP addresses, user data) 14 19 sendDefaultPii: true, 15 20 }); 16 21 22 + // Add Fly.io-specific context tags 23 + Sentry.setTags({ 24 + serverName: process.env.FLY_MACHINE_ID || 'local', 25 + region: process.env.FLY_REGION || 'local', 26 + processType: process.env.PROCESS_TYPE || 'unknown', 27 + }); 28 + 17 29 console.log( 18 - `[Sentry] Initialized for environment: ${sentryConfig.environment}`, 30 + `[Sentry] Initialized for environment: ${sentryConfig.environment}${release ? ` (release: ${release})` : ''}`, 19 31 ); 20 32 } else { 21 33 console.log('[Sentry] Skipped initialization (no DSN provided)');
+15
src/shared/infrastructure/http/middleware/AuthMiddleware.ts
··· 1 1 import { Request, Response, NextFunction } from 'express'; 2 + import * as Sentry from '@sentry/node'; 2 3 import { ITokenService } from '../../../../modules/user/application/services/ITokenService'; 3 4 import { CookieService } from '../services/CookieService'; 4 5 ··· 60 61 61 62 // Attach user DID to request for use in controllers 62 63 req.did = didResult.value; 64 + 65 + // Set user context in Sentry for error tracking 66 + Sentry.setUser({ id: didResult.value }); 63 67 64 68 // Continue to the next middleware or controller 65 69 next(); ··· 93 97 if (didResult.isOk() && didResult.value) { 94 98 // Attach user DID to request for use in controllers 95 99 req.did = didResult.value; 100 + 101 + // Set user context in Sentry for error tracking 102 + Sentry.setUser({ id: didResult.value }); 96 103 } 97 104 98 105 // Continue to the controller regardless of token validity ··· 132 139 } 133 140 134 141 req.did = didResult.value; 142 + 143 + // Set user context in Sentry for error tracking 144 + Sentry.setUser({ id: didResult.value }); 145 + 135 146 next(); 136 147 } catch (error) { 137 148 res.status(500).json({ message: 'Authentication error' }); ··· 168 179 } 169 180 170 181 req.did = didResult.value; 182 + 183 + // Set user context in Sentry for error tracking 184 + Sentry.setUser({ id: didResult.value }); 185 + 171 186 next(); 172 187 } catch (error) { 173 188 res.status(500).json({ message: 'Authentication error' });