π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Prune
Manav Rathi0119cddd5081
diff --git a/apps/photos/.env.development b/apps/photos/.env.developmentindex 6d48d6220b..670de82528 100644--- a/apps/photos/.env.development+++ b/apps/photos/.env.development@@ -20,9 +20,10 @@## A development build behaves differently in some aspects:#-# 1. Logs go to the browser console (in addition to the log file).+# 1. Logs go to the browser console (in addition to the log file), and there is+# additional logging too.#-# 2. Sentry crash reports go to a separate project.+# 2. Crash reports go to a separate "development" environment in Sentry.## Note that even in development build, the app still connects to the production# APIs by default (can be customized using the env vars below). This is usuallydiff --git a/packages/shared/apps/constants.ts b/packages/shared/apps/constants.tsindex 34016bf832..30c1b55940 100644--- a/packages/shared/apps/constants.ts+++ b/packages/shared/apps/constants.ts@@ -6,12 +6,6 @@ export enum APPS {ALBUMS = 'ALBUMS',}-export enum APP_ENV {- DEVELOPMENT = 'development',- PRODUCTION = 'production',- TEST = 'test',-}-export const CLIENT_PACKAGE_NAMES = new Map([[APPS.ALBUMS, 'io.ente.albums.web'],[APPS.PHOTOS, 'io.ente.photos.web'],diff --git a/packages/shared/apps/env.ts b/packages/shared/apps/env.tsindex 578415328f..988bedc454 100644--- a/packages/shared/apps/env.ts+++ b/packages/shared/apps/env.ts@@ -1,8 +1,3 @@-import { APP_ENV } from './constants';--export const getAppEnv = () =>- process.env.NEXT_PUBLIC_APP_ENV ?? APP_ENV.PRODUCTION;-export const isDisableSentryFlagSet = () => {return process.env.NEXT_PUBLIC_DISABLE_SENTRY === 'true';};diff --git a/packages/shared/logging/index.ts b/packages/shared/logging/index.tsindex 9f257cb3a0..d5c25d2af3 100644--- a/packages/shared/logging/index.ts+++ b/packages/shared/logging/index.ts@@ -1,9 +1,8 @@import isElectron from 'is-electron';import { logError } from '@ente/shared/sentry';-import { getAppEnv } from '../apps/env';-import { APP_ENV } from '../apps/constants';import { formatLog, logWeb } from './web';import { WorkerSafeElectronService } from '../electron/service';+import { isDevBuild } from '../network/api';export const MAX_LOG_SIZE = 5 * 1024 * 1024; // 5MBexport const MAX_LOG_LINES = 1000;@@ -14,7 +13,7 @@ export function addLogLine() {try {const completeLog = [log, ...optionalParams].join(' ');- if (getAppEnv() === APP_ENV.DEVELOPMENT) {+ if (isDevBuild()) {console.log(completeLog);}if (isElectron()) {@@ -29,7 +28,7 @@ export function addLogLine(}export const addLocalLog = (getLog: () => string) => {- if (getAppEnv() === APP_ENV.DEVELOPMENT) {+ if (isDevBuild()) {console.log(formatLog({logLine: getLog(),diff --git a/packages/shared/network/api.ts b/packages/shared/network/api.tsindex 6e72baa240..ca5f27f7ed 100644--- a/packages/shared/network/api.ts+++ b/packages/shared/network/api.ts@@ -75,15 +75,15 @@ export const getFamilyPortalURL = () => {};/**- * A build is considered as a development build if the NODE_ENV environment- * variable is set to 'development'.+ * A build is considered as a development build if either the NODE_ENV is+ * environment variable is set to 'development'.*- * This automatically happens when we run `yarn dev:foo`, but we can also- * explictly set it to development before invoking the build. From Next.js docs:+ * NODE_ENV is automatically set to 'development' when we run `yarn dev`. From+ * Next.js docs:*- * > If the environment variable NODE_ENV is unassigned, Next.js- * automatically assigns development when running the `next dev` command,- * or production for all other commands.+ * > If the environment variable NODE_ENV is unassigned, Next.js automatically+ * assigns development when running the `next dev` command, or production for+ * all other commands.*/export const isDevBuild = () => {return process.env.NODE_ENV === 'development';diff --git a/packages/shared/next/next.config.base.js b/packages/shared/next/next.config.base.jsindex 0df2ebcb04..b7537752c3 100644--- a/packages/shared/next/next.config.base.js+++ b/packages/shared/next/next.config.base.js@@ -42,8 +42,8 @@ module.exports = (phase) =>'@mui/icons-material',],env: {+ // Sentry reads this env var to set the "release" value.SENTRY_RELEASE: GIT_SHA,- NEXT_PUBLIC_IS_TEST_APP: process.env.IS_TEST_RELEASE || 'false',},// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6jdiff --git a/packages/shared/sentry/config/sentry.config.base.ts b/packages/shared/sentry/config/sentry.config.base.tsindex 6f3bbed6ed..a4349ad444 100644--- a/packages/shared/sentry/config/sentry.config.base.ts+++ b/packages/shared/sentry/config/sentry.config.base.ts@@ -2,44 +2,30 @@ import * as Sentry from '@sentry/nextjs';import { getSentryUserID } from '@ente/shared/sentry/utils';import { runningInBrowser } from '@ente/shared/platform';import { getHasOptedOutOfCrashReports } from '@ente/shared/storage/localStorage/helpers';-import { getIsSentryEnabled } from '@ente/shared/sentry/utils';-import { getAppEnv, getSentryRelease } from '@ente/shared/apps/env';export const setupSentry = async (dsn: string) => {- const HAS_OPTED_OUT_OF_CRASH_REPORTING =- runningInBrowser() && getHasOptedOutOfCrashReports();+ const optedOut = runningInBrowser() && getHasOptedOutOfCrashReports();+ if (optedOut) return;- if (!HAS_OPTED_OUT_OF_CRASH_REPORTING) {- const APP_ENV = getAppEnv();- const IS_ENABLED = getIsSentryEnabled();- const SENTRY_RELEASE = getSentryRelease();+ Sentry.init({+ dsn,+ environment: process.env.NODE_ENV,+ attachStacktrace: true,+ autoSessionTracking: false,+ tunnel: 'https://sentry-reporter.ente.io',+ beforeSend(event) {+ event.request = event.request || {};+ const currentURL = new URL(document.location.href);+ currentURL.hash = '';+ event.request.url = currentURL.href;+ return event;+ },+ integrations: function (i) {+ return i.filter(function (i) {+ return i.name !== 'Breadcrumbs';+ });+ },+ });- Sentry.init({- dsn,- enabled: IS_ENABLED,- environment: APP_ENV,- release: SENTRY_RELEASE,- attachStacktrace: true,- autoSessionTracking: false,- tunnel: 'https://sentry-reporter.ente.io',- beforeSend(event) {- event.request = event.request || {};- const currentURL = new URL(document.location.href);- currentURL.hash = '';- event.request.url = currentURL.href;- return event;- },- integrations: function (i) {- return i.filter(function (i) {- return i.name !== 'Breadcrumbs';- });- },- // ...- // Note: if you want to override the automatic release value, do not set a- // `release` value here - use the environment variable `SENTRY_RELEASE`, so- // that it will also get attached to your source maps- });-- Sentry.setUser({ id: await getSentryUserID() });- }+ Sentry.setUser({ id: await getSentryUserID() });};diff --git a/packages/shared/sentry/utils.ts b/packages/shared/sentry/utils.tsindex 20f342c77a..c9c0ff4d6c 100644--- a/packages/shared/sentry/utils.ts+++ b/packages/shared/sentry/utils.ts@@ -4,11 +4,10 @@ import {setLocalSentryUserID,} from '@ente/shared/storage/localStorage/helpers';import isElectron from 'is-electron';-import { getAppEnv } from '@ente/shared/apps/env';-import { APP_ENV } from '@ente/shared/apps/constants';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()) {@@ -49,7 +48,6 @@ export function isErrorUnnecessaryForSentry(error: any) {}export const getIsSentryEnabled = () => {- const isAppENVDevelopment = getAppEnv() === APP_ENV.DEVELOPMENT;const isSentryDisabled = isDisableSentryFlagSet();- return !isAppENVDevelopment && !isSentryDisabled;+ return !isDevBuild() && !isSentryDisabled;};diff --git a/scripts/deploy.sh b/scripts/deploy.shindex 9f39df2332..e76de2d487 100755--- a/scripts/deploy.sh+++ b/scripts/deploy.sh@@ -15,16 +15,6 @@ set -o xtracerm -rf out-# Cloudflare Pages has two separate environments - Production and Preview.-#-# Each of these have their separate environment variables. However, we need to-# deploy multiple production apps - so while for the "photos-release" branch-# (which corresponds to Cloudflare's "Production" environment) can have separate-# environment variables, the rest of the production deployments share the same-# environment variables (those that are set for the Preview environment in CF).-#-# So we instead tune environment variables for specific deployments here.-if test "$CF_PAGES_BRANCH" = "photos-release"; thenyarn export:photoscp -R apps/photos/out .@@ -32,10 +22,7 @@ elif test "$CF_PAGES_BRANCH" = "auth-release"; thenyarn export:authcp -R apps/auth/out .else- # Apart from the named branches, everything else gets treated as a- # development deployment.- export NODE_ENV=development- # Also, we connect all of them to the dev APIs.+ # Apart from the named branches, everything else connects to the dev APIs.export NEXT_PUBLIC_ENTE_ENDPOINT=https://dev-api.ente.ioexport NEXT_PUBLIC_ENTE_ALBUM_ENDPOINT=https://dev-albums.ente.iodiff --git a/turbo.json b/turbo.jsonindex e4c9dd4309..0932f39998 100644--- a/turbo.json+++ b/turbo.json@@ -24,10 +24,7 @@"NEXT_PUBLIC_ENTE_PAYMENT_ENDPOINT","NEXT_PUBLIC_ENTE_ALBUM_ENDPOINT","NEXT_PUBLIC_ENTE_FAMILY_PORTAL_ENDPOINT",- "NEXT_PUBLIC_ENTE_WEB_ENDPOINT",- "NEXT_PUBLIC_IS_TEST_APP","NODE_ENV",- "SENTRY_RELEASE",- "SENTRY_AUTH_TOKEN"+ "SENTRY_RELEASE"]}