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

Function enqueueSessionEndV2

apps/worker/src/utils/session-handler.ts:32–63  ·  view source on GitHub ↗
({
  payload,
  closedSession,
}: {
  payload: IServiceCreateEventPayload;
  closedSession: IClickhouseSession;
})

Source from the content-addressed store, hash-verified

30 * or by the reaper when a session has been idle past the timeout.
31 */
32export async function enqueueSessionEndV2({
33 payload,
34 closedSession,
35}: {
36 payload: IServiceCreateEventPayload;
37 closedSession: IClickhouseSession;
38}) {
39 const jobId = getSessionEndJobIdV2(closedSession.id);
40
41 return sessionsQueue.add(
42 'session',
43 {
44 type: 'createSessionEnd',
45 payload: {
46 ...payload,
47 projectId: closedSession.project_id,
48 deviceId: closedSession.device_id,
49 sessionId: closedSession.id,
50 profileId: closedSession.profile_id || payload.profileId,
51 },
52 snapshot: closedSession,
53 },
54 {
55 jobId,
56 attempts: 3,
57 backoff: {
58 type: 'exponential',
59 delay: 200,
60 },
61 }
62 );
63}

Callers 2

incomingEventFunction · 0.90
closeSessionFunction · 0.90

Calls 2

getSessionEndJobIdV2Function · 0.85
addMethod · 0.45

Tested by

no test coverage detected