Merge pull request #289 from ente-io/rename-sentry-variables

Rename sentry variables
This commit is contained in:
abhinavkgrd 2022-01-09 18:00:30 +05:30 committed by GitHub
commit cc67038b93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 45 deletions

View file

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

View file

@ -4,6 +4,7 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
const withWorkbox = require('@ente-io/next-with-workbox'); const withWorkbox = require('@ente-io/next-with-workbox');
const { withSentryConfig } = require('@sentry/nextjs'); const { withSentryConfig } = require('@sentry/nextjs');
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
const { const {
getGitSha, getGitSha,
@ -14,42 +15,46 @@ const {
CSP_DIRECTIVES, CSP_DIRECTIVES,
WORKBOX_CONFIG, WORKBOX_CONFIG,
ALL_ROUTES, ALL_ROUTES,
isSentryEnabled, getIsSentryEnabled,
} = require('./configUtil'); } = require('./configUtil');
const GIT_SHA = getGitSha(); const GIT_SHA = getGitSha();
const SENTRY_ENABLED = isSentryEnabled(); const IS_SENTRY_ENABLED = getIsSentryEnabled();
module.exports = withSentryConfig( module.exports = (phase) =>
withWorkbox( withSentryConfig(
withBundleAnalyzer({ withWorkbox(
env: { withBundleAnalyzer({
SENTRY_RELEASE: GIT_SHA, env: {
}, SENTRY_RELEASE: GIT_SHA,
workbox: WORKBOX_CONFIG, },
workbox: WORKBOX_CONFIG,
headers() { headers() {
return [ return [
{ {
// Apply these headers to all routes in your application.... // Apply these headers to all routes in your application....
source: ALL_ROUTES, source: ALL_ROUTES,
headers: convertToNextHeaderFormat({ headers: convertToNextHeaderFormat({
...COOP_COEP_HEADERS, ...COOP_COEP_HEADERS,
...WEB_SECURITY_HEADERS, ...WEB_SECURITY_HEADERS,
...buildCSPHeader(CSP_DIRECTIVES), ...buildCSPHeader(CSP_DIRECTIVES),
}), }),
}, },
]; ];
}, },
// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j // https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
webpack: (config, { isServer }) => { webpack: (config, { isServer }) => {
if (!isServer) { if (!isServer) {
config.resolve.fallback.fs = false; config.resolve.fallback.fs = false;
} }
return config; return config;
}, },
}) })
), ),
{ release: GIT_SHA, dryRun: !SENTRY_ENABLED } {
); release: GIT_SHA,
dryRun: phase === PHASE_DEVELOPMENT_SERVER || !IS_SENTRY_ENABLED,
}
);

View file

@ -5,18 +5,18 @@ import {
getSentryDSN, getSentryDSN,
getSentryENV, getSentryENV,
getSentryRelease, getSentryRelease,
isSentryEnabled, getIsSentryEnabled,
} from 'constants/sentry'; } from 'constants/sentry';
const SENTRY_DSN = getSentryDSN(); const SENTRY_DSN = getSentryDSN();
const SENTRY_ENV = getSentryENV(); const SENTRY_ENV = getSentryENV();
const SENTRY_RELEASE = getSentryRelease(); const SENTRY_RELEASE = getSentryRelease();
const ENABLED = isSentryEnabled(); const IS_ENABLED = getIsSentryEnabled();
Sentry.setUser({ id: getUserAnonymizedID() }); Sentry.setUser({ id: getUserAnonymizedID() });
Sentry.init({ Sentry.init({
dsn: SENTRY_DSN, dsn: SENTRY_DSN,
enabled: ENABLED, enabled: IS_ENABLED,
environment: SENTRY_ENV, environment: SENTRY_ENV,
release: SENTRY_RELEASE, release: SENTRY_RELEASE,
attachStacktrace: true, attachStacktrace: true,

View file

@ -3,17 +3,17 @@ import {
getSentryDSN, getSentryDSN,
getSentryENV, getSentryENV,
getSentryRelease, getSentryRelease,
isSentryEnabled, getIsSentryEnabled,
} from 'constants/sentry'; } from 'constants/sentry';
const SENTRY_DSN = getSentryDSN(); const SENTRY_DSN = getSentryDSN();
const SENTRY_ENV = getSentryENV(); const SENTRY_ENV = getSentryENV();
const SENTRY_RELEASE = getSentryRelease(); const SENTRY_RELEASE = getSentryRelease();
const ENABLED = isSentryEnabled(); const IS_ENABLED = getIsSentryEnabled();
Sentry.init({ Sentry.init({
dsn: SENTRY_DSN, dsn: SENTRY_DSN,
enabled: ENABLED, enabled: IS_ENABLED,
environment: SENTRY_ENV, environment: SENTRY_ENV,
release: SENTRY_RELEASE, release: SENTRY_RELEASE,
autoSessionTracking: false, autoSessionTracking: false,

View file

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

View file

@ -7,4 +7,4 @@ export const getSentryENV = () =>
export const getSentryRelease = () => process.env.SENTRY_RELEASE; export const getSentryRelease = () => process.env.SENTRY_RELEASE;
export { isSentryEnabled } from '../../../sentryConfigUtil'; export { getIsSentryEnabled } from '../../../sentryConfigUtil';