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

Function buildEvents

test/retention-fixtures.ts:167–196  ·  view source on GitHub ↗
(projectId: string)

Source from the content-addressed store, hash-verified

165}
166
167function buildEvents(projectId: string) {
168 const { users, day } = RETENTION_FIXTURE;
169 const dayAt = (date: string) => `${date} 12:00:00`;
170
171 const us = { country: 'US' };
172 const se = { country: 'SE' };
173
174 return [
175 // --- DAY scenario: app_open (self-retention) ---
176 buildEvent(projectId, users.ru1, 'app_open', dayAt(day.d0), us),
177 buildEvent(projectId, users.ru1, 'app_open', dayAt(day.d1), us),
178 buildEvent(projectId, users.ru1, 'app_open', dayAt(day.d2), us),
179 buildEvent(projectId, users.ru2, 'app_open', dayAt(day.d0), us),
180 buildEvent(projectId, users.ru2, 'app_open', dayAt(day.d2), us),
181 buildEvent(projectId, users.ru3, 'app_open', dayAt(day.d0), se),
182 buildEvent(projectId, users.ru4, 'app_open', dayAt(day.d1), us),
183 buildEvent(projectId, users.ru4, 'app_open', dayAt(day.d2), us),
184 buildEvent(projectId, users.ru5, 'app_open', dayAt(day.d1), us),
185
186 // --- DAY scenario: purchase (cross-event retention) ---
187 buildEvent(projectId, users.ru1, 'purchase', dayAt(day.d1), us),
188 buildEvent(projectId, users.ru2, 'purchase', dayAt(day.d2), us),
189
190 // --- WEEK scenario: app_open crossing the 2024->2025 boundary ---
191 // 2024-12-30 (Mon) falls in the Sunday-aligned week starting 2024-12-29.
192 buildEvent(projectId, users.wu1, 'app_open', '2024-12-30 12:00:00'),
193 buildEvent(projectId, users.wu1, 'app_open', '2025-01-06 12:00:00'),
194 buildEvent(projectId, users.wu2, 'app_open', '2024-12-30 12:00:00'),
195 ];
196}
197
198// ---------------------------------------------------------------------------
199// Public API

Callers 1

setupRetentionFixturesFunction · 0.85

Calls 2

dayAtFunction · 0.85
buildEventFunction · 0.70

Tested by

no test coverage detected