mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-06 20:15:17 +02:00
Merge pull request #1071 from JoeMakuta/feature/optimize-package-imports
feature : optimize package imports
This commit is contained in:
commit
b5ee177f2e
9 changed files with 36 additions and 20 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import posthog from "posthog-js";
|
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
export default function ErrorPage({
|
export default function ErrorPage({
|
||||||
|
|
@ -11,7 +11,11 @@ export default function ErrorPage({
|
||||||
reset: () => void;
|
reset: () => void;
|
||||||
}) {
|
}) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
import("posthog-js")
|
||||||
|
.then(({ default: posthog }) => {
|
||||||
posthog.captureException(error);
|
posthog.captureException(error);
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
}, [error]);
|
}, [error]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { CheckIcon } from "lucide-react";
|
import { CheckIcon } from "lucide-react";
|
||||||
import { Checkbox as CheckboxPrimitive } from "radix-ui";
|
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
||||||
import type * as React from "react";
|
import type * as React from "react";
|
||||||
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
|
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
|
||||||
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
||||||
import type * as React from "react";
|
import type * as React from "react";
|
||||||
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Separator as SeparatorPrimitive } from "radix-ui";
|
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
||||||
import type * as React from "react";
|
import type * as React from "react";
|
||||||
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import type { VariantProps } from "class-variance-authority";
|
import type { VariantProps } from "class-variance-authority";
|
||||||
import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui";
|
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { toggleVariants } from "@/components/ui/toggle";
|
import { toggleVariants } from "@/components/ui/toggle";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { cva, type VariantProps } from "class-variance-authority";
|
import { cva, type VariantProps } from "class-variance-authority";
|
||||||
import { Toggle as TogglePrimitive } from "radix-ui";
|
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
||||||
import type * as React from "react";
|
import type * as React from "react";
|
||||||
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Tooltip as TooltipPrimitive } from "radix-ui";
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
||||||
import type * as React from "react";
|
import type * as React from "react";
|
||||||
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import posthog from "posthog-js";
|
|
||||||
import type { ZodType } from "zod";
|
import type { ZodType } from "zod";
|
||||||
import { getBearerToken, handleUnauthorized, refreshAccessToken } from "../auth-utils";
|
import { getBearerToken, handleUnauthorized, refreshAccessToken } from "../auth-utils";
|
||||||
import { AppError, AuthenticationError, AuthorizationError, NotFoundError } from "../error";
|
import { AppError, AuthenticationError, AuthorizationError, NotFoundError } from "../error";
|
||||||
|
|
@ -234,7 +233,8 @@ class BaseApiService {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Request failed:", JSON.stringify(error));
|
console.error("Request failed:", JSON.stringify(error));
|
||||||
if (!(error instanceof AuthenticationError)) {
|
if (!(error instanceof AuthenticationError)) {
|
||||||
try {
|
import("posthog-js")
|
||||||
|
.then(({ default: posthog }) => {
|
||||||
posthog.captureException(error, {
|
posthog.captureException(error, {
|
||||||
api_url: url,
|
api_url: url,
|
||||||
api_method: options?.method ?? "GET",
|
api_method: options?.method ?? "GET",
|
||||||
|
|
@ -243,9 +243,11 @@ class BaseApiService {
|
||||||
status_text: error.statusText,
|
status_text: error.statusText,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
} catch {
|
})
|
||||||
// PostHog capture failed — don't block the error flow
|
.catch(() => {
|
||||||
}
|
// PostHog is not available in the current environment
|
||||||
|
console.error("Failed to capture exception in PostHog");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,16 @@ const nextConfig: NextConfig = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
experimental: {
|
||||||
|
optimizePackageImports: [
|
||||||
|
"lucide-react",
|
||||||
|
"@tabler/icons-react",
|
||||||
|
"date-fns",
|
||||||
|
"@assistant-ui/react",
|
||||||
|
"@assistant-ui/react-markdown",
|
||||||
|
"motion",
|
||||||
|
],
|
||||||
|
},
|
||||||
// Turbopack config (used during `next dev --turbopack`)
|
// Turbopack config (used during `next dev --turbopack`)
|
||||||
turbopack: {
|
turbopack: {
|
||||||
rules: {
|
rules: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue