cdp-edge 1.26.0 → 1.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdp-edge",
3
- "version": "1.26.0",
3
+ "version": "1.27.0",
4
4
  "description": "CDP Edge - Quantum Tracking - Sistema multi-agente para tracking digital Cloudflare Native (Workers + D1)",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -973,15 +973,18 @@ export default {
973
973
  },
974
974
 
975
975
  // ── Queue Consumer — Retry de eventos com falha ───────────────────────────────
976
- async queue(batch: any, env: Env) {
976
+ async queue(batch: any, env: Env, ctx: ExecutionContext) {
977
977
  for (const message of batch.messages) {
978
978
  const { eventType, payload, platform } = message.body as { eventType: string; payload: TrackPayload; platform: string; attempt?: number };
979
979
 
980
-
981
980
  try {
982
- if (platform === 'meta') await sendMetaCapi(env, eventType, payload, null, null);
983
- if (platform === 'ga4') await sendGA4Mp(env, eventType, payload, null);
984
- if (platform === 'tiktok') await sendTikTokApi(env, eventType, payload, null, null);
981
+ if (platform === 'meta') await sendMetaCapi(env, eventType, payload, null, ctx);
982
+ if (platform === 'ga4') await sendGA4Mp(env, eventType, payload, ctx);
983
+ if (platform === 'tiktok') await sendTikTokApi(env, eventType, payload, null, ctx);
984
+ if (platform === 'pinterest') await sendPinterestCapi(env, eventType, payload, null, ctx);
985
+ if (platform === 'reddit') await sendRedditCapi(env, eventType, payload, null, ctx);
986
+ if (platform === 'linkedin') await sendLinkedInCapi(env, eventType, payload, null, ctx);
987
+ if (platform === 'spotify') await sendSpotifyCapi(env, eventType, payload, null, ctx);
985
988
 
986
989
  message.ack();
987
990
  } catch (err: any) {
@@ -65,6 +65,10 @@ export async function sendPinterestCapi(env: Env, eventName: string, payload: Tr
65
65
  } catch (err: any) {
66
66
  console.error('Pinterest CAPI fetch failed:', err?.message || String(err));
67
67
  if (env.DB && ctx) ctx.waitUntil(logApiFailure(env.DB, 'pinterest', eventName, 'FETCH_ERROR', err?.message || String(err), '', JSON.stringify(body)));
68
+ if (env.RETRY_QUEUE) {
69
+ const send = env.RETRY_QUEUE.send({ eventType: eventName, payload, platform: 'pinterest' });
70
+ if (ctx) ctx.waitUntil(send); else send.catch(() => {});
71
+ }
68
72
  return { error: err?.message || String(err) };
69
73
  }
70
74
  }
@@ -123,6 +127,10 @@ export async function sendRedditCapi(env: Env, eventName: string, payload: Track
123
127
  } catch (err: any) {
124
128
  console.error('Reddit CAPI fetch failed:', err?.message || String(err));
125
129
  if (env.DB && ctx) ctx.waitUntil(logApiFailure(env.DB, 'reddit', eventName, 'FETCH_ERROR', err?.message || String(err), '', JSON.stringify(body)));
130
+ if (env.RETRY_QUEUE) {
131
+ const send = env.RETRY_QUEUE.send({ eventType: eventName, payload, platform: 'reddit' });
132
+ if (ctx) ctx.waitUntil(send); else send.catch(() => {});
133
+ }
126
134
  return { error: err?.message || String(err) };
127
135
  }
128
136
  }
@@ -178,6 +186,10 @@ export async function sendLinkedInCapi(env: Env, eventName: string, payload: Tra
178
186
  } catch (err: any) {
179
187
  console.error('LinkedIn CAPI fetch failed:', err?.message || String(err));
180
188
  if (env.DB && ctx) ctx.waitUntil(logApiFailure(env.DB, 'linkedin', eventName, 'FETCH_ERROR', err?.message || String(err), '', JSON.stringify(body)));
189
+ if (env.RETRY_QUEUE) {
190
+ const send = env.RETRY_QUEUE.send({ eventType: eventName, payload, platform: 'linkedin' });
191
+ if (ctx) ctx.waitUntil(send); else send.catch(() => {});
192
+ }
181
193
  return { error: err?.message || String(err) };
182
194
  }
183
195
  }
@@ -234,6 +246,10 @@ export async function sendSpotifyCapi(env: Env, eventName: string, payload: Trac
234
246
  } catch (err: any) {
235
247
  console.error('Spotify CAPI fetch failed:', err?.message || String(err));
236
248
  if (env.DB && ctx) ctx.waitUntil(logApiFailure(env.DB, 'spotify', eventName, 'FETCH_ERROR', err?.message || String(err), '', JSON.stringify(body)));
249
+ if (env.RETRY_QUEUE) {
250
+ const send = env.RETRY_QUEUE.send({ eventType: eventName, payload, platform: 'spotify' });
251
+ if (ctx) ctx.waitUntil(send); else send.catch(() => {});
252
+ }
237
253
  return { error: err?.message || String(err) };
238
254
  }
239
255
  }