MCPcopy
hub / github.com/simstudioai/sim / captureServerEvent

Function captureServerEvent

apps/sim/lib/posthog/server.ts:64–90  ·  view source on GitHub ↗
(
  distinctId: string,
  event: E,
  properties: PostHogEventMap[E],
  options?: CaptureOptions
)

Source from the content-addressed store, hash-verified

62 * @param options - Optional groups, $set, and $set_once person properties.
63 */
64export function captureServerEvent<E extends PostHogEventName>(
65 distinctId: string,
66 event: E,
67 properties: PostHogEventMap[E],
68 options?: CaptureOptions
69): void {
70 try {
71 const client = getClient()
72 if (!client) return
73
74 const contextRequestId = getRequestContext()?.requestId
75 const props = properties as Record<string, unknown>
76 client.capture({
77 distinctId,
78 event,
79 properties: {
80 ...properties,
81 ...(contextRequestId && !('request_id' in props) ? { request_id: contextRequestId } : {}),
82 ...(options?.groups ? { $groups: options.groups } : {}),
83 ...(options?.set ? { $set: options.set } : {}),
84 ...(options?.setOnce ? { $set_once: options.setOnce } : {}),
85 },
86 })
87 } catch (error) {
88 logger.warn('Failed to capture PostHog server event', { event, error })
89 }
90}

Callers 15

performDeleteCredentialFunction · 0.90
auth.tsFile · 0.90
performCreateJobFunction · 0.90
performDeleteJobFunction · 0.90
executeWorkflowFunction · 0.90
performRevertToVersionFunction · 0.90
runTableImportFunction · 0.90
acceptInvitationFunction · 0.90
performCreateMcpServerFunction · 0.90

Calls 3

getRequestContextFunction · 0.90
getClientFunction · 0.70
warnMethod · 0.65

Tested by

no test coverage detected