@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
@@ -398,12 +398,12 @@
398
398
  pageView: { enabled: false },
399
399
  purchase: { enabled: true },
400
400
  lead: { enabled: true },
401
- addToCart: { enabled: false },
402
- removeFromCart: { enabled: false },
403
- initiateCheckout: { enabled: false },
404
- addPaymentInfo: { enabled: false },
401
+ addToCart: { enabled: false, sources: [] },
402
+ removeFromCart: { enabled: false, sources: [] },
403
+ initiateCheckout: { enabled: false, sources: [] },
404
+ addPaymentInfo: { enabled: false, sources: [] },
405
405
  search: { enabled: true },
406
- viewContent: { enabled: false },
406
+ viewContent: { enabled: false, sources: [] },
407
407
  },
408
408
  auto: {
409
409
  enabled: false,
@@ -0,0 +1,380 @@
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>Pixel v2 — Landing Page + Commerce PAGE_VIEW</title>
7
+ <style>
8
+ :root {
9
+ --bg: #f8fafc;
10
+ --card: #fff;
11
+ --border: #e2e8f0;
12
+ --text: #0f172a;
13
+ --muted: #64748b;
14
+ --accent: #7c3aed;
15
+ --accent-soft: #ede9fe;
16
+ }
17
+ * { box-sizing: border-box; }
18
+ body {
19
+ margin: 0;
20
+ font-family: "Segoe UI", system-ui, sans-serif;
21
+ background:
22
+ radial-gradient(circle at top right, #ede9fe 0%, transparent 45%),
23
+ linear-gradient(180deg, var(--bg) 0%, #eef2ff 100%);
24
+ color: var(--text);
25
+ line-height: 1.45;
26
+ }
27
+ .wrap { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
28
+ h1 { font-size: 1.6rem; margin: 0 0 0.35rem; }
29
+ .sub { color: var(--muted); margin: 0 0 1rem; font-size: 0.92rem; }
30
+ .hero {
31
+ background: var(--card);
32
+ border: 1px solid var(--border);
33
+ border-radius: 16px;
34
+ padding: 1.5rem;
35
+ margin-bottom: 1rem;
36
+ box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
37
+ }
38
+ .hero h2 { margin: 0 0 0.5rem; font-size: 1.35rem; }
39
+ .price { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
40
+ .hint {
41
+ background: var(--accent-soft);
42
+ border: 1px solid #c4b5fd;
43
+ border-radius: 10px;
44
+ padding: 0.85rem 1rem;
45
+ font-size: 0.9rem;
46
+ margin-bottom: 1rem;
47
+ }
48
+ .grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 1rem; }
49
+ @media (max-width: 800px) { .grid { grid-template-columns: 1fr; } }
50
+ .card {
51
+ background: var(--card);
52
+ border: 1px solid var(--border);
53
+ border-radius: 12px;
54
+ padding: 1rem;
55
+ margin-bottom: 1rem;
56
+ }
57
+ .card h3 { margin: 0 0 0.75rem; font-size: 1rem; }
58
+ button {
59
+ appearance: none;
60
+ border: 1px solid var(--border);
61
+ background: #fff;
62
+ color: var(--text);
63
+ border-radius: 8px;
64
+ padding: 0.5rem 0.85rem;
65
+ cursor: pointer;
66
+ font: inherit;
67
+ }
68
+ button.primary {
69
+ background: var(--accent);
70
+ border-color: var(--accent);
71
+ color: #fff;
72
+ }
73
+ .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
74
+ .status, pre {
75
+ background: #0f172a;
76
+ color: #e2e8f0;
77
+ border-radius: 8px;
78
+ padding: 0.75rem;
79
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
80
+ font-size: 0.78rem;
81
+ white-space: pre-wrap;
82
+ word-break: break-word;
83
+ max-height: 220px;
84
+ overflow: auto;
85
+ }
86
+ .pill {
87
+ display: inline-block;
88
+ border-radius: 999px;
89
+ padding: 0.15rem 0.55rem;
90
+ font-size: 0.72rem;
91
+ background: #e2e8f0;
92
+ color: #334155;
93
+ margin-left: 0.35rem;
94
+ }
95
+ .pill.ok { background: #bbf7d0; color: #166534; }
96
+ .checklist { margin: 0; padding-left: 1.1rem; font-size: 0.88rem; color: var(--muted); }
97
+ code { font-size: 0.85em; }
98
+ </style>
99
+ </head>
100
+ <body>
101
+ <div class="wrap">
102
+ <h1>Landing Page — Commerce + PAGE_VIEW enriquecido</h1>
103
+ <p class="sub">
104
+ Etapa 14A · <code>commerce.cart.mode: 'landing_page'</code> ·
105
+ <code>enrichment.pageView.enabled: true</code>
106
+ <span class="pill" id="init-pill">offline</span>
107
+ </p>
108
+
109
+ <div class="hint">
110
+ <strong>Contexto:</strong> página de vendas sem checkout. O Core dispara PAGE_VIEW no init
111
+ (<code>trackInitialPageView: true</code>). O enrichment completa o payload com dados do
112
+ carrinho seed (<code>initialItems</code> + catálogo).
113
+ </div>
114
+
115
+ <div class="hero" data-product-id="main_offer" data-product-price="197" data-currency="BRL">
116
+ <h2>Curso Pixel Avançado</h2>
117
+ <p class="sub" style="margin: 0 0 0.5rem">Oferta de lançamento — acesso vitalício</p>
118
+ <div class="price">R$ 197</div>
119
+ <div class="actions">
120
+ <button type="button" class="primary" data-track="view_content">Ver conteúdo</button>
121
+ <button type="button" data-track="add_to_cart">Quero começar</button>
122
+ </div>
123
+ </div>
124
+
125
+ <div class="grid">
126
+ <div>
127
+ <div class="card">
128
+ <h3>Lifecycle</h3>
129
+ <div class="actions">
130
+ <button id="btn-reinit" class="primary" type="button">Reinitialize</button>
131
+ <button id="btn-destroy" type="button">Destroy</button>
132
+ <button id="btn-clear" type="button">Clear logs</button>
133
+ </div>
134
+ <div class="status" id="runtime-status" style="margin-top: 0.75rem">Aguardando init...</div>
135
+ </div>
136
+ <div class="card">
137
+ <h3>Checklist</h3>
138
+ <ul class="checklist">
139
+ <li>[ ] PAGE_VIEW no init com value/items do cart (≈197)</li>
140
+ <li>[ ] <code>commerce.cart.mode</code> = landing_page</li>
141
+ <li>[ ] <code>enrichment.pageView.enabled</code> = true</li>
142
+ <li>[ ] VIEW_CONTENT manual por clique (opcional)</li>
143
+ </ul>
144
+ </div>
145
+ </div>
146
+ <div>
147
+ <div class="card">
148
+ <h3>Event counts</h3>
149
+ <div class="status" id="event-counts">Nenhum evento ainda</div>
150
+ </div>
151
+ <div class="card">
152
+ <h3>Last PAGE_VIEW payload</h3>
153
+ <pre id="pageview-payload">null</pre>
154
+ </div>
155
+ <div class="card">
156
+ <h3>Event log</h3>
157
+ <pre id="logs">Aguardando eventos...</pre>
158
+ </div>
159
+ </div>
160
+ </div>
161
+ </div>
162
+
163
+ <script src="../../dist/v2/global.global.js"></script>
164
+ <script>
165
+ const { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
166
+ const API_ENDPOINT =
167
+ 'https://micro-service-pixel-production-4826.up.railway.app';
168
+ const PIXEL_ID = 'pix_7315610';
169
+
170
+ const els = {
171
+ initPill: document.getElementById('init-pill'),
172
+ runtimeStatus: document.getElementById('runtime-status'),
173
+ eventCounts: document.getElementById('event-counts'),
174
+ pageviewPayload: document.getElementById('pageview-payload'),
175
+ logs: document.getElementById('logs'),
176
+ btnReinit: document.getElementById('btn-reinit'),
177
+ btnDestroy: document.getElementById('btn-destroy'),
178
+ btnClear: document.getElementById('btn-clear'),
179
+ };
180
+
181
+ let pixel = null;
182
+ const counts = {};
183
+
184
+ function buildConfig() {
185
+ const base = DEFAULT_PIXEL_CONFIG;
186
+ return {
187
+ ...base,
188
+ app: { ...base.app, environment: 'development', debug: true },
189
+ transport: {
190
+ ...DEFAULT_PIXEL_CONFIG.transport,
191
+ apiEndpoint: API_ENDPOINT,
192
+ timeoutMs: 10000,
193
+ },
194
+ identity: { ...base.identity, pixelId: PIXEL_ID },
195
+ commerce: {
196
+ enabled: true,
197
+ currency: 'BRL',
198
+ catalog: {
199
+ products: [
200
+ {
201
+ id: 'main_offer',
202
+ name: 'Curso Pixel Avançado',
203
+ type: 'main',
204
+ price: 197,
205
+ currency: 'BRL',
206
+ quantity: 1,
207
+ },
208
+ ],
209
+ },
210
+ cart: {
211
+ mode: 'landing_page',
212
+ initialItems: [{ productId: 'main_offer', quantity: 1 }],
213
+ allowDynamicItems: true,
214
+ calculateValueFrom: 'cart',
215
+ },
216
+ mappings: {
217
+ attributes: {
218
+ productId: ['data-product-id', 'data-sku'],
219
+ price: ['data-product-price', 'data-price'],
220
+ currency: ['data-currency'],
221
+ },
222
+ fields: {
223
+ productId: ['productId', 'product_id'],
224
+ price: ['price', 'amount'],
225
+ currency: ['currency'],
226
+ },
227
+ },
228
+ enrichment: {
229
+ pageView: { enabled: true, source: 'cart' },
230
+ viewContent: { enabled: true, source: 'event_or_cart' },
231
+ lead: { enabled: false, source: 'event_or_cart' },
232
+ addToCart: { enabled: true, source: 'event_or_cart' },
233
+ removeFromCart: { enabled: true, source: 'event_or_cart' },
234
+ initiateCheckout: { enabled: false, source: 'cart' },
235
+ addPaymentInfo: { enabled: false, source: 'cart' },
236
+ purchase: { enabled: true, source: 'cart' },
237
+ },
238
+ },
239
+ modules: {
240
+ ...base.modules,
241
+ core: {
242
+ ...base.modules.core,
243
+ enabled: true,
244
+ pageView: {
245
+ ...base.modules.core.pageView,
246
+ enabled: true,
247
+ trackInitialPageView: true,
248
+ spa: false,
249
+ },
250
+ },
251
+ behavior: { ...base.modules.behavior, enabled: false },
252
+ privacy: { ...base.modules.privacy, enabled: false },
253
+ transport: {
254
+ enabled: true,
255
+ mockSender: { enabled: false },
256
+ sender: { mode: 'http' },
257
+ },
258
+ integrations: { ...base.modules.integrations, enabled: false },
259
+ conversion: {
260
+ enabled: true,
261
+ manual: {
262
+ pageView: { enabled: false },
263
+ purchase: { enabled: false },
264
+ lead: { enabled: false },
265
+ addToCart: { enabled: true },
266
+ removeFromCart: { enabled: false },
267
+ initiateCheckout: { enabled: false },
268
+ addPaymentInfo: { enabled: false },
269
+ search: { enabled: false },
270
+ viewContent: { enabled: true },
271
+ },
272
+ auto: {
273
+ enabled: true,
274
+ detectors: {
275
+ lead: { enabled: false, sources: [] },
276
+ purchase: { enabled: false, sources: [] },
277
+ addToCart: {
278
+ enabled: true,
279
+ sources: [
280
+ {
281
+ name: 'landing-cta',
282
+ type: 'selector',
283
+ selector: '[data-track="add_to_cart"]',
284
+ selectorType: 'css',
285
+ trigger: 'click',
286
+ fireOnce: false,
287
+ },
288
+ ],
289
+ },
290
+ removeFromCart: { enabled: false, sources: [] },
291
+ initiateCheckout: { enabled: false, sources: [] },
292
+ addPaymentInfo: { enabled: false, sources: [] },
293
+ search: { enabled: false, sources: [] },
294
+ viewContent: {
295
+ enabled: true,
296
+ sources: [
297
+ {
298
+ name: 'view-content-cta',
299
+ type: 'selector',
300
+ selector: '[data-track="view_content"]',
301
+ selectorType: 'css',
302
+ trigger: 'click',
303
+ fireOnce: false,
304
+ },
305
+ ],
306
+ },
307
+ },
308
+ },
309
+ rules: {
310
+ enabled: false,
311
+ selectors: [],
312
+ texts: [],
313
+ urlPatterns: [],
314
+ checkout: { enabled: false },
315
+ card: { enabled: false },
316
+ },
317
+ },
318
+ },
319
+ };
320
+ }
321
+
322
+ function appendLog(message) {
323
+ const line = '[' + new Date().toISOString() + '] ' + message;
324
+ const prev = els.logs.textContent;
325
+ els.logs.textContent =
326
+ prev === 'Aguardando eventos...' ? line : line + '\n' + prev;
327
+ }
328
+
329
+ function renderCounts() {
330
+ const lines = Object.keys(counts)
331
+ .sort()
332
+ .map(function (type) { return type + ': ' + counts[type]; });
333
+ els.eventCounts.textContent =
334
+ lines.length > 0 ? lines.join('\n') : 'Nenhum evento ainda';
335
+ }
336
+
337
+ function onEvent(event) {
338
+ const type = event && event.type ? event.type : 'UNKNOWN';
339
+ counts[type] = (counts[type] || 0) + 1;
340
+ renderCounts();
341
+ appendLog(type + ' → ' + JSON.stringify(event.data || {}));
342
+ if (type === 'PAGE_VIEW') {
343
+ els.pageviewPayload.textContent = JSON.stringify(event.data || {}, null, 2);
344
+ }
345
+ }
346
+
347
+ async function initPixel() {
348
+ if (pixel) await pixel.destroy();
349
+ pixel = new Pixel(buildConfig());
350
+ pixel.on('event', onEvent);
351
+ await pixel.init();
352
+ els.initPill.textContent = 'online';
353
+ els.initPill.classList.add('ok');
354
+ els.runtimeStatus.textContent = 'Pixel init OK — PAGE_VIEW deve ter disparado';
355
+ appendLog('init complete');
356
+ }
357
+
358
+ els.btnReinit.addEventListener('click', function () { initPixel(); });
359
+ els.btnDestroy.addEventListener('click', async function () {
360
+ if (!pixel) return;
361
+ await pixel.destroy();
362
+ pixel = null;
363
+ els.initPill.textContent = 'offline';
364
+ els.initPill.classList.remove('ok');
365
+ els.runtimeStatus.textContent = 'destroyed';
366
+ appendLog('destroy');
367
+ });
368
+ els.btnClear.addEventListener('click', function () {
369
+ els.logs.textContent = 'Aguardando eventos...';
370
+ els.pageviewPayload.textContent = 'null';
371
+ Object.keys(counts).forEach(function (k) { delete counts[k]; });
372
+ renderCounts();
373
+ });
374
+
375
+ initPixel().catch(function (err) {
376
+ els.runtimeStatus.textContent = 'Erro: ' + (err && err.message ? err.message : err);
377
+ });
378
+ </script>
379
+ </body>
380
+ </html>
@@ -0,0 +1,108 @@
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>Pixel v2 — Runtime Diagnostics (16)</title>
7
+ <style>
8
+ body { font-family: system-ui, sans-serif; max-width: 920px; 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: 480px; }
11
+ .hint { color: #64748b; font-size: 0.9rem; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <h1>Runtime Diagnostics</h1>
16
+ <p class="hint">
17
+ Etapa 16 — <code>pixel.getDebugSnapshot()</code> (read-only, sanitizado).
18
+ Sem email/telefone/token reais neste playground.
19
+ </p>
20
+ <p>
21
+ <button type="button" id="btn-init">Init</button>
22
+ <button type="button" id="btn-snap">Get Snapshot</button>
23
+ <button type="button" id="btn-destroy">Destroy</button>
24
+ <button type="button" id="btn-reinit">Reinit</button>
25
+ </p>
26
+ <pre id="out">Aguardando…</pre>
27
+ <script src="../../dist/v2/global.global.js"></script>
28
+ <script>
29
+ (async function () {
30
+ var out = document.getElementById('out');
31
+ var pixel = null;
32
+ var { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
33
+
34
+ function log(label, data) {
35
+ out.textContent = label + '\n' + JSON.stringify(data, null, 2);
36
+ console.debug('[diagnostics]', label, data);
37
+ }
38
+
39
+ function config() {
40
+ return {
41
+ ...DEFAULT_PIXEL_CONFIG,
42
+ app: { ...DEFAULT_PIXEL_CONFIG.app, debug: true },
43
+ identity: {
44
+ ...DEFAULT_PIXEL_CONFIG.identity,
45
+ pixelId: 'pix_runtime_diag',
46
+ },
47
+ modules: {
48
+ ...DEFAULT_PIXEL_CONFIG.modules,
49
+ core: {
50
+ ...DEFAULT_PIXEL_CONFIG.modules.core,
51
+ enabled: true,
52
+ urlContext: { enabled: true },
53
+ },
54
+ conversion: {
55
+ ...DEFAULT_PIXEL_CONFIG.modules.conversion,
56
+ enabled: true,
57
+ },
58
+ transport: {
59
+ ...DEFAULT_PIXEL_CONFIG.modules.transport,
60
+ enabled: false,
61
+ },
62
+ integrations: {
63
+ ...DEFAULT_PIXEL_CONFIG.modules.integrations,
64
+ enabled: false,
65
+ },
66
+ behavior: {
67
+ ...DEFAULT_PIXEL_CONFIG.modules.behavior,
68
+ enabled: false,
69
+ },
70
+ },
71
+ };
72
+ }
73
+
74
+ document.getElementById('btn-init').onclick = async function () {
75
+ if (pixel) await pixel.destroy();
76
+ pixel = new Pixel(config());
77
+ log('before init', pixel.getDebugSnapshot());
78
+ await pixel.init();
79
+ log('after init', pixel.getDebugSnapshot());
80
+ };
81
+
82
+ document.getElementById('btn-snap').onclick = function () {
83
+ if (!pixel) {
84
+ pixel = new Pixel(config());
85
+ }
86
+ log('snapshot', pixel.getDebugSnapshot());
87
+ };
88
+
89
+ document.getElementById('btn-destroy').onclick = async function () {
90
+ if (!pixel) return;
91
+ await pixel.destroy();
92
+ log('after destroy', pixel.getDebugSnapshot());
93
+ };
94
+
95
+ document.getElementById('btn-reinit').onclick = async function () {
96
+ if (pixel) await pixel.destroy();
97
+ pixel = new Pixel(config());
98
+ await pixel.init();
99
+ log('after reinit', pixel.getDebugSnapshot());
100
+ };
101
+
102
+ // snapshot pré-init imediato
103
+ pixel = new Pixel(config());
104
+ log('ready (pre-init)', pixel.getDebugSnapshot());
105
+ })();
106
+ </script>
107
+ </body>
108
+ </html>
@@ -357,12 +357,12 @@
357
357
  pageView: { enabled: false },
358
358
  purchase: { enabled: true },
359
359
  lead: { enabled: true },
360
- addToCart: { enabled: false },
361
- removeFromCart: { enabled: false },
362
- initiateCheckout: { enabled: false },
363
- addPaymentInfo: { enabled: false },
360
+ addToCart: { enabled: false, sources: [] },
361
+ removeFromCart: { enabled: false, sources: [] },
362
+ initiateCheckout: { enabled: false, sources: [] },
363
+ addPaymentInfo: { enabled: false, sources: [] },
364
364
  search: { enabled: true },
365
- viewContent: { enabled: false },
365
+ viewContent: { enabled: false, sources: [] },
366
366
  },
367
367
  auto: {
368
368
  enabled: false,
@@ -0,0 +1,64 @@
1
+ # Full Funnel — Pixel v2 (Etapa 15B)
2
+
3
+ Playground do funil completo para validação de:
4
+
5
+ ```txt
6
+ - UrlContext (sid, UTMs, forward, link decoration)
7
+ - Conversion (LEAD → PURCHASE)
8
+ - Commerce (catalog + cart.initialItems)
9
+ - Lifecycle (destroy / reinit na thank-you)
10
+ ```
11
+
12
+ **Transport permanece opcional e desligado por padrão.**
13
+ A validação HTTP real é feita pelas suites smoke (`npm run test:smoke:real`), não por este playground.
14
+
15
+ **Bundle:** `../../../dist/v2/global.global.js` → `window.PixelV2`
16
+ **Versão:** `0.1.0-rc.4`
17
+
18
+ ## Contrato usado
19
+
20
+ ```ts
21
+ commerce: {
22
+ enabled: true,
23
+ catalog: {
24
+ products: [{ id: 'main_offer', name: '...', price: 97, type: 'main' }],
25
+ },
26
+ cart: {
27
+ mode: 'checkout', // ou landing_page
28
+ initialItems: [{ productId: 'main_offer', quantity: 1 }],
29
+ },
30
+ }
31
+
32
+ // PaymentMethod oficial:
33
+ paymentMethod: 'CREDIT_CARD' | 'PIX' | 'BANK_SLIP'
34
+
35
+ // UrlContext:
36
+ linkDecoration.allowedDomains: '*' | string[] // '*' = todos os hosts
37
+ ```
38
+
39
+ ## Páginas
40
+
41
+ | Arquivo | Papel |
42
+ |---------|--------|
43
+ | `landing.html` | Gera `sid`, captura UTMs/affid, LEAD / ADD_TO_CART → checkout |
44
+ | `checkout.html` | `order_id` no href **antes** do init · IC / payment / PURCHASE → upsell |
45
+ | `upsell.html` | Aceitar → thank-you · Recusar → downsell |
46
+ | `downsell.html` | Oferta final → thank-you |
47
+ | `thank-you.html` | Snapshot + destroy/reinit |
48
+
49
+ ## Como usar
50
+
51
+ ```bash
52
+ npm run build
53
+ # servir examples/html-script ou abrir via file:// após build
54
+ ```
55
+
56
+ 1. Abra `landing.html?utm_source=facebook&affid=aff_demo&fbclid=test_fb`.
57
+ 2. Verifique `sid=` na URL e nos links decorados.
58
+ 3. Navegue checkout → upsell/downsell → thank-you.
59
+ 4. Confirme no `<pre>`: `query_params`, `url_context.managed.sid`, UTMs.
60
+
61
+ ## Segurança
62
+
63
+ Nunca na URL: token de pagamento, PAN, CVV, password, authorization secret.
64
+ Permitidos: `sid`, `order_id`, `utm_*`, `affid`, click IDs públicos.