cdp-edge 1.8.1 → 1.9.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.8.1",
3
+ "version": "1.9.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",
@@ -0,0 +1,46 @@
1
+ /**
2
+ * LinkedIn Insight Tag — Browser Template — CDP Edge Quantum Tier
3
+ *
4
+ * Inclui no <head> do projeto. Captura li_fat_id e dispara eventos
5
+ * de conversão via tag browser + envia server-side via CAPI v2.
6
+ */
7
+
8
+ (function(l) {
9
+ if (!l) {
10
+ window.lintrk = function(a, b) { window.lintrk.q.push([a, b]) };
11
+ window.lintrk.q = [];
12
+ }
13
+ var s = document.getElementsByTagName("script")[0];
14
+ var b = document.createElement("script");
15
+ b.type = "text/javascript";
16
+ b.async = true;
17
+ b.src = "https://snap.licdn.com/li.lms-analytics/insight.beta.min.js";
18
+ s.parentNode.insertBefore(b, s);
19
+ })(window.lintrk);
20
+
21
+ // ── Inicialização com Partner ID ──────────────────────────────────────────────
22
+ window._linkedin_partner_id = "{{LINKEDIN_PARTNER_ID}}";
23
+ window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
24
+ window._linkedin_data_partner_ids.push(window._linkedin_partner_id);
25
+
26
+ // ── Captura li_fat_id (LinkedIn First-Party Cookie) ──────────────────────────
27
+ function getLinkedInFatId() {
28
+ const match = document.cookie.match(/li_fat_id=([^;]+)/);
29
+ return match ? match[1] : null;
30
+ }
31
+
32
+ // ── Evento de Conversão Browser ──────────────────────────────────────────────
33
+ // Mapeamento CDP Edge → LinkedIn
34
+ // Lead → Lead Conversion
35
+ // Purchase → Purchase Conversion
36
+ // CompleteRegistration → Registration
37
+
38
+ function trackLinkedInEvent(conversionId) {
39
+ if (typeof window.lintrk === 'function') {
40
+ window.lintrk('track', { conversion_id: conversionId });
41
+ }
42
+ }
43
+
44
+ // ── Integração com cdpTrack.js ────────────────────────────────────────────────
45
+ // O cdpTrack.js envia o li_fat_id para o Worker via payload.liFatId
46
+ // O Worker repassa ao LinkedIn CAPI v2 server-side
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Spotify Pixel — Browser Template — CDP Edge Quantum Tier
3
+ *
4
+ * Inclui no <head> do projeto. Inicializa o Spotify Pixel SDK
5
+ * e captura eventos de conversão browser-side.
6
+ */
7
+
8
+ // ── Inicialização do Spotify Pixel ───────────────────────────────────────────
9
+ !function(e){
10
+ if (!window.SpotifyPixel) {
11
+ var n = window.SpotifyPixel = function() {
12
+ n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments)
13
+ };
14
+ n.push = n;
15
+ n.loaded = !0;
16
+ n.version = "1.0";
17
+ n.queue = [];
18
+ var t = document.createElement("script");
19
+ t.async = !0;
20
+ t.src = "https://pixel.byspotify.com/ping.min.js";
21
+ var r = document.getElementsByTagName("script")[0];
22
+ r.parentNode.insertBefore(t, r);
23
+ }
24
+ }();
25
+
26
+ window.SpotifyPixel('init', '{{SPOTIFY_PIXEL_ID}}');
27
+ window.SpotifyPixel('track', 'PAGE_VIEW');
28
+
29
+ // ── Mapeamento de Eventos CDP Edge → Spotify ──────────────────────────────────
30
+ // PageView → PAGE_VIEW
31
+ // ViewContent → VIEW_CONTENT
32
+ // Lead → LEAD
33
+ // Purchase → PURCHASE
34
+ // AddToCart → ADD_TO_CART
35
+ // InitiateCheckout → INITIATE_CHECKOUT
36
+ // CompleteRegistration → SIGN_UP
37
+
38
+ function trackSpotifyEvent(eventType, params) {
39
+ if (typeof window.SpotifyPixel === 'function') {
40
+ window.SpotifyPixel('track', eventType, params || {});
41
+ }
42
+ }
43
+
44
+ // ── Integração com cdpTrack.js ────────────────────────────────────────────────
45
+ // O cdpTrack.js envia o evento para o Worker server-side via sendSpotifyCapi()
46
+ // O browser dispara via trackSpotifyEvent() em paralelo para deduplicação