MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / randomProps

Function randomProps

apps/api/e2e/session-stress.ts:77–85  ·  view source on GitHub ↗
(ip: string)

Source from the content-addressed store, hash-verified

75const pick = <T>(arr: T[]): T => arr[Math.floor(Math.random() * arr.length)]!;
76
77function randomProps(ip: string): Record<string, unknown> {
78 const props: Record<string, unknown> = { __ip: ip };
79 const n = Math.floor(Math.random() * 4); // 0–3 extra properties
80 for (let k = 0; k < n; k++) {
81 props[`prop_${pick(WORDS)}`] =
82 Math.random() < 0.5 ? pick(WORDS) : Math.floor(Math.random() * 1000);
83 }
84 return props;
85}
86
87// One event in a session: the entry is always a screen_view; the rest are a
88// 50/50 mix of more screen_views and random custom events.

Callers 1

sendSessionEventFunction · 0.85

Calls 1

pickFunction · 0.70

Tested by

no test coverage detected