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

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 (189) hide show
  1. package/CHANGELOG.md +303 -4
  2. package/README.md +90 -128
  3. package/RELEASE_CANDIDATE.md +218 -101
  4. package/dist/Pixel-BnN86r4X.d.ts +797 -0
  5. package/dist/Pixel-BoUGqCbP.d.mts +797 -0
  6. package/dist/{StorageFactory-CAkJJqVD.d.ts → StorageFactory-BfCArzMM.d.ts} +2 -2
  7. package/dist/{StorageFactory-BhpbB6Jj.d.mts → StorageFactory-C0prtNR7.d.mts} +2 -2
  8. package/dist/browser/index.cjs.js +3 -0
  9. package/dist/browser/index.cjs.js.map +1 -0
  10. package/dist/browser/index.d.mts +71 -0
  11. package/dist/browser/index.d.ts +71 -0
  12. package/dist/browser/index.esm.js +3 -0
  13. package/dist/browser/index.esm.js.map +1 -0
  14. package/dist/browser/pixel.buygoods-checkout.global.js +4 -0
  15. package/dist/browser/pixel.buygoods-checkout.global.js.map +1 -0
  16. package/dist/browser/pixel.buygoods-landing.global.js +4 -0
  17. package/dist/browser/pixel.buygoods-landing.global.js.map +1 -0
  18. package/dist/browser/pixel.global.js +4 -0
  19. package/dist/browser/pixel.global.js.map +1 -0
  20. package/dist/config/index.cjs.js +1 -1
  21. package/dist/config/index.cjs.js.map +1 -1
  22. package/dist/config/index.d.mts +16 -5
  23. package/dist/config/index.d.ts +16 -5
  24. package/dist/config/index.esm.js +1 -1
  25. package/dist/config/index.esm.js.map +1 -1
  26. package/dist/events/index.cjs.js +1 -1
  27. package/dist/events/index.cjs.js.map +1 -1
  28. package/dist/events/index.d.mts +2 -1
  29. package/dist/events/index.d.ts +2 -1
  30. package/dist/events/index.esm.js +1 -1
  31. package/dist/events/index.esm.js.map +1 -1
  32. package/dist/examples/html-script/README.md +21 -55
  33. package/dist/examples/html-script/RELEASE_CANDIDATE.md +39 -26
  34. package/dist/examples/html-script/add-payment-info/README.md +3 -3
  35. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-autocomplete.html +107 -96
  36. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-disabled.html +107 -96
  37. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-fields.html +106 -95
  38. package/dist/examples/html-script/add-payment-info/example-add-payment-info-data-track.html +114 -95
  39. package/dist/examples/html-script/add-payment-info/example-add-payment-info-dedupe.html +106 -95
  40. package/dist/examples/html-script/add-payment-info/example-add-payment-info-manual.html +97 -95
  41. package/dist/examples/html-script/add-payment-info/example-add-payment-info-rules-card.html +106 -95
  42. package/dist/examples/html-script/add-payment-info/example-add-payment-info-security.html +106 -95
  43. package/dist/examples/html-script/add-to-cart/README.md +9 -6
  44. package/dist/examples/html-script/add-to-cart/example-add-to-cart-attribute.html +133 -119
  45. package/dist/examples/html-script/add-to-cart/example-add-to-cart-auto.html +146 -130
  46. package/dist/examples/html-script/add-to-cart/example-add-to-cart-click.html +144 -127
  47. package/dist/examples/html-script/add-to-cart/example-add-to-cart-dedupe.html +133 -119
  48. package/dist/examples/html-script/add-to-cart/example-add-to-cart-link.html +590 -0
  49. package/dist/examples/html-script/add-to-cart/example-add-to-cart-manual.html +124 -116
  50. package/dist/examples/html-script/add-to-cart/example-add-to-cart-order-bump.html +133 -119
  51. package/dist/examples/html-script/add-to-cart/example-add-to-cart-text.html +147 -130
  52. package/dist/examples/html-script/behavior/example-behavior-engagement.html +489 -0
  53. package/dist/examples/html-script/behavior/example-behavior-heartbeat.html +350 -0
  54. package/dist/examples/html-script/behavior/example-behavior-runtime-intelligence.html +433 -0
  55. package/dist/examples/html-script/behavior/example-behavior-viewport.html +397 -0
  56. package/dist/examples/html-script/{example-behavior.html → behavior/example-behavior.html} +23 -17
  57. package/dist/examples/html-script/buygoods/example-buygoods-checkout.html +50 -0
  58. package/dist/examples/html-script/buygoods/ladding.html +184 -0
  59. package/dist/examples/html-script/example-basic.html +1 -1
  60. package/dist/examples/html-script/example-checkout-commerce.html +826 -0
  61. package/dist/examples/html-script/example-conversion.html +42 -49
  62. package/dist/examples/html-script/example-global-factory-classic.html +45 -0
  63. package/dist/examples/html-script/example-global-factory.html +40 -0
  64. package/dist/examples/html-script/example-integration.html +45 -51
  65. package/dist/examples/html-script/example-landing-commerce.html +416 -0
  66. package/dist/examples/html-script/example-runtime-diagnostics.html +108 -0
  67. package/dist/examples/html-script/example-transport.html +70 -63
  68. package/dist/examples/html-script/full-funnel/README.md +64 -0
  69. package/dist/examples/html-script/full-funnel/checkout.html +118 -0
  70. package/dist/examples/html-script/full-funnel/downsell.html +60 -0
  71. package/dist/examples/html-script/full-funnel/landing.html +153 -0
  72. package/dist/examples/html-script/full-funnel/thank-you.html +87 -0
  73. package/dist/examples/html-script/full-funnel/upsell.html +66 -0
  74. package/dist/examples/html-script/initiate-checkout/README.md +6 -6
  75. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-attribute.html +135 -122
  76. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-auto.html +143 -128
  77. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-click.html +144 -128
  78. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-manual.html +127 -120
  79. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-snapshot.html +136 -123
  80. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-submit.html +144 -131
  81. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-text.html +146 -130
  82. package/dist/examples/html-script/internal-checkout/example-cardioclear-checkout.html +103 -0
  83. package/dist/examples/html-script/internal-checkout/example-slimsoda-checkout.html +103 -0
  84. package/dist/examples/html-script/lead/README.md +9 -7
  85. package/dist/examples/html-script/lead/example-lead-trigger-attribute.html +107 -94
  86. package/dist/examples/html-script/lead/example-lead-trigger-auto.html +118 -103
  87. package/dist/examples/html-script/lead/example-lead-trigger-click.html +118 -102
  88. package/dist/examples/html-script/release-candidate.html +219 -107
  89. package/dist/examples/html-script/remove-from-cart/README.md +4 -4
  90. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-attribute.html +134 -121
  91. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-css.html +134 -121
  92. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-dedupe.html +141 -128
  93. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-manual.html +125 -118
  94. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-multi.html +135 -122
  95. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-state.html +136 -123
  96. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-text.html +139 -124
  97. package/dist/examples/html-script/search/README.md +1 -1
  98. package/dist/examples/html-script/search/example-search-attribute.html +107 -99
  99. package/dist/examples/html-script/search/example-search-button-sync.html +107 -99
  100. package/dist/examples/html-script/search/example-search-dedupe.html +107 -99
  101. package/dist/examples/html-script/search/example-search-input.html +108 -99
  102. package/dist/examples/html-script/search/example-search-manual.html +98 -96
  103. package/dist/examples/html-script/search/example-search-submit.html +107 -99
  104. package/dist/examples/html-script/search/example-search-text.html +112 -99
  105. package/dist/examples/html-script/url-context/example-url-context-allowed-domains.html +92 -0
  106. package/dist/examples/html-script/url-context/example-url-context-landing.html +110 -0
  107. package/dist/examples/html-script/url-context/example-url-context-upsell.html +105 -0
  108. package/dist/examples/html-script/url-context/example-url-context.html +205 -0
  109. package/dist/examples/html-script/view-content/README.md +1 -1
  110. package/dist/examples/html-script/view-content/example-view-content-attribute.html +126 -118
  111. package/dist/examples/html-script/view-content/example-view-content-css.html +126 -118
  112. package/dist/examples/html-script/view-content/example-view-content-dedupe.html +126 -118
  113. package/dist/examples/html-script/view-content/example-view-content-empty.html +126 -118
  114. package/dist/examples/html-script/view-content/example-view-content-manual.html +117 -115
  115. package/dist/examples/html-script/view-content/example-view-content-product-card.html +126 -118
  116. package/dist/examples/html-script/view-content/example-view-content-text.html +131 -121
  117. package/dist/examples/release-candidate/README.md +2 -1
  118. package/dist/examples/v2/README.md +16 -13
  119. package/dist/index-B8u_3PGG.d.ts +460 -0
  120. package/dist/index-BxT2d-TK.d.mts +460 -0
  121. package/dist/index.cjs.js +1 -1
  122. package/dist/index.cjs.js.map +1 -1
  123. package/dist/index.d.mts +23 -361
  124. package/dist/index.d.ts +23 -361
  125. package/dist/index.esm.js +1 -1
  126. package/dist/index.esm.js.map +1 -1
  127. package/dist/pixel-DNGbAN5C.d.ts +871 -0
  128. package/dist/pixel-_BSDpx4M.d.mts +871 -0
  129. package/dist/pixel-default-config-BMYaqs7i.d.ts +21 -0
  130. package/dist/pixel-default-config-DLRya1tl.d.mts +21 -0
  131. package/dist/pixel-settings-D-t9zQb4.d.ts +40 -0
  132. package/dist/pixel-settings-DGxl0MVm.d.mts +40 -0
  133. package/dist/runtime/index.cjs.js +1 -1
  134. package/dist/runtime/index.cjs.js.map +1 -1
  135. package/dist/runtime/index.d.mts +19 -26
  136. package/dist/runtime/index.d.ts +19 -26
  137. package/dist/runtime/index.esm.js +1 -1
  138. package/dist/runtime/index.esm.js.map +1 -1
  139. package/dist/services/index.cjs.js +1 -1
  140. package/dist/services/index.cjs.js.map +1 -1
  141. package/dist/services/index.d.mts +14 -6
  142. package/dist/services/index.d.ts +14 -6
  143. package/dist/services/index.esm.js +1 -1
  144. package/dist/services/index.esm.js.map +1 -1
  145. package/dist/types-B-Nzagpk.d.mts +19 -0
  146. package/dist/types-D0KVsgzs.d.mts +293 -0
  147. package/dist/types-D3kJ9bfT.d.ts +293 -0
  148. package/dist/types-Dfi9C49l.d.ts +19 -0
  149. package/dist/url-context-Ck2LK18V.d.mts +87 -0
  150. package/dist/url-context-Ck2LK18V.d.ts +87 -0
  151. package/dist/v2/global.global.js +1 -1
  152. package/dist/v2/global.global.js.map +1 -1
  153. package/dist/v2/index.cjs.js +1 -1
  154. package/dist/v2/index.cjs.js.map +1 -1
  155. package/dist/v2/index.d.mts +26 -6
  156. package/dist/v2/index.d.ts +26 -6
  157. package/dist/v2/index.esm.js +1 -1
  158. package/dist/v2/index.esm.js.map +1 -1
  159. package/docs/public/README.md +80 -0
  160. package/docs/public/api/exports.md +55 -0
  161. package/docs/public/api/pixel.md +86 -0
  162. package/docs/public/configuration/commerce.md +44 -0
  163. package/docs/public/configuration/modules.md +63 -0
  164. package/docs/public/configuration/overview.md +85 -0
  165. package/docs/public/configuration/transport.md +127 -0
  166. package/docs/public/events/catalog.md +67 -0
  167. package/docs/public/getting-started/installation.md +87 -0
  168. package/docs/public/getting-started/quick-start.md +142 -0
  169. package/docs/public/getting-started/react-nextjs.md +78 -0
  170. package/docs/public/getting-started/script-tag.md +94 -0
  171. package/docs/public/guides/funnel-checkout.md +52 -0
  172. package/docs/public/guides/funnel-downsell.md +53 -0
  173. package/docs/public/guides/funnel-full.md +64 -0
  174. package/docs/public/guides/funnel-landing.md +70 -0
  175. package/docs/public/guides/funnel-thank-you.md +48 -0
  176. package/docs/public/guides/funnel-upsell.md +72 -0
  177. package/docs/public/limitations.md +33 -0
  178. package/docs/public/privacy/limitations.md +33 -0
  179. package/docs/public/release-candidate/validation.md +42 -0
  180. package/docs/public/troubleshooting.md +56 -0
  181. package/package.json +38 -20
  182. package/dist/index-DUfFzniE.d.mts +0 -274
  183. package/dist/index-DUfFzniE.d.ts +0 -274
  184. package/dist/pixel-CbeF25mD.d.mts +0 -555
  185. package/dist/pixel-CbeF25mD.d.ts +0 -555
  186. package/dist/pixel-default-config-1VgLFOiL.d.mts +0 -5
  187. package/dist/pixel-default-config-Bxb-Vdd8.d.ts +0 -5
  188. package/dist/types-CTpRvFKZ.d.ts +0 -71
  189. package/dist/types-DGlBdsAy.d.mts +0 -71
@@ -0,0 +1,416 @@
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
+ CTA externo usa source <code>type: 'link'</code> (destino do href).
114
+ </div>
115
+
116
+ <div class="hero" data-product-id="main_offer" data-product-price="197" data-currency="BRL">
117
+ <h2>Curso Pixel Avançado</h2>
118
+ <p class="sub" style="margin: 0 0 0.5rem">Oferta de lançamento — acesso vitalício</p>
119
+ <div class="price">R$ 197</div>
120
+ <div class="actions">
121
+ <button type="button" class="primary" data-track="view_content">Ver conteúdo</button>
122
+ <button type="button" data-track="add_to_cart">Quero começar</button>
123
+ <a
124
+ id="checkout-link"
125
+ data-demo-stay
126
+ data-product-id="main_offer"
127
+ href="https://checkout.example.com/pay/offer_landing?product=main_offer"
128
+ style="display:inline-block;text-decoration:none;border-radius:8px;padding:0.5rem 0.85rem;background:#0f766e;color:#fff;border:1px solid #0f766e;font:inherit;"
129
+ >Ir ao checkout (link)</a>
130
+ </div>
131
+ </div>
132
+
133
+ <div class="grid">
134
+ <div>
135
+ <div class="card">
136
+ <h3>Lifecycle</h3>
137
+ <div class="actions">
138
+ <button id="btn-reinit" class="primary" type="button">Reinitialize</button>
139
+ <button id="btn-destroy" type="button">Destroy</button>
140
+ <button id="btn-clear" type="button">Clear logs</button>
141
+ </div>
142
+ <div class="status" id="runtime-status" style="margin-top: 0.75rem">Aguardando init...</div>
143
+ </div>
144
+ <div class="card">
145
+ <h3>Checklist</h3>
146
+ <ul class="checklist">
147
+ <li>[ ] PAGE_VIEW no init com value/items do cart (≈197)</li>
148
+ <li>[ ] <code>commerce.cart.mode</code> = landing_page</li>
149
+ <li>[ ] <code>enrichment.pageView.enabled</code> = true</li>
150
+ <li>[ ] VIEW_CONTENT manual por clique (opcional)</li>
151
+ <li>[ ] Link checkout → <code>ConfiguredLink</code> + ADD_TO_CART</li>
152
+ </ul>
153
+ </div>
154
+ </div>
155
+ <div>
156
+ <div class="card">
157
+ <h3>Event counts</h3>
158
+ <div class="status" id="event-counts">Nenhum evento ainda</div>
159
+ </div>
160
+ <div class="card">
161
+ <h3>Last PAGE_VIEW payload</h3>
162
+ <pre id="pageview-payload">null</pre>
163
+ </div>
164
+ <div class="card">
165
+ <h3>Event log</h3>
166
+ <pre id="logs">Aguardando eventos...</pre>
167
+ </div>
168
+ </div>
169
+ </div>
170
+ </div>
171
+
172
+ <script src="../../v2/global.global.js"></script>
173
+ <script>
174
+ const { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
175
+ const API_ENDPOINT =
176
+ 'https://micro-service-pixel-production-4826.up.railway.app';
177
+ const PIXEL_ID = 'pix_7315610';
178
+
179
+ const els = {
180
+ initPill: document.getElementById('init-pill'),
181
+ runtimeStatus: document.getElementById('runtime-status'),
182
+ eventCounts: document.getElementById('event-counts'),
183
+ pageviewPayload: document.getElementById('pageview-payload'),
184
+ logs: document.getElementById('logs'),
185
+ btnReinit: document.getElementById('btn-reinit'),
186
+ btnDestroy: document.getElementById('btn-destroy'),
187
+ btnClear: document.getElementById('btn-clear'),
188
+ };
189
+
190
+ let pixel = null;
191
+ const counts = {};
192
+
193
+ function buildConfig() {
194
+ const base = DEFAULT_PIXEL_CONFIG;
195
+ return {
196
+ ...base,
197
+ app: { ...base.app, environment: 'development', debug: true },
198
+ transport: {
199
+ ...base.transport,
200
+ enabled: true,
201
+ sender: { mode: 'internal', baseUrl: API_ENDPOINT },
202
+ },
203
+ identity: { ...base.identity, pixelId: PIXEL_ID },
204
+ commerce: {
205
+ enabled: true,
206
+ currency: 'BRL',
207
+ catalog: {
208
+ products: [
209
+ {
210
+ id: 'main_offer',
211
+ name: 'Curso Pixel Avançado',
212
+ type: 'main',
213
+ price: 197,
214
+ currency: 'BRL',
215
+ quantity: 1,
216
+ },
217
+ ],
218
+ },
219
+ cart: {
220
+ mode: 'landing_page',
221
+ initialItems: [{ productId: 'main_offer', quantity: 1 }],
222
+ allowDynamicItems: true,
223
+ calculateValueFrom: 'cart',
224
+ },
225
+ mappings: {
226
+ attributes: {
227
+ productId: ['data-product-id', 'data-sku'],
228
+ price: ['data-product-price', 'data-price'],
229
+ currency: ['data-currency'],
230
+ },
231
+ fields: {
232
+ productId: ['productId', 'product_id'],
233
+ price: ['price', 'amount'],
234
+ currency: ['currency'],
235
+ },
236
+ },
237
+ enrichment: {
238
+ pageView: { enabled: true, source: 'cart' },
239
+ viewContent: { enabled: true, source: 'event_or_cart' },
240
+ lead: { enabled: false, source: 'event_or_cart' },
241
+ addToCart: { enabled: true, source: 'event_or_cart' },
242
+ removeFromCart: { enabled: true, source: 'event_or_cart' },
243
+ initiateCheckout: { enabled: false, source: 'cart' },
244
+ addPaymentInfo: { enabled: false, source: 'cart' },
245
+ purchase: { enabled: true, source: 'cart' },
246
+ },
247
+ },
248
+ modules: {
249
+ ...base.modules,
250
+ core: {
251
+ ...base.modules.core,
252
+ enabled: true,
253
+ pageView: {
254
+ ...base.modules.core.pageView,
255
+ enabled: true,
256
+ trackInitialPageView: true,
257
+ spa: false,
258
+ },
259
+ },
260
+ behavior: { ...base.modules.behavior, enabled: false },
261
+ privacy: { ...base.modules.privacy, enabled: false },
262
+ integrations: { ...base.modules.integrations, enabled: false },
263
+ conversion: {
264
+ enabled: true,
265
+ manual: {
266
+ pageView: { enabled: false },
267
+ purchase: { enabled: false },
268
+ lead: { enabled: false },
269
+ addToCart: { enabled: true },
270
+ removeFromCart: { enabled: false },
271
+ initiateCheckout: { enabled: false },
272
+ addPaymentInfo: { enabled: false },
273
+ search: { enabled: false },
274
+ viewContent: { enabled: true },
275
+ },
276
+ auto: {
277
+ enabled: true,
278
+ detectors: {
279
+ lead: { enabled: false, sources: [] },
280
+ purchase: { enabled: false, sources: [] },
281
+ addToCart: {
282
+ enabled: true,
283
+ sources: [
284
+ {
285
+ name: 'landing-cta',
286
+ type: 'selector',
287
+ selector: '[data-track="add_to_cart"]',
288
+ selectorType: 'css',
289
+ trigger: 'click',
290
+ fireOnce: false,
291
+ },
292
+ {
293
+ name: 'checkout-product-link',
294
+ type: 'link',
295
+ fireOnce: false,
296
+ match: {
297
+ protocols: ['https:'],
298
+ origins: ['https://checkout.example.com'],
299
+ path: { template: '/pay/:offerId' },
300
+ query: {
301
+ mode: 'all',
302
+ conditions: [
303
+ { key: 'product', operator: 'exists' },
304
+ ],
305
+ },
306
+ },
307
+ bindings: {
308
+ productId: {
309
+ from: [
310
+ { source: 'dataset', key: 'productId' },
311
+ { source: 'query', key: 'product' },
312
+ ],
313
+ required: true,
314
+ },
315
+ },
316
+ },
317
+ ],
318
+ },
319
+ removeFromCart: { enabled: false, sources: [] },
320
+ initiateCheckout: { enabled: false, sources: [] },
321
+ addPaymentInfo: { enabled: false, sources: [] },
322
+ search: { enabled: false, sources: [] },
323
+ viewContent: {
324
+ enabled: true,
325
+ sources: [
326
+ {
327
+ name: 'view-content-cta',
328
+ type: 'selector',
329
+ selector: '[data-track="view_content"]',
330
+ selectorType: 'css',
331
+ trigger: 'click',
332
+ fireOnce: false,
333
+ },
334
+ ],
335
+ },
336
+ },
337
+ },
338
+ rules: {
339
+ enabled: false,
340
+ selectors: [],
341
+ texts: [],
342
+ urlPatterns: [],
343
+ checkout: { enabled: false },
344
+ card: { enabled: false },
345
+ },
346
+ },
347
+ },
348
+ };
349
+ }
350
+
351
+ function appendLog(message) {
352
+ const line = '[' + new Date().toISOString() + '] ' + message;
353
+ const prev = els.logs.textContent;
354
+ els.logs.textContent =
355
+ prev === 'Aguardando eventos...' ? line : line + '\n' + prev;
356
+ }
357
+
358
+ function renderCounts() {
359
+ const lines = Object.keys(counts)
360
+ .sort()
361
+ .map(function (type) { return type + ': ' + counts[type]; });
362
+ els.eventCounts.textContent =
363
+ lines.length > 0 ? lines.join('\n') : 'Nenhum evento ainda';
364
+ }
365
+
366
+ function onEvent(event) {
367
+ const type = event && event.type ? event.type : 'UNKNOWN';
368
+ counts[type] = (counts[type] || 0) + 1;
369
+ renderCounts();
370
+ appendLog(type + ' → ' + JSON.stringify(event.data || {}));
371
+ if (type === 'PAGE_VIEW') {
372
+ els.pageviewPayload.textContent = JSON.stringify(event.data || {}, null, 2);
373
+ }
374
+ }
375
+
376
+ async function initPixel() {
377
+ if (pixel) await pixel.destroy();
378
+ pixel = new Pixel(buildConfig());
379
+ pixel.on('event', onEvent);
380
+ await pixel.init();
381
+ els.initPill.textContent = 'online';
382
+ els.initPill.classList.add('ok');
383
+ els.runtimeStatus.textContent = 'Pixel init OK — PAGE_VIEW deve ter disparado';
384
+ appendLog('init complete');
385
+ }
386
+
387
+ els.btnReinit.addEventListener('click', function () { initPixel(); });
388
+ els.btnDestroy.addEventListener('click', async function () {
389
+ if (!pixel) return;
390
+ await pixel.destroy();
391
+ pixel = null;
392
+ els.initPill.textContent = 'offline';
393
+ els.initPill.classList.remove('ok');
394
+ els.runtimeStatus.textContent = 'destroyed';
395
+ appendLog('destroy');
396
+ });
397
+ els.btnClear.addEventListener('click', function () {
398
+ els.logs.textContent = 'Aguardando eventos...';
399
+ els.pageviewPayload.textContent = 'null';
400
+ Object.keys(counts).forEach(function (k) { delete counts[k]; });
401
+ renderCounts();
402
+ });
403
+
404
+ document.querySelectorAll('[data-demo-stay]').forEach(function (el) {
405
+ el.addEventListener('click', function (event) {
406
+ event.preventDefault();
407
+ appendLog('(playground) navegação bloqueada — link source já trackeou em capture');
408
+ });
409
+ });
410
+
411
+ initPixel().catch(function (err) {
412
+ els.runtimeStatus.textContent = 'Erro: ' + (err && err.message ? err.message : err);
413
+ });
414
+ </script>
415
+ </body>
416
+ </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="../../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
+ transport: {
48
+ ...DEFAULT_PIXEL_CONFIG.transport,
49
+ enabled: false,
50
+ },
51
+ modules: {
52
+ ...DEFAULT_PIXEL_CONFIG.modules,
53
+ core: {
54
+ ...DEFAULT_PIXEL_CONFIG.modules.core,
55
+ enabled: true,
56
+ urlContext: { enabled: true },
57
+ },
58
+ conversion: {
59
+ ...DEFAULT_PIXEL_CONFIG.modules.conversion,
60
+ enabled: true,
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>