Merge pull request #719 from ente-io/store-sentry-config-in-code
Store sentry config in code
This commit is contained in:
commit
a5a4f44947
3
sentry.properties
Normal file
3
sentry.properties
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
defaults.url=https://sentry.ente.io/
|
||||||
|
defaults.org=ente
|
||||||
|
defaults.project=bada-frame
|
|
@ -1,10 +1,11 @@
|
||||||
|
const ENV_DEVELOPMENT = 'development';
|
||||||
|
|
||||||
module.exports.getIsSentryEnabled = () => {
|
module.exports.getIsSentryEnabled = () => {
|
||||||
if (process.env.NEXT_PUBLIC_IS_SENTRY_ENABLED) {
|
if (process.env.NEXT_PUBLIC_SENTRY_ENV === ENV_DEVELOPMENT) {
|
||||||
return process.env.NEXT_PUBLIC_IS_SENTRY_ENABLED === 'yes';
|
return false;
|
||||||
|
} else if (process.env.DISABLE_SENTRY === 'true') {
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (process.env.NEXT_PUBLIC_SENTRY_ENV) {
|
return true;
|
||||||
return process.env.NEXT_PUBLIC_SENTRY_ENV !== 'development';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
|
export const ENV_DEVELOPMENT = 'development';
|
||||||
|
export const ENV_PRODUCTION = 'production';
|
||||||
|
|
||||||
export const getSentryDSN = () =>
|
export const getSentryDSN = () =>
|
||||||
process.env.NEXT_PUBLIC_SENTRY_DSN ??
|
process.env.NEXT_PUBLIC_SENTRY_DSN ??
|
||||||
'https://60abb33b597c42f6a3fb27cd82c55101@sentry.ente.io/2';
|
'https://60abb33b597c42f6a3fb27cd82c55101@sentry.ente.io/2';
|
||||||
|
|
||||||
export const getSentryENV = () =>
|
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 const getSentryRelease = () => process.env.SENTRY_RELEASE;
|
||||||
|
|
||||||
export { getIsSentryEnabled } from '../../../sentryConfigUtil';
|
export { getIsSentryEnabled } from '../../../sentryConfigUtil';
|
||||||
|
|
||||||
|
export const isDEVSentryENV = () => getSentryENV() === ENV_DEVELOPMENT;
|
||||||
|
|
|
@ -33,6 +33,7 @@ import {
|
||||||
VISIBILITY_STATE,
|
VISIBILITY_STATE,
|
||||||
} from 'types/magicMetadata';
|
} from 'types/magicMetadata';
|
||||||
import { IsArchived, updateMagicMetadataProps } from 'utils/magicMetadata';
|
import { IsArchived, updateMagicMetadataProps } from 'utils/magicMetadata';
|
||||||
|
import { ENV_DEVELOPMENT } from 'constants/sentry';
|
||||||
|
|
||||||
export enum COLLECTION_OPS_TYPE {
|
export enum COLLECTION_OPS_TYPE {
|
||||||
ADD,
|
ADD,
|
||||||
|
@ -121,7 +122,7 @@ export function appendCollectionKeyToShareURL(
|
||||||
}
|
}
|
||||||
const bs58 = require('bs58');
|
const bs58 = require('bs58');
|
||||||
const sharableURL = new URL(url);
|
const sharableURL = new URL(url);
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === ENV_DEVELOPMENT) {
|
||||||
sharableURL.host = getAlbumSiteHost();
|
sharableURL.host = getAlbumSiteHost();
|
||||||
sharableURL.protocol = 'http';
|
sharableURL.protocol = 'http';
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,10 @@ import { ElectronFile } from 'types/upload';
|
||||||
import { convertBytesToHumanReadable } from 'utils/file/size';
|
import { convertBytesToHumanReadable } from 'utils/file/size';
|
||||||
import { formatDateTime } from 'utils/time';
|
import { formatDateTime } from 'utils/time';
|
||||||
import { saveLogLine, getLogs } from 'utils/storage';
|
import { saveLogLine, getLogs } from 'utils/storage';
|
||||||
|
import { isDEVSentryENV } from 'constants/sentry';
|
||||||
|
|
||||||
export function addLogLine(log: string) {
|
export function addLogLine(log: string) {
|
||||||
if (!process.env.NEXT_PUBLIC_SENTRY_ENV) {
|
if (isDEVSentryENV()) {
|
||||||
console.log(log);
|
console.log(log);
|
||||||
}
|
}
|
||||||
saveLogLine({
|
saveLogLine({
|
||||||
|
@ -14,7 +15,7 @@ export function addLogLine(log: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addLocalLog = (getLog: () => string) => {
|
export const addLocalLog = (getLog: () => string) => {
|
||||||
if (!process.env.NEXT_PUBLIC_SENTRY_ENV) {
|
if (isDEVSentryENV()) {
|
||||||
console.log(getLog());
|
console.log(getLog());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as Sentry from '@sentry/nextjs';
|
import * as Sentry from '@sentry/nextjs';
|
||||||
|
import { isDEVSentryENV } from 'constants/sentry';
|
||||||
import { addLogLine } from 'utils/logging';
|
import { addLogLine } from 'utils/logging';
|
||||||
import { getSentryUserID } from 'utils/user';
|
import { getSentryUserID } from 'utils/user';
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ export const logError = (
|
||||||
error?.stack
|
error?.stack
|
||||||
} msg: ${msg} info: ${JSON.stringify(info)}`
|
} msg: ${msg} info: ${JSON.stringify(info)}`
|
||||||
);
|
);
|
||||||
if (!process.env.NEXT_PUBLIC_SENTRY_ENV) {
|
if (isDEVSentryENV()) {
|
||||||
console.log(error, { msg, info });
|
console.log(error, { msg, info });
|
||||||
}
|
}
|
||||||
Sentry.captureException(err, {
|
Sentry.captureException(err, {
|
||||||
|
|
Loading…
Reference in a new issue