cdp-edge 1.25.1 → 1.26.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
|
@@ -62,6 +62,11 @@ export async function sendGA4Mp(env: Env, ga4EventName: string, payload: TrackPa
|
|
|
62
62
|
ctx.waitUntil(logApiFailure(env.DB, 'ga4', ga4EventName, 'FETCH_ERROR', err?.message || String(err), '', JSON.stringify(body)));
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
if (env.RETRY_QUEUE) {
|
|
66
|
+
const send = env.RETRY_QUEUE.send({ eventType: ga4EventName, payload, platform: 'ga4' });
|
|
67
|
+
if (ctx) ctx.waitUntil(send); else send.catch(() => {});
|
|
68
|
+
}
|
|
69
|
+
|
|
65
70
|
return { error: err?.message || String(err) };
|
|
66
71
|
}
|
|
67
72
|
}
|
|
@@ -133,6 +133,11 @@ export async function sendMetaCapi(env: Env, eventName: string, payload: TrackPa
|
|
|
133
133
|
ctx.waitUntil(logApiFailure(env.DB, 'meta', eventName, 'FETCH_ERROR', err?.message || String(err), eventPayload.event_id, JSON.stringify(requestBody)));
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
if (env.RETRY_QUEUE) {
|
|
137
|
+
const send = env.RETRY_QUEUE.send({ eventType: eventName, payload, platform: 'meta' });
|
|
138
|
+
if (ctx) ctx.waitUntil(send); else send.catch(() => {});
|
|
139
|
+
}
|
|
140
|
+
|
|
136
141
|
return { error: err?.message || String(err) };
|
|
137
142
|
}
|
|
138
143
|
}
|
|
@@ -97,6 +97,11 @@ export async function sendTikTokApi(env: Env, eventName: string, payload: TrackP
|
|
|
97
97
|
ctx.waitUntil(logApiFailure(env.DB, 'tiktok', eventName, 'FETCH_ERROR', err?.message || String(err), '', JSON.stringify(body)));
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
if (env.RETRY_QUEUE) {
|
|
101
|
+
const send = env.RETRY_QUEUE.send({ eventType: eventName, payload, platform: 'tiktok' });
|
|
102
|
+
if (ctx) ctx.waitUntil(send); else send.catch(() => {});
|
|
103
|
+
}
|
|
104
|
+
|
|
100
105
|
return { error: err?.message || String(err) };
|
|
101
106
|
}
|
|
102
107
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Tipos para o Cloudflare Worker e bindings
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { D1Database, KVNamespace, R2Bucket } from '@cloudflare/workers-types';
|
|
6
|
+
import { D1Database, KVNamespace, Queue, R2Bucket } from '@cloudflare/workers-types';
|
|
7
7
|
|
|
8
8
|
// ── Environment Bindings ─────────────────────────────────────────────────────
|
|
9
9
|
export interface Env {
|
|
@@ -22,6 +22,9 @@ export interface Env {
|
|
|
22
22
|
// Rate Limiter
|
|
23
23
|
RATE_LIMITER?: any;
|
|
24
24
|
|
|
25
|
+
// Queue — Retry de eventos com falha de rede
|
|
26
|
+
RETRY_QUEUE?: Queue<QueueMessage>;
|
|
27
|
+
|
|
25
28
|
// Public Variables
|
|
26
29
|
META_PIXEL_ID?: string;
|
|
27
30
|
GA4_MEASUREMENT_ID?: string;
|