Skip to content

Commit d5f4e50

Browse files
msukkariclaude
andcommitted
fix(web): add error logging in captureEvent catch block
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bb091c0 commit d5f4e50

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/web/src/lib/posthog.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { PostHog } from 'posthog-node'
2-
import { env, SOURCEBOT_VERSION } from '@sourcebot/shared'
2+
import { createLogger, env, SOURCEBOT_VERSION } from '@sourcebot/shared'
33
import { RequestCookies } from 'next/dist/compiled/@edge-runtime/cookies';
44
import * as Sentry from "@sentry/nextjs";
55
import { PosthogEvent, PosthogEventMap } from './posthogEvents';
66
import { cookies, headers } from 'next/headers';
77
import { getAuthenticatedUser } from '@/middleware/withAuth';
88

9+
const logger = createLogger('posthog');
10+
911
/**
1012
* @note: This is a subset of the properties stored in the
1113
* ph_phc_<id>_posthog cookie.
@@ -99,7 +101,7 @@ export async function captureEvent<E extends PosthogEvent>(event: E, properties:
99101
},
100102
distinctId,
101103
});
102-
} catch {
103-
// Telemetry should never break application functionality.
104+
} catch (error) {
105+
logger.error('Failed to capture PostHog event:', error);
104106
}
105107
}

0 commit comments

Comments
 (0)