Further prune down Sentry

This commit is contained in:
Manav Rathi 2024-02-10 17:36:08 +05:30
parent 0119cddd50
commit c34654e995
8 changed files with 12 additions and 63 deletions

View file

@ -90,7 +90,7 @@ export default function App(props: EnteAppProps) {
const main = async () => {
addLogLine(`userID: ${(getData(LS_KEYS.USER) as User)?.id}`);
addLogLine(`sentryID: ${await getSentryUserID()}`);
addLogLine(`sentry release ID: ${process.env.SENTRY_RELEASE}`);
addLogLine(`sentry release: ${process.env.SENTRY_RELEASE}`);
};
main();
}, []);

View file

@ -57,13 +57,6 @@
#
# NEXT_PUBLIC_ENTE_FAMILY_PORTAL_ENDPOINT = http://localhost:3003
# Set this to true to disable reporting of crashes to Sentry.
#
# Crash reporting is disabled if the user has opted out. This provides another
# way to disable crash reporting, say for local test branches.
#
# NEXT_PUBLIC_DISABLE_SENTRY=true
# Set this to "true" to disable the upload of files of Cloudflare Workers.
#
# These workers were introduced as a way of make the file uploads faster
@ -77,4 +70,5 @@
# The path of the JSON file which contains the expected results of our
# integration tests. See `upload.test.ts` for more details.
#
# NEXT_PUBLIC_ENTE_TEST_EXPECTED_JSON_PATH = /path/to/dataset/expected.json

View file

@ -171,7 +171,7 @@ export default function App(props: EnteAppProps) {
const main = async () => {
addLogLine(`userID: ${(getData(LS_KEYS.USER) as User)?.id}`);
addLogLine(`sentryID: ${await getSentryUserID()}`);
addLogLine(`sentry release ID: ${process.env.SENTRY_RELEASE}`);
addLogLine(`sentry release: ${process.env.SENTRY_RELEASE}`);
};
main();
}, []);

View file

@ -1,5 +0,0 @@
export const isDisableSentryFlagSet = () => {
return process.env.NEXT_PUBLIC_DISABLE_SENTRY === 'true';
};
export const getSentryRelease = () => process.env.SENTRY_RELEASE;

View file

@ -1,17 +0,0 @@
const ENV_DEVELOPMENT = 'development';
const ENV_PRODUCTION = 'production';
const ENV_TEST = 'test';
module.exports = {
ENV_DEVELOPMENT,
ENV_PRODUCTION,
ENV_TEST,
};
module.exports.getAppEnv = () => {
return process.env.NEXT_PUBLIC_APP_ENV ?? ENV_PRODUCTION;
};
module.exports.isDisableSentryFlagSet = () => {
return process.env.NEXT_PUBLIC_DISABLE_SENTRY === 'true';
};

View file

@ -1,11 +1,12 @@
const { withSentryConfig } = require('@sentry/nextjs');
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
const { getGitSha, getIsSentryEnabled } = require('./utils/sentry');
const cp = require('child_process');
const GIT_SHA = getGitSha();
const IS_SENTRY_ENABLED = getIsSentryEnabled();
const gitSHA = cp.execSync('git rev-parse --short HEAD', {
cwd: __dirname,
encoding: 'utf8',
});
module.exports = (phase) =>
withSentryConfig(
@ -43,7 +44,8 @@ module.exports = (phase) =>
],
env: {
// Sentry reads this env var to set the "release" value.
SENTRY_RELEASE: GIT_SHA,
// TODO(MR): We also set this below, are both places required?
SENTRY_RELEASE: gitSHA,
},
// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
@ -55,7 +57,7 @@ module.exports = (phase) =>
},
},
{
dryRun: phase === PHASE_DEVELOPMENT_SERVER || !IS_SENTRY_ENABLED,
release: GIT_SHA,
dryRun: phase === PHASE_DEVELOPMENT_SERVER,
release: gitSHA,
}
);

View file

@ -1,18 +0,0 @@
const {
getAppEnv,
ENV_DEVELOPMENT,
isDisableSentryFlagSet,
} = require('../env.js');
const cp = require('child_process');
module.exports.getIsSentryEnabled = () => {
const isAppENVDevelopment = getAppEnv() === ENV_DEVELOPMENT;
const isSentryDisabled = isDisableSentryFlagSet();
return !isAppENVDevelopment && !isSentryDisabled;
};
module.exports.getGitSha = () =>
cp.execSync('git rev-parse --short HEAD', {
cwd: __dirname,
encoding: 'utf8',
});

View file

@ -4,10 +4,8 @@ import {
setLocalSentryUserID,
} from '@ente/shared/storage/localStorage/helpers';
import isElectron from 'is-electron';
import { isDisableSentryFlagSet } from '@ente/shared/apps/env';
import { ApiError } from '../error';
import { HttpStatusCode } from 'axios';
import { isDevBuild } from '../network/api';
export async function getSentryUserID() {
if (isElectron()) {
@ -46,8 +44,3 @@ export function isErrorUnnecessaryForSentry(error: any) {
}
return false;
}
export const getIsSentryEnabled = () => {
const isSentryDisabled = isDisableSentryFlagSet();
return !isDevBuild() && !isSentryDisabled;
};