Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add error id on user notification #88

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"tabWidth": 2,
"printWidth": 100
"printWidth": 80
}
7 changes: 5 additions & 2 deletions src/pages/Modals/ConnectVaultModal/components/A2_SignStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,13 @@ export default function SignStep({
}
}
} catch (e) {
Sentry.captureException(e);
const eventId = Sentry.captureException(e);
console.error(e);
notificationAdded({
text: "En error occurred, please clean your cache and refresh your page.",
text:
"En error occurred, please clean your cache and refresh your page." +
" - Error id: " +
eventId,
type: "error",
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ export default function AccessRecoveryKey({ onConnected }: Props): JSX.Element {
setNoVaultFound(true);
}
} catch (e) {
Sentry.captureException(e);
const eventId = Sentry.captureException(e);
notificationAdded({
text: "En error occurred, please clean your cache and refresh your page.",
text:
"En error occurred, please clean your cache and refresh your page." +
" - Error id: " +
eventId,
type: "error",
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,19 @@ export default function CreateVaultStep({
await create(ownershipSignature, seed, identifier);
onCreated();
} catch (e) {
let eventId: string;
Sentry.withScope(function (scope) {
scope.setLevel("fatal");
Sentry.captureException(e);
eventId = Sentry.captureException(e);
});
console.error(e);
setStatus("idle");
notificationAdded({
type: "error",
text: "An error occurred, while importing new owner",
text:
"An error occurred, while importing new owner" +
" - Error id: " +
eventId,
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ export default function VaultDetectedStep({
throw new Error();
}
} catch (e) {
Sentry.captureException(e);
const eventId = Sentry.captureException(e);
console.error(e);
notificationAdded({
text: "En error occurred, please clean your cache and refresh your page.",
text:
"En error occurred, please clean your cache and refresh your page." +
" - Error id: " +
eventId,
type: "error",
});
}
Expand Down
8 changes: 6 additions & 2 deletions src/pages/Modals/GenerateRecoveryKey/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,17 @@ export default function GenerateRecoveryKeyModal(): JSX.Element {
setKey(_key);
setName(_name);
} catch (e) {
let eventId: string;
Sentry.withScope(function (scope) {
scope.setLevel("fatal");
Sentry.captureException(e);
eventId = Sentry.captureException(e);
});
console.log("e", e);
notificationAdded({
text: "An error occurred while saving your vault, please try again.",
text:
"An error occurred while saving your vault, please try again." +
" - Error id: " +
eventId,
type: "error",
});
} finally {
Expand Down
55 changes: 40 additions & 15 deletions src/pages/Modals/ImportAccount/provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,19 @@ export default function ImportAccountModalProvider({
setAccountTypes(null);
};

const triggerError = (e) => {
const triggerError = (e: Error) => {
let eventId: string;
Sentry.withScope(function (scope) {
scope.setLevel("fatal");
Sentry.captureException(e?.response?.data);
eventId = Sentry.captureException(e);
});
console.error(e);
const text = e?.message
? e.message
: "An error occurred while saving your vault, please try again.";

notificationAdded({
text: "An error occurred while saving your vault, please try again.",
text: text + " - Error id: " + eventId,
type: "error",
});
setImporting(null);
Expand Down Expand Up @@ -124,7 +129,7 @@ export default function ImportAccountModalProvider({

if (_importType === "owner") {
if (alreadyOwner) {
triggerError("Already imported as Owner");
triggerError(new Error("Account already imported as Owner"));
return;
}
await vault.addOwner({
Expand Down Expand Up @@ -157,13 +162,17 @@ export default function ImportAccountModalProvider({
commitmentReceipt = _commitmentReceipt;
commitmentMapperPubKey = _commitmentMapperPubKey;
} catch (e) {
let eventId: string;
Sentry.withScope(function (scope) {
scope.setLevel("fatal");
Sentry.captureException(e?.response?.data);
eventId = Sentry.captureException(e);
});
console.error(e);
notificationAdded({
text: "Account already imported into another vault.",
text:
"Account already imported into another vault." +
" - Error id: " +
eventId,
type: "error",
});
setImporting(null);
Expand All @@ -173,7 +182,7 @@ export default function ImportAccountModalProvider({

if (_importType === "account") {
if (alreadyImported) {
triggerError("Already imported");
triggerError(new Error("Account already imported"));
return;
}
await vault.importAccount({
Expand Down Expand Up @@ -241,12 +250,16 @@ export default function ImportAccountModalProvider({
e?.response?.data?.error === "Address is already used for a commitment!"
) {
console.error(e);
let eventId: string;
Sentry.withScope(function (scope) {
scope.setLevel("fatal");
Sentry.captureException(e?.response?.data);
eventId = Sentry.captureException(e);
});
notificationAdded({
text: "Telegram account already imported in this vault or in another one",
text:
"Telegram account already imported in this vault or in another one" +
" - Error id: " +
eventId,
type: "error",
});
setImporting(null);
Expand Down Expand Up @@ -302,12 +315,16 @@ export default function ImportAccountModalProvider({
e?.response?.data?.error === "Address is already used for a commitment!"
) {
console.error(e);
let eventId: string;
Sentry.withScope(function (scope) {
scope.setLevel("fatal");
Sentry.captureException(e?.response?.data);
eventId = Sentry.captureException(e);
});
notificationAdded({
text: "Github account already imported in this vault or in another one",
text:
"Github account already imported in this vault or in another one" +
" - Error id: " +
eventId,
type: "error",
});
setImporting(null);
Expand Down Expand Up @@ -365,12 +382,16 @@ export default function ImportAccountModalProvider({
e?.response?.data?.error === "Address is already used for a commitment!"
) {
console.error(e);
let eventId: string;
Sentry.withScope(function (scope) {
scope.setLevel("fatal");
Sentry.captureException(e?.response?.data);
eventId = Sentry.captureException(e);
});
notificationAdded({
text: "Twitter account already imported in this vault or in another one",
text:
"Twitter account already imported in this vault or in another one" +
" - Error id: " +
eventId,
type: "error",
});
setImporting(null);
Expand Down Expand Up @@ -427,12 +448,16 @@ export default function ImportAccountModalProvider({
e?.response?.data?.error === "Address is already used for a commitment!"
) {
console.error(e);
let eventId: string;
Sentry.withScope(function (scope) {
scope.setLevel("fatal");
Sentry.captureException(e?.response?.data);
eventId = Sentry.captureException(e);
});
notificationAdded({
text: "Twitter account already imported in this vault or in another one",
text:
"Twitter account already imported in this vault or in another one" +
" - Error id: " +
eventId,
type: "error",
});
setImporting(null);
Expand Down
7 changes: 5 additions & 2 deletions src/pages/Modals/MyVault/Settings/components/Customize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,17 @@ export default function Customize() {
setEditIsOpen(false);
} catch (e) {
console.error("Update name", e);
Sentry.captureException(e, {
const eventId = Sentry.captureException(e, {
tags: {
file: "Customization.tsx",
function: "saveNewName",
},
});
notificationAdded({
text: "An error occurred while saving your vault, please try again.",
text:
"An error occurred while saving your vault, please try again." +
" - Error id: " +
eventId,
type: "error",
});
} finally {
Expand Down
7 changes: 5 additions & 2 deletions src/pages/Modals/MyVault/Settings/components/Security.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ export default function Security() {
try {
await vault.setKeepConnected(vault.connectedOwner, !vault.keepConnected);
} catch (e) {
Sentry.captureException(e);
const eventId = Sentry.captureException(e);
notificationAdded({
text: "An error occurred while saving your vault, please try again.",
text:
"An error occurred while saving your vault, please try again." +
" - Error id: " +
eventId,
type: "error",
});
} finally {
Expand Down
Loading