Merge pull request #280 from ente-io/disable-sentry-release-cli-for-local-build

disable sentry release cli for local build
This commit is contained in:
Vishnu Mohandas 2022-01-08 18:44:27 +05:30 committed by GitHub
commit 5d3e284fcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 13 deletions

View file

@ -1,4 +1,5 @@
const cp = require('child_process');
const { isSentryEnabled } = require('./sentryConfigUtil');
module.exports = {
COOP_COEP_HEADERS: {
@ -50,4 +51,5 @@ module.exports = {
cwd: __dirname,
encoding: 'utf8',
}),
isSentryEnabled: isSentryEnabled,
};

View file

@ -14,15 +14,18 @@ const {
CSP_DIRECTIVES,
WORKBOX_CONFIG,
ALL_ROUTES,
isSentryEnabled,
} = require('./configUtil');
const gitSha = getGitSha();
const GIT_SHA = getGitSha();
const SENTRY_ENABLED = isSentryEnabled();
module.exports = withSentryConfig(
withWorkbox(
withBundleAnalyzer({
env: {
SENTRY_RELEASE: gitSha,
SENTRY_RELEASE: GIT_SHA,
},
workbox: WORKBOX_CONFIG,
@ -48,5 +51,5 @@ module.exports = withSentryConfig(
},
})
),
{ release: gitSha }
{ release: GIT_SHA, dryRun: !SENTRY_ENABLED }
);

View file

@ -1,18 +1,24 @@
import * as Sentry from '@sentry/nextjs';
import { getSentryTunnelUrl } from 'utils/common/apiUtil';
import { getUserAnonymizedID } from 'utils/user';
import {
getSentryDSN,
getSentryENV,
getSentryRelease,
isSentryEnabled,
} from 'constants/sentry';
const SENTRY_DSN =
process.env.NEXT_PUBLIC_SENTRY_DSN ??
'https://860186db60c54c7fbacfe255124958e8@errors.ente.io/4';
const SENTRY_ENV = process.env.NEXT_PUBLIC_SENTRY_ENV ?? 'development';
const SENTRY_DSN = getSentryDSN();
const SENTRY_ENV = getSentryENV();
const SENTRY_RELEASE = getSentryRelease();
const ENABLED = isSentryEnabled();
Sentry.setUser({ id: getUserAnonymizedID() });
Sentry.init({
dsn: SENTRY_DSN,
enabled: SENTRY_ENV !== 'development',
enabled: ENABLED,
environment: SENTRY_ENV,
release: process.env.SENTRY_RELEASE,
release: SENTRY_RELEASE,
attachStacktrace: true,
autoSessionTracking: false,
tunnel: getSentryTunnelUrl(),

View file

@ -1,12 +1,20 @@
import * as Sentry from '@sentry/nextjs';
import {
getSentryDSN,
getSentryENV,
getSentryRelease,
isSentryEnabled,
} from 'constants/sentry';
const SENTRY_DSN = process.env.NEXT_PUBLIC_SENTRY_DSN ?? 'https://860186db60c54c7fbacfe255124958e8@errors.ente.io/4';
const SENTRY_ENV = process.env.NEXT_PUBLIC_SENTRY_ENV ?? 'development';
const SENTRY_DSN = getSentryDSN();
const SENTRY_ENV = getSentryENV();
const SENTRY_RELEASE = getSentryRelease();
const ENABLED = isSentryEnabled();
Sentry.init({
dsn: SENTRY_DSN,
enabled: SENTRY_ENV !== 'development',
enabled: ENABLED,
environment: SENTRY_ENV,
release: process.env.SENTRY_RELEASE,
release: SENTRY_RELEASE,
autoSessionTracking: false,
});

10
sentryConfigUtil.js Normal file
View file

@ -0,0 +1,10 @@
module.exports.isSentryEnabled = () => {
if (process.env.SENTRY_ENABLED) {
return process.env.SENTRY_ENABLED === 'yes';
} else {
if (process.env.NEXT_PUBLIC_SENTRY_ENV) {
return process.env.NEXT_PUBLIC_SENTRY_ENV !== 'development';
}
}
return false;
};

View file

@ -0,0 +1,10 @@
export const getSentryDSN = () =>
process.env.NEXT_PUBLIC_SENTRY_DSN ??
'https://860186db60c54c7fbacfe255124958e8@errors.ente.io/4';
export const getSentryENV = () =>
process.env.NEXT_PUBLIC_SENTRY_ENV ?? 'development';
export const getSentryRelease = () => process.env.SENTRY_RELEASE;
export { isSentryEnabled } from '../../../sentryConfigUtil';