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

Method send

packages/sdks/sdk/src/index.ts:120–145  ·  view source on GitHub ↗
(payload: TrackHandlerPayload)

Source from the content-addressed store, hash-verified

118 }
119
120 async send(payload: TrackHandlerPayload) {
121 if (this.options.filter && !this.options.filter(payload)) {
122 return Promise.resolve();
123 }
124
125 if (this.shouldQueue(payload)) {
126 this.addQueue(payload);
127 return Promise.resolve();
128 }
129
130 // Disable keepalive for replay since it has a hard body limit and breaks the request
131 const result = await this.api.fetch<
132 TrackHandlerPayload,
133 { deviceId: string; sessionId: string }
134 >('/track', payload, { keepalive: payload.type !== 'replay' });
135 this.deviceId = result?.deviceId;
136 const hadSession = !!this.sessionId;
137 this.sessionId = result?.sessionId;
138
139 // Flush queued items (e.g. replay chunks) when sessionId first arrives
140 if (!hadSession && this.sessionId) {
141 this.flush();
142 }
143
144 return result;
145 }
146
147 setGlobalProperties(properties: Record<string, unknown>) {
148 this.global = {

Callers 12

trackMethod · 0.95
identifyMethod · 0.95
upsertGroupMethod · 0.95
setGroupMethod · 0.95
setGroupsMethod · 0.95
incrementMethod · 0.95
decrementMethod · 0.95
flushMethod · 0.95
constructorMethod · 0.95
sendEmailFunction · 0.45
produceIncomingEventFunction · 0.45
processRequestFunction · 0.45

Calls 3

shouldQueueMethod · 0.95
addQueueMethod · 0.95
flushMethod · 0.95

Tested by

no test coverage detected