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

Method add

packages/db/src/buffers/bot-buffer.ts:27–44  ·  view source on GitHub ↗
(event: IClickhouseBotEvent)

Source from the content-addressed store, hash-verified

25 }
26
27 async add(event: IClickhouseBotEvent) {
28 return this.timeAdd(async () => {
29 try {
30 const result = await this.redis
31 .multi()
32 .rpush(this.redisKey, JSON.stringify(event))
33 .llen(this.redisKey)
34 .exec();
35
36 const bufferLength = (result?.[1]?.[1] as number) ?? 0;
37 if (bufferLength >= this.batchSize) {
38 await this.tryFlush({ trigger: 'add' });
39 }
40 } catch (error) {
41 this.logger.error({ err: error }, 'Failed to add bot event');
42 }
43 });
44 }
45
46 async processBuffer() {
47 const lrangeStart = performance.now();

Callers 15

country-codes.tsFile · 0.45
groupByLabelsFunction · 0.45
formatFunction · 0.45
computeFunction · 0.45
getFunnelMethod · 0.45
getUserJourneyMethod · 0.45
enqueueCohortComputeFunction · 0.45
createEventFunction · 0.45
createBotEventFunction · 0.45

Calls 4

timeAddMethod · 0.80
tryFlushMethod · 0.80
stringifyMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected