MCPcopy Index your code
hub / github.com/CapSoftware/Cap / generateTestEvent

Function generateTestEvent

scripts/analytics/populate-test-data.js:57–86  ·  view source on GitHub ↗
(videoId, orgId = "", index = 0)

Source from the content-addressed store, hash-verified

55}
56
57function generateTestEvent(videoId, orgId = "", index = 0) {
58 const timestamp = generateRandomTimestamp(30);
59 const city = randomChoice(CITIES);
60 const browser = randomChoice(BROWSERS);
61 const device = randomChoice(DEVICES);
62 const os = randomChoice(OS_OPTIONS);
63 const sessionId = generateSessionId(
64 videoId,
65 timestamp,
66 city.name,
67 browser,
68 index,
69 );
70
71 return {
72 timestamp,
73 session_id: sessionId,
74 tenant_id: orgId,
75 action: "page_hit",
76 version: "test_data_v1",
77 pathname: `/s/${videoId}`,
78 video_id: videoId,
79 country: city.country,
80 region: city.region,
81 city: city.name,
82 browser,
83 device,
84 os,
85 };
86}
87
88function toNdjson(rows) {
89 return rows.map((r) => JSON.stringify(r)).join("\n");

Callers 1

mainFunction · 0.85

Calls 3

generateRandomTimestampFunction · 0.85
randomChoiceFunction · 0.85
generateSessionIdFunction · 0.85

Tested by

no test coverage detected