MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / captureEvent

Function captureEvent

packages/web/src/lib/posthog.ts:82–108  ·  view source on GitHub ↗
(event: E, properties: PosthogEventMap[E])

Source from the content-addressed store, hash-verified

80}
81
82export async function captureEvent<E extends PosthogEvent>(event: E, properties: PosthogEventMap[E]) {
83 try {
84 if (env.SOURCEBOT_TELEMETRY_DISABLED === 'true') {
85 return;
86 }
87
88 const distinctId = await tryGetPostHogDistinctId();
89 const posthog = await createPostHogClient();
90
91 const headersList = await headers();
92 const host = headersList.get("host") ?? undefined;
93
94 posthog.capture({
95 event,
96 properties: {
97 ...properties,
98 sourcebot_version: SOURCEBOT_VERSION,
99 install_id: env.SOURCEBOT_INSTALL_ID,
100 $host: host,
101 },
102 distinctId,
103 groups: { company: env.SOURCEBOT_INSTALL_ID },
104 });
105 } catch (error) {
106 logger.error('Failed to capture PostHog event:', error);
107 }
108}

Callers 15

auth.tsFile · 0.90
wrappedHandlerFunction · 0.90
toVercelAIToolFunction · 0.90
registerMcpToolFunction · 0.90
createChatFunction · 0.90
claimAnonymousChatsFunction · 0.90
createCheckoutSessionFunction · 0.90
PageFunction · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 2

tryGetPostHogDistinctIdFunction · 0.85
createPostHogClientFunction · 0.85

Tested by

no test coverage detected