-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update and activate sentry configuration + sentry multiple enviroment
- Loading branch information
Showing
19 changed files
with
110 additions
and
77 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import config from '../config' | ||
|
||
export type Environment = 'local' | 'test' | 'production' | ||
|
||
export function getEnvironment (): Environment { | ||
// Use SENTRY_ENVIRONMENT if available | ||
const sentryEnv = config.sentry.env.toLowerCase() | ||
if (sentryEnv) { | ||
// Validate that it's one of our expected environments | ||
if (['local', 'test', 'production'].includes(sentryEnv)) { | ||
return sentryEnv as Environment | ||
} | ||
// If invalid value, log warning and default to production | ||
console.warn(`Invalid SENTRY_ENVIRONMENT value: ${sentryEnv}. Defaulting to production`) | ||
return 'production' | ||
} | ||
// If no SENTRY_ENVIRONMENT set, assume local development | ||
return 'local' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as Sentry from '@sentry/node' | ||
import config from '../config' | ||
import { ProfilingIntegration } from '@sentry/profiling-node' | ||
import { getEnvironment } from './environments' | ||
|
||
const env = getEnvironment() | ||
|
||
// Configure sample rates based on environment | ||
const sampleRates = { | ||
local: { | ||
traces: 1.0, // Higher sampling in local for testing | ||
profiles: 1.0 | ||
}, | ||
test: { | ||
traces: 0.5, // Medium sampling in test | ||
profiles: 1.0 | ||
}, | ||
production: { | ||
traces: 0.1, // Lower sampling in production for performance | ||
profiles: 1.0 | ||
} | ||
} | ||
|
||
Sentry.init({ | ||
dsn: config.sentry.dsn, | ||
release: config.commitHash, | ||
environment: env, | ||
integrations: [ | ||
new ProfilingIntegration() | ||
], | ||
tracesSampleRate: sampleRates[env].traces, | ||
profilesSampleRate: sampleRates[env].profiles | ||
}) | ||
|
||
Sentry.setTags({ botName: config.botName }) | ||
|
||
export { Sentry } |