From e3f8db353b691f39bf6f9920406f45815cd87717 Mon Sep 17 00:00:00 2001 From: zeudev Date: Mon, 30 Sep 2024 07:10:56 -0700 Subject: [PATCH] fix: throw errors on insight creation failure (#4145) --- pages/workspaces/[workspaceId]/contributor-insights/new.tsx | 2 ++ pages/workspaces/[workspaceId]/repository-insights/new.tsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pages/workspaces/[workspaceId]/contributor-insights/new.tsx b/pages/workspaces/[workspaceId]/contributor-insights/new.tsx index 71c1536f3..916033069 100644 --- a/pages/workspaces/[workspaceId]/contributor-insights/new.tsx +++ b/pages/workspaces/[workspaceId]/contributor-insights/new.tsx @@ -3,6 +3,7 @@ import { useRouter } from "next/router"; import { GetServerSidePropsContext } from "next"; import { ComponentProps, useEffect, useState } from "react"; import { createPagesServerClient } from "@supabase/auth-helpers-nextjs"; +import { captureException } from "@sentry/nextjs"; import { fetchApiData } from "helpers/fetchApiData"; import { deleteCookie, setCookie } from "lib/utils/server/cookies"; import { WORKSPACE_ID_COOKIE_NAME } from "lib/utils/caching"; @@ -116,6 +117,7 @@ export default function CreateContributorInsightPage({ if (error) { toast({ description: "An error has occurred. Try again.", variant: "danger" }); setLoading(false); + captureException(new Error(`Error creating a contributor insight`, { cause: error })); return; } diff --git a/pages/workspaces/[workspaceId]/repository-insights/new.tsx b/pages/workspaces/[workspaceId]/repository-insights/new.tsx index bf7ea68a0..f5d9be3fe 100644 --- a/pages/workspaces/[workspaceId]/repository-insights/new.tsx +++ b/pages/workspaces/[workspaceId]/repository-insights/new.tsx @@ -3,6 +3,7 @@ import { useRouter } from "next/router"; import { ComponentProps, useEffect, useState } from "react"; import { GetServerSidePropsContext } from "next"; import { createPagesServerClient } from "@supabase/auth-helpers-nextjs"; +import { captureException } from "@sentry/nextjs"; import useSupabaseAuth from "lib/hooks/useSupabaseAuth"; import { createRepositoryInsight } from "lib/utils/workspace-utils"; @@ -72,6 +73,7 @@ const NewInsightPage = () => { if (error) { toast({ description: "An error has occurred. Try again.", variant: "danger" }); setLoading(false); + captureException(new Error(`Error creating a repository insight`, { cause: error })); return; }