Skip to content

Commit

Permalink
Merge pull request #886 from Shelf-nu/fixing-sentry-errors
Browse files Browse the repository at this point in the history
Fixing sentry errors
  • Loading branch information
DonKoko authored Apr 2, 2024
2 parents b9bb9a3 + 8214fa0 commit 60d13f4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
15 changes: 12 additions & 3 deletions app/modules/auth/service.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,21 @@ export async function verifyOtpAndSignin(email: string, otp: string) {

return mapAuthSession(session);
} catch (cause) {
let message =
"Something went wrong. Please try again later or contact support.";
let shouldBeCaptured = true;

if (isAuthApiError(cause) && cause.message !== "") {
message = cause.message;
shouldBeCaptured = false;
}

throw new ShelfError({
cause,
message:
"Something went wrong. Please try again later or contact support.",
additionalData: { email },
message,
label,
shouldBeCaptured,
additionalData: { email },
});
}
}
2 changes: 2 additions & 0 deletions app/modules/user/service.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ export async function createUser(
organizationIds.push(organizationId);
}

// @TODO this is weird and organizationIds is not used
// We haev to figure out why its being called 2 times and whats going on here
await Promise.all([
createUserOrgAssociation(tx, {
userId: user.id,
Expand Down
6 changes: 3 additions & 3 deletions app/routes/_auth+/otp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ export default function OtpPage() {
/>

{data?.error.message ? (
<p className="text-center text-sm text-error-500">
<div className="!mt-1 text-sm text-error-500">
{data.error.message}
</p>
</div>
) : null}
{message?.message && (
<p
className={tw(
"text-center text-sm",
" text-sm",
message.type === "error"
? "text-error-500"
: "text-success-500"
Expand Down
2 changes: 1 addition & 1 deletion app/utils/extract-image-name-from-supabase-url.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const extractImageNameFromSupabaseUrl = ({
`\\/${bucketName}\\/([a-f0-9-]+)\\/([a-z0-9]+)\\/([a-z0-9\\-]+\\.[a-z]{3,4})`,
"i"
);
const match = url.match(regex);
const match = url.split("?")[0].match(regex); // split the url at '?' and take the first part
if (match) {
const path = `${match[1]}/${match[2]}/${match[3]}`;
return path;
Expand Down
1 change: 0 additions & 1 deletion app/utils/storage.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ export async function deleteAssetImage({
}) {
try {
const path = extractImageNameFromSupabaseUrl({ url, bucketName });

if (!path) {
throw new ShelfError({
cause: null,
Expand Down

0 comments on commit 60d13f4

Please sign in to comment.