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

Function scenarioIdentify

apps/api/e2e/session-e2e.ts:223–249  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

221}
222
223async function scenarioIdentify() {
224 scenario('identified visit → profile index + profile_id on events');
225 const ip = `10.${(runId >> 16) & 255}.4.${runId & 255 || 1}`;
226 const profileId = `e2e-user-${runId}`;
227
228 const { deviceId, sessionId } = await screenView(ip, '/account');
229 await track(
230 {
231 type: 'track',
232 payload: { name: 'signed_in', profileId, properties: { __ip: ip } },
233 },
234 ip
235 );
236
237 const ptr = await pollUntil(async () =>
238 (await redis.get(profileKey(profileId))) === deviceId ? true : null
239 );
240 check('redis: profile→device pointer written', !!ptr);
241
242 const profiled = await pollUntil(async () => {
243 const rows = await chQuery<{ c: string }>(
244 `SELECT count() AS c FROM events WHERE project_id = '${PROJECT_ID}' AND session_id = '${sessionId}' AND profile_id = '${profileId}'`
245 );
246 return Number(rows[0]?.c ?? 0) > 0 ? true : null;
247 });
248 check('clickhouse: event carries the identified profile_id', !!profiled);
249}
250
251async function main() {
252 console.log(

Callers 1

mainFunction · 0.85

Calls 7

scenarioFunction · 0.90
screenViewFunction · 0.90
trackFunction · 0.90
pollUntilFunction · 0.90
profileKeyFunction · 0.90
checkFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected