Merge pull request #719 from ente-io/store-sentry-config-in-code

Store sentry config in code
This commit is contained in:
Vishnu Mohandas 2022-09-23 17:59:22 +05:30 committed by GitHub
commit a5a4f44947
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 11 deletions

3
sentry.properties Normal file
View file

@ -0,0 +1,3 @@
defaults.url=https://sentry.ente.io/
defaults.org=ente
defaults.project=bada-frame

View file

@ -1,10 +1,11 @@
const ENV_DEVELOPMENT = 'development';
module.exports.getIsSentryEnabled = () => {
if (process.env.NEXT_PUBLIC_IS_SENTRY_ENABLED) {
return process.env.NEXT_PUBLIC_IS_SENTRY_ENABLED === 'yes';
} else {
if (process.env.NEXT_PUBLIC_SENTRY_ENV) {
return process.env.NEXT_PUBLIC_SENTRY_ENV !== 'development';
}
}
if (process.env.NEXT_PUBLIC_SENTRY_ENV === ENV_DEVELOPMENT) {
return false;
} else if (process.env.DISABLE_SENTRY === 'true') {
return false;
} else {
return true;
}
};

View file

@ -1,10 +1,15 @@
export const ENV_DEVELOPMENT = 'development';
export const ENV_PRODUCTION = 'production';
export const getSentryDSN = () =>
process.env.NEXT_PUBLIC_SENTRY_DSN ??
'https://60abb33b597c42f6a3fb27cd82c55101@sentry.ente.io/2';
export const getSentryENV = () =>
process.env.NEXT_PUBLIC_SENTRY_ENV ?? 'development';
process.env.NEXT_PUBLIC_SENTRY_ENV ?? ENV_PRODUCTION;
export const getSentryRelease = () => process.env.SENTRY_RELEASE;
export { getIsSentryEnabled } from '../../../sentryConfigUtil';
export const isDEVSentryENV = () => getSentryENV() === ENV_DEVELOPMENT;

View file

@ -33,6 +33,7 @@ import {
VISIBILITY_STATE,
} from 'types/magicMetadata';
import { IsArchived, updateMagicMetadataProps } from 'utils/magicMetadata';
import { ENV_DEVELOPMENT } from 'constants/sentry';
export enum COLLECTION_OPS_TYPE {
ADD,
@ -121,7 +122,7 @@ export function appendCollectionKeyToShareURL(
}
const bs58 = require('bs58');
const sharableURL = new URL(url);
if (process.env.NODE_ENV === 'development') {
if (process.env.NODE_ENV === ENV_DEVELOPMENT) {
sharableURL.host = getAlbumSiteHost();
sharableURL.protocol = 'http';
}

View file

@ -2,9 +2,10 @@ import { ElectronFile } from 'types/upload';
import { convertBytesToHumanReadable } from 'utils/file/size';
import { formatDateTime } from 'utils/time';
import { saveLogLine, getLogs } from 'utils/storage';
import { isDEVSentryENV } from 'constants/sentry';
export function addLogLine(log: string) {
if (!process.env.NEXT_PUBLIC_SENTRY_ENV) {
if (isDEVSentryENV()) {
console.log(log);
}
saveLogLine({
@ -14,7 +15,7 @@ export function addLogLine(log: string) {
}
export const addLocalLog = (getLog: () => string) => {
if (!process.env.NEXT_PUBLIC_SENTRY_ENV) {
if (isDEVSentryENV()) {
console.log(getLog());
}
};

View file

@ -1,4 +1,5 @@
import * as Sentry from '@sentry/nextjs';
import { isDEVSentryENV } from 'constants/sentry';
import { addLogLine } from 'utils/logging';
import { getSentryUserID } from 'utils/user';
@ -16,7 +17,7 @@ export const logError = (
error?.stack
} msg: ${msg} info: ${JSON.stringify(info)}`
);
if (!process.env.NEXT_PUBLIC_SENTRY_ENV) {
if (isDEVSentryENV()) {
console.log(error, { msg, info });
}
Sentry.captureException(err, {