@beworke/pixel 0.1.0-rc.1

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 (123) hide show
  1. package/CHANGELOG.md +194 -0
  2. package/README.md +163 -0
  3. package/RELEASE_CANDIDATE.md +256 -0
  4. package/dist/PixelLogger-B21lEjep.d.mts +8 -0
  5. package/dist/PixelLogger-B21lEjep.d.ts +8 -0
  6. package/dist/StorageFactory-BhpbB6Jj.d.mts +8 -0
  7. package/dist/StorageFactory-CAkJJqVD.d.ts +8 -0
  8. package/dist/config/index.cjs.js +3 -0
  9. package/dist/config/index.cjs.js.map +1 -0
  10. package/dist/config/index.d.mts +19 -0
  11. package/dist/config/index.d.ts +19 -0
  12. package/dist/config/index.esm.js +3 -0
  13. package/dist/config/index.esm.js.map +1 -0
  14. package/dist/events/index.cjs.js +3 -0
  15. package/dist/events/index.cjs.js.map +1 -0
  16. package/dist/events/index.d.mts +1 -0
  17. package/dist/events/index.d.ts +1 -0
  18. package/dist/events/index.esm.js +3 -0
  19. package/dist/events/index.esm.js.map +1 -0
  20. package/dist/examples/html-script/README.md +71 -0
  21. package/dist/examples/html-script/RELEASE_CANDIDATE.md +121 -0
  22. package/dist/examples/html-script/add-payment-info/README.md +46 -0
  23. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-autocomplete.html +494 -0
  24. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-disabled.html +478 -0
  25. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-fields.html +486 -0
  26. package/dist/examples/html-script/add-payment-info/example-add-payment-info-data-track.html +479 -0
  27. package/dist/examples/html-script/add-payment-info/example-add-payment-info-dedupe.html +492 -0
  28. package/dist/examples/html-script/add-payment-info/example-add-payment-info-manual.html +495 -0
  29. package/dist/examples/html-script/add-payment-info/example-add-payment-info-rules-card.html +469 -0
  30. package/dist/examples/html-script/add-payment-info/example-add-payment-info-security.html +489 -0
  31. package/dist/examples/html-script/add-to-cart/README.md +36 -0
  32. package/dist/examples/html-script/add-to-cart/example-add-to-cart-attribute.html +517 -0
  33. package/dist/examples/html-script/add-to-cart/example-add-to-cart-auto.html +512 -0
  34. package/dist/examples/html-script/add-to-cart/example-add-to-cart-click.html +519 -0
  35. package/dist/examples/html-script/add-to-cart/example-add-to-cart-dedupe.html +514 -0
  36. package/dist/examples/html-script/add-to-cart/example-add-to-cart-manual.html +517 -0
  37. package/dist/examples/html-script/add-to-cart/example-add-to-cart-order-bump.html +527 -0
  38. package/dist/examples/html-script/add-to-cart/example-add-to-cart-text.html +524 -0
  39. package/dist/examples/html-script/example-basic.html +350 -0
  40. package/dist/examples/html-script/example-behavior.html +435 -0
  41. package/dist/examples/html-script/example-conversion.html +479 -0
  42. package/dist/examples/html-script/example-integration.html +709 -0
  43. package/dist/examples/html-script/example-transport.html +748 -0
  44. package/dist/examples/html-script/initiate-checkout/README.md +38 -0
  45. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-attribute.html +485 -0
  46. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-auto.html +491 -0
  47. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-click.html +493 -0
  48. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-manual.html +494 -0
  49. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-snapshot.html +497 -0
  50. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-submit.html +502 -0
  51. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-text.html +496 -0
  52. package/dist/examples/html-script/lead/README.md +25 -0
  53. package/dist/examples/html-script/lead/example-lead-trigger-attribute.html +594 -0
  54. package/dist/examples/html-script/lead/example-lead-trigger-auto.html +431 -0
  55. package/dist/examples/html-script/lead/example-lead-trigger-click.html +587 -0
  56. package/dist/examples/html-script/release-candidate.html +726 -0
  57. package/dist/examples/html-script/remove-from-cart/README.md +36 -0
  58. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-attribute.html +532 -0
  59. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-css.html +524 -0
  60. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-dedupe.html +540 -0
  61. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-manual.html +533 -0
  62. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-multi.html +557 -0
  63. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-state.html +539 -0
  64. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-text.html +524 -0
  65. package/dist/examples/html-script/search/README.md +41 -0
  66. package/dist/examples/html-script/search/example-search-attribute.html +454 -0
  67. package/dist/examples/html-script/search/example-search-button-sync.html +455 -0
  68. package/dist/examples/html-script/search/example-search-dedupe.html +466 -0
  69. package/dist/examples/html-script/search/example-search-input.html +456 -0
  70. package/dist/examples/html-script/search/example-search-manual.html +473 -0
  71. package/dist/examples/html-script/search/example-search-submit.html +450 -0
  72. package/dist/examples/html-script/search/example-search-text.html +441 -0
  73. package/dist/examples/html-script/view-content/README.md +48 -0
  74. package/dist/examples/html-script/view-content/example-view-content-attribute.html +488 -0
  75. package/dist/examples/html-script/view-content/example-view-content-css.html +467 -0
  76. package/dist/examples/html-script/view-content/example-view-content-dedupe.html +485 -0
  77. package/dist/examples/html-script/view-content/example-view-content-empty.html +469 -0
  78. package/dist/examples/html-script/view-content/example-view-content-manual.html +496 -0
  79. package/dist/examples/html-script/view-content/example-view-content-product-card.html +478 -0
  80. package/dist/examples/html-script/view-content/example-view-content-text.html +473 -0
  81. package/dist/examples/release-candidate/README.md +14 -0
  82. package/dist/examples/v2/README.md +33 -0
  83. package/dist/index-DUfFzniE.d.mts +274 -0
  84. package/dist/index-DUfFzniE.d.ts +274 -0
  85. package/dist/index.cjs.js +3 -0
  86. package/dist/index.cjs.js.map +1 -0
  87. package/dist/index.d.mts +364 -0
  88. package/dist/index.d.ts +364 -0
  89. package/dist/index.esm.js +3 -0
  90. package/dist/index.esm.js.map +1 -0
  91. package/dist/logger/index.cjs.js +3 -0
  92. package/dist/logger/index.cjs.js.map +1 -0
  93. package/dist/logger/index.d.mts +12 -0
  94. package/dist/logger/index.d.ts +12 -0
  95. package/dist/logger/index.esm.js +3 -0
  96. package/dist/logger/index.esm.js.map +1 -0
  97. package/dist/pixel-CbeF25mD.d.mts +555 -0
  98. package/dist/pixel-CbeF25mD.d.ts +555 -0
  99. package/dist/pixel-default-config-1VgLFOiL.d.mts +5 -0
  100. package/dist/pixel-default-config-Bxb-Vdd8.d.ts +5 -0
  101. package/dist/runtime/index.cjs.js +3 -0
  102. package/dist/runtime/index.cjs.js.map +1 -0
  103. package/dist/runtime/index.d.mts +48 -0
  104. package/dist/runtime/index.d.ts +48 -0
  105. package/dist/runtime/index.esm.js +3 -0
  106. package/dist/runtime/index.esm.js.map +1 -0
  107. package/dist/services/index.cjs.js +3 -0
  108. package/dist/services/index.cjs.js.map +1 -0
  109. package/dist/services/index.d.mts +169 -0
  110. package/dist/services/index.d.ts +169 -0
  111. package/dist/services/index.esm.js +3 -0
  112. package/dist/services/index.esm.js.map +1 -0
  113. package/dist/types-CTpRvFKZ.d.ts +71 -0
  114. package/dist/types-DGlBdsAy.d.mts +71 -0
  115. package/dist/v2/global.global.js +3 -0
  116. package/dist/v2/global.global.js.map +1 -0
  117. package/dist/v2/index.cjs.js +3 -0
  118. package/dist/v2/index.cjs.js.map +1 -0
  119. package/dist/v2/index.d.mts +7 -0
  120. package/dist/v2/index.d.ts +7 -0
  121. package/dist/v2/index.esm.js +3 -0
  122. package/dist/v2/index.esm.js.map +1 -0
  123. package/package.json +101 -0
@@ -0,0 +1,441 @@
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 — SEARCH text selector</title>
7
+ <style>
8
+ :root {
9
+ --bg: #f8fafc; --card: #fff; --border: #e2e8f0; --text: #0f172a;
10
+ --muted: #64748b; --accent: #0f766e; --accent-soft: #ccfbf1;
11
+ --warn: #9a3412; --warn-soft: #ffedd5;
12
+ }
13
+ * { box-sizing: border-box; }
14
+ body {
15
+ margin: 0;
16
+ font-family: "Segoe UI", system-ui, sans-serif;
17
+ background:
18
+ radial-gradient(circle at top left, #ecfeff 0%, transparent 40%),
19
+ linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
20
+ color: var(--text); line-height: 1.45;
21
+ }
22
+ .wrap { max-width: 980px; margin: 0 auto; padding: 1.5rem; }
23
+ h1 { font-size: 1.5rem; margin: 0 0 0.35rem; letter-spacing: -0.02em; }
24
+ h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }
25
+ .sub { color: var(--muted); margin: 0 0 1rem; font-size: 0.92rem; }
26
+ .nav { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
27
+ .nav a {
28
+ text-decoration: none; border: 1px solid var(--border); background: #fff;
29
+ color: var(--text); border-radius: 999px; padding: 0.3rem 0.7rem; font-size: 0.78rem;
30
+ }
31
+ .nav a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
32
+ .grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 1rem; }
33
+ @media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
34
+ .card {
35
+ background: var(--card); border: 1px solid var(--border); border-radius: 12px;
36
+ padding: 1rem; margin-bottom: 1rem; box-shadow: 0 1px 0 rgba(15,23,42,.03);
37
+ }
38
+ .hint {
39
+ background: var(--accent-soft); border: 1px solid #99f6e4; border-radius: 10px;
40
+ padding: 0.85rem 1rem; font-size: 0.9rem; margin-bottom: 1rem;
41
+ }
42
+ .hint.warn { background: var(--warn-soft); border-color: #fdba74; color: var(--warn); }
43
+ .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
44
+ button {
45
+ appearance: none; border: 1px solid var(--border); background: #fff; color: var(--text);
46
+ border-radius: 8px; padding: 0.5rem 0.85rem; cursor: pointer; font: inherit;
47
+ }
48
+ button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
49
+ button.danger { background: #7f1d1d; border-color: #7f1d1d; color: #fff; }
50
+ label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.25rem; }
51
+ input {
52
+ width: 100%; border: 1px solid var(--border); border-radius: 8px;
53
+ padding: 0.55rem 0.7rem; font: inherit; background: #fff;
54
+ }
55
+ .search-bar { display: flex; gap: 0.5rem; align-items: stretch; }
56
+ .search-bar input { flex: 1; }
57
+ .status, pre {
58
+ background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 0.75rem;
59
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
60
+ font-size: 0.78rem; white-space: pre-wrap; word-break: break-word;
61
+ max-height: 260px; overflow: auto;
62
+ }
63
+ .pill {
64
+ display: inline-block; border-radius: 999px; padding: 0.15rem 0.55rem;
65
+ font-size: 0.72rem; background: #e2e8f0; color: #334155; margin-left: 0.35rem;
66
+ }
67
+ .pill.ok { background: #bbf7d0; color: #166534; }
68
+ .checklist { margin: 0; padding-left: 1.1rem; font-size: 0.88rem; color: var(--muted); }
69
+ .checklist li { margin: 0.35rem 0; }
70
+ .ctx {
71
+ border-left: 3px solid var(--accent); padding-left: 0.75rem; margin-bottom: 0.85rem;
72
+ color: var(--muted); font-size: 0.88rem;
73
+ }
74
+ code { font-size: 0.85em; }
75
+ </style>
76
+ </head>
77
+ <body>
78
+ <div class="wrap">
79
+ <h1>SEARCH — text:Buscar</h1>
80
+ <p class="sub">
81
+ Cenário isolado para validação do Pixel v2.
82
+ <span class="pill" id="init-pill">offline</span>
83
+ </p>
84
+ <div class="nav"><a href="example-search-attribute.html" class="">1. data-query</a>
85
+ <a href="example-search-button-sync.html" class="">2. Botão + sync</a>
86
+ <a href="example-search-input.html" class="">3. Input value</a>
87
+ <a href="example-search-submit.html" class="">4. Form submit</a>
88
+ <a href="example-search-text.html" class="active">5. Text</a>
89
+ <a href="example-search-manual.html" class="">6. Manual API</a>
90
+ <a href="example-search-dedupe.html" class="">7. Dedupe</a></div>
91
+ <div class="hint"><strong>Contexto:</strong> match por texto do botão
92
+ <code>text:Buscar</code> + <code>data-query</code> no mesmo elemento.</div>
93
+
94
+ <div class="card">
95
+ <h2>Lifecycle</h2>
96
+ <div class="actions">
97
+ <button id="btn-reinit" class="primary" type="button">Reinitialize</button>
98
+ <button id="btn-destroy" class="danger" type="button">Destroy</button>
99
+ <button id="btn-clear" type="button">Clear logs</button>
100
+ </div>
101
+ <div class="status" id="runtime-status">Aguardando init...</div>
102
+ </div>
103
+
104
+ <div class="grid">
105
+ <div>
106
+ <div class="card">
107
+ <h2>CTA por texto <span class="pill">text:</span></h2>
108
+ <div class="actions">
109
+ <button type="button" class="primary" data-query="notebook gamer">
110
+ Buscar
111
+ </button>
112
+ <button type="button" data-query="notebook gamer" id="btn-other">
113
+ Pesquisar
114
+ </button>
115
+ </div>
116
+ <p class="sub">“Pesquisar” não casa com text:Buscar.</p>
117
+ </div>
118
+ <div class="card">
119
+ <h2>Checklist</h2>
120
+ <ul class="checklist">
121
+ <li>[ ] Buscar → SEARCH query=notebook gamer</li>
122
+ <li>[ ] Pesquisar → não dispara</li>
123
+ </ul>
124
+ </div>
125
+ </div>
126
+ <div>
127
+ <div class="card">
128
+ <h2>Event counts</h2>
129
+ <div class="status" id="event-counts">Nenhum evento ainda</div>
130
+ </div>
131
+ <div class="card">
132
+ <h2>Search payload (último)</h2>
133
+ <div class="status" id="search-payload">null</div>
134
+ </div>
135
+ <div class="card">
136
+ <h2>Active detectors</h2>
137
+ <div class="status" id="detectors">—</div>
138
+ </div>
139
+
140
+ <div class="card">
141
+ <h2>Last event JSON</h2>
142
+ <pre id="last-event">null</pre>
143
+ </div>
144
+ <div class="card">
145
+ <h2>Event log</h2>
146
+ <pre id="logs">Aguardando eventos...</pre>
147
+ </div>
148
+ </div>
149
+ </div>
150
+ </div>
151
+
152
+ <script src="../../../dist/v2/global.global.js"></script>
153
+ <script>
154
+ const { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
155
+ const API_ENDPOINT =
156
+ 'https://micro-service-pixel-production-4826.up.railway.app';
157
+ const PIXEL_ID = 'pix_7315610';
158
+
159
+ const els = {
160
+ logs: document.getElementById('logs'),
161
+ last: document.getElementById('last-event'),
162
+ counts: document.getElementById('event-counts'),
163
+ payload: document.getElementById('search-payload'),
164
+ detectors: document.getElementById('detectors'),
165
+ dedupe: document.getElementById('dedupe-keys'),
166
+ runtime: document.getElementById('runtime-status'),
167
+ pill: document.getElementById('init-pill'),
168
+ };
169
+
170
+ let pixel = null;
171
+ let unsubscribe = null;
172
+ let initCount = 0;
173
+ let destroyCount = 0;
174
+ const counts = {};
175
+
176
+ function searchDetectorConfig() {
177
+ return {
178
+ enabled: true,
179
+ selector: ['text:Buscar', { type: 'text', value: 'Buscar', exact: true }],
180
+ selectorType: 'css',
181
+ };
182
+ }
183
+
184
+ function buildConfig() {
185
+ const base = DEFAULT_PIXEL_CONFIG;
186
+ return {
187
+ ...base,
188
+ app: {
189
+ ...base.app,
190
+ source: 'custom',
191
+ environment: 'development',
192
+ debug: true,
193
+ },
194
+ transport: {
195
+ ...DEFAULT_PIXEL_CONFIG.transport,
196
+ apiEndpoint: API_ENDPOINT,
197
+ timeoutMs: 10000,
198
+ },
199
+ identity: { ...base.identity, pixelId: PIXEL_ID },
200
+ modules: {
201
+ ...base.modules,
202
+ core: {
203
+ ...base.modules.core,
204
+ enabled: false,
205
+ pageView: {
206
+ ...base.modules.core.pageView,
207
+ enabled: false,
208
+ trackInitialPageView: false,
209
+ spa: false,
210
+ },
211
+ },
212
+ behavior: { ...base.modules.behavior, enabled: false },
213
+ privacy: { ...base.modules.privacy, enabled: false },
214
+ transport: {
215
+ enabled: true,
216
+ mockSender: { enabled: false },
217
+ sender: { mode: 'http' },
218
+ persistence: { enabled: true },
219
+ replay: { enabled: true },
220
+ ordering: { enabled: true },
221
+ coordination: { enabled: true },
222
+ circuitBreaker: {
223
+ enabled: true,
224
+ failureThreshold: 5,
225
+ resetTimeoutMs: 30000,
226
+ halfOpenMaxAttempts: 2,
227
+ },
228
+ backpressure: {
229
+ enabled: true,
230
+ maxQueueSize: 500,
231
+ policy: 'drop_oldest',
232
+ sampleRate: 0.5,
233
+ },
234
+ deadLetter: { enabled: true, maxEntries: 200 },
235
+ compression: { enabled: true, strategy: 'identity' },
236
+ retry: {
237
+ enabled: true,
238
+ maxAttempts: 4,
239
+ baseDelayMs: 500,
240
+ maxDelayMs: 4000,
241
+ multiplier: 2,
242
+ },
243
+ batch: {
244
+ enabled: true,
245
+ batchSize: 10,
246
+ flushIntervalMs: 2000,
247
+ maxWaitMs: 5000,
248
+ },
249
+ timeout: { enabled: true, timeoutMs: 10000 },
250
+ offline: { enabled: true },
251
+ flush: {
252
+ enabled: true,
253
+ flushIntervalMs: 2000,
254
+ flushOnDestroy: true,
255
+ prepareUnloadHooks: true,
256
+ },
257
+ },
258
+ integrations: { ...base.modules.integrations, enabled: false },
259
+ conversion: {
260
+ enabled: true,
261
+ commerce: {
262
+ currency: 'BRL',
263
+ catalog: { products: [] },
264
+ checkout: {
265
+ mode: 'single_product',
266
+ selectedItems: [],
267
+ calculateValueFrom: 'selected_items',
268
+ allowDynamicItems: true,
269
+ },
270
+ mappings: {
271
+ attributes: {
272
+ productId: ['data-product-id'],
273
+ productName: ['data-product-name'],
274
+ price: ['data-product-price'],
275
+ quantity: ['data-quantity'],
276
+ currency: ['data-currency'],
277
+ },
278
+ fields: {
279
+ email: ['email'],
280
+ phone: ['phone'],
281
+ productId: ['productId'],
282
+ productName: ['productName'],
283
+ price: ['price'],
284
+ quantity: ['quantity'],
285
+ currency: ['currency'],
286
+ },
287
+ },
288
+ },
289
+ manual: {
290
+ pageView: { enabled: false },
291
+ purchase: { enabled: false },
292
+ lead: { enabled: false },
293
+ addToCart: { enabled: false },
294
+ removeFromCart: { enabled: false },
295
+ initiateCheckout: { enabled: false },
296
+ addPaymentInfo: { enabled: false },
297
+ search: { enabled: true },
298
+ viewContent: { enabled: false },
299
+ },
300
+ auto: {
301
+ enabled: true,
302
+ detectors: {
303
+ lead: { enabled: false },
304
+ purchase: { enabled: false },
305
+ addToCart: { enabled: false },
306
+ removeFromCart: { enabled: false },
307
+ initiateCheckout: { enabled: false },
308
+ addPaymentInfo: {
309
+ enabled: false,
310
+ paymentMethod: 'CREDIT_CARD',
311
+ cardDetection: false,
312
+ autoDispatch: false,
313
+ },
314
+ search: searchDetectorConfig(),
315
+ viewContent: { enabled: false },
316
+ },
317
+ },
318
+ rules: {
319
+ enabled: false,
320
+ selectors: [],
321
+ texts: [],
322
+ urlPatterns: [],
323
+ checkout: { enabled: false },
324
+ card: { enabled: false },
325
+ },
326
+ },
327
+ },
328
+ };
329
+ }
330
+
331
+ function appendLog(message) {
332
+ const line = '[' + new Date().toISOString() + '] ' + message;
333
+ const prev = els.logs.textContent;
334
+ els.logs.textContent =
335
+ prev === 'Aguardando eventos...' ? line : line + '\n' + prev;
336
+ }
337
+
338
+ function renderCounts() {
339
+ const lines = Object.keys(counts)
340
+ .sort()
341
+ .map(function (type) { return type + ': ' + counts[type]; });
342
+ els.counts.textContent =
343
+ lines.length > 0 ? lines.join('\n') : 'Nenhum evento ainda';
344
+ }
345
+
346
+ function renderPayload(event) {
347
+ if (!els.payload) return;
348
+ if (!event || event.type !== 'SEARCH') {
349
+ els.payload.textContent = 'null';
350
+ return;
351
+ }
352
+ els.payload.textContent = JSON.stringify(event.data || {}, null, 2);
353
+ }
354
+
355
+ function renderDebug() {
356
+ const detectors =
357
+ pixel && pixel.getDebugActiveDetectors
358
+ ? pixel.getDebugActiveDetectors()
359
+ : [];
360
+ els.detectors.textContent =
361
+ detectors.length > 0 ? detectors.join('\n') : 'Nenhum detector ativo';
362
+ if (els.dedupe) {
363
+ const keys =
364
+ pixel && pixel.getDebugDedupeKeys ? pixel.getDebugDedupeKeys() : [];
365
+ els.dedupe.textContent =
366
+ keys.length > 0 ? keys.join('\n') : 'Nenhuma chave';
367
+ }
368
+ els.runtime.textContent =
369
+ 'initialized: ' +
370
+ (pixel ? pixel.isInitialized() : false) +
371
+ '\ninit count: ' +
372
+ initCount +
373
+ '\ndestroy count: ' +
374
+ destroyCount +
375
+ '\npixelId: ' +
376
+ PIXEL_ID +
377
+ '\nscenario: text:Buscar';
378
+ els.pill.textContent =
379
+ pixel && pixel.isInitialized() ? 'ready' : 'offline';
380
+ els.pill.className =
381
+ 'pill' + (pixel && pixel.isInitialized() ? ' ok' : '');
382
+ }
383
+
384
+ function onEvent(event) {
385
+ counts[event.type] = (counts[event.type] || 0) + 1;
386
+ renderCounts();
387
+ renderPayload(event);
388
+ els.last.textContent = JSON.stringify(event, null, 2);
389
+ appendLog(event.type + ' ' + JSON.stringify(event.data || {}));
390
+ renderDebug();
391
+ }
392
+
393
+ async function boot() {
394
+ if (unsubscribe) { unsubscribe(); unsubscribe = null; }
395
+ if (pixel) {
396
+ await pixel.destroy();
397
+ destroyCount += 1;
398
+ pixel = null;
399
+ }
400
+ pixel = new Pixel(buildConfig());
401
+ await pixel.init();
402
+ initCount += 1;
403
+ const services = pixel.getDebugServices();
404
+ if (services && services.dispatcher) {
405
+ unsubscribe = services.dispatcher.subscribe(onEvent);
406
+ }
407
+ appendLog('Pixel initialized — text:Buscar');
408
+ renderDebug();
409
+ }
410
+
411
+ async function destroyPixel() {
412
+ if (unsubscribe) { unsubscribe(); unsubscribe = null; }
413
+ if (pixel) {
414
+ await pixel.destroy();
415
+ destroyCount += 1;
416
+ pixel = null;
417
+ }
418
+ appendLog('Pixel destroyed');
419
+ renderDebug();
420
+ }
421
+
422
+ document.getElementById('btn-reinit').onclick = function () { boot(); };
423
+ document.getElementById('btn-destroy').onclick = function () { destroyPixel(); };
424
+ document.getElementById('btn-clear').onclick = function () {
425
+ els.logs.textContent = 'Aguardando eventos...';
426
+ els.last.textContent = 'null';
427
+ if (els.payload) els.payload.textContent = 'null';
428
+ Object.keys(counts).forEach(function (k) { delete counts[k]; });
429
+ renderCounts();
430
+ };
431
+
432
+
433
+ document.getElementById('btn-other').onclick = function () {
434
+ appendLog('(playground) texto diferente — esperado: nenhum SEARCH');
435
+ };
436
+
437
+
438
+ boot();
439
+ </script>
440
+ </body>
441
+ </html>
@@ -0,0 +1,48 @@
1
+ # Pixel v2 — VIEW_CONTENT (cenários isolados)
2
+
3
+ Cada HTML valida **um** comportamento. Abra um de cada vez.
4
+
5
+ ## Como a SDK funciona
6
+
7
+ `viewContent` usa `ConfiguredAutoDetectorConfig` (**sem** `selectorForm`).
8
+
9
+ | Caminho | Detalhe |
10
+ |---------|---------|
11
+ | Auto | `ConfiguredSelectorDetector` (click + submit) |
12
+ | Extract | `ProductExtractor`: `productId → contentId`, `price → value`, `currency` |
13
+ | Manual | `pixel.viewContent({ contentId, contentType, category, value, currency })` |
14
+ | Vazio | **permitido** (`{}`) — diferente de SEARCH/LEAD |
15
+ | Commerce | **não** passa pelo CommerceResolver · **não** altera state |
16
+ | Dedupe | `VIEW_CONTENT:content:{id}` ou `interaction:{bucket}` (~500ms) |
17
+
18
+ | # | Arquivo | O que valida |
19
+ |---|---------|--------------|
20
+ | 1 | [`example-view-content-attribute.html`](./example-view-content-attribute.html) | `data-track` + product attrs |
21
+ | 2 | [`example-view-content-product-card.html`](./example-view-content-product-card.html) | Card com walk-up |
22
+ | 3 | [`example-view-content-text.html`](./example-view-content-text.html) | `text:Ver produto` |
23
+ | 4 | [`example-view-content-css.html`](./example-view-content-css.html) | `.view-content` |
24
+ | 5 | [`example-view-content-manual.html`](./example-view-content-manual.html) | API completa / parcial / vazia |
25
+ | 6 | [`example-view-content-empty.html`](./example-view-content-empty.html) | Auto sem attrs → `{}` |
26
+ | 7 | [`example-view-content-dedupe.html`](./example-view-content-dedupe.html) | Dedupe content vs bucket |
27
+
28
+ ## Como abrir
29
+
30
+ 1. Na raiz: `npm run build`
31
+ 2. Abra o HTML (live server)
32
+ 3. Script: `../../../dist/v2/global.global.js`
33
+
34
+ ## Ordem sugerida
35
+
36
+ `atributo → card → text → css → manual → empty → dedupe`
37
+
38
+ ## Suíte completa de conversão (html-script)
39
+
40
+ | Evento | Pasta |
41
+ |--------|-------|
42
+ | LEAD | [`../lead/`](../lead/) |
43
+ | ADD_TO_CART | [`../add-to-cart/`](../add-to-cart/) |
44
+ | REMOVE_FROM_CART | [`../remove-from-cart/`](../remove-from-cart/) |
45
+ | INITIATE_CHECKOUT | [`../initiate-checkout/`](../initiate-checkout/) |
46
+ | ADD_PAYMENT_INFO | [`../add-payment-info/`](../add-payment-info/) |
47
+ | SEARCH | [`../search/`](../search/) |
48
+ | VIEW_CONTENT | esta pasta |