aboutsummaryrefslogtreecommitdiff
path: root/packages/lib
diff options
context:
space:
mode:
authorMaheshtheDev <[email protected]>2025-11-09 07:32:51 +0000
committerMaheshtheDev <[email protected]>2025-11-09 07:32:52 +0000
commit10ada4a1e21ff913ab8edc58ca71039d91cc0ece (patch)
treee76b4361f4bd381be83431a9df25515e5b66256e /packages/lib
parentchore: update posthog findings (#569) (diff)
downloadsupermemory-10ada4a1e21ff913ab8edc58ca71039d91cc0ece.tar.xz
supermemory-10ada4a1e21ff913ab8edc58ca71039d91cc0ece.zip
fix(web): sentry issues across the web app (#570)11-08-fix_web_sentry_issues_across_the_web_app
Fixes all following sentry issues - CONSUMER-APP-FF - CONSUMER-APP-1T - CONSUMER-APP-86 - CONSUMER-APP-7H - CONSUMER-APP-4F - CONSUMER-APP-7X
Diffstat (limited to 'packages/lib')
-rw-r--r--packages/lib/auth-context.tsx30
-rw-r--r--packages/lib/posthog.tsx29
2 files changed, 35 insertions, 24 deletions
diff --git a/packages/lib/auth-context.tsx b/packages/lib/auth-context.tsx
index 7e6462fa..db24ec45 100644
--- a/packages/lib/auth-context.tsx
+++ b/packages/lib/auth-context.tsx
@@ -38,17 +38,23 @@ export function AuthProvider({ children }: { children: ReactNode }) {
// biome-ignore lint/correctness/useExhaustiveDependencies: ignoring the setActiveOrg dependency
useEffect(() => {
if (session?.session.activeOrganizationId) {
- authClient.organization.getFullOrganization().then((org) => {
- // TODO: Uncomment this when we have a way to handle consumer organizations better way
- //if (org.metadata?.isConsumer === true) {
- setOrg(org)
- //} else {
- // const consumerOrg = orgs?.find((o) => o.metadata?.isConsumer === true)
- // if (consumerOrg) {
- // setActiveOrg(consumerOrg.slug)
- // }
- //}
- })
+ authClient.organization
+ .getFullOrganization()
+ .then((org) => {
+ // TODO: Uncomment this when we have a way to handle consumer organizations better way
+ //if (org.metadata?.isConsumer === true) {
+ setOrg(org)
+ //} else {
+ // const consumerOrg = orgs?.find((o) => o.metadata?.isConsumer === true)
+ // if (consumerOrg) {
+ // setActiveOrg(consumerOrg.slug)
+ // }
+ //}
+ })
+ .catch((error) => {
+ // Silently handle organization fetch failures to prevent unhandled rejections
+ console.error("Failed to fetch organization:", error)
+ })
}
}, [session?.session.activeOrganizationId, orgs])
@@ -68,7 +74,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
if (pendingMethod) {
const now = Date.now()
- const ts = pendingTsRaw ? Number.parseInt(pendingTsRaw, 10) : NaN
+ const ts = pendingTsRaw ? Number.parseInt(pendingTsRaw, 10) : Number.NaN
const isFresh = Number.isFinite(ts) && now - ts < 10 * 60 * 1000 // 10 minutes TTL
if (isFresh) {
diff --git a/packages/lib/posthog.tsx b/packages/lib/posthog.tsx
index 62a60e09..0c436e1e 100644
--- a/packages/lib/posthog.tsx
+++ b/packages/lib/posthog.tsx
@@ -22,7 +22,7 @@ function PostHogPageTracking() {
$current_url: url,
path: pathname,
search_params: searchParams.toString(),
- page_type: getPageType(pathname),
+ page_type: getPageType(),
org_slug: getOrgSlug(pathname),
}
@@ -39,16 +39,21 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
useEffect(() => {
if (typeof window !== "undefined") {
const posthogKey = process.env.NEXT_PUBLIC_POSTHOG_KEY
- if (posthogKey){
- posthog.init(posthogKey, {
- api_host: process.env.NEXT_PUBLIC_BACKEND_URL + "/orange",
- ui_host: "https://us.i.posthog.com",
- person_profiles: "identified_only",
- capture_pageview: false,
- capture_pageleave: true,
- })}
- else{
- console.warn("PostHog API key is not set. PostHog will not be initialized.")
+ const backendUrl =
+ process.env.NEXT_PUBLIC_BACKEND_URL ?? "https://api.supermemory.ai"
+
+ if (posthogKey) {
+ posthog.init(posthogKey, {
+ api_host: `${backendUrl}/orange`,
+ ui_host: "https://us.i.posthog.com",
+ person_profiles: "identified_only",
+ capture_pageview: false,
+ capture_pageleave: true,
+ })
+ } else {
+ console.warn(
+ "PostHog API key is not set. PostHog will not be initialized.",
+ )
}
}
}, [])
@@ -75,7 +80,7 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
)
}
-function getPageType(pathname: string): string {
+function getPageType(): string {
return "other"
}