Skip to content

Commit 62e1137

Browse files
perf: lazy-load sentry in auth forms to reduce first-load JS (#951) (#954)
Co-authored-by: Ona <no-reply@ona.com>
1 parent 6a9f7d4 commit 62e1137

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/app/(auth)/forgot-password/forgot-password-form.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { useState } from "react";
44
import Link from "next/link";
55
import { getClient } from "@/lib/supabase/lazy-client";
6-
import { captureSupabaseError } from "@/lib/sentry";
76
import { Button } from "@/components/ui/button";
87
import { Input } from "@/components/ui/input";
98
import { Label } from "@/components/ui/label";
@@ -36,7 +35,9 @@ export function ForgotPasswordForm() {
3635
});
3736

3837
if (resetError) {
39-
captureSupabaseError(resetError, "forgot-password:resetPasswordForEmail");
38+
import("@/lib/sentry").then(({ captureSupabaseError }) =>
39+
captureSupabaseError(resetError, "forgot-password:resetPasswordForEmail"),
40+
);
4041
setError(resetError.message);
4142
setLoading(false);
4243
return;

src/app/(auth)/reset-password/reset-password-form.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useState } from "react";
44
import { useRouter } from "next/navigation";
55
import Link from "next/link";
66
import { getClient } from "@/lib/supabase/lazy-client";
7-
import { captureSupabaseError } from "@/lib/sentry";
87
import { Button } from "@/components/ui/button";
98
import { Input } from "@/components/ui/input";
109
import { Label } from "@/components/ui/label";
@@ -46,7 +45,9 @@ export function ResetPasswordForm() {
4645
});
4746

4847
if (updateError) {
49-
captureSupabaseError(updateError, "reset-password:updateUser");
48+
import("@/lib/sentry").then(({ captureSupabaseError }) =>
49+
captureSupabaseError(updateError, "reset-password:updateUser"),
50+
);
5051
setError(updateError.message);
5152
setLoading(false);
5253
return;

src/components/auth/oauth-buttons.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ describe("OAuthButtons — OAuth enabled", () => {
159159
expect(screen.getByRole("alert")).toHaveTextContent(
160160
"Provider not enabled",
161161
);
162+
expect(mockCaptureSupabaseError).toHaveBeenCalledWith(
163+
oauthError,
164+
"oauth.signIn.github",
165+
);
162166
});
163-
expect(mockCaptureSupabaseError).toHaveBeenCalledWith(
164-
oauthError,
165-
"oauth.signIn.github",
166-
);
167167
});
168168

169169
it("disables both buttons while a provider is loading", async () => {

src/components/auth/oauth-buttons.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { useState } from "react";
44
import { getClient } from "@/lib/supabase/lazy-client";
5-
import { captureSupabaseError } from "@/lib/sentry";
65
import { Button } from "@/components/ui/button";
76
import {
87
Tooltip,
@@ -61,7 +60,9 @@ export function OAuthButtons() {
6160
});
6261

6362
if (oauthError) {
64-
captureSupabaseError(oauthError as unknown as Error, `oauth.signIn.${provider}`);
63+
import("@/lib/sentry").then(({ captureSupabaseError }) =>
64+
captureSupabaseError(oauthError as unknown as Error, `oauth.signIn.${provider}`),
65+
);
6566
setError(oauthError.message);
6667
setLoadingProvider(null);
6768
}

0 commit comments

Comments
 (0)