MCPcopy
hub / github.com/CapSoftware/Cap / trackEvent

Function trackEvent

apps/web/app/utils/analytics.ts:35–69  ·  view source on GitHub ↗
(
	eventName: string,
	properties?: Record<string, any>,
)

Source from the content-addressed store, hash-verified

33}
34
35export function trackEvent(
36 eventName: string,
37 properties?: Record<string, any>,
38) {
39 try {
40 if (!posthog || typeof posthog.capture !== "function") {
41 console.warn(`PostHog not available for event: ${eventName}`);
42 return;
43 }
44
45 posthog.capture(eventName, { ...properties, platform: "web" });
46
47 const metaEventMap: Record<string, string> = {
48 purchase_completed: "Purchase",
49 subscription_purchased: "Purchase",
50 user_signed_up: "CompleteRegistration",
51 };
52
53 const metaEventName = metaEventMap[eventName];
54 if (metaEventName) {
55 const isSignup = eventName === "user_signed_up";
56 const metaParameters = isSignup ? undefined : properties;
57 const eventId = isSignup
58 ? `signup_${posthog.get_distinct_id?.() ?? "unknown"}`
59 : undefined;
60 trackMetaEvent(
61 metaEventName,
62 metaParameters,
63 eventId ? { eventId } : undefined,
64 );
65 }
66 } catch (error) {
67 console.error(`Error tracking event ${eventName}:`, error);
68 }
69}

Callers 15

processFileFunction · 0.90
trimVideoFunction · 0.90
processTrimFunction · 0.90
handleDownloadFunction · 0.90
resetTrimmerFunction · 0.90
checkSupportFunction · 0.90
validateAndSetFileFunction · 0.90
convertFileFunction · 0.90
extractAudioFromVideoFunction · 0.90
convertVideoToGifFunction · 0.90
convertVideoFormatFunction · 0.90
handleDownloadFunction · 0.90

Calls 1

trackMetaEventFunction · 0.90

Tested by

no test coverage detected