@beworke/pixel 0.1.0-rc.1 → 0.1.0-rc.6

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.
Files changed (156) hide show
  1. package/CHANGELOG.md +260 -4
  2. package/README.md +65 -118
  3. package/RELEASE_CANDIDATE.md +181 -36
  4. package/dist/{StorageFactory-BhpbB6Jj.d.mts → StorageFactory-CPghDPBj.d.mts} +2 -2
  5. package/dist/{StorageFactory-CAkJJqVD.d.ts → StorageFactory-tjfzk57c.d.ts} +2 -2
  6. package/dist/config/index.cjs.js +1 -1
  7. package/dist/config/index.cjs.js.map +1 -1
  8. package/dist/config/index.d.mts +4 -3
  9. package/dist/config/index.d.ts +4 -3
  10. package/dist/config/index.esm.js +1 -1
  11. package/dist/config/index.esm.js.map +1 -1
  12. package/dist/events/index.cjs.js +1 -1
  13. package/dist/events/index.cjs.js.map +1 -1
  14. package/dist/events/index.d.mts +2 -1
  15. package/dist/events/index.d.ts +2 -1
  16. package/dist/events/index.esm.js +1 -1
  17. package/dist/events/index.esm.js.map +1 -1
  18. package/dist/examples/html-script/README.md +24 -2
  19. package/dist/examples/html-script/RELEASE_CANDIDATE.md +20 -6
  20. package/dist/examples/html-script/add-payment-info/README.md +3 -3
  21. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-autocomplete.html +66 -48
  22. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-disabled.html +66 -48
  23. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-fields.html +65 -47
  24. package/dist/examples/html-script/add-payment-info/example-add-payment-info-data-track.html +73 -47
  25. package/dist/examples/html-script/add-payment-info/example-add-payment-info-dedupe.html +65 -47
  26. package/dist/examples/html-script/add-payment-info/example-add-payment-info-manual.html +56 -47
  27. package/dist/examples/html-script/add-payment-info/example-add-payment-info-rules-card.html +65 -47
  28. package/dist/examples/html-script/add-payment-info/example-add-payment-info-security.html +65 -47
  29. package/dist/examples/html-script/add-to-cart/README.md +3 -3
  30. package/dist/examples/html-script/add-to-cart/example-add-to-cart-attribute.html +90 -70
  31. package/dist/examples/html-script/add-to-cart/example-add-to-cart-auto.html +103 -81
  32. package/dist/examples/html-script/add-to-cart/example-add-to-cart-click.html +101 -78
  33. package/dist/examples/html-script/add-to-cart/example-add-to-cart-dedupe.html +90 -70
  34. package/dist/examples/html-script/add-to-cart/example-add-to-cart-manual.html +81 -67
  35. package/dist/examples/html-script/add-to-cart/example-add-to-cart-order-bump.html +90 -70
  36. package/dist/examples/html-script/add-to-cart/example-add-to-cart-text.html +104 -81
  37. package/dist/examples/html-script/behavior/example-behavior-engagement.html +489 -0
  38. package/dist/examples/html-script/behavior/example-behavior-heartbeat.html +350 -0
  39. package/dist/examples/html-script/behavior/example-behavior-runtime-intelligence.html +433 -0
  40. package/dist/examples/html-script/behavior/example-behavior-viewport.html +397 -0
  41. package/dist/examples/html-script/{example-behavior.html → behavior/example-behavior.html} +23 -17
  42. package/dist/examples/html-script/example-checkout-commerce.html +825 -0
  43. package/dist/examples/html-script/example-integration.html +5 -5
  44. package/dist/examples/html-script/example-landing-commerce.html +380 -0
  45. package/dist/examples/html-script/example-runtime-diagnostics.html +108 -0
  46. package/dist/examples/html-script/example-transport.html +5 -5
  47. package/dist/examples/html-script/full-funnel/README.md +64 -0
  48. package/dist/examples/html-script/full-funnel/checkout.html +116 -0
  49. package/dist/examples/html-script/full-funnel/downsell.html +58 -0
  50. package/dist/examples/html-script/full-funnel/landing.html +99 -0
  51. package/dist/examples/html-script/full-funnel/thank-you.html +85 -0
  52. package/dist/examples/html-script/full-funnel/upsell.html +64 -0
  53. package/dist/examples/html-script/initiate-checkout/README.md +6 -6
  54. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-attribute.html +94 -74
  55. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-auto.html +102 -80
  56. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-click.html +103 -80
  57. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-manual.html +86 -72
  58. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-snapshot.html +95 -75
  59. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-submit.html +103 -83
  60. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-text.html +105 -82
  61. package/dist/examples/html-script/lead/README.md +9 -7
  62. package/dist/examples/html-script/lead/example-lead-trigger-attribute.html +67 -47
  63. package/dist/examples/html-script/lead/example-lead-trigger-auto.html +78 -56
  64. package/dist/examples/html-script/lead/example-lead-trigger-click.html +78 -55
  65. package/dist/examples/html-script/release-candidate.html +187 -76
  66. package/dist/examples/html-script/remove-from-cart/README.md +1 -1
  67. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-attribute.html +93 -73
  68. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-css.html +93 -73
  69. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-dedupe.html +93 -73
  70. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-manual.html +84 -70
  71. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-multi.html +94 -74
  72. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-state.html +95 -75
  73. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-text.html +98 -76
  74. package/dist/examples/html-script/search/README.md +1 -1
  75. package/dist/examples/html-script/search/example-search-attribute.html +66 -51
  76. package/dist/examples/html-script/search/example-search-button-sync.html +66 -51
  77. package/dist/examples/html-script/search/example-search-dedupe.html +66 -51
  78. package/dist/examples/html-script/search/example-search-input.html +67 -51
  79. package/dist/examples/html-script/search/example-search-manual.html +57 -48
  80. package/dist/examples/html-script/search/example-search-submit.html +66 -51
  81. package/dist/examples/html-script/search/example-search-text.html +71 -51
  82. package/dist/examples/html-script/url-context/example-url-context-allowed-domains.html +63 -0
  83. package/dist/examples/html-script/url-context/example-url-context-landing.html +70 -0
  84. package/dist/examples/html-script/url-context/example-url-context-upsell.html +67 -0
  85. package/dist/examples/html-script/url-context/example-url-context.html +171 -0
  86. package/dist/examples/html-script/view-content/README.md +1 -1
  87. package/dist/examples/html-script/view-content/example-view-content-attribute.html +85 -70
  88. package/dist/examples/html-script/view-content/example-view-content-css.html +85 -70
  89. package/dist/examples/html-script/view-content/example-view-content-dedupe.html +85 -70
  90. package/dist/examples/html-script/view-content/example-view-content-empty.html +85 -70
  91. package/dist/examples/html-script/view-content/example-view-content-manual.html +76 -67
  92. package/dist/examples/html-script/view-content/example-view-content-product-card.html +85 -70
  93. package/dist/examples/html-script/view-content/example-view-content-text.html +90 -73
  94. package/dist/examples/v2/README.md +4 -1
  95. package/dist/{index-DUfFzniE.d.ts → index-CQAyT5Od.d.ts} +170 -3
  96. package/dist/{index-DUfFzniE.d.mts → index-JlKPz4pp.d.mts} +170 -3
  97. package/dist/index.cjs.js +1 -1
  98. package/dist/index.cjs.js.map +1 -1
  99. package/dist/index.d.mts +435 -12
  100. package/dist/index.d.ts +435 -12
  101. package/dist/index.esm.js +1 -1
  102. package/dist/index.esm.js.map +1 -1
  103. package/dist/{pixel-CbeF25mD.d.mts → pixel-BxZZx8l5.d.ts} +248 -72
  104. package/dist/{pixel-CbeF25mD.d.ts → pixel-CKc4OQUx.d.mts} +248 -72
  105. package/dist/{pixel-default-config-1VgLFOiL.d.mts → pixel-default-config-CJl-eypl.d.mts} +1 -1
  106. package/dist/{pixel-default-config-Bxb-Vdd8.d.ts → pixel-default-config-aAOujzwp.d.ts} +1 -1
  107. package/dist/runtime/index.cjs.js +1 -1
  108. package/dist/runtime/index.cjs.js.map +1 -1
  109. package/dist/runtime/index.d.mts +19 -26
  110. package/dist/runtime/index.d.ts +19 -26
  111. package/dist/runtime/index.esm.js +1 -1
  112. package/dist/runtime/index.esm.js.map +1 -1
  113. package/dist/services/index.cjs.js +1 -1
  114. package/dist/services/index.cjs.js.map +1 -1
  115. package/dist/services/index.d.mts +14 -6
  116. package/dist/services/index.d.ts +14 -6
  117. package/dist/services/index.esm.js +1 -1
  118. package/dist/services/index.esm.js.map +1 -1
  119. package/dist/types-BP8dz1gP.d.mts +19 -0
  120. package/dist/types-C75pQP31.d.ts +19 -0
  121. package/dist/types-DMhzHSVC.d.mts +293 -0
  122. package/dist/types-D_SsCur9.d.ts +293 -0
  123. package/dist/url-context-BjAsQoVl.d.mts +85 -0
  124. package/dist/url-context-BjAsQoVl.d.ts +85 -0
  125. package/dist/v2/global.global.js +1 -1
  126. package/dist/v2/global.global.js.map +1 -1
  127. package/dist/v2/index.cjs.js +1 -1
  128. package/dist/v2/index.cjs.js.map +1 -1
  129. package/dist/v2/index.d.mts +8 -6
  130. package/dist/v2/index.d.ts +8 -6
  131. package/dist/v2/index.esm.js +1 -1
  132. package/dist/v2/index.esm.js.map +1 -1
  133. package/docs/public/README.md +75 -0
  134. package/docs/public/api/exports.md +47 -0
  135. package/docs/public/api/pixel.md +65 -0
  136. package/docs/public/configuration/commerce.md +44 -0
  137. package/docs/public/configuration/modules.md +66 -0
  138. package/docs/public/configuration/overview.md +66 -0
  139. package/docs/public/events/catalog.md +65 -0
  140. package/docs/public/getting-started/installation.md +75 -0
  141. package/docs/public/getting-started/quick-start.md +77 -0
  142. package/docs/public/getting-started/react-nextjs.md +55 -0
  143. package/docs/public/getting-started/script-tag.md +57 -0
  144. package/docs/public/guides/funnel-checkout.md +52 -0
  145. package/docs/public/guides/funnel-downsell.md +53 -0
  146. package/docs/public/guides/funnel-full.md +64 -0
  147. package/docs/public/guides/funnel-landing.md +68 -0
  148. package/docs/public/guides/funnel-thank-you.md +48 -0
  149. package/docs/public/guides/funnel-upsell.md +72 -0
  150. package/docs/public/limitations.md +32 -0
  151. package/docs/public/privacy/limitations.md +33 -0
  152. package/docs/public/release-candidate/validation.md +37 -0
  153. package/docs/public/troubleshooting.md +55 -0
  154. package/package.json +13 -1
  155. package/dist/types-CTpRvFKZ.d.ts +0 -71
  156. package/dist/types-DGlBdsAy.d.mts +0 -71
@@ -0,0 +1,116 @@
1
+ <!doctype html>
2
+ <html lang="pt-BR">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Full Funnel — Checkout</title>
7
+ <style>
8
+ body { font-family: system-ui, sans-serif; max-width: 720px; margin: 2rem auto; padding: 0 1rem; }
9
+ a, button { display: inline-block; margin: 0.35rem 0.35rem 0 0; padding: 0.5rem 0.85rem; border-radius: 8px; border: 0; background: #0f766e; color: #fff; text-decoration: none; font: inherit; cursor: pointer; }
10
+ pre { background: #0f172a; color: #e2e8f0; padding: 0.75rem; border-radius: 8px; font-size: 0.75rem; overflow: auto; max-height: 320px; }
11
+ .hint { color: #64748b; font-size: 0.9rem; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <h1>Checkout</h1>
16
+ <p class="hint">
17
+ Esperado: <code>sid</code> + UTMs preservados. Sem token/CVV na URL.
18
+ <code>paymentMethod</code> oficial: <code>CREDIT_CARD</code> | <code>PIX</code> | <code>BANK_SLIP</code>.
19
+ </p>
20
+ <p>
21
+ <button type="button" id="btn-ic">INITIATE_CHECKOUT</button>
22
+ <button type="button" id="btn-pay">ADD_PAYMENT_INFO</button>
23
+ <button type="button" id="btn-purchase">PURCHASE</button>
24
+ <a id="to-upsell" href="upsell.html">Ir ao upsell</a>
25
+ </p>
26
+ <pre id="out">init…</pre>
27
+ <script src="../../../dist/v2/global.global.js"></script>
28
+ <script>
29
+ (async function () {
30
+ var out = document.getElementById('out');
31
+ function log(label, data) {
32
+ out.textContent = label + '\n' + JSON.stringify(data, null, 2);
33
+ console.debug('[full-funnel checkout]', label, data);
34
+ }
35
+ var { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
36
+
37
+ // order_id no href ANTES do init — UrlContext/LinkDecorator vê o href definitivo
38
+ var orderId = 'ord_' + Date.now().toString(36);
39
+ var upsell = document.getElementById('to-upsell');
40
+ var baseHref = upsell.getAttribute('href') || 'upsell.html';
41
+ upsell.setAttribute(
42
+ 'href',
43
+ baseHref +
44
+ (baseHref.indexOf('?') >= 0 ? '&' : '?') +
45
+ 'order_id=' +
46
+ encodeURIComponent(orderId)
47
+ );
48
+
49
+ var pixel = new Pixel({
50
+ ...DEFAULT_PIXEL_CONFIG,
51
+ app: { ...DEFAULT_PIXEL_CONFIG.app, debug: true },
52
+ identity: { ...DEFAULT_PIXEL_CONFIG.identity, pixelId: 'pix_ff_checkout' },
53
+ commerce: {
54
+ ...DEFAULT_PIXEL_CONFIG.commerce,
55
+ enabled: true,
56
+ catalog: {
57
+ products: [
58
+ {
59
+ id: 'main_offer',
60
+ name: 'Oferta principal',
61
+ price: 97,
62
+ currency: 'BRL',
63
+ type: 'main',
64
+ },
65
+ ],
66
+ },
67
+ cart: {
68
+ ...DEFAULT_PIXEL_CONFIG.commerce.cart,
69
+ mode: 'checkout',
70
+ initialItems: [{ productId: 'main_offer', quantity: 1 }],
71
+ },
72
+ },
73
+ modules: {
74
+ ...DEFAULT_PIXEL_CONFIG.modules,
75
+ core: {
76
+ ...DEFAULT_PIXEL_CONFIG.modules.core,
77
+ urlContext: {
78
+ enabled: true,
79
+ linkDecoration: {
80
+ enabled: true,
81
+ strategy: 'both',
82
+ allowedDomains: '*',
83
+ mergeDefaultExcludedDomains: false,
84
+ },
85
+ },
86
+ },
87
+ conversion: { ...DEFAULT_PIXEL_CONFIG.modules.conversion, enabled: true },
88
+ behavior: { ...DEFAULT_PIXEL_CONFIG.modules.behavior, enabled: false },
89
+ transport: { ...DEFAULT_PIXEL_CONFIG.modules.transport, enabled: false },
90
+ integrations: { ...DEFAULT_PIXEL_CONFIG.modules.integrations, enabled: false },
91
+ },
92
+ });
93
+ await pixel.init();
94
+ var uc = pixel.getDebugServices().urlContext;
95
+ log('ready', {
96
+ href: location.href,
97
+ orderId: orderId,
98
+ snapshot: uc.getSnapshot(),
99
+ upsell: upsell.getAttribute('href'),
100
+ });
101
+ document.getElementById('btn-ic').onclick = function () {
102
+ pixel.initiateCheckout();
103
+ log('INITIATE_CHECKOUT', uc.getSnapshot());
104
+ };
105
+ document.getElementById('btn-pay').onclick = function () {
106
+ pixel.addPaymentInfo({ paymentMethod: 'CREDIT_CARD' });
107
+ log('ADD_PAYMENT_INFO', uc.getSnapshot());
108
+ };
109
+ document.getElementById('btn-purchase').onclick = function () {
110
+ pixel.purchase({ orderId: orderId, value: 97, currency: 'BRL' });
111
+ log('PURCHASE', uc.getSnapshot());
112
+ };
113
+ })();
114
+ </script>
115
+ </body>
116
+ </html>
@@ -0,0 +1,58 @@
1
+ <!doctype html>
2
+ <html lang="pt-BR">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Full Funnel — Downsell</title>
7
+ <style>
8
+ body { font-family: system-ui, sans-serif; max-width: 720px; margin: 2rem auto; padding: 0 1rem; }
9
+ a { display: inline-block; margin: 0.35rem 0; padding: 0.5rem 0.85rem; border-radius: 8px; background: #0f766e; color: #fff; text-decoration: none; }
10
+ pre { background: #0f172a; color: #e2e8f0; padding: 0.75rem; border-radius: 8px; font-size: 0.75rem; overflow: auto; max-height: 320px; }
11
+ .hint { color: #64748b; font-size: 0.9rem; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <h1>Downsell</h1>
16
+ <p class="hint">Última oferta — contexto de URL deve continuar intacto.</p>
17
+ <p><a id="finish" href="thank-you.html?accepted=0">Finalizar</a></p>
18
+ <pre id="out">init…</pre>
19
+ <script src="../../../dist/v2/global.global.js"></script>
20
+ <script>
21
+ (async function () {
22
+ var { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
23
+ var pixel = new Pixel({
24
+ ...DEFAULT_PIXEL_CONFIG,
25
+ app: { ...DEFAULT_PIXEL_CONFIG.app, debug: true },
26
+ identity: { ...DEFAULT_PIXEL_CONFIG.identity, pixelId: 'pix_ff_downsell' },
27
+ modules: {
28
+ ...DEFAULT_PIXEL_CONFIG.modules,
29
+ core: {
30
+ ...DEFAULT_PIXEL_CONFIG.modules.core,
31
+ urlContext: {
32
+ enabled: true,
33
+ linkDecoration: {
34
+ enabled: true,
35
+ strategy: 'both',
36
+ allowedDomains: '*',
37
+ mergeDefaultExcludedDomains: false,
38
+ },
39
+ },
40
+ },
41
+ conversion: { ...DEFAULT_PIXEL_CONFIG.modules.conversion, enabled: false },
42
+ transport: { ...DEFAULT_PIXEL_CONFIG.modules.transport, enabled: false },
43
+ integrations: { ...DEFAULT_PIXEL_CONFIG.modules.integrations, enabled: false },
44
+ behavior: { ...DEFAULT_PIXEL_CONFIG.modules.behavior, enabled: false },
45
+ },
46
+ });
47
+ await pixel.init();
48
+ var debug = {
49
+ href: location.href,
50
+ snapshot: pixel.getDebugServices().urlContext.getSnapshot(),
51
+ finish: document.getElementById('finish').getAttribute('href'),
52
+ };
53
+ document.getElementById('out').textContent = JSON.stringify(debug, null, 2);
54
+ console.debug('[full-funnel downsell]', debug);
55
+ })();
56
+ </script>
57
+ </body>
58
+ </html>
@@ -0,0 +1,99 @@
1
+ <!doctype html>
2
+ <html lang="pt-BR">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Full Funnel — Landing</title>
7
+ <style>
8
+ body { font-family: system-ui, sans-serif; max-width: 720px; margin: 2rem auto; padding: 0 1rem; }
9
+ a, button { display: inline-block; margin: 0.35rem 0.35rem 0 0; padding: 0.5rem 0.85rem; border-radius: 8px; border: 1px solid #cbd5e1; background: #0f766e; color: #fff; text-decoration: none; font: inherit; cursor: pointer; }
10
+ pre { background: #0f172a; color: #e2e8f0; padding: 0.75rem; border-radius: 8px; font-size: 0.75rem; overflow: auto; max-height: 320px; }
11
+ .hint { color: #64748b; font-size: 0.9rem; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <h1>Landing</h1>
16
+ <p class="hint">
17
+ Funil 15B · contrato oficial <code>commerce.catalog</code> + <code>cart.initialItems</code>.
18
+ Params seguros: <code>utm_*</code>, <code>affid</code>, <code>sid</code>.
19
+ <code>allowedDomains: '*'</code> = qualquer domínio (exc. densylist padrão se merge ativo).
20
+ </p>
21
+ <p>
22
+ <button type="button" id="btn-lead">LEAD</button>
23
+ <button type="button" id="btn-atc">ADD_TO_CART</button>
24
+ <a id="to-checkout" href="checkout.html#step">Ir ao checkout</a>
25
+ </p>
26
+ <pre id="out">init…</pre>
27
+ <script src="../../../dist/v2/global.global.js"></script>
28
+ <script>
29
+ (async function () {
30
+ var out = document.getElementById('out');
31
+ function log(label, data) {
32
+ out.textContent = label + '\n' + JSON.stringify(data, null, 2);
33
+ console.debug('[full-funnel landing]', label, data);
34
+ }
35
+ var { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
36
+ var pixel = new Pixel({
37
+ ...DEFAULT_PIXEL_CONFIG,
38
+ app: { ...DEFAULT_PIXEL_CONFIG.app, debug: true },
39
+ identity: { ...DEFAULT_PIXEL_CONFIG.identity, pixelId: 'pix_ff_landing' },
40
+ commerce: {
41
+ ...DEFAULT_PIXEL_CONFIG.commerce,
42
+ enabled: true,
43
+ catalog: {
44
+ products: [
45
+ {
46
+ id: 'main_offer',
47
+ name: 'Oferta principal',
48
+ price: 97,
49
+ currency: 'BRL',
50
+ type: 'main',
51
+ },
52
+ ],
53
+ },
54
+ cart: {
55
+ ...DEFAULT_PIXEL_CONFIG.commerce.cart,
56
+ mode: 'landing_page',
57
+ initialItems: [{ productId: 'main_offer', quantity: 1 }],
58
+ },
59
+ },
60
+ modules: {
61
+ ...DEFAULT_PIXEL_CONFIG.modules,
62
+ core: {
63
+ ...DEFAULT_PIXEL_CONFIG.modules.core,
64
+ urlContext: {
65
+ enabled: true,
66
+ linkDecoration: {
67
+ enabled: true,
68
+ strategy: 'both',
69
+ // '*' = todos os hosts (contrato oficial UrlLinkDecorationConfig)
70
+ allowedDomains: '*',
71
+ mergeDefaultExcludedDomains: false,
72
+ },
73
+ },
74
+ },
75
+ conversion: { ...DEFAULT_PIXEL_CONFIG.modules.conversion, enabled: true },
76
+ behavior: { ...DEFAULT_PIXEL_CONFIG.modules.behavior, enabled: false },
77
+ transport: { ...DEFAULT_PIXEL_CONFIG.modules.transport, enabled: false },
78
+ integrations: { ...DEFAULT_PIXEL_CONFIG.modules.integrations, enabled: false },
79
+ },
80
+ });
81
+ await pixel.init();
82
+ var uc = pixel.getDebugServices().urlContext;
83
+ log('ready', {
84
+ href: location.href,
85
+ snapshot: uc.getSnapshot(),
86
+ checkoutHref: document.getElementById('to-checkout').getAttribute('href'),
87
+ });
88
+ document.getElementById('btn-lead').onclick = function () {
89
+ pixel.lead({ email: 'demo@example.com' });
90
+ log('LEAD', uc.getSnapshot());
91
+ };
92
+ document.getElementById('btn-atc').onclick = function () {
93
+ pixel.addToCart();
94
+ log('ADD_TO_CART', uc.getSnapshot());
95
+ };
96
+ })();
97
+ </script>
98
+ </body>
99
+ </html>
@@ -0,0 +1,85 @@
1
+ <!doctype html>
2
+ <html lang="pt-BR">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Full Funnel — Thank You</title>
7
+ <style>
8
+ body { font-family: system-ui, sans-serif; max-width: 720px; margin: 2rem auto; padding: 0 1rem; }
9
+ button { margin: 0.35rem 0.35rem 0 0; padding: 0.5rem 0.85rem; border-radius: 8px; border: 0; background: #0f766e; color: #fff; font: inherit; cursor: pointer; }
10
+ pre { background: #0f172a; color: #e2e8f0; padding: 0.75rem; border-radius: 8px; font-size: 0.75rem; overflow: auto; max-height: 360px; }
11
+ .hint { color: #64748b; font-size: 0.9rem; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <h1>Thank you</h1>
16
+ <p class="hint">Snapshot final + destroy / reinit lifecycle.</p>
17
+ <p>
18
+ <button type="button" id="btn-snap">Log snapshot</button>
19
+ <button type="button" id="btn-destroy">Destroy</button>
20
+ <button type="button" id="btn-reinit">Reinit</button>
21
+ </p>
22
+ <pre id="out">init…</pre>
23
+ <script src="../../../dist/v2/global.global.js"></script>
24
+ <script>
25
+ (async function () {
26
+ var out = document.getElementById('out');
27
+ var pixel = null;
28
+ var { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
29
+
30
+ function config() {
31
+ return {
32
+ ...DEFAULT_PIXEL_CONFIG,
33
+ app: { ...DEFAULT_PIXEL_CONFIG.app, debug: true },
34
+ identity: { ...DEFAULT_PIXEL_CONFIG.identity, pixelId: 'pix_ff_thanks' },
35
+ modules: {
36
+ ...DEFAULT_PIXEL_CONFIG.modules,
37
+ core: {
38
+ ...DEFAULT_PIXEL_CONFIG.modules.core,
39
+ urlContext: { enabled: true },
40
+ },
41
+ conversion: { ...DEFAULT_PIXEL_CONFIG.modules.conversion, enabled: false },
42
+ transport: { ...DEFAULT_PIXEL_CONFIG.modules.transport, enabled: false },
43
+ integrations: { ...DEFAULT_PIXEL_CONFIG.modules.integrations, enabled: false },
44
+ behavior: { ...DEFAULT_PIXEL_CONFIG.modules.behavior, enabled: false },
45
+ },
46
+ };
47
+ }
48
+
49
+ function log(label) {
50
+ var data = {
51
+ href: location.href,
52
+ enabled: pixel ? pixel.getDebugServices().urlContext.isEnabled() : false,
53
+ snapshot: pixel
54
+ ? pixel.getDebugServices().urlContext.getSnapshot()
55
+ : null,
56
+ };
57
+ out.textContent = label + '\n' + JSON.stringify(data, null, 2);
58
+ console.debug('[full-funnel thanks]', label, data);
59
+ }
60
+
61
+ async function boot() {
62
+ pixel = new Pixel(config());
63
+ await pixel.init();
64
+ log('ready');
65
+ }
66
+
67
+ await boot();
68
+ document.getElementById('btn-snap').onclick = function () {
69
+ if (!pixel) return;
70
+ log('snapshot');
71
+ };
72
+ document.getElementById('btn-destroy').onclick = async function () {
73
+ if (!pixel) return;
74
+ await pixel.destroy();
75
+ pixel = null;
76
+ log('destroyed');
77
+ };
78
+ document.getElementById('btn-reinit').onclick = async function () {
79
+ if (pixel) await pixel.destroy();
80
+ await boot();
81
+ };
82
+ })();
83
+ </script>
84
+ </body>
85
+ </html>
@@ -0,0 +1,64 @@
1
+ <!doctype html>
2
+ <html lang="pt-BR">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Full Funnel — Upsell</title>
7
+ <style>
8
+ body { font-family: system-ui, sans-serif; max-width: 720px; margin: 2rem auto; padding: 0 1rem; }
9
+ a { display: inline-block; margin: 0.35rem 0.35rem 0 0; padding: 0.5rem 0.85rem; border-radius: 8px; background: #0f766e; color: #fff; text-decoration: none; }
10
+ a.secondary { background: #64748b; }
11
+ pre { background: #0f172a; color: #e2e8f0; padding: 0.75rem; border-radius: 8px; font-size: 0.75rem; overflow: auto; max-height: 320px; }
12
+ .hint { color: #64748b; font-size: 0.9rem; }
13
+ </style>
14
+ </head>
15
+ <body>
16
+ <h1>Upsell</h1>
17
+ <p class="hint">Links devem preservar <code>sid</code> / <code>order_id</code> / UTMs via UrlContext.</p>
18
+ <p>
19
+ <a id="accept" href="thank-you.html?accepted=1">Aceitar upsell</a>
20
+ <a id="decline" class="secondary" href="downsell.html">Recusar → downsell</a>
21
+ </p>
22
+ <pre id="out">init…</pre>
23
+ <script src="../../../dist/v2/global.global.js"></script>
24
+ <script>
25
+ (async function () {
26
+ var { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
27
+ var pixel = new Pixel({
28
+ ...DEFAULT_PIXEL_CONFIG,
29
+ app: { ...DEFAULT_PIXEL_CONFIG.app, debug: true },
30
+ identity: { ...DEFAULT_PIXEL_CONFIG.identity, pixelId: 'pix_ff_upsell' },
31
+ modules: {
32
+ ...DEFAULT_PIXEL_CONFIG.modules,
33
+ core: {
34
+ ...DEFAULT_PIXEL_CONFIG.modules.core,
35
+ urlContext: {
36
+ enabled: true,
37
+ linkDecoration: {
38
+ enabled: true,
39
+ strategy: 'both',
40
+ allowedDomains: '*',
41
+ mergeDefaultExcludedDomains: false,
42
+ },
43
+ },
44
+ },
45
+ conversion: { ...DEFAULT_PIXEL_CONFIG.modules.conversion, enabled: true },
46
+ transport: { ...DEFAULT_PIXEL_CONFIG.modules.transport, enabled: false },
47
+ integrations: { ...DEFAULT_PIXEL_CONFIG.modules.integrations, enabled: false },
48
+ behavior: { ...DEFAULT_PIXEL_CONFIG.modules.behavior, enabled: false },
49
+ },
50
+ });
51
+ await pixel.init();
52
+ var snap = pixel.getDebugServices().urlContext.getSnapshot();
53
+ var debug = {
54
+ href: location.href,
55
+ snapshot: snap,
56
+ accept: document.getElementById('accept').getAttribute('href'),
57
+ decline: document.getElementById('decline').getAttribute('href'),
58
+ };
59
+ document.getElementById('out').textContent = JSON.stringify(debug, null, 2);
60
+ console.debug('[full-funnel upsell]', debug);
61
+ })();
62
+ </script>
63
+ </body>
64
+ </html>
@@ -2,16 +2,16 @@
2
2
 
3
3
  Cada HTML valida **um** comportamento. Abra um de cada vez.
4
4
 
5
- `initiateCheckout` **tem** `selectorForm` (como LEAD / ADD_TO_CART).
6
- O resolver monta snapshot (`items` / `value`) a partir de selectedItems + catálogo.
5
+ `initiateCheckout` usa `sources[]` com `type: form` (como LEAD / ADD_TO_CART).
6
+ O resolver monta snapshot (`items` / `value`) a partir de `cart.initialItems` + catálogo.
7
7
  **Não** escreve CommerceState.
8
8
 
9
9
  | # | Arquivo | Como dispara | O que valida |
10
10
  |---|---------|--------------|--------------|
11
11
  | 1 | [`example-initiate-checkout-attribute.html`](./example-initiate-checkout-attribute.html) | `[data-track="initiate_checkout"]` | SelectorDetector + snapshot |
12
- | 2 | [`example-initiate-checkout-click.html`](./example-initiate-checkout-click.html) | `selectorForm` + `trigger: click` | Gate email+phone |
13
- | 3 | [`example-initiate-checkout-submit.html`](./example-initiate-checkout-submit.html) | `selectorForm` + `trigger: submit` | Submit clássico + fireOnce |
14
- | 4 | [`example-initiate-checkout-auto.html`](./example-initiate-checkout-auto.html) | `selectorForm` + `trigger: auto` | Disparo ao completar contato |
12
+ | 2 | [`example-initiate-checkout-click.html`](./example-initiate-checkout-click.html) | source `type: form` + `trigger: click` | Gate email+phone |
13
+ | 3 | [`example-initiate-checkout-submit.html`](./example-initiate-checkout-submit.html) | source `type: form` + `trigger: submit` | Submit clássico + fireOnce |
14
+ | 4 | [`example-initiate-checkout-auto.html`](./example-initiate-checkout-auto.html) | source `type: form` + `trigger: auto` | Disparo ao completar contato |
15
15
  | 5 | [`example-initiate-checkout-text.html`](./example-initiate-checkout-text.html) | `text:Finalizar compra` | Match por texto + form |
16
16
  | 6 | [`example-initiate-checkout-manual.html`](./example-initiate-checkout-manual.html) | `pixel.initiateCheckout()` | API + override de value |
17
17
  | 7 | [`example-initiate-checkout-snapshot.html`](./example-initiate-checkout-snapshot.html) | atributo / manual | value = main+bump (≈244) |
@@ -20,7 +20,7 @@ O resolver monta snapshot (`items` / `value`) a partir de selectedItems + catál
20
20
 
21
21
  ```txt
22
22
  1. Payload manual (value/items preservados)
23
- 2. checkout.selectedItems
23
+ 2. `cart.initialItems` (estado runtime)
24
24
  3. catálogo commerce
25
25
  4. defaults (currency)
26
26
  ```
@@ -96,7 +96,7 @@ code { font-size: 0.85em; }
96
96
  <div class="hint"><strong>Contexto:</strong> CTA de checkout com
97
97
  <code>data-track="initiate_checkout"</code>. Sem <code>selectorForm</code> —
98
98
  clique dispara; <code>CommerceResolver</code> monta snapshot a partir de
99
- <code>selectedItems</code> + catálogo.</div>
99
+ <code>initialItems</code> + catálogo.</div>
100
100
 
101
101
  <div class="card">
102
102
  <h2>Lifecycle</h2>
@@ -112,7 +112,7 @@ code { font-size: 0.85em; }
112
112
  <div>
113
113
  <div class="card">
114
114
  <h2>Checkout por atributo <span class="pill">ConfiguredSelector</span></h2>
115
- <div class="ctx">selectedItems: main_offer (R$ 197).</div>
115
+ <div class="ctx">initialItems: main_offer (R$ 197).</div>
116
116
  <div class="product">
117
117
  <strong>Oferta Principal — R$ 197</strong>
118
118
  <div class="actions">
@@ -132,7 +132,7 @@ code { font-size: 0.85em; }
132
132
  <ul class="checklist">
133
133
  <li>[ ] Sem data-track → não dispara</li>
134
134
  <li>[ ] Com data-track → <code>INITIATE_CHECKOUT</code></li>
135
- <li>[ ] Snapshot com value/items do selectedItems</li>
135
+ <li>[ ] Snapshot com value/items do initialItems</li>
136
136
  <li>[ ] Detector: <code>ConfiguredSelector(INITIATE_CHECKOUT)</code></li>
137
137
  </ul>
138
138
  </div>
@@ -189,10 +189,19 @@ code { font-size: 0.85em; }
189
189
 
190
190
  function initiateCheckoutDetectorConfig() {
191
191
  return {
192
- enabled: true,
193
- selector: ['[data-track="initiate_checkout"]'],
194
- selectorType: 'css',
195
- };
192
+ enabled: true,
193
+ sources: [
194
+ {
195
+ name: 'initiateCheckout-selector',
196
+ type: 'selector',
197
+ selector: [
198
+ '[data-track=\'initiate_checkout\']'
199
+ ],
200
+ selectorType: 'css',
201
+ trigger: 'click'
202
+ }
203
+ ]
204
+ };
196
205
  }
197
206
 
198
207
  function buildConfig() {
@@ -211,6 +220,70 @@ code { font-size: 0.85em; }
211
220
  timeoutMs: 10000,
212
221
  },
213
222
  identity: { ...base.identity, pixelId: PIXEL_ID },
223
+ commerce: {
224
+ enabled: true,
225
+ currency: 'BRL',
226
+ catalog: { products: [
227
+ {
228
+ id: 'main_offer',
229
+ name: 'Oferta Principal',
230
+ type: 'main',
231
+ price: 197,
232
+ currency: 'BRL',
233
+ quantity: 1,
234
+ },
235
+ {
236
+ id: 'order_bump_01',
237
+ name: 'Order Bump Especial',
238
+ type: 'order_bump',
239
+ price: 47,
240
+ currency: 'BRL',
241
+ quantity: 1,
242
+ },
243
+ {
244
+ id: 'upsell_01',
245
+ name: 'Upsell 01',
246
+ type: 'upsell',
247
+ price: 97,
248
+ currency: 'BRL',
249
+ quantity: 1,
250
+ },
251
+ ] },
252
+ cart: {
253
+ mode: 'single_product',
254
+ initialItems: [{ productId: "main_offer", quantity: 1 }],
255
+ calculateValueFrom: 'cart',
256
+ allowDynamicItems: true,
257
+ },
258
+ mappings: {
259
+ attributes: {
260
+ productId: ['data-product-id', 'data-sku', 'data-offer-id'],
261
+ productName: ['data-product-name', 'data-name'],
262
+ price: ['data-product-price', 'data-price'],
263
+ quantity: ['data-quantity', 'data-qty'],
264
+ currency: ['data-currency'],
265
+ },
266
+ fields: {
267
+ productId: ['productId', 'product_id', 'offerId', 'sku'],
268
+ productName: ['productName', 'product_name'],
269
+ price: ['price', 'amount'],
270
+ quantity: ['quantity', 'qty'],
271
+ currency: ['currency'],
272
+ email: ['email', 'customerEmail'],
273
+ phone: ['phone', 'telefone', 'customerPhone'],
274
+ },
275
+ },
276
+ enrichment: {
277
+ pageView: { enabled: false, source: 'cart' },
278
+ viewContent: { enabled: true, source: 'event_or_cart' },
279
+ lead: { enabled: false, source: 'event_or_cart' },
280
+ addToCart: { enabled: true, source: 'event_or_cart' },
281
+ removeFromCart: { enabled: true, source: 'event_or_cart' },
282
+ initiateCheckout: { enabled: true, source: 'cart' },
283
+ addPaymentInfo: { enabled: true, source: 'cart' },
284
+ purchase: { enabled: true, source: 'cart' },
285
+ }
286
+ },
214
287
  modules: {
215
288
  ...base.modules,
216
289
  core: {
@@ -272,81 +345,28 @@ code { font-size: 0.85em; }
272
345
  integrations: { ...base.modules.integrations, enabled: false },
273
346
  conversion: {
274
347
  enabled: true,
275
- commerce: {
276
- currency: 'BRL',
277
- catalog: { products: [
278
- {
279
- id: 'main_offer',
280
- name: 'Oferta Principal',
281
- type: 'main',
282
- price: 197,
283
- currency: 'BRL',
284
- quantity: 1,
285
- },
286
- {
287
- id: 'order_bump_01',
288
- name: 'Order Bump Especial',
289
- type: 'order_bump',
290
- price: 47,
291
- currency: 'BRL',
292
- quantity: 1,
293
- },
294
- {
295
- id: 'upsell_01',
296
- name: 'Upsell 01',
297
- type: 'upsell',
298
- price: 97,
299
- currency: 'BRL',
300
- quantity: 1,
301
- },
302
- ] },
303
- checkout: {
304
- mode: 'single_product',
305
- selectedItems: [{ productId: "main_offer", quantity: 1 }],
306
- calculateValueFrom: 'selected_items',
307
- allowDynamicItems: true,
308
- },
309
- mappings: {
310
- attributes: {
311
- productId: ['data-product-id', 'data-sku', 'data-offer-id'],
312
- productName: ['data-product-name', 'data-name'],
313
- price: ['data-product-price', 'data-price'],
314
- quantity: ['data-quantity', 'data-qty'],
315
- currency: ['data-currency'],
316
- },
317
- fields: {
318
- productId: ['productId', 'product_id', 'offerId', 'sku'],
319
- productName: ['productName', 'product_name'],
320
- price: ['price', 'amount'],
321
- quantity: ['quantity', 'qty'],
322
- currency: ['currency'],
323
- email: ['email', 'customerEmail'],
324
- phone: ['phone', 'telefone', 'customerPhone'],
325
- },
326
- },
327
- },
328
348
  manual: {
329
349
  pageView: { enabled: false },
330
- purchase: { enabled: false },
331
- lead: { enabled: false },
332
- addToCart: { enabled: false },
333
- removeFromCart: { enabled: false },
350
+ purchase: { enabled: false, sources: [] },
351
+ lead: { enabled: false, sources: [] },
352
+ addToCart: { enabled: false, sources: [] },
353
+ removeFromCart: { enabled: false, sources: [] },
334
354
  initiateCheckout: { enabled: true },
335
- addPaymentInfo: { enabled: false },
336
- search: { enabled: false },
337
- viewContent: { enabled: false },
355
+ addPaymentInfo: { enabled: false, sources: [] },
356
+ search: { enabled: false, sources: [] },
357
+ viewContent: { enabled: false, sources: [] },
338
358
  },
339
359
  auto: {
340
360
  enabled: true,
341
361
  detectors: {
342
- lead: { enabled: false },
343
- purchase: { enabled: false },
344
- addToCart: { enabled: false },
345
- removeFromCart: { enabled: false },
362
+ lead: { enabled: false, sources: [] },
363
+ purchase: { enabled: false, sources: [] },
364
+ addToCart: { enabled: false, sources: [] },
365
+ removeFromCart: { enabled: false, sources: [] },
346
366
  initiateCheckout: initiateCheckoutDetectorConfig(),
347
- addPaymentInfo: { enabled: false },
348
- search: { enabled: false },
349
- viewContent: { enabled: false },
367
+ addPaymentInfo: { enabled: false, sources: [] },
368
+ search: { enabled: false, sources: [] },
369
+ viewContent: { enabled: false, sources: [] },
350
370
  },
351
371
  },
352
372
  rules: {