log.error regex replacement

- logError\(e, (".+")\);
- log.error($1, e);

+ a whole bunch of manual tweakings
This commit is contained in:
Manav Rathi 2024-04-09 10:44:49 +05:30
parent 2b7aa372bd
commit 1dc8f4617e
No known key found for this signature in database
96 changed files with 497 additions and 560 deletions

View file

@ -1,8 +1,8 @@
import log from "@/next/log";
import { VerticallyCentered } from "@ente/shared/components/Container";
import EnteSpinner from "@ente/shared/components/EnteSpinner";
import { ACCOUNTS_PAGES } from "@ente/shared/constants/pages";
import HTTPService from "@ente/shared/network/HTTPService";
import { logError } from "@ente/shared/sentry";
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
import { useRouter } from "next/router";
import { useEffect } from "react";
@ -16,7 +16,7 @@ const AccountHandoff = () => {
router.push(ACCOUNTS_PAGES.PASSKEYS);
} catch (e) {
logError(e, "Failed to deserialize and set passed user data");
log.error("Failed to deserialize and set passed user data", e);
router.push(ACCOUNTS_PAGES.LOGIN);
}
};

View file

@ -1,3 +1,4 @@
import log from "@/next/log";
import { APPS, CLIENT_PACKAGE_NAMES } from "@ente/shared/apps/constants";
import {
CenteredFlex,
@ -7,7 +8,6 @@ import EnteButton from "@ente/shared/components/EnteButton";
import EnteSpinner from "@ente/shared/components/EnteSpinner";
import FormPaper from "@ente/shared/components/Form/FormPaper";
import HTTPService from "@ente/shared/network/HTTPService";
import { logError } from "@ente/shared/sentry";
import { LS_KEYS, setData } from "@ente/shared/storage/localStorage";
import InfoIcon from "@mui/icons-material/Info";
import { Box, Typography } from "@mui/material";
@ -73,7 +73,7 @@ const PasskeysFlow = () => {
try {
beginData = await beginAuthentication(passkeySessionID);
} catch (e) {
logError(e, "Couldn't begin passkey authentication");
log.error("Couldn't begin passkey authentication", e);
setErrored(true);
return;
} finally {
@ -89,7 +89,7 @@ const PasskeysFlow = () => {
try {
credential = await getCredential(beginData.options.publicKey);
} catch (e) {
logError(e, "Couldn't get credential");
log.error("Couldn't get credential", e);
continue;
} finally {
tries++;
@ -117,7 +117,7 @@ const PasskeysFlow = () => {
beginData.ceremonySessionID,
);
} catch (e) {
logError(e, "Couldn't finish passkey authentication");
log.error("Couldn't finish passkey authentication", e);
setErrored(true);
setLoading(false);
return;

View file

@ -1,8 +1,8 @@
import log from "@/next/log";
import { CenteredFlex } from "@ente/shared/components/Container";
import FormPaper from "@ente/shared/components/Form/FormPaper";
import SingleInputForm from "@ente/shared/components/SingleInputForm";
import { ACCOUNTS_PAGES } from "@ente/shared/constants/pages";
import { logError } from "@ente/shared/sentry";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { Box, Typography } from "@mui/material";
import { t } from "i18next";
@ -104,7 +104,7 @@ const Passkeys = () => {
try {
newCredential = await navigator.credentials.create(options);
} catch (e) {
logError(e, "Error creating credential");
log.error("Error creating credential", e);
setFieldError("Failed to create credential");
return;
}

View file

@ -1,8 +1,9 @@
import log from "@/next/log";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import _sodium from "libsodium-wrappers";
const ENDPOINT = getEndpoint();
export const getPasskeys = async () => {
@ -16,7 +17,7 @@ export const getPasskeys = async () => {
);
return await response.data;
} catch (e) {
logError(e, "get passkeys failed");
log.error("get passkeys failed", e);
throw e;
}
};
@ -33,7 +34,7 @@ export const renamePasskey = async (id: string, name: string) => {
);
return await response.data;
} catch (e) {
logError(e, "rename passkey failed");
log.error("rename passkey failed", e);
throw e;
}
};
@ -50,7 +51,7 @@ export const deletePasskey = async (id: string) => {
);
return await response.data;
} catch (e) {
logError(e, "delete passkey failed");
log.error("delete passkey failed", e);
throw e;
}
};
@ -68,7 +69,7 @@ export const getPasskeyRegistrationOptions = async () => {
);
return await response.data;
} catch (e) {
logError(e, "get passkey registration options failed");
log.error("get passkey registration options failed", e);
throw e;
}
};
@ -116,7 +117,7 @@ export const finishPasskeyRegistration = async (
);
return await response.data;
} catch (e) {
logError(e, "finish passkey registration failed");
log.error("finish passkey registration failed", e);
throw e;
}
};
@ -142,7 +143,7 @@ export const beginPasskeyAuthentication = async (
return data.data;
} catch (e) {
logError(e, "begin passkey authentication failed");
log.error("begin passkey authentication failed", e);
throw e;
}
};
@ -194,7 +195,7 @@ export const finishPasskeyAuthentication = async (
return data.data;
} catch (e) {
logError(e, "finish passkey authentication failed");
log.error("finish passkey authentication failed", e);
throw e;
}
};

View file

@ -1,8 +1,8 @@
import log from "@/next/log";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { ApiError, CustomError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { getActualKey } from "@ente/shared/user";
import { HttpStatusCode } from "axios";
@ -62,7 +62,7 @@ export const getAuthCodes = async (): Promise<Code[]> => {
return filteredAuthCodes;
} catch (e) {
if (e.message !== CustomError.AUTH_KEY_NOT_FOUND) {
logError(e, "get authenticator entities failed");
log.error("get authenticator entities failed", e);
}
throw e;
}
@ -85,7 +85,7 @@ export const getAuthKey = async (): Promise<AuthKey> => {
) {
throw Error(CustomError.AUTH_KEY_NOT_FOUND);
} else {
logError(e, "Get key failed");
log.error("Get key failed", e);
throw e;
}
}
@ -109,7 +109,7 @@ export const getDiff = async (
);
return resp.data.diff;
} catch (e) {
logError(e, "Get diff failed");
log.error("Get diff failed", e);
throw e;
}
};

View file

@ -1,4 +1,4 @@
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import PairedSuccessfullyOverlay from "components/PairedSuccessfullyOverlay";
import Theatre from "components/Theatre";
import { FILE_TYPE } from "constants/file";
@ -54,7 +54,7 @@ export default function Slideshow() {
);
}
} catch (e) {
logError(e, "error during sync");
log.error("error during sync", e);
router.push("/");
}
};
@ -107,7 +107,7 @@ export default function Slideshow() {
return () => clearTimeout(timeoutId);
} catch (e) {
logError(e, "error during sync");
log.error("error during sync", e);
router.push("/");
}
}, []);

View file

@ -1,10 +1,9 @@
import log from "@/next/log";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { CustomError, parseSharingErrorCodes } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import localForage from "@ente/shared/storage/localForage";
import { Collection, CollectionPublicMagicMetadata } from "types/collection";
import { EncryptedEnteFile, EnteFile } from "types/file";
import { decryptFile, mergeMetadata, sortFiles } from "utils/file";
@ -150,14 +149,14 @@ export const syncPublicFiles = async (
setPublicFiles([...sortFiles(mergeMetadata(files), sortAsc)]);
} catch (e) {
const parsedError = parseSharingErrorCodes(e);
logError(e, "failed to sync shared collection files");
log.error("failed to sync shared collection files", e);
if (parsedError.message === CustomError.TOKEN_EXPIRED) {
throw e;
}
}
return [...sortFiles(mergeMetadata(files), sortAsc)];
} catch (e) {
logError(e, "failed to get local or sync shared collection files");
log.error("failed to get local or sync shared collection files", e);
throw e;
}
};
@ -217,7 +216,7 @@ const fetchFiles = async (
} while (resp.data.hasMore);
return decryptedFiles;
} catch (e) {
logError(e, "Get cast files failed");
log.error("Get cast files failed", e);
throw e;
}
};
@ -264,7 +263,7 @@ export const getCastCollection = async (
await saveCollection(collection);
return collection;
} catch (e) {
logError(e, "failed to get cast collection");
log.error("failed to get cast collection", e);
throw e;
}
};

View file

@ -1,13 +1,14 @@
import { convertBytesToHumanReadable } from "@/next/file";
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
export async function getUint8ArrayView(file: Blob): Promise<Uint8Array> {
try {
return new Uint8Array(await file.arrayBuffer());
} catch (e) {
logError(e, "reading file blob failed", {
fileSize: convertBytesToHumanReadable(file.size),
});
log.error(
`Failed to read file blob of size ${convertBytesToHumanReadable(file.size)}`,
e,
);
throw e;
}
}

View file

@ -1,6 +1,5 @@
import { convertBytesToHumanReadable } from "@/next/file";
import log from "@/next/log";
import { CustomError } from "@ente/shared/error";
import { logError } from "@ente/shared/sentry";
import { FILE_TYPE } from "constants/file";
import {
KNOWN_NON_MEDIA_FORMATS,
@ -42,7 +41,6 @@ export async function getFileType(receivedFile: File): Promise<FileTypeInfo> {
};
} catch (e) {
const fileFormat = getFileExtension(receivedFile.name);
const fileSize = convertBytesToHumanReadable(receivedFile.size);
const whiteListedFormat = WHITELISTED_FILE_FORMATS.find(
(a) => a.exactType === fileFormat,
);
@ -53,16 +51,10 @@ export async function getFileType(receivedFile: File): Promise<FileTypeInfo> {
throw Error(CustomError.UNSUPPORTED_FILE_FORMAT);
}
if (e.message === CustomError.NON_MEDIA_FILE) {
logError(e, "unsupported file format", {
fileFormat,
fileSize,
});
log.error(`unsupported file format ${fileFormat}`, e);
throw Error(CustomError.UNSUPPORTED_FILE_FORMAT);
}
logError(e, "type detection failed", {
fileFormat,
fileSize,
});
log.error(`type detection failed for format ${fileFormat}`, e);
throw Error(CustomError.TYPE_DETECTION_FAILED(fileFormat));
}
}

View file

@ -1,5 +1,4 @@
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { logError } from "@ente/shared/sentry";
import { FILE_TYPE, RAW_FORMATS } from "constants/file";
import CastDownloadManager from "services/castDownloadManager";
import { decodeLivePhoto } from "services/livePhotoService";
@ -10,6 +9,7 @@ import {
FileMagicMetadata,
FilePublicMagicMetadata,
} from "types/file";
import log from "@/next/log";
export function sortFiles(files: EnteFile[], sortAsc = false) {
// sort based on the time of creation time of the file,
@ -80,7 +80,7 @@ export async function decryptFile(
pubMagicMetadata: filePubMagicMetadata,
};
} catch (e) {
logError(e, "file decryption failed");
log.error("file decryption failed", e);
throw e;
}
}
@ -160,6 +160,6 @@ export const getPreviewableImage = async (
fileBlob = new Blob([fileBlob], { type: fileType.mimeType });
return fileBlob;
} catch (e) {
logError(e, "failed to download file");
log.error("failed to download file", e);
}
};

View file

@ -1,14 +1,14 @@
import { useContext, useEffect, useState } from "react";
import log from "@/next/log";
import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
import VerifyMasterPasswordForm, {
VerifyMasterPasswordFormProps,
} from "@ente/shared/components/VerifyMasterPasswordForm";
import { logError } from "@ente/shared/sentry";
import { getData, LS_KEYS } from "@ente/shared/storage/localStorage";
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
import { KeyAttributes, User } from "@ente/shared/user/types";
import { t } from "i18next";
import { AppContext } from "pages/_app";
import { useContext, useEffect, useState } from "react";
interface Iprops {
open: boolean;
onClose: () => void;
@ -51,7 +51,7 @@ export default function AuthenticateUserModal({
setKeyAttributes(keyAttributes);
}
} catch (e) {
logError(e, "AuthenticateUserModal initialization failed");
log.error("AuthenticateUserModal initialization failed", e);
onClose();
somethingWentWrong();
}

View file

@ -1,6 +1,6 @@
import log from "@/next/log";
import { HorizontalFlex } from "@ente/shared/components/Container";
import OverflowMenu from "@ente/shared/components/OverflowMenu/menu";
import { logError } from "@ente/shared/sentry";
import MoreHoriz from "@mui/icons-material/MoreHoriz";
import { Box } from "@mui/material";
import {
@ -161,22 +161,15 @@ const CollectionOptions = (props: CollectionOptionsProps) => {
case CollectionActions.SHOW_ALBUM_CAST_DIALOG:
callback = showCastAlbumDialog;
break;
default:
logError(
Error("invalid collection action "),
"handleCollectionAction failed",
);
{
action;
}
log.error(`invalid collection action ${action}`);
}
return async (...args: any) => {
try {
loader && startLoading();
await callback(...args);
} catch (e) {
logError(e, "collection action failed", { action });
log.error(`collection action ${action} failed`, e);
setDialogMessage({
title: t("ERROR"),
content: t("UNKNOWN_ERROR"),

View file

@ -1,4 +1,4 @@
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import BlockIcon from "@mui/icons-material/Block";
import DoneIcon from "@mui/icons-material/Done";
import ModeEditIcon from "@mui/icons-material/ModeEdit";
@ -63,8 +63,7 @@ export default function ManageParticipant({
selectedParticipant.role = newRole;
await galleryContext.syncWithRemote(false, true);
} catch (e) {
const errorMessage = handleSharingErrors(e);
logError(e, errorMessage);
log.error(handleSharingErrors(e), e);
}
};

View file

@ -2,7 +2,6 @@ import { logoutUser } from "@ente/accounts/services/user";
import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
import EnteButton from "@ente/shared/components/EnteButton";
import { DELETE_ACCOUNT_EMAIL } from "@ente/shared/constants/urls";
import { logError } from "@ente/shared/sentry";
import { Button, Link, Stack } from "@mui/material";
import { Formik, FormikHelpers } from "formik";
import { t } from "i18next";
@ -92,7 +91,7 @@ const DeleteAccountModal = ({ open, onClose }: Iprops) => {
askToMailForDeletion();
}
} catch (e) {
logError(e, "Error while initiating account deletion");
log.error("Error while initiating account deletion", e);
somethingWentWrong();
} finally {
setLoading(false);
@ -147,7 +146,7 @@ const DeleteAccountModal = ({ open, onClose }: Iprops) => {
await deleteAccount(decryptedChallenge, reason, feedback);
logoutUser();
} catch (e) {
logError(e, "solveChallengeAndDeleteAccount failed");
log.error("solveChallengeAndDeleteAccount failed", e);
somethingWentWrong();
} finally {
setLoading(false);

View file

@ -1,6 +1,6 @@
import ElectronAPIs from "@/next/electron";
import log from "@/next/log";
import LinkButton from "@ente/shared/components/LinkButton";
import { logError } from "@ente/shared/sentry";
import { Tooltip } from "@mui/material";
import { styled } from "@mui/material/styles";
@ -21,7 +21,7 @@ export const DirectoryPath = ({ width, path }) => {
try {
await ElectronAPIs.openDirectory(path);
} catch (e) {
logError(e, "openDirectory failed");
log.error("openDirectory failed", e);
}
};
return (

View file

@ -1,4 +1,3 @@
import { logError } from "@ente/shared/sentry";
import { Box, DialogProps, Typography } from "@mui/material";
import { EnteDrawer } from "components/EnteDrawer";
import { t } from "i18next";
@ -41,7 +40,7 @@ const MLSearchSettings = ({ open, onClose, onRootClose }) => {
updateMlSearchEnabled(true);
}
} catch (e) {
logError(e, "Enable ML search failed");
log.error("Enable ML search failed", e);
somethingWentWrong();
}
};
@ -54,7 +53,7 @@ const MLSearchSettings = ({ open, onClose, onRootClose }) => {
closeEnableFaceSearch();
finishLoading();
} catch (e) {
logError(e, "Enable face search failed");
log.error("Enable face search failed", e);
somethingWentWrong();
}
};
@ -64,7 +63,7 @@ const MLSearchSettings = ({ open, onClose, onRootClose }) => {
await updateMlSearchEnabled(false);
onClose();
} catch (e) {
logError(e, "Disable ML search failed");
log.error("Disable ML search failed", e);
somethingWentWrong();
}
};
@ -76,7 +75,7 @@ const MLSearchSettings = ({ open, onClose, onRootClose }) => {
await disableMlSearch();
finishLoading();
} catch (e) {
logError(e, "Disable face search failed");
log.error("Disable face search failed", e);
somethingWentWrong();
}
};

View file

@ -1,5 +1,4 @@
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { CACHES } from "@ente/shared/storage/cacheStorage/constants";
import { styled } from "@mui/material";
import { Legend } from "components/PhotoViewer/styledComponents/Legend";
@ -130,7 +129,7 @@ export function AllPeopleList(props: AllPeopleListProps) {
}
!didCancel && setPeople(people);
} catch (e) {
logError(e, "updateFaceImages failed");
log.error("updateFaceImages failed", e);
}
}
updateFaceImages();

View file

@ -1,8 +1,8 @@
import log from "@/next/log";
import { PHOTOS_PAGES } from "@ente/shared/constants/pages";
import { CustomError } from "@ente/shared/error";
import useMemoSingleThreaded from "@ente/shared/hooks/useMemoSingleThreaded";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { styled } from "@mui/material";
import PhotoViewer from "components/PhotoViewer";
import { TRASH_SECTION } from "constants/collection";
@ -348,7 +348,7 @@ const PhotoFrame = ({
// ignore
}
} catch (e) {
logError(e, "getSlideData failed get msrc url failed");
log.error("getSlideData failed get msrc url failed", e);
thumbFetching[item.id] = false;
}
}
@ -452,7 +452,7 @@ const PhotoFrame = ({
}
}
} catch (e) {
logError(e, "getSlideData failed get src url failed");
log.error("getSlideData failed get src url failed", e);
fetching[item.id] = false;
// no-op
}
@ -493,7 +493,10 @@ const PhotoFrame = ({
}
} catch (e) {
if (e.message !== CustomError.URL_ALREADY_SET) {
logError(e, "updating photoswipe after msrc url update failed");
log.error(
"updating photoswipe after msrc url update failed",
e,
);
}
// ignore
}
@ -524,7 +527,7 @@ const PhotoFrame = ({
throw e;
}
} catch (e) {
logError(e, "getConvertedVideo failed get src url failed");
log.error("getConvertedVideo failed get src url failed", e);
fetching[item.id] = false;
// no-op
}

View file

@ -1,5 +1,5 @@
import log from "@/next/log";
import { FlexWrapper } from "@ente/shared/components/Container";
import { logError } from "@ente/shared/sentry";
import Close from "@mui/icons-material/Close";
import Done from "@mui/icons-material/Done";
import { Box, IconButton, TextField } from "@mui/material";
@ -48,7 +48,7 @@ export function RenderCaption({
scheduleUpdate();
}
} catch (e) {
logError(e, "failed to update caption");
log.error("failed to update caption", e);
}
};

View file

@ -1,5 +1,4 @@
import { FlexWrapper } from "@ente/shared/components/Container";
import { logError } from "@ente/shared/sentry";
import { formatDate, formatTime } from "@ente/shared/time/format";
import CalendarTodayIcon from "@mui/icons-material/CalendarToday";
import EnteDateTimePicker from "components/EnteDateTimePicker";
@ -44,7 +43,7 @@ export function RenderCreationTime({
scheduleUpdate();
}
} catch (e) {
logError(e, "failed to update creationTime");
log.error("failed to update creationTime", e);
} finally {
closeEditMode();
setLoading(false);

View file

@ -1,5 +1,4 @@
import { FlexWrapper } from "@ente/shared/components/Container";
import { logError } from "@ente/shared/sentry";
import PhotoOutlined from "@mui/icons-material/PhotoOutlined";
import VideocamOutlined from "@mui/icons-material/VideocamOutlined";
import Box from "@mui/material/Box";
@ -86,7 +85,7 @@ export function RenderFileName({
scheduleUpdate();
}
} catch (e) {
logError(e, "failed to update file name");
log.error("failed to update file name", e);
throw e;
}
};

View file

@ -1,4 +1,4 @@
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import Crop169Icon from "@mui/icons-material/Crop169";
import Crop32Icon from "@mui/icons-material/Crop32";
import CropSquareIcon from "@mui/icons-material/CropSquare";
@ -172,10 +172,13 @@ const TransformMenu = () => {
setCanvasLoading(false);
setTransformationPerformed(true);
} catch (e) {
logError(e, "crop handler failed", {
widthRatio,
heightRatio,
});
log.error(
`crop handler failed - ${JSON.stringify({
widthRatio,
heightRatio,
})}`,
e,
);
}
};
const createRotationHandler = (rotation: "left" | "right") => () => {
@ -189,9 +192,7 @@ const TransformMenu = () => {
setCanvasLoading(false);
setTransformationPerformed(true);
} catch (e) {
logError(e, "rotation handler failed", {
rotation,
});
log.error(`rotation handler (${rotation}) failed`, e);
}
};
@ -204,9 +205,7 @@ const TransformMenu = () => {
setCanvasLoading(false);
setTransformationPerformed(true);
} catch (e) {
logError(e, "flip handler failed", {
direction,
});
log.error(`flip handler ${direction} failed`, e);
}
};

View file

@ -23,7 +23,6 @@ import {
HorizontalFlex,
} from "@ente/shared/components/Container";
import EnteButton from "@ente/shared/components/EnteButton";
import { logError } from "@ente/shared/sentry";
import { downloadUsingAnchor } from "@ente/shared/utils";
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
import CloseIcon from "@mui/icons-material/Close";
@ -275,7 +274,7 @@ const ImageEditorOverlay = (props: IProps) => {
invert !== FILTER_DEFAULT_VALUES.invert,
);
} catch (e) {
logError(e, "Error applying filters");
log.error("Error applying filters", e);
}
}, [brightness, contrast, blur, saturation, invert, canvasRef, fileURL]);
@ -329,7 +328,7 @@ const ImageEditorOverlay = (props: IProps) => {
});
}
} catch (e) {
logError(e, "Error applying filters");
log.error("Error applying filters", e);
throw e;
}
};
@ -422,7 +421,7 @@ const ImageEditorOverlay = (props: IProps) => {
};
});
} catch (e) {
logError(e, "Error loading canvas");
log.error("Error loading canvas", e);
}
};
@ -447,7 +446,7 @@ const ImageEditorOverlay = (props: IProps) => {
canvas.toBlob(resolve, mimeType);
});
} catch (e) {
logError(e, "Error exporting canvas to blob");
log.error("Error exporting canvas to blob", e);
throw e;
}
};
@ -492,7 +491,7 @@ const ImageEditorOverlay = (props: IProps) => {
);
downloadUsingAnchor(tempImgURL, editedFile.name);
} catch (e) {
logError(e, "Error downloading edited photo");
log.error("Error downloading edited photo", e);
}
};
@ -520,7 +519,7 @@ const ImageEditorOverlay = (props: IProps) => {
props.onClose();
props.closePhotoViewer();
} catch (e) {
logError(e, "Error saving copy to ente");
log.error("Error saving copy to ente", e);
}
};
return (

View file

@ -1,4 +1,4 @@
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import Photoswipe from "photoswipe";
import PhotoswipeUIDefault from "photoswipe/dist/photoswipe-ui-default";
import { useContext, useEffect, useMemo, useRef, useState } from "react";
@ -16,7 +16,6 @@ import {
isSupportedRawFormat,
} from "utils/file";
import log from "@/next/log";
import { FlexWrapper } from "@ente/shared/components/Container";
import EnteSpinner from "@ente/shared/components/EnteSpinner";
import AlbumOutlined from "@mui/icons-material/AlbumOutlined";
@ -496,7 +495,7 @@ function PhotoViewer(props: Iprops) {
}
needUpdate.current = true;
} catch (e) {
logError(e, "onFavClick failed");
log.error("onFavClick failed", e);
}
};
@ -511,7 +510,7 @@ function PhotoViewer(props: Iprops) {
updateItems(props.items.filter((item) => item.id !== file.id));
needUpdate.current = true;
} catch (e) {
logError(e, "trashFile failed");
log.error("trashFile failed", e);
}
};
@ -562,7 +561,7 @@ function PhotoViewer(props: Iprops) {
}
}
} catch (e) {
logError(e, "updateItems failed");
log.error("updateItems failed", e);
}
};
@ -573,7 +572,7 @@ function PhotoViewer(props: Iprops) {
photoSwipe.updateSize(true);
}
} catch (e) {
logError(e, "refreshPhotoswipe failed");
log.error("refreshPhotoswipe failed", e);
}
};

View file

@ -9,7 +9,6 @@ import { t } from "i18next";
import { useContext, useEffect, useState } from "react";
import { VerticallyCenteredFlex } from "@ente/shared/components/Container";
import { logError } from "@ente/shared/sentry";
import { EnteMenuItem } from "components/Menu/EnteMenuItem";
import { MenuItemGroup } from "components/Menu/MenuItemGroup";
import isElectron from "is-electron";
@ -41,7 +40,7 @@ export default function AdvancedSettings({ open, onClose, onRootClose }) {
try {
appContext.setIsCFProxyDisabled(!appContext.isCFProxyDisabled);
} catch (e) {
logError(e, "toggleFasterUpload failed");
log.error("toggleFasterUpload failed", e);
}
};
const [indexingStatus, setIndexingStatus] = useState<ClipExtractionStatus>({

View file

@ -1,4 +1,4 @@
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import { Box, DialogProps } from "@mui/material";
import { EnteDrawer } from "components/EnteDrawer";
import { AppContext } from "pages/_app";
@ -14,7 +14,7 @@ const ModifyMapEnabled = ({ open, onClose, onRootClose, mapEnabled }) => {
await updateMapEnabled(false);
onClose();
} catch (e) {
logError(e, "Disable Map failed");
log.error("Disable Map failed", e);
somethingWentWrong();
}
};
@ -24,7 +24,7 @@ const ModifyMapEnabled = ({ open, onClose, onRootClose, mapEnabled }) => {
await updateMapEnabled(true);
onClose();
} catch (e) {
logError(e, "Enable Map failed");
log.error("Enable Map failed", e);
somethingWentWrong();
}
};

View file

@ -21,7 +21,6 @@ import {
generateEncryptionKey,
} from "@ente/shared/crypto/internal/libsodium";
import { getAccountsURL } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import { THEME_COLOR } from "@ente/shared/themes/constants";
import { EnteMenuItem } from "components/Menu/EnteMenuItem";
import WatchFolder from "components/WatchFolder";
@ -109,7 +108,7 @@ export default function UtilitySection({ closeSidebar }) {
)}&token=${accountsToken}`,
);
} catch (e) {
logError(e, "failed to redirect to accounts page");
log.error("failed to redirect to accounts page", e);
}
};

View file

@ -1,6 +1,6 @@
import log from "@/next/log";
import { CustomError } from "@ente/shared/error";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { isPromise } from "@ente/shared/utils";
import DiscFullIcon from "@mui/icons-material/DiscFull";
import UserNameInputDialog from "components/UserNameInputDialog";
@ -257,7 +257,7 @@ export default function Uploader(props: Props) {
);
setElectronFiles(electronFiles);
} catch (e) {
logError(e, "failed to upload desktop dropped files");
log.error("failed to upload desktop dropped files", e);
setWebFiles(props.dragAndDropFiles);
}
};
@ -388,7 +388,7 @@ export default function Uploader(props: Props) {
uploaderName,
);
} catch (e) {
logError(e, "Failed to upload files to existing collections");
log.error("Failed to upload files to existing collections", e);
}
};
@ -447,7 +447,7 @@ export default function Uploader(props: Props) {
}
} catch (e) {
closeUploadProgress();
logError(e, "Failed to create album");
log.error("Failed to create album", e);
appContext.setDialogMessage({
title: t("ERROR"),
@ -462,7 +462,7 @@ export default function Uploader(props: Props) {
);
toUploadFiles.current = null;
} catch (e) {
logError(e, "Failed to upload files to new collections");
log.error("Failed to upload files to new collections", e);
}
};
@ -698,7 +698,7 @@ export default function Uploader(props: Props) {
intent: CollectionSelectorIntent.upload,
});
} catch (e) {
logError(e, "handleCollectionCreationAndUpload failed");
log.error("handleCollectionCreationAndUpload failed", e);
}
};
@ -771,7 +771,7 @@ export default function Uploader(props: Props) {
uploaderName,
);
} catch (e) {
logError(e, "public upload failed ");
log.error("public upload failed ", e);
}
};

View file

@ -1,4 +1,4 @@
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import { styled } from "@mui/material";
import { useTheme } from "@mui/material/styles";
import { GalleryContext } from "pages/gallery";
@ -47,7 +47,7 @@ const Avatar: React.FC<AvatarProps> = ({ file, email, opacity }) => {
// getting email from in-memory id-email map
const email = userIDToEmailMap.get(file.ownerID);
if (!email) {
logError(Error(), "email not found in userIDToEmailMap");
log.error("email not found in userIDToEmailMap");
return;
}
const colorIndex =
@ -58,8 +58,7 @@ const Avatar: React.FC<AvatarProps> = ({ file, email, opacity }) => {
} else if (file.ownerID === user.id) {
const uploaderName = file.pubMagicMetadata.data.uploaderName;
if (!uploaderName) {
logError(
Error(),
log.error(
"uploaderName not found in file.pubMagicMetadata.data",
);
return;
@ -67,8 +66,8 @@ const Avatar: React.FC<AvatarProps> = ({ file, email, opacity }) => {
setUserLetter(uploaderName[0].toUpperCase());
setColorCode(PUBLIC_COLLECTED_FILES_AVATAR_COLOR_CODE);
}
} catch (err) {
logError(err, "AvatarIcon.tsx - useLayoutEffect file failed");
} catch (e) {
log.error("AvatarIcon.tsx - useLayoutEffect file failed", e);
}
}, [file]);
@ -87,15 +86,15 @@ const Avatar: React.FC<AvatarProps> = ({ file, email, opacity }) => {
(key) => userIDToEmailMap.get(key) === email,
);
if (!id) {
logError(Error(), `ID not found for email: ${email}`);
log.error(`ID not found for email: ${email}`);
return;
}
const colorIndex = id % theme.colors.avatarColors.length;
const colorCode = theme.colors.avatarColors[colorIndex];
setUserLetter(email[0].toUpperCase());
setColorCode(colorCode);
} catch (err) {
logError(err, "AvatarIcon.tsx - useLayoutEffect email failed");
} catch (e) {
log.error("AvatarIcon.tsx - useLayoutEffect email failed", e);
}
}, [email]);

View file

@ -1,6 +1,5 @@
import { SUPPORT_EMAIL } from "@ente/shared/constants/urls";
import { useLocalState } from "@ente/shared/hooks/useLocalState";
import { logError } from "@ente/shared/sentry";
import { LS_KEYS } from "@ente/shared/storage/localStorage";
import { Link, Stack } from "@mui/material";
import { PLAN_PERIOD } from "constants/gallery";
@ -92,7 +91,7 @@ function PlanSelectorCard(props: Props) {
}
setPlans(plans);
} catch (e) {
logError(e, "plan selector modal open failed");
log.error("plan selector modal open failed", e);
props.closeModal();
appContext.setDialogMessage({
title: t("OPEN_PLAN_SELECTOR_MODAL_FAILED"),

View file

@ -1,7 +1,6 @@
import { Overlay } from "@ente/shared/components/Container";
import { CustomError } from "@ente/shared/error";
import useLongPress from "@ente/shared/hooks/useLongPress";
import { logError } from "@ente/shared/sentry";
import { formatDateRelative } from "@ente/shared/time/format";
import AlbumOutlined from "@mui/icons-material/AlbumOutlined";
import PlayCircleOutlineOutlinedIcon from "@mui/icons-material/PlayCircleOutlineOutlined";
@ -271,7 +270,7 @@ export default function PreviewCard(props: IProps) {
updateURL(file.id, url);
} catch (e) {
if (e.message !== CustomError.URL_ALREADY_SET) {
logError(e, "preview card useEffect failed");
log.error("preview card useEffect failed", e);
}
// no-op
}

View file

@ -1,6 +1,7 @@
import { CustomHead } from "@/next/components/Head";
import ElectronAPIs from "@/next/electron";
import { setupI18n } from "@/next/i18n";
import log from "@/next/log";
import { logStartupBanner } from "@/next/log-web";
import { AppUpdateInfo } from "@/next/types/ipc";
import {
@ -28,7 +29,6 @@ import { Events, eventBus } from "@ente/shared/events";
import { useLocalState } from "@ente/shared/hooks/useLocalState";
import { addLogLine } from "@ente/shared/logging";
import HTTPService from "@ente/shared/network/HTTPService";
import { logError } from "@ente/shared/sentry";
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
import {
getLocalMapEnabled,
@ -190,7 +190,7 @@ export default function App({ Component, pageProps }: AppProps) {
setMlSearchEnabled(mlSearchConfig.enabled);
mlWorkManager.setMlSearchEnabled(mlSearchConfig.enabled);
} catch (e) {
logError(e, "Error while loading mlSearchEnabled");
log.error("Error while loading mlSearchEnabled", e);
}
};
loadMlSearchState();
@ -200,7 +200,7 @@ export default function App({ Component, pageProps }: AppProps) {
mlWorkManager.setMlSearchEnabled(false);
});
} catch (e) {
logError(e, "Error while subscribing to logout event");
log.error("Error while subscribing to logout event", e);
}
}, []);
@ -242,7 +242,7 @@ export default function App({ Component, pageProps }: AppProps) {
exportService.scheduleExport();
}
} catch (e) {
logError(e, "init export failed");
log.error("init export failed", e);
}
};
initExport();
@ -251,7 +251,7 @@ export default function App({ Component, pageProps }: AppProps) {
exportService.disableContinuousExport();
});
} catch (e) {
logError(e, "Error while subscribing to logout event");
log.error("Error while subscribing to logout event", e);
}
}, []);
@ -337,7 +337,7 @@ export default function App({ Component, pageProps }: AppProps) {
setMlSearchEnabled(enabled);
mlWorkManager.setMlSearchEnabled(enabled);
} catch (e) {
logError(e, "Error while updating mlSearchEnabled");
log.error("Error while updating mlSearchEnabled", e);
}
};
@ -347,7 +347,7 @@ export default function App({ Component, pageProps }: AppProps) {
setLocalMapEnabled(enabled);
setMapEnabled(enabled);
} catch (e) {
logError(e, "Error while updating mapEnabled");
log.error("Error while updating mapEnabled", e);
}
};

View file

@ -60,9 +60,9 @@ import {
sortFiles,
} from "utils/file";
import log from "@/next/log";
import { PHOTOS_PAGES as PAGES } from "@ente/shared/constants/pages";
import { CustomError } from "@ente/shared/error";
import { logError } from "@ente/shared/sentry";
import CollectionNamer, {
CollectionNamerAttributes,
} from "components/Collections/CollectionNamer";
@ -719,7 +719,7 @@ export default function Gallery() {
router.push(PAGES.CREDENTIALS);
break;
default:
logError(e, "syncWithRemote failed");
log.error("syncWithRemote failed", e);
}
} finally {
setTempDeletedFileIds(new Set());

View file

@ -6,7 +6,6 @@ import EnteSpinner from "@ente/shared/components/EnteSpinner";
import { PHOTOS_PAGES as PAGES } from "@ente/shared/constants/pages";
import { saveKeyInSessionStore } from "@ente/shared/crypto/helpers";
import { getAlbumsURL } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import localForage from "@ente/shared/storage/localForage";
import { getData, LS_KEYS } from "@ente/shared/storage/localStorage";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
@ -135,7 +134,7 @@ export default function LandingPage() {
try {
key = await electron.getEncryptionKey();
} catch (e) {
logError(e, "getEncryptionKey failed");
log.error("getEncryptionKey failed", e);
}
if (key) {
await saveKeyInSessionStore(
@ -159,7 +158,7 @@ export default function LandingPage() {
try {
await localForage.ready();
} catch (e) {
logError(e, "usage in incognito mode tried");
log.error("usage in incognito mode tried", e);
appContext.setDialogMessage({
title: t("LOCAL_STORAGE_NOT_ACCESSIBLE"),

View file

@ -46,7 +46,6 @@ import { PHOTOS_PAGES as PAGES } from "@ente/shared/constants/pages";
import { ENTE_WEBSITE_LINK } from "@ente/shared/constants/urls";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import useFileInput from "@ente/shared/hooks/useFileInput";
import { logError } from "@ente/shared/sentry";
import AddPhotoAlternateOutlined from "@mui/icons-material/AddPhotoAlternateOutlined";
import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined";
import MoreHoriz from "@mui/icons-material/MoreHoriz";
@ -292,7 +291,7 @@ export default function PublicCollectionGallery() {
setFilesDownloadProgressAttributes,
);
} catch (e) {
logError(e, "failed to downloads shared album all files");
log.error("failed to downloads shared album all files", e);
}
};
@ -417,7 +416,7 @@ export default function PublicCollectionGallery() {
setPublicCollection(null);
setPublicFiles(null);
} else {
logError(e, "failed to sync public album with remote");
log.error("failed to sync public album with remote", e);
}
} finally {
appContext.finishLoading();
@ -441,7 +440,7 @@ export default function PublicCollectionGallery() {
publicUrl.memLimit,
);
} catch (e) {
logError(e, "failed to derive key for verifyLinkPassword");
log.error("failed to derive key for verifyLinkPassword", e);
setFieldError(`${t("UNKNOWN_ERROR")} ${e.message}`);
return;
}
@ -468,7 +467,7 @@ export default function PublicCollectionGallery() {
await syncWithRemote();
appContext.finishLoading();
} catch (e) {
logError(e, "failed to verifyLinkPassword");
log.error("failed to verifyLinkPassword", e);
setFieldError(`${t("UNKNOWN_ERROR")} ${e.message}`);
}
};
@ -528,7 +527,7 @@ export default function PublicCollectionGallery() {
);
clearSelection();
} catch (e) {
logError(e, "failed to download selected files");
log.error("failed to download selected files", e);
}
};

View file

@ -1,6 +1,6 @@
import log from "@/next/log";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint, getPaymentsURL } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import {
LS_KEYS,
removeData,
@ -40,7 +40,7 @@ class billingService {
const { plans } = response.data;
return plans;
} catch (e) {
logError(e, "failed to get plans");
log.error("failed to get plans", e);
}
}
@ -56,7 +56,7 @@ class billingService {
const { subscription } = response.data;
setData(LS_KEYS.SUBSCRIPTION, subscription);
} catch (e) {
logError(e, "failed to get user's subscription details");
log.error("failed to get user's subscription details", e);
}
}
@ -69,7 +69,7 @@ class billingService {
PaymentActionType.Buy,
);
} catch (e) {
logError(e, "unable to buy subscription");
log.error("unable to buy subscription", e);
throw e;
}
}
@ -83,7 +83,7 @@ class billingService {
PaymentActionType.Update,
);
} catch (e) {
logError(e, "subscription update failed");
log.error("subscription update failed", e);
throw e;
}
}
@ -101,7 +101,7 @@ class billingService {
const { subscription } = response.data;
setData(LS_KEYS.SUBSCRIPTION, subscription);
} catch (e) {
logError(e, "subscription cancel failed");
log.error("subscription cancel failed", e);
throw e;
}
}
@ -119,7 +119,7 @@ class billingService {
const { subscription } = response.data;
setData(LS_KEYS.SUBSCRIPTION, subscription);
} catch (e) {
logError(e, "failed to activate subscription");
log.error("failed to activate subscription", e);
throw e;
}
}
@ -163,7 +163,7 @@ class billingService {
});
removeData(LS_KEYS.FAMILY_DATA);
} catch (e) {
logError(e, "/family/leave failed");
log.error("/family/leave failed", e);
throw e;
}
}
@ -177,7 +177,7 @@ class billingService {
const redirectURL = this.getRedirectURL();
window.location.href = `${getPaymentsURL()}?productID=${productID}&paymentToken=${paymentToken}&action=${action}&redirectURL=${redirectURL}`;
} catch (e) {
logError(e, "unable to get payments url");
log.error("unable to get payments url", e);
throw e;
}
}
@ -194,7 +194,7 @@ class billingService {
);
window.location.href = response.data.url;
} catch (e) {
logError(e, "unable to get customer portal url");
log.error("unable to get customer portal url", e);
throw e;
}
}

View file

@ -1,9 +1,9 @@
import ElectronAPIs from "@/next/electron";
import log from "@/next/log";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { CustomError } from "@ente/shared/error";
import { Events, eventBus } from "@ente/shared/events";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
import { FILE_TYPE } from "constants/file";
import isElectron from "is-electron";
@ -73,7 +73,7 @@ class ClipServiceImpl {
eventBus.on(Events.FILE_UPLOADED, this.onFileUploadedHandler, this);
addLogLine("setup file upload listener successfully");
} catch (e) {
logError(e, "failed to setup clip service");
log.error("failed to setup clip service", e);
}
};
@ -92,7 +92,7 @@ class ClipServiceImpl {
this.onFileUploadedHandler = null;
addLogLine("removed file upload listener successfully");
} catch (e) {
logError(e, "failed to remove clip service");
log.error("failed to remove clip service", e);
}
};
@ -107,7 +107,7 @@ class ClipServiceImpl {
}
return this.clipExtractionStatus;
} catch (e) {
logError(e, "failed to get clip indexing status");
log.error("failed to get clip indexing status", e);
}
};
@ -148,7 +148,7 @@ class ClipServiceImpl {
}
} catch (e) {
if (e.message !== CustomError.REQUEST_CANCELLED) {
logError(e, "failed to schedule clip embedding extraction");
log.error("failed to schedule clip embedding extraction", e);
}
}
};
@ -163,7 +163,7 @@ class ClipServiceImpl {
if (e?.message?.includes(CustomError.UNSUPPORTED_PLATFORM)) {
this.unsupportedPlatform = true;
}
logError(e, "failed to compute text embedding");
log.error("failed to compute text embedding", e);
throw e;
}
};
@ -244,7 +244,7 @@ class ClipServiceImpl {
}
} catch (e) {
if (e.message !== CustomError.REQUEST_CANCELLED) {
logError(e, "failed to extract clip embedding");
log.error("failed to extract clip embedding", e);
}
throw e;
}
@ -294,7 +294,7 @@ class ClipServiceImpl {
`successfully extracted clip embedding for file: ${enteFile.metadata.title} fileID: ${enteFile.id}`,
);
} catch (e) {
logError(e, "Failed in ML onFileUploadedHandler");
log.error("Failed in ML onFileUploadedHandler", e);
}
}

View file

@ -2,10 +2,10 @@ import { getEndpoint } from "@ente/shared/network/api";
import localForage from "@ente/shared/storage/localForage";
import { getData, LS_KEYS } from "@ente/shared/storage/localStorage";
import log from "@/next/log";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { CustomError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
import { logError } from "@ente/shared/sentry";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { getActualKey } from "@ente/shared/user";
import { User } from "@ente/shared/user/types";
@ -212,7 +212,7 @@ const getCollections = async (
);
return collections;
} catch (e) {
logError(e, "getCollections failed");
log.error("getCollections failed", e);
throw e;
}
};
@ -340,7 +340,7 @@ export const getCollection = async (
);
return collectionWithSecrets;
} catch (e) {
logError(e, "failed to get collection");
log.error("failed to get collection", e);
throw e;
}
};
@ -462,7 +462,7 @@ const createCollection = async (
);
return decryptedCreatedCollection;
} catch (e) {
logError(e, "create collection failed");
log.error("create collection failed", e);
throw e;
}
};
@ -480,7 +480,7 @@ const postCollection = async (
);
return response.data.collection;
} catch (e) {
logError(e, "post Collection failed ");
log.error("post Collection failed ", e);
}
};
@ -496,7 +496,7 @@ export const addToFavorites = async (file: EnteFile) => {
}
await addToCollection(favCollection, [file]);
} catch (e) {
logError(e, "failed to add to favorite");
log.error("failed to add to favorite", e);
}
};
@ -508,7 +508,7 @@ export const removeFromFavorites = async (file: EnteFile) => {
}
await removeFromCollection(favCollection.id, [file]);
} catch (e) {
logError(e, "remove from favorite failed");
log.error("remove from favorite failed", e);
}
};
@ -537,7 +537,7 @@ export const addToCollection = async (
);
}
} catch (e) {
logError(e, "Add to collection Failed ");
log.error("Add to collection Failed ", e);
throw e;
}
};
@ -567,7 +567,7 @@ export const restoreToCollection = async (
);
}
} catch (e) {
logError(e, "restore to collection Failed ");
log.error("restore to collection Failed ", e);
throw e;
}
};
@ -598,7 +598,7 @@ export const moveToCollection = async (
);
}
} catch (e) {
logError(e, "move to collection Failed ");
log.error("move to collection Failed ", e);
throw e;
}
};
@ -649,7 +649,7 @@ export const removeFromCollection = async (
await removeUserFiles(collectionID, userFiles, allFiles);
}
} catch (e) {
logError(e, "remove from collection failed ");
log.error("remove from collection failed ", e);
throw e;
}
};
@ -715,7 +715,7 @@ export const removeUserFiles = async (
leftFiles,
);
} catch (e) {
logError(e, "remove user files failed ");
log.error("remove user files failed ", e);
throw e;
}
};
@ -742,7 +742,7 @@ export const removeNonUserFiles = async (
);
}
} catch (e) {
logError(e, "remove non user files failed ");
log.error("remove non user files failed ", e);
throw e;
}
};
@ -768,7 +768,7 @@ export const deleteCollection = async (
{ "X-Auth-Token": token },
);
} catch (e) {
logError(e, "delete collection failed ");
log.error("delete collection failed ", e);
throw e;
}
};
@ -784,7 +784,7 @@ export const leaveSharedAlbum = async (collectionID: number) => {
{ "X-Auth-Token": token },
);
} catch (e) {
logError(e, "leave shared album failed ");
log.error("leave shared album failed ", e);
throw e;
}
};
@ -976,7 +976,7 @@ export const shareCollection = async (
},
);
} catch (e) {
logError(e, "share collection failed ");
log.error("share collection failed ", e);
throw e;
}
};
@ -1000,7 +1000,7 @@ export const unshareCollection = async (
},
);
} catch (e) {
logError(e, "unshare collection failed ");
log.error("unshare collection failed ", e);
}
};
@ -1023,7 +1023,7 @@ export const createShareableURL = async (collection: Collection) => {
);
return resp.data.result as PublicURL;
} catch (e) {
logError(e, "createShareableURL failed ");
log.error("createShareableURL failed ", e);
throw e;
}
};
@ -1043,7 +1043,7 @@ export const deleteShareableURL = async (collection: Collection) => {
},
);
} catch (e) {
logError(e, "deleteShareableURL failed ");
log.error("deleteShareableURL failed ", e);
throw e;
}
};
@ -1066,7 +1066,7 @@ export const updateShareableURL = async (
);
return res.data.result as PublicURL;
} catch (e) {
logError(e, "updateShareableURL failed ");
log.error("updateShareableURL failed ", e);
throw e;
}
};
@ -1392,7 +1392,7 @@ export async function moveToHiddenCollection(files: EnteFile[]) {
await moveToCollection(collectionID, hiddenCollection, files);
}
} catch (e) {
logError(e, "move to hidden collection failed ");
log.error("move to hidden collection failed ", e);
throw e;
}
}
@ -1411,7 +1411,7 @@ export async function unhideToCollection(
await moveToCollection(collectionID, collection, files);
}
} catch (e) {
logError(e, "unhide to collection failed ");
log.error("unhide to collection failed ", e);
throw e;
}
}

View file

@ -1,6 +1,5 @@
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { FILE_TYPE } from "constants/file";
import { EnteFile } from "types/file";
@ -64,7 +63,7 @@ export async function getDuplicates(
return result;
} catch (e) {
logError(e, "failed to get duplicate files");
log.error("failed to get duplicate files", e);
}
}
@ -156,7 +155,7 @@ async function fetchDuplicateFileIDs() {
);
return (response.data as DuplicatesResponse).duplicates;
} catch (e) {
logError(e, "failed to fetch duplicate file IDs");
log.error("failed to fetch duplicate file IDs", e);
}
}

View file

@ -4,13 +4,13 @@ import {
getRenderableFileURL,
} from "utils/file";
import log from "@/next/log";
import { APPS } from "@ente/shared/apps/constants";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
import { CustomError } from "@ente/shared/error";
import { Events, eventBus } from "@ente/shared/events";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { CacheStorageService } from "@ente/shared/storage/cacheStorage";
import { CACHES } from "@ente/shared/storage/cacheStorage/constants";
import { LimitedCache } from "@ente/shared/storage/cacheStorage/types";
@ -90,7 +90,7 @@ class DownloadManagerImpl {
this.ready = true;
eventBus.on(Events.LOGOUT, this.logoutHandler.bind(this), this);
} catch (e) {
logError(e, "DownloadManager init failed");
log.error("DownloadManager init failed", e);
throw e;
}
}
@ -108,7 +108,7 @@ class DownloadManagerImpl {
this.progressUpdater = () => {};
addLogLine("downloadManager logoutHandler completed");
} catch (e) {
logError(e, "downloadManager logoutHandler failed");
log.error("downloadManager logoutHandler failed", e);
}
}
@ -138,7 +138,7 @@ class DownloadManagerImpl {
return new Uint8Array(await cacheResp.arrayBuffer());
}
} catch (e) {
logError(e, "failed to get cached thumbnail");
log.error("failed to get cached thumbnail", e);
throw e;
}
}
@ -153,7 +153,7 @@ class DownloadManagerImpl {
);
return cacheResp?.clone();
} catch (e) {
logError(e, "failed to get cached file");
log.error("failed to get cached file", e);
throw e;
}
}
@ -185,12 +185,12 @@ class DownloadManagerImpl {
this.thumbnailCache
?.put(file.id.toString(), new Response(thumb))
.catch((e) => {
logError(e, "thumb cache put failed");
log.error("thumb cache put failed", e);
// TODO: handle storage full exception.
});
return thumb;
} catch (e) {
logError(e, "getThumbnail failed");
log.error("getThumbnail failed", e);
throw e;
}
}
@ -215,7 +215,7 @@ class DownloadManagerImpl {
return thumb;
} catch (e) {
this.thumbnailObjectURLPromises.delete(file.id);
logError(e, "get DownloadManager preview Failed");
log.error("get DownloadManager preview Failed", e);
throw e;
}
}
@ -253,7 +253,7 @@ class DownloadManagerImpl {
return fileURLs;
} catch (e) {
this.fileConversionPromises.delete(file.id);
logError(e, "download manager getFileForPreview Failed");
log.error("download manager getFileForPreview Failed", e);
throw e;
}
};
@ -291,7 +291,7 @@ class DownloadManagerImpl {
}
} catch (e) {
this.fileObjectURLPromises.delete(file.id);
logError(e, "download manager getFile Failed");
log.error("download manager getFile Failed", e);
throw e;
}
}
@ -321,7 +321,7 @@ class DownloadManagerImpl {
this.diskFileCache
.put(file.id.toString(), encrypted.clone())
.catch((e) => {
logError(e, "file cache put failed");
log.error("file cache put failed", e);
// TODO: handle storage full exception.
});
}
@ -360,7 +360,7 @@ class DownloadManagerImpl {
this.diskFileCache
.put(file.id.toString(), resp.clone())
.catch((e) => {
logError(e, "file cache put failed");
log.error("file cache put failed", e);
});
}
}
@ -495,7 +495,10 @@ class DownloadManagerImpl {
controller.close();
}
} catch (e) {
logError(e, "Failed to process file chunk");
log.error(
"Failed to process file chunk",
e,
);
controller.error(e);
}
});
@ -503,14 +506,14 @@ class DownloadManagerImpl {
push();
} catch (e) {
logError(e, "Failed to process file stream");
log.error("Failed to process file stream", e);
controller.error(e);
}
},
});
return stream;
} catch (e) {
logError(e, "Failed to download file");
log.error("Failed to download file", e);
throw e;
}
}
@ -549,7 +552,7 @@ async function openThumbnailCache() {
try {
return await CacheStorageService.open(CACHES.THUMBS);
} catch (e) {
logError(e, "Failed to open thumbnail cache");
log.error("Failed to open thumbnail cache", e);
if (isInternalUser()) {
throw e;
} else {
@ -565,7 +568,7 @@ async function openDiskFileCache() {
}
return await CacheStorageService.open(CACHES.FILES);
} catch (e) {
logError(e, "Failed to open file cache");
log.error("Failed to open file cache", e);
if (isInternalUser()) {
throw e;
} else {

View file

@ -1,9 +1,9 @@
import log from "@/next/log";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { CustomError } from "@ente/shared/error";
import { addLogLine } from "@ente/shared/logging";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import localForage from "@ente/shared/storage/localForage";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import {
@ -138,7 +138,7 @@ export const syncEmbeddings = async (models: Model[] = [Model.ONNX_CLIP]) => {
} while (response.diff.length === DIFF_LIMIT);
}
} catch (e) {
logError(e, "Sync embeddings failed");
log.error("Sync embeddings failed", e);
}
};
@ -164,7 +164,7 @@ export const getEmbeddingsDiff = async (
);
return await response.data;
} catch (e) {
logError(e, "get embeddings diff failed");
log.error("get embeddings diff failed", e);
throw e;
}
};
@ -187,7 +187,7 @@ export const putEmbedding = async (
);
return resp.data;
} catch (e) {
logError(e, "put embedding failed");
log.error("put embedding failed", e);
throw e;
}
};

View file

@ -2,7 +2,6 @@ import ComlinkCryptoWorker from "@ente/shared/crypto";
import { addLogLine } from "@ente/shared/logging";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import localForage from "@ente/shared/storage/localForage";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { getActualKey } from "@ente/shared/user";
@ -82,7 +81,7 @@ const getEntityKey = async (type: EntityType) => {
localForage.setItem(ENTITY_KEY_TABLES[type], decryptedEntityKey);
return decryptedEntityKey;
} catch (e) {
logError(e, "Get entity key failed");
log.error("Get entity key failed", e);
throw e;
}
};
@ -92,7 +91,7 @@ export const getLatestEntities = async <T>(type: EntityType) => {
await syncEntity<T>(type);
return await getLocalEntity<T>(type);
} catch (e) {
logError(e, "Sync entities failed");
log.error("Sync entities failed", e);
throw e;
}
};
@ -101,7 +100,7 @@ export const syncEntities = async () => {
try {
await syncEntity(EntityType.LOCATION_TAG);
} catch (e) {
logError(e, "Sync entities failed");
log.error("Sync entities failed", e);
throw e;
}
};
@ -162,7 +161,7 @@ const syncEntity = async <T>(type: EntityType): Promise<Entity<T>> => {
);
} while (response.diff.length === DIFF_LIMIT);
} catch (e) {
logError(e, "Sync entity failed");
log.error("Sync entity failed", e);
}
};
@ -189,7 +188,7 @@ const getEntityDiff = async (
return resp.data;
} catch (e) {
logError(e, "Get entity diff failed");
log.error("Get entity diff failed", e);
throw e;
}
};

View file

@ -2,7 +2,6 @@ import log from "@/next/log";
import type { Electron } from "@/next/types/ipc";
import { CustomError } from "@ente/shared/error";
import { Events, eventBus } from "@ente/shared/events";
import { logError } from "@ente/shared/sentry";
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
import { User } from "@ente/shared/user/types";
import { sleep } from "@ente/shared/utils";
@ -111,7 +110,7 @@ class ExportService {
this.exportSettings = exportSettings;
return exportSettings;
} catch (e) {
logError(e, "getExportSettings failed");
log.error("getExportSettings failed", e);
throw e;
}
}
@ -123,7 +122,7 @@ class ExportService {
this.exportSettings = newSettings;
setData(LS_KEYS.EXPORT, newSettings);
} catch (e) {
logError(e, "updateExportSettings failed");
log.error("updateExportSettings failed", e);
throw e;
}
}
@ -138,7 +137,7 @@ class ExportService {
await migrateExport(exportDir, exportRecord, updateProgress);
log.info("migration completed");
} catch (e) {
logError(e, "migration failed");
log.error("migration failed", e);
throw e;
}
}
@ -178,7 +177,7 @@ class ExportService {
return newExportDir;
} catch (e) {
if (e.message !== CustomError.SELECT_FOLDER_ABORTED) {
logError(e, "changeExportDirectory failed");
log.error("changeExportDirectory failed", e);
}
throw e;
}
@ -200,7 +199,7 @@ class ExportService {
this.continuousExportEventHandler,
);
} catch (e) {
logError(e, "failed to enableContinuousExport ");
log.error("failed to enableContinuousExport ", e);
throw e;
}
}
@ -218,7 +217,7 @@ class ExportService {
);
this.continuousExportEventHandler = null;
} catch (e) {
logError(e, "failed to disableContinuousExport");
log.error("failed to disableContinuousExport", e);
throw e;
}
}
@ -248,7 +247,7 @@ class ExportService {
);
return unExportedFiles;
} catch (e) {
logError(e, "getUpdateFileLists failed");
log.error("getUpdateFileLists failed", e);
throw e;
}
};
@ -280,7 +279,7 @@ class ExportService {
const pendingExports = await this.getPendingExports(exportRecord);
this.uiUpdater.setPendingExports(pendingExports);
} catch (e) {
logError(e, "postExport failed");
log.error("postExport failed", e);
}
}
@ -292,7 +291,7 @@ class ExportService {
this.reRunNeeded = false;
await this.postExport();
} catch (e) {
logError(e, "stopRunningExport failed");
log.error("stopRunningExport failed", e);
}
}
@ -341,7 +340,7 @@ class ExportService {
e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST &&
e.message !== CustomError.EXPORT_STOPPED
) {
logError(e, "scheduleExport failed");
log.error("scheduleExport failed", e);
}
}
};
@ -475,7 +474,7 @@ class ExportService {
e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST &&
e.message !== CustomError.EXPORT_STOPPED
) {
logError(e, "runExport failed");
log.error("runExport failed", e);
}
throw e;
}
@ -544,7 +543,7 @@ class ExportService {
`renaming collection with id ${collection.id} from ${oldCollectionExportName} to ${newCollectionExportName} successful`,
);
} catch (e) {
logError(e, "collectionRenamer failed a collection");
log.error("collectionRenamer failed a collection", e);
if (
e.message ===
CustomError.UPDATE_EXPORTED_RECORD_FAILED ||
@ -561,7 +560,7 @@ class ExportService {
e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST &&
e.message !== CustomError.EXPORT_STOPPED
) {
logError(e, "collectionRenamer failed");
log.error("collectionRenamer failed", e);
}
throw e;
}
@ -626,7 +625,7 @@ class ExportService {
`removing collection with id ${collectionID} from export folder successful`,
);
} catch (e) {
logError(e, "collectionRemover failed a collection");
log.error("collectionRemover failed a collection", e);
if (
e.message ===
CustomError.UPDATE_EXPORTED_RECORD_FAILED ||
@ -643,7 +642,7 @@ class ExportService {
e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST &&
e.message !== CustomError.EXPORT_STOPPED
) {
logError(e, "collectionRemover failed");
log.error("collectionRemover failed", e);
}
throw e;
}
@ -717,7 +716,7 @@ class ExportService {
);
} catch (e) {
incrementFailed();
logError(e, "export failed for a file");
log.error("export failed for a file", e);
if (
e.message ===
CustomError.UPDATE_EXPORTED_RECORD_FAILED ||
@ -734,7 +733,7 @@ class ExportService {
e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST &&
e.message !== CustomError.EXPORT_STOPPED
) {
logError(e, "fileExporter failed");
log.error("fileExporter failed", e);
}
throw e;
}
@ -873,7 +872,7 @@ class ExportService {
}
log.info(`trashing file with id ${fileUID} successful`);
} catch (e) {
logError(e, "trashing failed for a file");
log.error("trashing failed for a file", e);
if (
e.message ===
CustomError.UPDATE_EXPORTED_RECORD_FAILED ||
@ -890,7 +889,7 @@ class ExportService {
e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST &&
e.message !== CustomError.EXPORT_STOPPED
) {
logError(e, "fileTrasher failed");
log.error("fileTrasher failed", e);
}
throw e;
}
@ -913,7 +912,7 @@ class ExportService {
await this.updateExportRecord(folder, exportRecord);
} catch (e) {
if (e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST) {
logError(e, "addFileExportedRecord failed");
log.error("addFileExportedRecord failed", e);
}
throw e;
}
@ -937,7 +936,7 @@ class ExportService {
await this.updateExportRecord(folder, exportRecord);
} catch (e) {
if (e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST) {
logError(e, "addCollectionExportedRecord failed");
log.error("addCollectionExportedRecord failed", e);
}
throw e;
}
@ -956,7 +955,7 @@ class ExportService {
await this.updateExportRecord(folder, exportRecord);
} catch (e) {
if (e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST) {
logError(e, "removeCollectionExportedRecord failed");
log.error("removeCollectionExportedRecord failed", e);
}
throw e;
}
@ -973,7 +972,7 @@ class ExportService {
await this.updateExportRecord(folder, exportRecord);
} catch (e) {
if (e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST) {
logError(e, "removeFileExportedRecord failed");
log.error("removeFileExportedRecord failed", e);
}
throw e;
}
@ -1002,7 +1001,7 @@ class ExportService {
if (e.message === CustomError.EXPORT_FOLDER_DOES_NOT_EXIST) {
throw e;
}
logError(e, "error updating Export Record");
log.error("error updating Export Record", e);
throw Error(CustomError.UPDATE_EXPORTED_RECORD_FAILED);
}
}
@ -1030,7 +1029,7 @@ class ExportService {
return await this.getExportRecord(folder, false);
}
if (e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST) {
logError(e, "export Record JSON parsing failed");
log.error("export Record JSON parsing failed", e);
}
throw e;
}
@ -1109,7 +1108,7 @@ class ExportService {
}
}
} catch (e) {
logError(e, "download and save failed");
log.error("download and save failed", e);
throw e;
}
}
@ -1213,7 +1212,7 @@ class ExportService {
}
} catch (e) {
if (e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST) {
logError(e, "verifyExportFolderExists failed");
log.error("verifyExportFolderExists failed", e);
}
throw e;
}

View file

@ -1,4 +1,4 @@
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import {
FFMPEG_PLACEHOLDER,
INPUT_PATH_PLACEHOLDER,
@ -40,7 +40,7 @@ export async function generateVideoThumbnail(
seekTime--;
}
} catch (e) {
logError(e, "ffmpeg generateVideoThumbnail failed");
log.error("ffmpeg generateVideoThumbnail failed", e);
throw e;
}
}
@ -72,7 +72,7 @@ export async function extractVideoMetadata(file: File | ElectronFile) {
new Uint8Array(await metadata.arrayBuffer()),
);
} catch (e) {
logError(e, "ffmpeg extractVideoMetadata failed");
log.error("ffmpeg extractVideoMetadata failed", e);
throw e;
}
}
@ -94,7 +94,7 @@ export async function convertToMP4(file: File | ElectronFile) {
true,
);
} catch (e) {
logError(e, "ffmpeg convertToMP4 failed");
log.error("ffmpeg convertToMP4 failed", e);
throw e;
}
}

View file

@ -1,11 +1,11 @@
import { getEndpoint } from "@ente/shared/network/api";
import localForage from "@ente/shared/storage/localForage";
import log from "@/next/log";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { Events, eventBus } from "@ente/shared/events";
import { addLogLine } from "@ente/shared/logging";
import HTTPService from "@ente/shared/network/HTTPService";
import { logError } from "@ente/shared/sentry";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { REQUEST_BATCH_SIZE } from "constants/api";
import { Collection } from "types/collection";
@ -48,7 +48,7 @@ const setLocalFiles = async (type: "normal" | "hidden", files: EnteFile[]) => {
try {
eventBus.emit(Events.LOCAL_FILES_UPDATED);
} catch (e) {
logError(e, "Error in localFileUpdated handlers");
log.error("Error in localFileUpdated handlers", e);
}
} catch (e1) {
try {
@ -151,7 +151,7 @@ export const getFiles = async (
} while (resp.data.hasMore);
return decryptedFiles;
} catch (e) {
logError(e, "Get files failed");
log.error("Get files failed", e);
throw e;
}
};
@ -192,7 +192,7 @@ export const trashFiles = async (filesToTrash: EnteFile[]) => {
);
}
} catch (e) {
logError(e, "trash file failed");
log.error("trash file failed", e);
throw e;
}
};
@ -216,7 +216,7 @@ export const deleteFromTrash = async (filesToDelete: number[]) => {
);
}
} catch (e) {
logError(e, "deleteFromTrash failed");
log.error("deleteFromTrash failed", e);
throw e;
}
};

View file

@ -1,8 +1,8 @@
import { convertBytesToHumanReadable } from "@/next/file";
import log from "@/next/log";
import { ComlinkWorker } from "@/next/worker/comlink-worker";
import { CustomError } from "@ente/shared/error";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { retryAsyncFunction } from "@ente/shared/utils";
import QueueProcessor from "@ente/shared/utils/queueProcessor";
import { getDedicatedConvertWorker } from "utils/comlink/ComlinkConvertWorker";
@ -87,7 +87,7 @@ class HEICConverter {
this.workerPool.push(convertWorker);
return convertedHEIC;
} catch (e) {
logError(e, "heic conversion failed");
log.error("heic conversion failed", e);
convertWorker.terminate();
this.workerPool.push(getDedicatedConvertWorker());
throw e;

View file

@ -1,4 +1,3 @@
import { logError } from "@ente/shared/sentry";
import WasmHEICConverterService from "./heic-convert/service";
class HeicConversionService {
@ -6,7 +5,7 @@ class HeicConversionService {
try {
return await WasmHEICConverterService.convert(heicFileData);
} catch (e) {
logError(e, "failed to convert heic file");
log.error("failed to convert heic file", e);
throw e;
}
}

View file

@ -1,5 +1,4 @@
import ElectronAPIs from "@/next/electron";
import { logError } from "@ente/shared/sentry";
import { PICKED_UPLOAD_TYPE } from "constants/upload";
import { Collection } from "types/collection";
import { ElectronFile, FileWithCollection } from "types/upload";
@ -20,7 +19,7 @@ class ImportService {
if (e?.message?.includes("ENOENT: no such file or directory")) {
// ignore
} else {
logError(e, "failed to getPendingUploads ");
log.error("failed to getPendingUploads ", e);
}
return { files: [], collectionName: null, type: null };
}

View file

@ -1,4 +1,3 @@
import { logError } from "@ente/shared/sentry";
import { LocationTagData } from "types/entity";
import { Location } from "types/upload";
@ -30,7 +29,7 @@ class LocationSearchService {
});
await this.citiesPromise;
} catch (e) {
logError(e, "LocationSearchService loadCities failed");
log.error("LocationSearchService loadCities failed", e);
this.citiesPromise = null;
}
}
@ -47,7 +46,7 @@ class LocationSearchService {
.startsWith(searchTerm.toLowerCase());
});
} catch (e) {
logError(e, "LocationSearchService searchCities failed");
log.error("LocationSearchService searchCities failed", e);
throw e;
}
}

View file

@ -1,7 +1,6 @@
import { APPS } from "@ente/shared/apps/constants";
import { CustomError, parseUploadErrorCodes } from "@ente/shared/error";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import "@tensorflow/tfjs-backend-cpu";
import "@tensorflow/tfjs-backend-webgl";
import * as tf from "@tensorflow/tfjs-core";
@ -294,7 +293,7 @@ class MachineLearningService {
syncContext.nSyncedFiles += 1;
return mlFileData;
} catch (e) {
logError(e, "ML syncFile failed");
log.error("ML syncFile failed", e);
let error = e;
console.error(
"Error in ml sync, fileId: ",
@ -362,7 +361,7 @@ class MachineLearningService {
newMlFile.lastErrorMessage = undefined;
await this.persistMLFileData(syncContext, newMlFile);
} catch (e) {
logError(e, "ml detection failed");
log.error("ml detection failed", e);
newMlFile.mlVersion = oldMlFile.mlVersion;
throw e;
} finally {

View file

@ -1,7 +1,7 @@
import log from "@/next/log";
import { ComlinkWorker } from "@/next/worker/comlink-worker";
import { eventBus, Events } from "@ente/shared/events";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { getToken, getUserID } from "@ente/shared/storage/localStorage/helpers";
import { FILE_TYPE } from "constants/file";
import debounce from "debounce";
@ -96,7 +96,7 @@ class MLWorkManager {
try {
this.startSyncJob();
} catch (e) {
logError(e, "Failed in ML appStart Handler");
log.error("Failed in ML appStart Handler", e);
}
}
@ -108,7 +108,7 @@ class MLWorkManager {
await this.terminateLiveSyncWorker();
await mlIDbStorage.clearMLDB();
} catch (e) {
logError(e, "Failed in ML logout Handler");
log.error("Failed in ML logout Handler", e);
}
}
@ -233,7 +233,7 @@ class MLWorkManager {
return jobResult;
} catch (e) {
logError(e, "Failed to run MLSync Job");
log.error("Failed to run MLSync Job", e);
}
}
@ -256,7 +256,7 @@ class MLWorkManager {
}
this.mlSyncJob.start();
} catch (e) {
logError(e, "Failed to start MLSync Job");
log.error("Failed to start MLSync Job", e);
}
}
@ -266,7 +266,7 @@ class MLWorkManager {
this.mlSyncJob?.stop();
terminateWorker && this.terminateSyncJobWorker();
} catch (e) {
logError(e, "Failed to stop MLSync Job");
log.error("Failed to stop MLSync Job", e);
}
}
}

View file

@ -1,4 +1,4 @@
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import { FILE_TYPE } from "constants/file";
import { MLSyncContext, MLSyncFileContext } from "types/machineLearning";
import {
@ -51,7 +51,7 @@ class ReaderService {
return fileContext.imageBitmap;
} catch (e) {
logError(e, "failed to create image bitmap");
log.error("failed to create image bitmap", e);
throw e;
}
}

View file

@ -1,8 +1,8 @@
import log from "@/next/log";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { CustomError, parseSharingErrorCodes } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import localForage from "@ente/shared/storage/localForage";
import { Collection, CollectionPublicMagicMetadata } from "types/collection";
import { EncryptedEnteFile, EnteFile } from "types/file";
@ -223,14 +223,14 @@ export const syncPublicFiles = async (
setPublicFiles([...sortFiles(mergeMetadata(files), sortAsc)]);
} catch (e) {
const parsedError = parseSharingErrorCodes(e);
logError(e, "failed to sync shared collection files");
log.error("failed to sync shared collection files", e);
if (parsedError.message === CustomError.TOKEN_EXPIRED) {
throw e;
}
}
return [...sortFiles(mergeMetadata(files), sortAsc)];
} catch (e) {
logError(e, "failed to get local or sync shared collection files");
log.error("failed to get local or sync shared collection files", e);
throw e;
}
};
@ -294,7 +294,7 @@ const getPublicFiles = async (
} while (resp.data.hasMore);
return decryptedFiles;
} catch (e) {
logError(e, "Get public files failed");
log.error("Get public files failed", e);
throw e;
}
};
@ -347,7 +347,7 @@ export const getPublicCollection = async (
await saveReferralCode(referralCode);
return [collection, referralCode];
} catch (e) {
logError(e, "failed to get public collection");
log.error("failed to get public collection", e);
throw e;
}
};
@ -366,7 +366,7 @@ export const verifyPublicCollectionPassword = async (
const jwtToken = resp.data.jwtToken;
return jwtToken;
} catch (e) {
logError(e, "failed to verify public collection password");
log.error("failed to verify public collection password", e);
throw e;
}
};

View file

@ -1,5 +1,5 @@
import { convertBytesToHumanReadable } from "@/next/file";
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import { ElectronFile } from "types/upload";
export async function getUint8ArrayView(
@ -8,9 +8,10 @@ export async function getUint8ArrayView(
try {
return new Uint8Array(await file.arrayBuffer());
} catch (e) {
logError(e, "reading file blob failed", {
fileSize: convertBytesToHumanReadable(file.size),
});
log.error(
`Failed to read file blob of size ${convertBytesToHumanReadable(file.size)}`,
e,
);
throw e;
}
}

View file

@ -1,11 +1,9 @@
import * as chrono from "chrono-node";
import { t } from "i18next";
import { getAllPeople } from "utils/machineLearning";
import log from "@/next/log";
import { CustomError } from "@ente/shared/error";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import * as chrono from "chrono-node";
import { FILE_TYPE } from "constants/file";
import { t } from "i18next";
import { Collection } from "types/collection";
import { Model } from "types/embedding";
import { EntityType, LocationTag, LocationTagData } from "types/entity";
@ -21,6 +19,7 @@ import {
} from "types/search";
import ComlinkSearchWorker from "utils/comlink/ComlinkSearchWorker";
import { getUniqueFiles } from "utils/file";
import { getAllPeople } from "utils/machineLearning";
import { getMLSyncConfig } from "utils/machineLearning/config";
import { getFormattedDate } from "utils/search";
import mlIDbStorage from "utils/storage/mlIDbStorage";
@ -64,7 +63,7 @@ export const getAutoCompleteSuggestions =
return convertSuggestionsToOptions(suggestions);
} catch (e) {
logError(e, "getAutoCompleteSuggestions failed");
log.error("getAutoCompleteSuggestions failed", e);
return [];
}
};
@ -159,7 +158,7 @@ function getYearSuggestion(searchPhrase: string): Suggestion[] {
];
}
} catch (e) {
logError(e, "getYearSuggestion failed");
log.error("getYearSuggestion failed", e);
}
}
return [];
@ -175,7 +174,7 @@ export async function getAllPeopleSuggestion(): Promise<Array<Suggestion>> {
hide: true,
}));
} catch (e) {
logError(e, "getAllPeopleSuggestion failed");
log.error("getAllPeopleSuggestion failed", e);
return [];
}
}
@ -205,7 +204,7 @@ export async function getIndexStatusSuggestion(): Promise<Suggestion> {
hide: true,
};
} catch (e) {
logError(e, "getIndexStatusSuggestion failed");
log.error("getIndexStatusSuggestion failed", e);
}
}
@ -319,7 +318,7 @@ async function getClipSuggestion(searchPhrase: string): Promise<Suggestion> {
};
} catch (e) {
if (!e.message?.includes(CustomError.MODEL_DOWNLOAD_PENDING)) {
logError(e, "getClipSuggestion failed");
log.error("getClipSuggestion failed", e);
}
return null;
}

View file

@ -1,16 +1,14 @@
import log from "@/next/log";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import localForage from "@ente/shared/storage/localForage";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { Collection } from "types/collection";
import { SetFiles } from "types/gallery";
import { decryptFile, sortTrashFiles } from "utils/file";
import { getCollection } from "./collectionService";
import HTTPService from "@ente/shared/network/HTTPService";
import { EnteFile } from "types/file";
import { SetFiles } from "types/gallery";
import { EncryptedTrashItem, Trash } from "types/trash";
import { mergeMetadata } from "utils/file";
import { decryptFile, mergeMetadata, sortTrashFiles } from "utils/file";
import { getCollection } from "./collectionService";
const TRASH = "file-trash";
const TRASH_TIME = "trash-time";
@ -135,7 +133,7 @@ export const updateTrash = async (
} while (resp.data.hasMore);
return updatedTrash;
} catch (e) {
logError(e, "Get trash files failed");
log.error("Get trash files failed", e);
}
return currentTrash;
};
@ -170,7 +168,7 @@ export const emptyTrash = async () => {
},
);
} catch (e) {
logError(e, "empty trash failed");
log.error("empty trash failed", e);
throw e;
}
};

View file

@ -1,6 +1,5 @@
import { convertBytesToHumanReadable } from "@/next/file";
import log from "@/next/log";
import { CustomError } from "@ente/shared/error";
import { logError } from "@ente/shared/sentry";
import { FILE_TYPE } from "constants/file";
import {
KNOWN_NON_MEDIA_FORMATS,
@ -10,7 +9,6 @@ import FileType, { FileTypeResult } from "file-type";
import { ElectronFile, FileTypeInfo } from "types/upload";
import { getFileExtension } from "utils/file";
import { getUint8ArrayView } from "./readerService";
import { getFileSize } from "./upload/fileService";
const TYPE_VIDEO = "video";
const TYPE_IMAGE = "image";
@ -51,7 +49,6 @@ export async function getFileType(
};
} catch (e) {
const fileFormat = getFileExtension(receivedFile.name);
const fileSize = convertBytesToHumanReadable(getFileSize(receivedFile));
const whiteListedFormat = WHITELISTED_FILE_FORMATS.find(
(a) => a.exactType === fileFormat,
);
@ -62,16 +59,10 @@ export async function getFileType(
throw Error(CustomError.UNSUPPORTED_FILE_FORMAT);
}
if (e.message === CustomError.NON_MEDIA_FILE) {
logError(e, "unsupported file format", {
fileFormat,
fileSize,
});
log.error(`unsupported file format ${fileFormat}`, e);
throw Error(CustomError.UNSUPPORTED_FILE_FORMAT);
}
logError(e, "type detection failed", {
fileFormat,
fileSize,
});
log.error(`type detection failed for format ${fileFormat}`, e);
throw Error(CustomError.TYPE_DETECTION_FAILED(fileFormat));
}
}

View file

@ -1,4 +1,4 @@
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import { validateAndGetCreationUnixTimeInMicroSeconds } from "@ente/shared/time";
import type { FixOption } from "components/FixCreationTime";
import { FILE_TYPE } from "constants/file";
@ -88,7 +88,7 @@ export async function updateCreationTimeWithExif(
updateExistingFilePubMetadata(file, updatedFile);
}
} catch (e) {
logError(e, "failed to updated a CreationTime With Exif");
log.error("failed to updated a CreationTime With Exif", e);
completedWithError = true;
} finally {
setProgressTracker({
@ -98,7 +98,7 @@ export async function updateCreationTimeWithExif(
}
}
} catch (e) {
logError(e, "update CreationTime With Exif failed");
log.error("update CreationTime With Exif failed", e);
completedWithError = true;
}
return completedWithError;

View file

@ -1,5 +1,5 @@
import log from "@/next/log";
import { CustomError } from "@ente/shared/error";
import { logError } from "@ente/shared/sentry";
import { validateAndGetCreationUnixTimeInMicroSeconds } from "@ente/shared/time";
import { EXIFLESS_FORMATS, NULL_LOCATION } from "constants/upload";
import exifr from "exifr";
@ -330,7 +330,7 @@ export async function updateFileCreationDateInEXIF(
const exifInsertedFile = piexif.insert(exifBytes, imageDataURL);
return dataURIToBlob(exifInsertedFile);
} catch (e) {
logError(e, "updateFileModifyDateInEXIF failed");
log.error("updateFileModifyDateInEXIF failed", e);
return fileBlob;
}
}

View file

@ -1,7 +1,10 @@
import { getFileNameSize } from "@/next/file";
import log from "@/next/log";
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { Remote } from "comlink";
import { FILE_READER_CHUNK_SIZE, MULTIPART_PART_SIZE } from "constants/upload";
import { EncryptedMagicMetadata } from "types/magicMetadata";
import {
DataStream,
ElectronFile,
@ -13,10 +16,6 @@ import {
ParsedMetadataJSON,
ParsedMetadataJSONMap,
} from "types/upload";
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
import { Remote } from "comlink";
import { EncryptedMagicMetadata } from "types/magicMetadata";
import {
getElectronFileStream,
getFileStream,
@ -152,7 +151,7 @@ export async function encryptFile(
};
return result;
} catch (e) {
logError(e, "Error encrypting files");
log.error("Error encrypting files", e);
throw e;
}
}

View file

@ -2,11 +2,11 @@ import { getFileNameSize } from "@/next/file";
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
import { CustomError } from "@ente/shared/error";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { Remote } from "comlink";
import { FILE_READER_CHUNK_SIZE } from "constants/upload";
import { getElectronFileStream, getFileStream } from "services/readerService";
import { DataStream, ElectronFile } from "types/upload";
import log from "@/next/log";
export async function getFileHash(
worker: Remote<DedicatedCryptoWorker>,
@ -43,7 +43,7 @@ export async function getFileHash(
);
return hash;
} catch (e) {
logError(e, "getFileHash failed");
log.error("getFileHash failed", e);
addLogLine(
`file hashing failed ${getFileNameSize(file)} ,${e.message} `,
);

View file

@ -1,6 +1,6 @@
import log from "@/next/log";
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
import { CustomError } from "@ente/shared/error";
import { logError } from "@ente/shared/sentry";
import { Remote } from "comlink";
import { FILE_TYPE } from "constants/file";
import { LIVE_PHOTO_ASSET_SIZE_LIMIT } from "constants/upload";
@ -213,7 +213,7 @@ export async function clusterLivePhotoFiles(mediaFiles: FileWithCollection[]) {
if (e.message === CustomError.UPLOAD_CANCELLED) {
throw e;
} else {
logError(e, "failed to cluster live photo");
log.error("failed to cluster live photo", e);
throw e;
}
}

View file

@ -1,5 +1,5 @@
import log from "@/next/log";
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
import { logError } from "@ente/shared/sentry";
import {
parseDateFromFusedDateString,
tryToParseDateTime,
@ -109,7 +109,7 @@ export async function getImageMetadata(
height: exifData?.imageHeight ?? null,
};
} catch (e) {
logError(e, "getExifData failed");
log.error("getExifData failed", e);
}
return imageMetadata;
}
@ -206,7 +206,7 @@ export async function parseMetadataJSON(receivedFile: File | ElectronFile) {
}
return parsedMetadataJSON;
} catch (e) {
logError(e, "parseMetadataJSON failed");
log.error("parseMetadataJSON failed", e);
// ignore
}
}
@ -237,7 +237,7 @@ export function extractDateFromFileName(filename: string): number {
}
return validateAndGetCreationUnixTimeInMicroSeconds(parsedDate);
} catch (e) {
logError(e, "failed to extract date From FileName ");
log.error("failed to extract date From FileName ", e);
return null;
}
}
@ -250,7 +250,7 @@ function convertSignalNameToFusedDateString(filename: string) {
const EDITED_FILE_SUFFIX = "-edited";
/*
Get the original file name for edited file to associate it to original file's metadataJSON file
Get the original file name for edited file to associate it to original file's metadataJSON file
as edited file doesn't have their own metadata file
*/
function getFileOriginalName(fileName: string) {

View file

@ -1,7 +1,7 @@
import log from "@/next/log";
import { CustomError, handleUploadError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import { EnteFile } from "types/file";
import { MultipartUploadURLs, UploadFile, UploadURL } from "types/upload";
import { retryHTTPCall } from "utils/upload/uploadRetrier";
@ -39,7 +39,7 @@ class PublicUploadHttpClient {
);
return response.data;
} catch (e) {
logError(e, "upload public File Failed");
log.error("upload public File Failed", e);
throw e;
}
}
@ -78,7 +78,7 @@ class PublicUploadHttpClient {
}
return this.uploadURLFetchInProgress;
} catch (e) {
logError(e, "fetch public upload-url failed ");
log.error("fetch public upload-url failed ", e);
throw e;
}
}
@ -107,7 +107,7 @@ class PublicUploadHttpClient {
return response.data["urls"];
} catch (e) {
logError(e, "fetch public multipart-upload-url failed");
log.error("fetch public multipart-upload-url failed", e);
throw e;
}
}

View file

@ -1,8 +1,8 @@
import ElectronAPIs from "@/next/electron";
import { convertBytesToHumanReadable, getFileNameSize } from "@/next/file";
import log from "@/next/log";
import { CustomError } from "@ente/shared/error";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { FILE_TYPE } from "constants/file";
import { BLACK_THUMBNAIL_BASE64 } from "constants/upload";
import isElectron from "is-electron";
@ -74,7 +74,7 @@ export async function generateThumbnail(
}
return { thumbnail, hasStaticThumbnail };
} catch (e) {
logError(e, "Error generating static thumbnail");
log.error("Error generating static thumbnail", e);
throw e;
}
}
@ -125,7 +125,7 @@ const generateImageThumbnailInElectron = async (
e.message !==
CustomError.WINDOWS_NATIVE_IMAGE_PROCESSING_NOT_SUPPORTED
) {
logError(e, "failed to generate image thumbnail natively");
log.error("failed to generate image thumbnail natively", e);
}
throw e;
}

View file

@ -1,7 +1,7 @@
import log from "@/next/log";
import { CustomError, handleUploadError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint, getUploadEndpoint } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { EnteFile } from "types/file";
import { MultipartUploadURLs, UploadFile, UploadURL } from "types/upload";
@ -30,7 +30,7 @@ class UploadHttpClient {
);
return response.data;
} catch (e) {
logError(e, "upload Files Failed");
log.error("upload Files Failed", e);
throw e;
}
}
@ -60,7 +60,7 @@ class UploadHttpClient {
}
return this.uploadURLFetchInProgress;
} catch (e) {
logError(e, "fetch upload-url failed ");
log.error("fetch upload-url failed ", e);
throw e;
}
}
@ -83,7 +83,7 @@ class UploadHttpClient {
return response.data["urls"];
} catch (e) {
logError(e, "fetch multipart-upload-url failed");
log.error("fetch multipart-upload-url failed", e);
throw e;
}
}
@ -108,7 +108,7 @@ class UploadHttpClient {
return fileUploadURL.objectKey;
} catch (e) {
if (e.message !== CustomError.UPLOAD_CANCELLED) {
logError(e, "putFile to dataStore failed ");
log.error("putFile to dataStore failed ", e);
}
throw e;
}
@ -134,7 +134,7 @@ class UploadHttpClient {
return fileUploadURL.objectKey;
} catch (e) {
if (e.message !== CustomError.UPLOAD_CANCELLED) {
logError(e, "putFile to dataStore failed ");
log.error("putFile to dataStore failed ", e);
}
throw e;
}
@ -164,7 +164,7 @@ class UploadHttpClient {
return response.headers.etag as string;
} catch (e) {
if (e.message !== CustomError.UPLOAD_CANCELLED) {
logError(e, "put filePart failed");
log.error("put filePart failed", e);
}
throw e;
}
@ -196,7 +196,7 @@ class UploadHttpClient {
return response.data.etag as string;
} catch (e) {
if (e.message !== CustomError.UPLOAD_CANCELLED) {
logError(e, "put filePart failed");
log.error("put filePart failed", e);
}
throw e;
}
@ -210,7 +210,7 @@ class UploadHttpClient {
}),
);
} catch (e) {
logError(e, "put file in parts failed");
log.error("put file in parts failed", e);
throw e;
}
}
@ -229,7 +229,7 @@ class UploadHttpClient {
),
);
} catch (e) {
logError(e, "put file in parts failed");
log.error("put file in parts failed", e);
throw e;
}
}

View file

@ -1,33 +1,10 @@
import { CustomError } from "@ente/shared/error";
import { Events, eventBus } from "@ente/shared/events";
import { logError } from "@ente/shared/sentry";
import { Collection } from "types/collection";
import { EncryptedEnteFile, EnteFile } from "types/file";
import { SetFiles } from "types/gallery";
import {
FileWithCollection,
ParsedMetadataJSON,
ParsedMetadataJSONMap,
PublicUploadProps,
} from "types/upload";
import { decryptFile, getUserOwnedFiles, sortFiles } from "utils/file";
import {
areFileWithCollectionsSame,
segregateMetadataAndMediaFiles,
} from "utils/upload";
import { getLocalFiles } from "../fileService";
import {
getMetadataJSONMapKeyForJSON,
parseMetadataJSON,
} from "./metadataService";
import UIService from "./uiService";
import UploadService from "./uploadService";
import uploader from "./uploader";
import { getFileNameSize } from "@/next/file";
import log from "@/next/log";
import { ComlinkWorker } from "@/next/worker/comlink-worker";
import { getDedicatedCryptoWorker } from "@ente/shared/crypto";
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
import { CustomError } from "@ente/shared/error";
import { Events, eventBus } from "@ente/shared/events";
import { addLogLine } from "@ente/shared/logging";
import { Remote } from "comlink";
import { UPLOAD_RESULT, UPLOAD_STAGES } from "constants/upload";
@ -39,9 +16,30 @@ import {
} from "services/publicCollectionService";
import { getDisableCFUploadProxyFlag } from "services/userService";
import watchFolderService from "services/watchFolder/watchFolderService";
import { Collection } from "types/collection";
import { EncryptedEnteFile, EnteFile } from "types/file";
import { SetFiles } from "types/gallery";
import {
FileWithCollection,
ParsedMetadataJSON,
ParsedMetadataJSONMap,
PublicUploadProps,
} from "types/upload";
import { ProgressUpdater } from "types/upload/ui";
import uiService from "./uiService";
import { decryptFile, getUserOwnedFiles, sortFiles } from "utils/file";
import {
areFileWithCollectionsSame,
segregateMetadataAndMediaFiles,
} from "utils/upload";
import { getLocalFiles } from "../fileService";
import {
getMetadataJSONMapKeyForJSON,
parseMetadataJSON,
} from "./metadataService";
import { default as UIService, default as uiService } from "./uiService";
import uploadCancelService from "./uploadCancelService";
import UploadService from "./uploadService";
import uploader from "./uploader";
const MAX_CONCURRENT_UPLOADS = 4;
@ -183,7 +181,7 @@ class UploadManager {
await ImportService.cancelRemainingUploads();
}
} else {
logError(e, "uploading failed with error");
log.error("uploading failed with error", e);
throw e;
}
} finally {
@ -200,7 +198,7 @@ class UploadManager {
return false;
}
} catch (e) {
logError(e, " failed to return shouldCloseProgressBar");
log.error(" failed to return shouldCloseProgressBar", e);
return false;
}
}
@ -241,7 +239,7 @@ class UploadManager {
throw e;
} else {
// and don't break for subsequent files just log and move on
logError(e, "parsing failed for a file");
log.error("parsing failed for a file", e);
addLogLine(
`failed to parse metadata json file ${getFileNameSize(
file,
@ -252,7 +250,7 @@ class UploadManager {
}
} catch (e) {
if (e.message !== CustomError.UPLOAD_CANCELLED) {
logError(e, "error seeding MetadataMap");
log.error("error seeding MetadataMap", e);
}
throw e;
}
@ -368,7 +366,7 @@ class UploadManager {
fileWithCollection.livePhotoAssets.image,
});
} catch (e) {
logError(e, "Error in fileUploaded handlers");
log.error("Error in fileUploaded handlers", e);
}
this.updateExistingFiles(decryptedFile);
}
@ -379,7 +377,7 @@ class UploadManager {
);
return fileUploadResult;
} catch (e) {
logError(e, "failed to do post file upload action");
log.error("failed to do post file upload action", e);
return UPLOAD_RESULT.FAILED;
}
}

View file

@ -1,7 +1,7 @@
import log from "@/next/log";
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
import { B64EncryptionResult } from "@ente/shared/crypto/types";
import { CustomError, handleUploadError } from "@ente/shared/error";
import { logError } from "@ente/shared/sentry";
import { Remote } from "comlink";
import { Collection } from "types/collection";
import { FilePublicMagicMetadataProps } from "types/file";
@ -231,7 +231,7 @@ class UploadService {
return backupedFile;
} catch (e) {
if (e.message !== CustomError.UPLOAD_CANCELLED) {
logError(e, "error uploading to bucket");
log.error("error uploading to bucket", e);
}
throw e;
}
@ -264,7 +264,7 @@ class UploadService {
await this.fetchUploadURLs();
// checking for any subscription related errors
} catch (e) {
logError(e, "prefetch uploadURL failed");
log.error("prefetch uploadURL failed", e);
handleUploadError(e);
}
}

View file

@ -1,6 +1,6 @@
import { getFileNameSize } from "@/next/file";
import log from "@/next/log";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { NULL_EXTRACTED_METADATA } from "constants/upload";
import * as ffmpegService from "services/ffmpeg/ffmpegService";
import { ElectronFile } from "types/upload";
@ -14,7 +14,7 @@ export async function getVideoMetadata(file: File | ElectronFile) {
`videoMetadata successfully extracted ${getFileNameSize(file)}`,
);
} catch (e) {
logError(e, "failed to get video metadata");
log.error("failed to get video metadata", e);
addLogLine(
`videoMetadata extracted failed ${getFileNameSize(file)} ,${
e.message

View file

@ -1,10 +1,10 @@
import log from "@/next/log";
import { putAttributes } from "@ente/accounts/api/user";
import { logoutUser } from "@ente/accounts/services/user";
import { getRecoveryKey } from "@ente/shared/crypto/helpers";
import { ApiError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint, getFamilyPortalURL } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import localForage from "@ente/shared/storage/localForage";
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
import {
@ -63,7 +63,7 @@ export const getFamiliesToken = async () => {
);
return resp.data["familiesToken"];
} catch (e) {
logError(e, "failed to get family token");
log.error("failed to get family token", e);
throw e;
}
};
@ -81,7 +81,7 @@ export const getAccountsToken = async () => {
);
return resp.data["accountsToken"];
} catch (e) {
logError(e, "failed to get accounts token");
log.error("failed to get accounts token", e);
throw e;
}
};
@ -99,7 +99,7 @@ export const getRoadmapRedirectURL = async () => {
);
return resp.data["url"];
} catch (e) {
logError(e, "failed to get roadmap url");
log.error("failed to get roadmap url", e);
throw e;
}
};
@ -128,15 +128,15 @@ export const isTokenValid = async (token: string) => {
getData(LS_KEYS.ORIGINAL_KEY_ATTRIBUTES),
);
} catch (e) {
logError(e, "put attribute failed");
log.error("put attribute failed", e);
}
}
} catch (e) {
logError(e, "hasSetKeys not set in session validity response");
log.error("hasSetKeys not set in session validity response", e);
}
return true;
} catch (e) {
logError(e, "session-validity api call failed");
log.error("session-validity api call failed", e);
if (
e instanceof ApiError &&
e.httpStatusCode === HttpStatusCode.Unauthorized
@ -172,7 +172,7 @@ export const getUserDetailsV2 = async (): Promise<UserDetails> => {
);
return resp.data;
} catch (e) {
logError(e, "failed to get user details v2");
log.error("failed to get user details v2", e);
throw e;
}
};
@ -185,7 +185,7 @@ export const getFamilyPortalRedirectURL = async () => {
window.location.origin
}/gallery`;
} catch (e) {
logError(e, "unable to generate to family portal URL");
log.error("unable to generate to family portal URL", e);
throw e;
}
};
@ -203,7 +203,7 @@ export const getAccountDeleteChallenge = async () => {
);
return resp.data as DeleteChallengeResponse;
} catch (e) {
logError(e, "failed to get account delete challenge");
log.error("failed to get account delete challenge", e);
throw e;
}
};
@ -228,7 +228,7 @@ export const deleteAccount = async (
},
);
} catch (e) {
logError(e, "deleteAccount api call failed");
log.error("deleteAccount api call failed", e);
throw e;
}
};
@ -262,7 +262,7 @@ export const getFaceSearchEnabledStatus = async () => {
);
return resp.data.value === "true";
} catch (e) {
logError(e, "failed to get face search enabled status");
log.error("failed to get face search enabled status", e);
throw e;
}
};
@ -282,7 +282,7 @@ export const updateFaceSearchEnabledStatus = async (newStatus: boolean) => {
},
);
} catch (e) {
logError(e, "failed to update face search enabled status");
log.error("failed to update face search enabled status", e);
throw e;
}
};
@ -292,7 +292,7 @@ export const syncMapEnabled = async () => {
const status = await getMapEnabledStatus();
setLocalMapEnabled(status);
} catch (e) {
logError(e, "failed to sync map enabled status");
log.error("failed to sync map enabled status", e);
throw e;
}
};
@ -313,7 +313,7 @@ export const getMapEnabledStatus = async () => {
);
return resp.data.value === "true";
} catch (e) {
logError(e, "failed to get map enabled status");
log.error("failed to get map enabled status", e);
throw e;
}
};
@ -333,7 +333,7 @@ export const updateMapEnabledStatus = async (newStatus: boolean) => {
},
);
} catch (e) {
logError(e, "failed to update map enabled status");
log.error("failed to update map enabled status", e);
throw e;
}
};
@ -363,7 +363,7 @@ export async function getDisableCFUploadProxyFlag(): Promise<boolean> {
).json() as GetFeatureFlagResponse;
return featureFlags.disableCFUploadProxy;
} catch (e) {
logError(e, "failed to get feature flags");
log.error("failed to get feature flags", e);
return false;
}
}

View file

@ -1,10 +1,10 @@
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { promiseWithTimeout } from "@ente/shared/utils";
import QueueProcessor from "@ente/shared/utils/queueProcessor";
import { generateTempName } from "@ente/shared/utils/temp";
import { createFFmpeg, FFmpeg } from "ffmpeg-wasm";
import { getUint8ArrayView } from "services/readerService";
import log from "@/next/log";
const INPUT_PATH_PLACEHOLDER = "INPUT";
const FFMPEG_PLACEHOLDER = "FFMPEG";
@ -51,7 +51,7 @@ export class WasmFFmpeg {
try {
return await response.promise;
} catch (e) {
logError(e, "ffmpeg run failed");
log.error("ffmpeg run failed", e);
throw e;
}
}
@ -96,12 +96,12 @@ export class WasmFFmpeg {
try {
this.ffmpeg.FS("unlink", tempInputFilePath);
} catch (e) {
logError(e, "unlink input file failed");
log.error("unlink input file failed", e);
}
try {
this.ffmpeg.FS("unlink", tempOutputFilePath);
} catch (e) {
logError(e, "unlink output file failed");
log.error("unlink output file failed", e);
}
}
}

View file

@ -1,5 +1,5 @@
import log from "@/next/log";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import { ElectronFile } from "types/upload";
import { EventQueueItem } from "types/watchFolder";
import watchFolderService from "./watchFolderService";
@ -26,7 +26,7 @@ export async function diskFileAddedCallback(file: ElectronFile) {
`added (upload) to event queue, collectionName:${event.collectionName} folderPath:${event.folderPath}, filesCount: ${event.files.length}`,
);
} catch (e) {
logError(e, "error while calling diskFileAddedCallback");
log.error("error while calling diskFileAddedCallback", e);
}
}
@ -52,7 +52,7 @@ export async function diskFileRemovedCallback(filePath: string) {
`added (trash) to event queue collectionName:${event.collectionName} folderPath:${event.folderPath} , pathsCount: ${event.paths.length}`,
);
} catch (e) {
logError(e, "error while calling diskFileRemovedCallback");
log.error("error while calling diskFileRemovedCallback", e);
}
}
@ -69,6 +69,6 @@ export async function diskFolderRemovedCallback(folderPath: string) {
watchFolderService.pushTrashedDir(folderPath);
addLogLine(`added trashedDir, ${folderPath}`);
} catch (e) {
logError(e, "error while calling diskFolderRemovedCallback");
log.error("error while calling diskFolderRemovedCallback", e);
}
}

View file

@ -1,9 +1,8 @@
import { t } from "i18next";
import log from "@/next/log";
import { SetDialogBoxAttributes } from "@ente/shared/components/DialogBox/types";
import { logError } from "@ente/shared/sentry";
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
import { REDIRECTS, getRedirectURL } from "constants/redirects";
import { t } from "i18next";
import { NextRouter } from "next/router";
import billingService from "services/billingService";
import { Plan, Subscription } from "types/billing";
@ -261,8 +260,8 @@ export async function manageFamilyMethod(
setLoading(true);
const familyPortalRedirectURL = getRedirectURL(REDIRECTS.FAMILIES);
openLink(familyPortalRedirectURL, true);
} catch (error) {
logError(error, "failed to redirect to family portal");
} catch (e) {
log.error("failed to redirect to family portal", e);
setDialogMessage({
title: t("ERROR"),
content: t("UNKNOWN_ERROR"),
@ -308,7 +307,7 @@ function handleFailureReason(
setDialogMessage: SetDialogBoxAttributes,
setLoading: SetLoading,
): void {
logError(Error(reason), "subscription purchase failed");
log.error(`subscription purchase failed: ${reason}`);
switch (reason) {
case FAILURE_REASON.CANCELED:
setDialogMessage({

View file

@ -1,8 +1,8 @@
import ElectronAPIs from "@/next/electron";
import log from "@/next/log";
import { CustomError } from "@ente/shared/error";
import { addLogLine } from "@ente/shared/logging";
import { getAlbumsURL } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
import { getUnixTimeInMicroSecondsWithDelta } from "@ente/shared/time";
import { User } from "@ente/shared/user/types";
@ -119,7 +119,7 @@ export async function downloadCollectionHelper(
setFilesDownloadProgressAttributes,
);
} catch (e) {
logError(e, "download collection failed ");
log.error("download collection failed ", e);
}
}
@ -140,7 +140,7 @@ export async function downloadDefaultHiddenCollectionHelper(
setFilesDownloadProgressAttributes,
);
} catch (e) {
logError(e, "download hidden files failed ");
log.error("download hidden files failed ", e);
}
}
@ -272,7 +272,7 @@ export const changeCollectionVisibility = async (
);
}
} catch (e) {
logError(e, "change collection visibility failed");
log.error("change collection visibility failed", e);
throw e;
}
};
@ -298,7 +298,7 @@ export const changeCollectionSortOrder = async (
updatedPubMagicMetadata,
);
} catch (e) {
logError(e, "change collection sort order failed");
log.error("change collection sort order failed", e);
}
};
@ -319,7 +319,7 @@ export const changeCollectionOrder = async (
await updateCollectionMagicMetadata(collection, updatedMagicMetadata);
} catch (e) {
logError(e, "change collection order failed");
log.error("change collection order failed", e);
}
};
@ -339,7 +339,7 @@ export const changeCollectionSubType = async (
);
await updateCollectionMagicMetadata(collection, updatedMagicMetadata);
} catch (e) {
logError(e, "change collection subType failed");
log.error("change collection subType failed", e);
throw e;
}
};

View file

@ -1,4 +1,4 @@
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import { FILE_TYPE } from "constants/file";
import { LivePhotoSourceURL, SourceURLs } from "services/download";
import { EnteFile } from "types/file";
@ -94,10 +94,7 @@ export async function updateFileSrcProps(
} else if (file.metadata.fileType === FILE_TYPE.IMAGE) {
file.src = url as string;
} else {
logError(
Error(`unknown file type - ${file.metadata.fileType}`),
"Unknown file type",
);
log.error(`unknown file type - ${file.metadata.fileType}`);
file.src = url as string;
}
}

View file

@ -1,6 +1,6 @@
import { haveWindow } from "@/next/env";
import log from "@/next/log";
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import {
DEFAULT_ML_SEARCH_CONFIG,
DEFAULT_ML_SYNC_CONFIG,
@ -75,21 +75,18 @@ class MLIDbStorage {
private openDB(): Promise<IDBPDatabase<MLDb>> {
return openDB<MLDb>(MLDATA_DB_NAME, 3, {
terminated: async () => {
console.error("ML Indexed DB terminated");
logError(new Error(), "ML Indexed DB terminated");
log.error("ML Indexed DB terminated");
this._db = undefined;
// TODO: remove if there is chance of this going into recursion in some case
await this.db;
},
blocked() {
// TODO: make sure we dont allow multiple tabs of app
console.error("ML Indexed DB blocked");
logError(new Error(), "ML Indexed DB blocked");
log.error("ML Indexed DB blocked");
},
blocking() {
// TODO: make sure we dont allow multiple tabs of app
console.error("ML Indexed DB blocking");
logError(new Error(), "ML Indexed DB blocking");
log.error("ML Indexed DB blocking");
},
async upgrade(db, oldVersion, newVersion, tx) {
if (oldVersion < 1) {

View file

@ -1,4 +1,3 @@
import { logError } from "@ente/shared/sentry";
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
import { User } from "@ente/shared/user/types";
import { FamilyData, FamilyMember } from "types/user";

View file

@ -14,7 +14,6 @@ import {
UpdateSRPAndKeysResponse,
} from "@ente/accounts/types/srp";
import { ApiError, CustomError } from "@ente/shared/error";
import { logError } from "@ente/shared/sentry";
import { HttpStatusCode } from "axios";
const ENDPOINT = getEndpoint();
@ -28,7 +27,7 @@ export const getSRPAttributes = async (
});
return (resp.data as GetSRPAttributesResponse).attributes;
} catch (e) {
logError(e, "failed to get SRP attributes");
log.error("failed to get SRP attributes", e);
return null;
}
};
@ -49,7 +48,7 @@ export const startSRPSetup = async (
return resp.data as SetupSRPResponse;
} catch (e) {
logError(e, "failed to post SRP attributes");
log.error("failed to post SRP attributes", e);
throw e;
}
};
@ -69,7 +68,7 @@ export const completeSRPSetup = async (
);
return resp.data as CompleteSRPSetupResponse;
} catch (e) {
logError(e, "failed to complete SRP setup");
log.error("failed to complete SRP setup", e);
throw e;
}
};
@ -85,7 +84,7 @@ export const createSRPSession = async (srpUserID: string, srpA: string) => {
);
return resp.data as CreateSRPSessionResponse;
} catch (e) {
logError(e, "createSRPSession failed");
log.error("createSRPSession failed", e);
throw e;
}
};
@ -107,7 +106,7 @@ export const verifySRPSession = async (
);
return resp.data as SRPVerificationResponse;
} catch (e) {
logError(e, "verifySRPSession failed");
log.error("verifySRPSession failed", e);
if (
e instanceof ApiError &&
e.httpStatusCode === HttpStatusCode.Unauthorized
@ -134,7 +133,7 @@ export const updateSRPAndKeys = async (
);
return resp.data as UpdateSRPAndKeysResponse;
} catch (e) {
logError(e, "updateSRPAndKeys failed");
log.error("updateSRPAndKeys failed", e);
throw e;
}
};

View file

@ -1,6 +1,4 @@
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint } from "@ente/shared/network/api";
import log from "@/next/log";
import {
RecoveryKey,
TwoFactorRecoveryResponse,
@ -11,7 +9,8 @@ import {
import { APPS, OTT_CLIENTS } from "@ente/shared/apps/constants";
import { B64EncryptionResult } from "@ente/shared/crypto/types";
import { ApiError, CustomError } from "@ente/shared/error";
import { logError } from "@ente/shared/sentry";
import HTTPService from "@ente/shared/network/HTTPService";
import { getEndpoint } from "@ente/shared/network/api";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { KeyAttributes } from "@ente/shared/user/types";
import { HttpStatusCode } from "axios";
@ -63,7 +62,7 @@ export const _logout = async () => {
) {
return;
}
logError(e, "/users/logout failed");
log.error("/users/logout failed", e);
throw e;
}
};

View file

@ -10,7 +10,7 @@ import { LS_KEYS, setData } from "@ente/shared/storage/localStorage";
import { Formik, FormikHelpers } from "formik";
import React, { useState } from "react";
import * as Yup from "yup";
import log from "@/next/log";
import { PasswordStrengthHint } from "@ente/accounts/components/PasswordStrength";
import { PAGES } from "@ente/accounts/constants/pages";
import { APPS } from "@ente/shared/apps/constants";
@ -19,7 +19,6 @@ import FormPaperFooter from "@ente/shared/components/Form/FormPaper/Footer";
import FormPaperTitle from "@ente/shared/components/Form/FormPaper/Title";
import ShowHidePassword from "@ente/shared/components/Form/ShowHidePassword";
import LinkButton from "@ente/shared/components/LinkButton";
import { logError } from "@ente/shared/sentry";
import {
setJustSignedUp,
setLocalReferralSource,
@ -110,8 +109,8 @@ export default function SignUp({ router, appName, login }: SignUpProps) {
setFieldError("confirm", t("PASSWORD_GENERATION_FAILED"));
throw e;
}
} catch (err) {
logError(err, "signup failed");
} catch (e) {
log.error("signup failed", e);
}
setLoading(false);
};

View file

@ -21,7 +21,6 @@ import {
import { B64EncryptionResult } from "@ente/shared/crypto/types";
import { CustomError } from "@ente/shared/error";
import { getAccountsURL } from "@ente/shared/network/api";
import { logError } from "@ente/shared/sentry";
import InMemoryStore, { MS_KEYS } from "@ente/shared/storage/InMemoryStore";
import {
LS_KEYS,
@ -74,7 +73,7 @@ export default function Credentials({ appContext, appName }: PageProps) {
try {
key = await ElectronAPIs.getEncryptionKey();
} catch (e) {
logError(e, "getEncryptionKey failed");
log.error("getEncryptionKey failed", e);
}
if (key) {
await saveKeyInSessionStore(
@ -198,7 +197,7 @@ export default function Credentials({ appContext, appName }: PageProps) {
}
} catch (e) {
if (e.message !== CustomError.TWO_FACTOR_ENABLED) {
logError(e, "getKeyAttributes failed");
log.error("getKeyAttributes failed", e);
}
throw e;
}
@ -238,13 +237,13 @@ export default function Credentials({ appContext, appName }: PageProps) {
await configureSRP(srpSetupAttributes);
}
} catch (e) {
logError(e, "migrate to srp failed");
log.error("migrate to srp failed", e);
}
const redirectURL = InMemoryStore.get(MS_KEYS.REDIRECT_URL);
InMemoryStore.delete(MS_KEYS.REDIRECT_URL);
router.push(redirectURL ?? APP_HOMES.get(appName));
} catch (e) {
logError(e, "useMasterPassword failed");
log.error("useMasterPassword failed", e);
}
};

View file

@ -1,6 +1,4 @@
import { t } from "i18next";
import { useEffect, useState } from "react";
import log from "@/next/log";
import { putAttributes } from "@ente/accounts/api/user";
import { configureSRP } from "@ente/accounts/services/srp";
import { logoutUser } from "@ente/accounts/services/user";
@ -11,6 +9,8 @@ import {
} from "@ente/shared/crypto/helpers";
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
import { SESSION_KEYS, getKey } from "@ente/shared/storage/sessionStorage";
import { t } from "i18next";
import { useEffect, useState } from "react";
import SetPasswordForm from "@ente/accounts/components/SetPasswordForm";
import { PAGES } from "@ente/accounts/constants/pages";
@ -23,7 +23,6 @@ import FormPaperFooter from "@ente/shared/components/Form/FormPaper/Footer";
import FormTitle from "@ente/shared/components/Form/FormPaper/Title";
import LinkButton from "@ente/shared/components/LinkButton";
import RecoveryKey from "@ente/shared/components/RecoveryKey";
import { logError } from "@ente/shared/sentry";
import {
justSignedUp,
setJustSignedUp,
@ -83,7 +82,7 @@ export default function Generate({ appContext, appName }: PageProps) {
setJustSignedUp(true);
setRecoveryModalView(true);
} catch (e) {
logError(e, "failed to generate password");
log.error("failed to generate password", e);
setFieldError("passphrase", t("PASSWORD_GENERATION_FAILED"));
}
};

View file

@ -1,6 +1,4 @@
import { t } from "i18next";
import { useEffect, useState } from "react";
import log from "@/next/log";
import { sendOtt } from "@ente/accounts/api/user";
import { PAGES } from "@ente/accounts/constants/pages";
import { APP_HOMES } from "@ente/shared/apps/constants";
@ -18,12 +16,13 @@ import {
decryptAndStoreToken,
saveKeyInSessionStore,
} from "@ente/shared/crypto/helpers";
import { logError } from "@ente/shared/sentry";
import InMemoryStore, { MS_KEYS } from "@ente/shared/storage/InMemoryStore";
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
import { SESSION_KEYS, getKey } from "@ente/shared/storage/sessionStorage";
import { KeyAttributes, User } from "@ente/shared/user/types";
import { t } from "i18next";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
const bip39 = require("bip39");
// mobile client library only supports english.
@ -88,7 +87,7 @@ export default function Recover({ appContext, appName }: PageProps) {
setData(LS_KEYS.SHOW_BACK_BUTTON, { value: false });
router.push(PAGES.CHANGE_PASSWORD);
} catch (e) {
logError(e, "password recovery failed");
log.error("password recovery failed", e);
setFieldError(t("INCORRECT_RECOVERY_KEY"));
}
};

View file

@ -1,29 +1,28 @@
import { VerticallyCentered } from "@ente/shared/components/Container";
import SingleInputForm, {
SingleInputFormProps,
} from "@ente/shared/components/SingleInputForm";
import { logError } from "@ente/shared/sentry";
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
import { useEffect, useState } from "react";
import log from "@/next/log";
import { recoverTwoFactor, removeTwoFactor } from "@ente/accounts/api/user";
import { PAGES } from "@ente/accounts/constants/pages";
import { TwoFactorType } from "@ente/accounts/constants/twofactor";
import { logoutUser } from "@ente/accounts/services/user";
import { PageProps } from "@ente/shared/apps/types";
import { VerticallyCentered } from "@ente/shared/components/Container";
import { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
import FormPaper from "@ente/shared/components/Form/FormPaper";
import FormPaperFooter from "@ente/shared/components/Form/FormPaper/Footer";
import FormPaperTitle from "@ente/shared/components/Form/FormPaper/Title";
import LinkButton from "@ente/shared/components/LinkButton";
import SingleInputForm, {
SingleInputFormProps,
} from "@ente/shared/components/SingleInputForm";
import { SUPPORT_EMAIL } from "@ente/shared/constants/urls";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { B64EncryptionResult } from "@ente/shared/crypto/types";
import { ApiError } from "@ente/shared/error";
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
import { Link } from "@mui/material";
import { HttpStatusCode } from "axios";
import { t } from "i18next";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
import { Trans } from "react-i18next";
const bip39 = require("bip39");
@ -80,7 +79,7 @@ export default function Recover({
) {
logoutUser();
} else {
logError(e, "two factor recovery page setup failed");
log.error("two factor recovery page setup failed", e);
setDoesHaveEncryptedRecoveryKey(false);
showContactSupportDialog({
text: t("GO_BACK"),
@ -132,7 +131,7 @@ export default function Recover({
setData(LS_KEYS.KEY_ATTRIBUTES, keyAttributes);
router.push(PAGES.CREDENTIALS);
} catch (e) {
logError(e, "two factor recovery failed");
log.error("two factor recovery failed", e);
setFieldError(t("INCORRECT_RECOVERY_KEY"));
}
};

View file

@ -1,3 +1,4 @@
import log from "@/next/log";
import { enableTwoFactor, setupTwoFactor } from "@ente/accounts/api/user";
import VerifyTwoFactor, {
VerifyTwoFactorCallback,
@ -9,7 +10,6 @@ import { PageProps } from "@ente/shared/apps/types";
import { VerticallyCentered } from "@ente/shared/components/Container";
import LinkButton from "@ente/shared/components/LinkButton";
import { encryptWithRecoveryKey } from "@ente/shared/crypto/helpers";
import { logError } from "@ente/shared/sentry";
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
import { Box, CardContent, Typography } from "@mui/material";
import Card from "@mui/material/Card";
@ -37,7 +37,7 @@ export default function SetupTwoFactor({ appName }: PageProps) {
const twoFactorSecret = await setupTwoFactor();
setTwoFactorSecret(twoFactorSecret);
} catch (e) {
logError(e, "failed to get two factor setup code");
log.error("failed to get two factor setup code", e);
}
};
main();

View file

@ -1,6 +1,6 @@
import log from "@/next/log";
import { CustomError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
import { logError } from "@ente/shared/sentry";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
export const isPasskeyRecoveryEnabled = async () => {
@ -21,7 +21,7 @@ export const isPasskeyRecoveryEnabled = async () => {
return resp.data["isPasskeyRecoveryEnabled"] as boolean;
} catch (e) {
logError(e, "failed to get passkey recovery status");
log.error("failed to get passkey recovery status", e);
throw e;
}
};
@ -50,7 +50,7 @@ export const configurePasskeyRecovery = async (
throw Error(CustomError.REQUEST_FAILED);
}
} catch (e) {
logError(e, "failed to configure passkey recovery");
log.error("failed to configure passkey recovery", e);
throw e;
}
};

View file

@ -2,7 +2,6 @@ import log from "@/next/log";
import { UserVerificationResponse } from "@ente/accounts/types/user";
import ComlinkCryptoWorker from "@ente/shared/crypto";
import { generateLoginSubKey } from "@ente/shared/crypto/helpers";
import { logError } from "@ente/shared/sentry";
import InMemoryStore, { MS_KEYS } from "@ente/shared/storage/InMemoryStore";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { SRP, SrpClient } from "fast-srp-hap";
@ -131,7 +130,7 @@ export const loginViaSRP = async (
log.debug(() => `srp server verify successful`);
return rest;
} catch (e) {
logError(e, "srp verify failed");
log.error("srp verify failed", e);
throw e;
}
};

View file

@ -1,6 +1,6 @@
import ElectronAPIs from "@/next/electron";
import log from "@/next/log";
import { Events, eventBus } from "@ente/shared/events";
import { logError } from "@ente/shared/sentry";
import InMemoryStore from "@ente/shared/storage/InMemoryStore";
import { deleteAllCache } from "@ente/shared/storage/cacheStorage/helpers";
import { clearFiles } from "@ente/shared/storage/localForage/helpers";
@ -22,42 +22,42 @@ export const logoutUser = async () => {
InMemoryStore.clear();
} catch (e) {
// ignore
logError(e, "clear InMemoryStore failed");
log.error("clear InMemoryStore failed", e);
}
try {
clearKeys();
} catch (e) {
logError(e, "clearKeys failed");
log.error("clearKeys failed", e);
}
try {
clearData();
} catch (e) {
logError(e, "clearData failed");
log.error("clearData failed", e);
}
try {
await deleteAllCache();
} catch (e) {
logError(e, "deleteAllCache failed");
log.error("deleteAllCache failed", e);
}
try {
await clearFiles();
} catch (e) {
logError(e, "clearFiles failed");
log.error("clearFiles failed", e);
}
if (isElectron()) {
try {
ElectronAPIs.clearElectronStore();
} catch (e) {
logError(e, "clearElectronStore failed");
log.error("clearElectronStore failed", e);
}
}
try {
eventBus.emit(Events.LOGOUT);
} catch (e) {
logError(e, "Error in logout handlers");
log.error("Error in logout handlers", e);
}
router.push(PAGES.ROOT);
} catch (e) {
logError(e, "logoutUser failed");
log.error("logoutUser failed", e);
}
};

View file

@ -1,6 +1,5 @@
import ElectronAPIs from "@/next/electron";
import LinkButton from "@ente/shared/components/LinkButton";
import { logError } from "@ente/shared/sentry";
import { Tooltip } from "@mui/material";
import { styled } from "@mui/material/styles";
@ -21,7 +20,7 @@ export const DirectoryPath = ({ width, path }) => {
try {
await ElectronAPIs.openDirectory(path);
} catch (e) {
logError(e, "openDirectory failed");
log.error("openDirectory failed", e);
}
};
return (

View file

@ -1,14 +1,12 @@
import { logError } from "@ente/shared/sentry";
import SingleInputForm, {
SingleInputFormProps,
} from "../components/SingleInputForm";
import { CustomError } from "../error";
import log from "@/next/log";
import { SRPAttributes } from "@ente/accounts/types/srp";
import { ButtonProps, Input } from "@mui/material";
import { t } from "i18next";
import SingleInputForm, {
SingleInputFormProps,
} from "../components/SingleInputForm";
import ComlinkCryptoWorker from "../crypto";
import { CustomError } from "../error";
import { KeyAttributes, User } from "../user/types";
export interface VerifyMasterPasswordFormProps {
@ -59,7 +57,7 @@ export default function VerifyMasterPasswordForm({
);
}
} catch (e) {
logError(e, "failed to derive key");
log.error("failed to derive key", e);
throw Error(CustomError.WEAK_DEVICE);
}
if (!keyAttributes && typeof getKeyAttributes === "function") {
@ -76,7 +74,7 @@ export default function VerifyMasterPasswordForm({
);
callback(key, kek, keyAttributes, passphrase);
} catch (e) {
logError(e, "user entered a wrong password");
log.error("user entered a wrong password", e);
throw Error(CustomError.INCORRECT_PASSWORD);
}
} catch (e) {
@ -85,7 +83,7 @@ export default function VerifyMasterPasswordForm({
// two factor enabled, user has been redirected to two factor page
return;
}
logError(e, "failed to verify passphrase");
log.error("failed to verify passphrase", e);
switch (e.message) {
case CustomError.WEAK_DEVICE:
setFieldError(t("WEAK_DEVICE"));

View file

@ -1,6 +1,6 @@
import ElectronAPIs from "@/next/electron";
import log from "@/next/log";
import { setRecoveryKey } from "@ente/accounts/api/user";
import { logError } from "@ente/shared/sentry";
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { SESSION_KEYS, setKey } from "@ente/shared/storage/sessionStorage";
@ -146,7 +146,7 @@ export const getRecoveryKey = async () => {
return recoveryKey;
} catch (e) {
console.log(e);
logError(e, "getRecoveryKey failed");
log.error("getRecoveryKey failed", e);
throw e;
}
};

View file

@ -1,7 +1,5 @@
import { addLogLine } from "@ente/shared/logging";
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
import { ApiError, CustomError, isApiErrorResponse } from "../error";
interface IHTTPHeaders {
@ -28,14 +26,17 @@ class HTTPService {
// that falls out of the range of 2xx
if (isApiErrorResponse(response.data)) {
const responseData = response.data;
logError(error, "HTTP Service Error", {
url: config.url,
method: config.method,
xRequestId: response.headers["x-request-id"],
httpStatus: response.status,
errMessage: responseData.message,
errCode: responseData.code,
});
log.error(
`HTTP Service Error - ${JSON.stringify({
url: config.url,
method: config.method,
xRequestId: response.headers["x-request-id"],
httpStatus: response.status,
errMessage: responseData.message,
errCode: responseData.code,
})}`,
error,
);
apiError = new ApiError(
responseData.message,
responseData.code,
@ -56,30 +57,30 @@ class HTTPService {
);
}
}
logError(apiError, "HTTP Service Error", {
url: config.url,
method: config.method,
cfRay: response.headers["cf-ray"],
xRequestId: response.headers["x-request-id"],
httpStatus: response.status,
});
log.error(
`HTTP Service Error - ${JSON.stringify({
url: config.url,
method: config.method,
cfRay: response.headers["cf-ray"],
xRequestId: response.headers["x-request-id"],
httpStatus: response.status,
})}`,
apiError,
);
throw apiError;
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
addLogLine(
"request failed- no response",
`url: ${config.url}`,
`method: ${config.method}`,
log.info(
`request failed - no response (${config.method} ${config.url}`,
);
return Promise.reject(error);
} else {
// Something happened in setting up the request that triggered an Error
addLogLine(
"request failed- axios error",
`url: ${config.url}`,
`method: ${config.method}`,
// Something happened in setting up the request that
// triggered an Error
log.info(
`request failed - axios error (${config.method} ${config.url}`,
);
return Promise.reject(error);
}

View file

@ -1,5 +1,5 @@
import log from "@/next/log";
import { ApiError } from "../error";
import { logError } from "../sentry";
import { getToken } from "../storage/localStorage/helpers";
import HTTPService from "./HTTPService";
import { getEndpoint } from "./api";
@ -14,7 +14,7 @@ class CastGateway {
`${getEndpoint()}/cast/cast-data/${code}`,
);
} catch (e) {
logError(e, "failed to getCastData");
log.error("failed to getCastData", e);
throw e;
}
return resp.data.encCastData;
@ -32,7 +32,7 @@ class CastGateway {
},
);
} catch (e) {
logError(e, "removeAllTokens failed");
log.error("removeAllTokens failed", e);
// swallow error
}
}
@ -52,7 +52,7 @@ class CastGateway {
if (e instanceof ApiError && e.httpStatusCode === 404) {
return "";
}
logError(e, "failed to getPublicKey");
log.error("failed to getPublicKey", e);
throw e;
}
return resp.data.publicKey;

View file

@ -1,7 +1,7 @@
import { logError } from "@ente/shared/sentry";
import { CacheStorageService } from ".";
import { CACHES } from "./constants";
import { LimitedCache } from "./types";
import log from "@/next/log";
export async function cached(
cacheName: string,
@ -50,6 +50,6 @@ export async function deleteAllCache() {
await CacheStorageService.delete(CACHES.FACE_CROPS);
await CacheStorageService.delete(CACHES.FILES);
} catch (e) {
logError(e, "deleteAllCache failed"); // log and ignore
log.error("deleteAllCache failed", e); // log and ignore
}
}

View file

@ -1,4 +1,4 @@
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
import { CacheStorageFactory } from "./factory";
const SecurityError = "SecurityError";
@ -15,7 +15,7 @@ async function openCache(cacheName: string, cacheLimit?: number) {
// no-op
} else {
// log and ignore, we don't want to break the caller flow, when cache is not available
logError(e, "openCache failed");
log.error("openCache failed", e);
}
}
}
@ -28,7 +28,7 @@ async function deleteCache(cacheName: string) {
// no-op
} else {
// log and ignore, we don't want to break the caller flow, when cache is not available
logError(e, "deleteCache failed");
log.error("deleteCache failed", e);
}
}
}

View file

@ -1,4 +1,4 @@
import { logError } from "@ente/shared/sentry";
import log from "@/next/log";
export enum LS_KEYS {
USER = "user",
@ -57,7 +57,7 @@ export const getData = (key: LS_KEYS) => {
const data = localStorage.getItem(key);
return data && JSON.parse(data);
} catch (e) {
logError(e, "Failed to Parse JSON for key " + key);
log.error(`Failed to Parse JSON for key ${key}`, e);
}
};