@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.
- package/CHANGELOG.md +194 -0
- package/README.md +163 -0
- package/RELEASE_CANDIDATE.md +256 -0
- package/dist/PixelLogger-B21lEjep.d.mts +8 -0
- package/dist/PixelLogger-B21lEjep.d.ts +8 -0
- package/dist/StorageFactory-BhpbB6Jj.d.mts +8 -0
- package/dist/StorageFactory-CAkJJqVD.d.ts +8 -0
- package/dist/config/index.cjs.js +3 -0
- package/dist/config/index.cjs.js.map +1 -0
- package/dist/config/index.d.mts +19 -0
- package/dist/config/index.d.ts +19 -0
- package/dist/config/index.esm.js +3 -0
- package/dist/config/index.esm.js.map +1 -0
- package/dist/events/index.cjs.js +3 -0
- package/dist/events/index.cjs.js.map +1 -0
- package/dist/events/index.d.mts +1 -0
- package/dist/events/index.d.ts +1 -0
- package/dist/events/index.esm.js +3 -0
- package/dist/events/index.esm.js.map +1 -0
- package/dist/examples/html-script/README.md +71 -0
- package/dist/examples/html-script/RELEASE_CANDIDATE.md +121 -0
- package/dist/examples/html-script/add-payment-info/README.md +46 -0
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-autocomplete.html +494 -0
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-disabled.html +478 -0
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-fields.html +486 -0
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-data-track.html +479 -0
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-dedupe.html +492 -0
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-manual.html +495 -0
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-rules-card.html +469 -0
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-security.html +489 -0
- package/dist/examples/html-script/add-to-cart/README.md +36 -0
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-attribute.html +517 -0
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-auto.html +512 -0
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-click.html +519 -0
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-dedupe.html +514 -0
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-manual.html +517 -0
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-order-bump.html +527 -0
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-text.html +524 -0
- package/dist/examples/html-script/example-basic.html +350 -0
- package/dist/examples/html-script/example-behavior.html +435 -0
- package/dist/examples/html-script/example-conversion.html +479 -0
- package/dist/examples/html-script/example-integration.html +709 -0
- package/dist/examples/html-script/example-transport.html +748 -0
- package/dist/examples/html-script/initiate-checkout/README.md +38 -0
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-attribute.html +485 -0
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-auto.html +491 -0
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-click.html +493 -0
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-manual.html +494 -0
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-snapshot.html +497 -0
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-submit.html +502 -0
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-text.html +496 -0
- package/dist/examples/html-script/lead/README.md +25 -0
- package/dist/examples/html-script/lead/example-lead-trigger-attribute.html +594 -0
- package/dist/examples/html-script/lead/example-lead-trigger-auto.html +431 -0
- package/dist/examples/html-script/lead/example-lead-trigger-click.html +587 -0
- package/dist/examples/html-script/release-candidate.html +726 -0
- package/dist/examples/html-script/remove-from-cart/README.md +36 -0
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-attribute.html +532 -0
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-css.html +524 -0
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-dedupe.html +540 -0
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-manual.html +533 -0
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-multi.html +557 -0
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-state.html +539 -0
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-text.html +524 -0
- package/dist/examples/html-script/search/README.md +41 -0
- package/dist/examples/html-script/search/example-search-attribute.html +454 -0
- package/dist/examples/html-script/search/example-search-button-sync.html +455 -0
- package/dist/examples/html-script/search/example-search-dedupe.html +466 -0
- package/dist/examples/html-script/search/example-search-input.html +456 -0
- package/dist/examples/html-script/search/example-search-manual.html +473 -0
- package/dist/examples/html-script/search/example-search-submit.html +450 -0
- package/dist/examples/html-script/search/example-search-text.html +441 -0
- package/dist/examples/html-script/view-content/README.md +48 -0
- package/dist/examples/html-script/view-content/example-view-content-attribute.html +488 -0
- package/dist/examples/html-script/view-content/example-view-content-css.html +467 -0
- package/dist/examples/html-script/view-content/example-view-content-dedupe.html +485 -0
- package/dist/examples/html-script/view-content/example-view-content-empty.html +469 -0
- package/dist/examples/html-script/view-content/example-view-content-manual.html +496 -0
- package/dist/examples/html-script/view-content/example-view-content-product-card.html +478 -0
- package/dist/examples/html-script/view-content/example-view-content-text.html +473 -0
- package/dist/examples/release-candidate/README.md +14 -0
- package/dist/examples/v2/README.md +33 -0
- package/dist/index-DUfFzniE.d.mts +274 -0
- package/dist/index-DUfFzniE.d.ts +274 -0
- package/dist/index.cjs.js +3 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.mts +364 -0
- package/dist/index.d.ts +364 -0
- package/dist/index.esm.js +3 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/logger/index.cjs.js +3 -0
- package/dist/logger/index.cjs.js.map +1 -0
- package/dist/logger/index.d.mts +12 -0
- package/dist/logger/index.d.ts +12 -0
- package/dist/logger/index.esm.js +3 -0
- package/dist/logger/index.esm.js.map +1 -0
- package/dist/pixel-CbeF25mD.d.mts +555 -0
- package/dist/pixel-CbeF25mD.d.ts +555 -0
- package/dist/pixel-default-config-1VgLFOiL.d.mts +5 -0
- package/dist/pixel-default-config-Bxb-Vdd8.d.ts +5 -0
- package/dist/runtime/index.cjs.js +3 -0
- package/dist/runtime/index.cjs.js.map +1 -0
- package/dist/runtime/index.d.mts +48 -0
- package/dist/runtime/index.d.ts +48 -0
- package/dist/runtime/index.esm.js +3 -0
- package/dist/runtime/index.esm.js.map +1 -0
- package/dist/services/index.cjs.js +3 -0
- package/dist/services/index.cjs.js.map +1 -0
- package/dist/services/index.d.mts +169 -0
- package/dist/services/index.d.ts +169 -0
- package/dist/services/index.esm.js +3 -0
- package/dist/services/index.esm.js.map +1 -0
- package/dist/types-CTpRvFKZ.d.ts +71 -0
- package/dist/types-DGlBdsAy.d.mts +71 -0
- package/dist/v2/global.global.js +3 -0
- package/dist/v2/global.global.js.map +1 -0
- package/dist/v2/index.cjs.js +3 -0
- package/dist/v2/index.cjs.js.map +1 -0
- package/dist/v2/index.d.mts +7 -0
- package/dist/v2/index.d.ts +7 -0
- package/dist/v2/index.esm.js +3 -0
- package/dist/v2/index.esm.js.map +1 -0
- package/package.json +101 -0
|
@@ -0,0 +1,726 @@
|
|
|
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 — Release Candidate (13A)</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
--bg: #f8fafc;
|
|
10
|
+
--card: #fff;
|
|
11
|
+
--border: #e2e8f0;
|
|
12
|
+
--text: #0f172a;
|
|
13
|
+
--muted: #64748b;
|
|
14
|
+
--accent: #0f766e;
|
|
15
|
+
--accent-soft: #ccfbf1;
|
|
16
|
+
--warn: #9a3412;
|
|
17
|
+
--warn-soft: #ffedd5;
|
|
18
|
+
--ok: #166534;
|
|
19
|
+
--ok-soft: #bbf7d0;
|
|
20
|
+
}
|
|
21
|
+
* { box-sizing: border-box; }
|
|
22
|
+
body {
|
|
23
|
+
margin: 0;
|
|
24
|
+
font-family: "Segoe UI", system-ui, sans-serif;
|
|
25
|
+
background:
|
|
26
|
+
radial-gradient(circle at top left, #ecfeff 0%, transparent 42%),
|
|
27
|
+
linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
|
|
28
|
+
color: var(--text);
|
|
29
|
+
line-height: 1.45;
|
|
30
|
+
}
|
|
31
|
+
.wrap { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
|
|
32
|
+
h1 { font-size: 1.55rem; margin: 0 0 0.35rem; letter-spacing: -0.02em; }
|
|
33
|
+
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }
|
|
34
|
+
.sub { color: var(--muted); margin: 0 0 1rem; font-size: 0.92rem; }
|
|
35
|
+
.grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 1rem; }
|
|
36
|
+
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
|
|
37
|
+
.card {
|
|
38
|
+
background: var(--card);
|
|
39
|
+
border: 1px solid var(--border);
|
|
40
|
+
border-radius: 12px;
|
|
41
|
+
padding: 1rem;
|
|
42
|
+
margin-bottom: 1rem;
|
|
43
|
+
box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
|
|
44
|
+
}
|
|
45
|
+
.hint {
|
|
46
|
+
background: var(--accent-soft);
|
|
47
|
+
border: 1px solid #99f6e4;
|
|
48
|
+
border-radius: 10px;
|
|
49
|
+
padding: 0.85rem 1rem;
|
|
50
|
+
font-size: 0.9rem;
|
|
51
|
+
margin-bottom: 1rem;
|
|
52
|
+
}
|
|
53
|
+
.hint.warn {
|
|
54
|
+
background: var(--warn-soft);
|
|
55
|
+
border-color: #fdba74;
|
|
56
|
+
color: var(--warn);
|
|
57
|
+
}
|
|
58
|
+
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
|
|
59
|
+
button {
|
|
60
|
+
appearance: none;
|
|
61
|
+
border: 1px solid var(--border);
|
|
62
|
+
background: #fff;
|
|
63
|
+
color: var(--text);
|
|
64
|
+
border-radius: 8px;
|
|
65
|
+
padding: 0.5rem 0.85rem;
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
font: inherit;
|
|
68
|
+
}
|
|
69
|
+
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
|
|
70
|
+
button.danger { background: #7f1d1d; border-color: #7f1d1d; color: #fff; }
|
|
71
|
+
button:disabled { opacity: 0.55; cursor: not-allowed; }
|
|
72
|
+
label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.25rem; }
|
|
73
|
+
input, select {
|
|
74
|
+
width: 100%;
|
|
75
|
+
border: 1px solid var(--border);
|
|
76
|
+
border-radius: 8px;
|
|
77
|
+
padding: 0.55rem 0.7rem;
|
|
78
|
+
font: inherit;
|
|
79
|
+
background: #fff;
|
|
80
|
+
}
|
|
81
|
+
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
|
|
82
|
+
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }
|
|
83
|
+
.status, pre, .log {
|
|
84
|
+
background: #0f172a;
|
|
85
|
+
color: #e2e8f0;
|
|
86
|
+
border-radius: 8px;
|
|
87
|
+
padding: 0.75rem;
|
|
88
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
89
|
+
font-size: 0.75rem;
|
|
90
|
+
white-space: pre-wrap;
|
|
91
|
+
word-break: break-word;
|
|
92
|
+
max-height: 280px;
|
|
93
|
+
overflow: auto;
|
|
94
|
+
}
|
|
95
|
+
.pill {
|
|
96
|
+
display: inline-block;
|
|
97
|
+
border-radius: 999px;
|
|
98
|
+
padding: 0.15rem 0.55rem;
|
|
99
|
+
font-size: 0.72rem;
|
|
100
|
+
background: #e2e8f0;
|
|
101
|
+
color: #334155;
|
|
102
|
+
margin-left: 0.35rem;
|
|
103
|
+
}
|
|
104
|
+
.pill.ok { background: var(--ok-soft); color: var(--ok); }
|
|
105
|
+
.pill.bad { background: #fecaca; color: #991b1b; }
|
|
106
|
+
.checklist { margin: 0; padding-left: 1.1rem; font-size: 0.86rem; color: var(--muted); }
|
|
107
|
+
.checklist li { margin: 0.3rem 0; }
|
|
108
|
+
.product {
|
|
109
|
+
border: 1px dashed var(--border);
|
|
110
|
+
border-radius: 10px;
|
|
111
|
+
padding: 0.75rem;
|
|
112
|
+
margin: 0.5rem 0;
|
|
113
|
+
}
|
|
114
|
+
fieldset {
|
|
115
|
+
border: 1px solid var(--border);
|
|
116
|
+
border-radius: 10px;
|
|
117
|
+
padding: 0.75rem;
|
|
118
|
+
margin: 0 0 0.75rem;
|
|
119
|
+
}
|
|
120
|
+
legend { padding: 0 0.35rem; font-size: 0.85rem; color: var(--muted); }
|
|
121
|
+
code { font-size: 0.85em; }
|
|
122
|
+
</style>
|
|
123
|
+
</head>
|
|
124
|
+
<body>
|
|
125
|
+
<div class="wrap">
|
|
126
|
+
<h1>
|
|
127
|
+
Pixel v2 — Release Candidate
|
|
128
|
+
<span class="pill" id="pixelv2-pill">PixelV2?</span>
|
|
129
|
+
<span class="pill" id="init-pill">offline</span>
|
|
130
|
+
</h1>
|
|
131
|
+
<p class="sub">
|
|
132
|
+
Etapa 13A — consumidor real via <code><script></code> +
|
|
133
|
+
<code>dist/v2/global.global.js</code> (<code>window.PixelV2</code>).
|
|
134
|
+
</p>
|
|
135
|
+
|
|
136
|
+
<div class="hint">
|
|
137
|
+
<strong>Como abrir:</strong> rode <code>npm run build</code> e abra este arquivo
|
|
138
|
+
(ou <code>dist/examples/html-script/release-candidate.html</code>) no navegador.
|
|
139
|
+
Endpoint / Pixel ID podem vir da query
|
|
140
|
+
<code>?endpoint=…&pixelId=…</code> ou dos campos abaixo — não commitam segredos.
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
<div class="card">
|
|
144
|
+
<h2>Conexão API</h2>
|
|
145
|
+
<div class="row">
|
|
146
|
+
<div>
|
|
147
|
+
<label for="api-endpoint">PIXEL_API_ENDPOINT</label>
|
|
148
|
+
<input id="api-endpoint" type="url" placeholder="https://sua-api.example.com" />
|
|
149
|
+
</div>
|
|
150
|
+
<div>
|
|
151
|
+
<label for="pixel-id">PIXEL_ID</label>
|
|
152
|
+
<input id="pixel-id" type="text" placeholder="pix_…" />
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
<div class="row" style="margin-top: 0.75rem">
|
|
156
|
+
<div>
|
|
157
|
+
<label for="batch-mode">Modo transport</label>
|
|
158
|
+
<select id="batch-mode">
|
|
159
|
+
<option value="event">Event (batchSize=1)</option>
|
|
160
|
+
<option value="batch">Batch (batchSize=10)</option>
|
|
161
|
+
</select>
|
|
162
|
+
</div>
|
|
163
|
+
<div>
|
|
164
|
+
<label for="sender-mode">Sender</label>
|
|
165
|
+
<select id="sender-mode">
|
|
166
|
+
<option value="http">HTTP real</option>
|
|
167
|
+
<option value="mock">Mock (sem API)</option>
|
|
168
|
+
</select>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
<div class="actions">
|
|
172
|
+
<button id="btn-init" class="primary" type="button">Init</button>
|
|
173
|
+
<button id="btn-reinit" type="button">Reinit</button>
|
|
174
|
+
<button id="btn-destroy" class="danger" type="button">Destroy</button>
|
|
175
|
+
<button id="btn-flush" type="button">Flush transport</button>
|
|
176
|
+
<button id="btn-clear" type="button">Clear logs</button>
|
|
177
|
+
</div>
|
|
178
|
+
<div class="status" id="runtime-status" style="margin-top: 0.75rem">Aguardando…</div>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<div class="grid">
|
|
182
|
+
<div>
|
|
183
|
+
<div class="card">
|
|
184
|
+
<h2>Manual</h2>
|
|
185
|
+
<div class="actions">
|
|
186
|
+
<button id="btn-lead" class="primary" type="button">LEAD</button>
|
|
187
|
+
<button id="btn-atc" type="button">ADD_TO_CART (parcial)</button>
|
|
188
|
+
<button id="btn-rfc" type="button">REMOVE_FROM_CART</button>
|
|
189
|
+
<button id="btn-ic" type="button">INITIATE_CHECKOUT</button>
|
|
190
|
+
<button id="btn-purchase" type="button">PURCHASE</button>
|
|
191
|
+
</div>
|
|
192
|
+
<p class="sub" style="margin-top: 0.75rem; margin-bottom: 0">
|
|
193
|
+
PAGE_VIEW vem do Core (<code>trackInitialPageView</code>) no init.
|
|
194
|
+
</p>
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<div class="card">
|
|
198
|
+
<h2>Auto — LEAD (selectorForm · trigger auto)</h2>
|
|
199
|
+
<fieldset>
|
|
200
|
+
<legend>Campos (mode: any · fireOnce)</legend>
|
|
201
|
+
<div class="row">
|
|
202
|
+
<div>
|
|
203
|
+
<label for="lead-email">email</label>
|
|
204
|
+
<input id="lead-email" name="email" type="email" autocomplete="email" />
|
|
205
|
+
</div>
|
|
206
|
+
<div>
|
|
207
|
+
<label for="lead-phone">phone</label>
|
|
208
|
+
<input id="lead-phone" name="phone" type="tel" autocomplete="tel" />
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
</fieldset>
|
|
212
|
+
<p class="sub">Preencha email ou phone — detector auto deve disparar LEAD.</p>
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
<div class="card">
|
|
216
|
+
<h2>Auto — ADD_TO_CART</h2>
|
|
217
|
+
<div class="product">
|
|
218
|
+
<strong>Oferta Principal RC — R$ 197</strong>
|
|
219
|
+
<div class="actions">
|
|
220
|
+
<button
|
|
221
|
+
type="button"
|
|
222
|
+
class="primary"
|
|
223
|
+
data-track="add_to_cart"
|
|
224
|
+
data-product-id="main_offer"
|
|
225
|
+
>
|
|
226
|
+
data-track add_to_cart
|
|
227
|
+
</button>
|
|
228
|
+
<button type="button">Comprar agora</button>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
<p class="sub">
|
|
232
|
+
Clique rápido 2× no mesmo botão: esperado 1 evento (<500ms).
|
|
233
|
+
Após 500ms: novo evento permitido.
|
|
234
|
+
</p>
|
|
235
|
+
</div>
|
|
236
|
+
|
|
237
|
+
<div class="card">
|
|
238
|
+
<h2>Auto — INITIATE_CHECKOUT (submit)</h2>
|
|
239
|
+
<form id="checkout-form">
|
|
240
|
+
<div class="row">
|
|
241
|
+
<div>
|
|
242
|
+
<label for="co-email">email</label>
|
|
243
|
+
<input id="co-email" name="email" type="email" required />
|
|
244
|
+
</div>
|
|
245
|
+
<div>
|
|
246
|
+
<label for="co-phone">phone</label>
|
|
247
|
+
<input id="co-phone" name="phone" type="tel" required />
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
<div class="actions">
|
|
251
|
+
<button type="submit" class="primary" data-track="initiate_checkout">
|
|
252
|
+
Finalizar checkout
|
|
253
|
+
</button>
|
|
254
|
+
</div>
|
|
255
|
+
</form>
|
|
256
|
+
</div>
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
<div>
|
|
260
|
+
<div class="card">
|
|
261
|
+
<h2>Event counts</h2>
|
|
262
|
+
<pre id="event-counts">—</pre>
|
|
263
|
+
</div>
|
|
264
|
+
<div class="card">
|
|
265
|
+
<h2>Transport debug</h2>
|
|
266
|
+
<pre id="transport-state">—</pre>
|
|
267
|
+
</div>
|
|
268
|
+
<div class="card">
|
|
269
|
+
<h2>Dedupe / detectors</h2>
|
|
270
|
+
<pre id="dedupe-state">—</pre>
|
|
271
|
+
</div>
|
|
272
|
+
<div class="card">
|
|
273
|
+
<h2>Último payload</h2>
|
|
274
|
+
<pre id="last-payload">—</pre>
|
|
275
|
+
</div>
|
|
276
|
+
<div class="card">
|
|
277
|
+
<h2>Logs</h2>
|
|
278
|
+
<div class="log" id="logs"></div>
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
<div class="card">
|
|
284
|
+
<h2>Checklist manual 13A</h2>
|
|
285
|
+
<ul class="checklist">
|
|
286
|
+
<li>[ ] window.PixelV2 existe</li>
|
|
287
|
+
<li>[ ] Pixel inicializa sem erro</li>
|
|
288
|
+
<li>[ ] PAGE_VIEW dispara no init (Core) — ver Transport sentCount ≥ 1</li>
|
|
289
|
+
<li>[ ] LEAD manual dispara</li>
|
|
290
|
+
<li>[ ] LEAD automático dispara com email/phone</li>
|
|
291
|
+
<li>[ ] LEAD vazio não dispara</li>
|
|
292
|
+
<li>[ ] ADD_TO_CART manual parcial completa pelo catálogo</li>
|
|
293
|
+
<li>[ ] ADD_TO_CART automático por data-track dispara</li>
|
|
294
|
+
<li>[ ] ADD_TO_CART por text:Comprar agora dispara</li>
|
|
295
|
+
<li>[ ] ADD_TO_CART rápido não duplica (<500ms)</li>
|
|
296
|
+
<li>[ ] ADD_TO_CART depois de 500ms dispara novamente</li>
|
|
297
|
+
<li>[ ] REMOVE_FROM_CART remove do state</li>
|
|
298
|
+
<li>[ ] INITIATE_CHECKOUT usa selectedItems</li>
|
|
299
|
+
<li>[ ] PURCHASE parcial completa items/value/currency</li>
|
|
300
|
+
<li>[ ] destroy remove listeners</li>
|
|
301
|
+
<li>[ ] reinit não duplica listeners</li>
|
|
302
|
+
<li>[ ] Transport Event real recebe ACK (HTTP)</li>
|
|
303
|
+
<li>[ ] Transport Batch real recebe ACK (modo Batch)</li>
|
|
304
|
+
</ul>
|
|
305
|
+
</div>
|
|
306
|
+
</div>
|
|
307
|
+
|
|
308
|
+
<script src="../../dist/v2/global.global.js"></script>
|
|
309
|
+
<script>
|
|
310
|
+
(function () {
|
|
311
|
+
var params = new URLSearchParams(window.location.search);
|
|
312
|
+
var stored = {};
|
|
313
|
+
try {
|
|
314
|
+
stored = JSON.parse(localStorage.getItem('pixel_rc_conn') || '{}');
|
|
315
|
+
} catch (e) {
|
|
316
|
+
stored = {};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
var endpointInput = document.getElementById('api-endpoint');
|
|
320
|
+
var pixelIdInput = document.getElementById('pixel-id');
|
|
321
|
+
endpointInput.value =
|
|
322
|
+
params.get('endpoint') ||
|
|
323
|
+
stored.endpoint ||
|
|
324
|
+
'';
|
|
325
|
+
pixelIdInput.value =
|
|
326
|
+
params.get('pixelId') ||
|
|
327
|
+
stored.pixelId ||
|
|
328
|
+
'';
|
|
329
|
+
|
|
330
|
+
var pixelv2Pill = document.getElementById('pixelv2-pill');
|
|
331
|
+
var initPill = document.getElementById('init-pill');
|
|
332
|
+
var runtimeStatus = document.getElementById('runtime-status');
|
|
333
|
+
var logsEl = document.getElementById('logs');
|
|
334
|
+
var countsEl = document.getElementById('event-counts');
|
|
335
|
+
var transportEl = document.getElementById('transport-state');
|
|
336
|
+
var dedupeEl = document.getElementById('dedupe-state');
|
|
337
|
+
var lastPayloadEl = document.getElementById('last-payload');
|
|
338
|
+
|
|
339
|
+
var pixel = null;
|
|
340
|
+
var unsubscribe = null;
|
|
341
|
+
var initCount = 0;
|
|
342
|
+
var destroyCount = 0;
|
|
343
|
+
var counts = {};
|
|
344
|
+
var lastEvent = null;
|
|
345
|
+
|
|
346
|
+
function hasPixelV2() {
|
|
347
|
+
return !!(window.PixelV2 && window.PixelV2.Pixel && window.PixelV2.DEFAULT_PIXEL_CONFIG);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function appendLog(msg) {
|
|
351
|
+
var line = '[' + new Date().toISOString() + '] ' + msg;
|
|
352
|
+
logsEl.textContent = line + '\n' + logsEl.textContent;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function bump(type) {
|
|
356
|
+
counts[type] = (counts[type] || 0) + 1;
|
|
357
|
+
renderCounts();
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function renderCounts() {
|
|
361
|
+
var keys = Object.keys(counts).sort();
|
|
362
|
+
countsEl.textContent = keys.length
|
|
363
|
+
? keys.map(function (k) { return k + ': ' + counts[k]; }).join('\n')
|
|
364
|
+
: 'Nenhum evento ainda';
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function renderTransport() {
|
|
368
|
+
if (!pixel || !pixel.getDebugTransportState) {
|
|
369
|
+
transportEl.textContent = '—';
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
var s = pixel.getDebugTransportState() || {};
|
|
373
|
+
var sender = s.sender || {};
|
|
374
|
+
transportEl.textContent = JSON.stringify(
|
|
375
|
+
{
|
|
376
|
+
sentCount: s.sentCount,
|
|
377
|
+
queueSize: s.queueSize,
|
|
378
|
+
inFlight: s.delivery && s.delivery.inFlight,
|
|
379
|
+
ackCount: s.delivery && s.delivery.ackCount,
|
|
380
|
+
lastAck: sender.lastAck,
|
|
381
|
+
senderMode: s.advanced && s.advanced.senderMode,
|
|
382
|
+
lastResponses: (sender.responses || []).slice(-3),
|
|
383
|
+
},
|
|
384
|
+
null,
|
|
385
|
+
2
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function renderDedupe() {
|
|
390
|
+
if (!pixel) {
|
|
391
|
+
dedupeEl.textContent = '—';
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
var keys = pixel.getDebugDedupeKeys ? pixel.getDebugDedupeKeys() : [];
|
|
395
|
+
var dets = pixel.getDebugActiveDetectors ? pixel.getDebugActiveDetectors() : [];
|
|
396
|
+
dedupeEl.textContent =
|
|
397
|
+
'detectors (' + dets.length + '):\n' +
|
|
398
|
+
(dets.join('\n') || '(none)') +
|
|
399
|
+
'\n\ndedupe keys (' + keys.length + '):\n' +
|
|
400
|
+
(keys.join('\n') || '(none)');
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function renderRuntime() {
|
|
404
|
+
var services = pixel && pixel.getDebugServices ? pixel.getDebugServices() : null;
|
|
405
|
+
runtimeStatus.textContent =
|
|
406
|
+
'PixelV2: ' + hasPixelV2() +
|
|
407
|
+
'\ninitialized: ' + (pixel ? pixel.isInitialized() : false) +
|
|
408
|
+
'\ninitCount: ' + initCount +
|
|
409
|
+
'\ndestroyCount: ' + destroyCount +
|
|
410
|
+
'\ndispatcher listeners: ' +
|
|
411
|
+
(services ? services.dispatcher.getListenerCount() : 0);
|
|
412
|
+
initPill.textContent = pixel && pixel.isInitialized() ? 'online' : 'offline';
|
|
413
|
+
initPill.className = 'pill ' + (pixel && pixel.isInitialized() ? 'ok' : 'bad');
|
|
414
|
+
renderTransport();
|
|
415
|
+
renderDedupe();
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function saveConn() {
|
|
419
|
+
try {
|
|
420
|
+
localStorage.setItem(
|
|
421
|
+
'pixel_rc_conn',
|
|
422
|
+
JSON.stringify({
|
|
423
|
+
endpoint: endpointInput.value.trim(),
|
|
424
|
+
pixelId: pixelIdInput.value.trim(),
|
|
425
|
+
})
|
|
426
|
+
);
|
|
427
|
+
} catch (e) {}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function buildConfig() {
|
|
431
|
+
var Pixel = window.PixelV2.Pixel;
|
|
432
|
+
var DEFAULT_PIXEL_CONFIG = window.PixelV2.DEFAULT_PIXEL_CONFIG;
|
|
433
|
+
var endpoint = endpointInput.value.trim();
|
|
434
|
+
var pixelId = pixelIdInput.value.trim();
|
|
435
|
+
var batchMode = document.getElementById('batch-mode').value;
|
|
436
|
+
var senderMode = document.getElementById('sender-mode').value;
|
|
437
|
+
var useHttp = senderMode === 'http';
|
|
438
|
+
var batchSize = batchMode === 'batch' ? 10 : 1;
|
|
439
|
+
|
|
440
|
+
if (useHttp && (!endpoint || !pixelId)) {
|
|
441
|
+
throw new Error('Preencha PIXEL_API_ENDPOINT e PIXEL_ID para sender HTTP.');
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return {
|
|
445
|
+
...DEFAULT_PIXEL_CONFIG,
|
|
446
|
+
app: {
|
|
447
|
+
...DEFAULT_PIXEL_CONFIG.app,
|
|
448
|
+
source: 'custom',
|
|
449
|
+
environment: 'development',
|
|
450
|
+
debug: true,
|
|
451
|
+
},
|
|
452
|
+
identity: {
|
|
453
|
+
...DEFAULT_PIXEL_CONFIG.identity,
|
|
454
|
+
pixelId: pixelId || 'pixel-rc-demo',
|
|
455
|
+
},
|
|
456
|
+
transport: {
|
|
457
|
+
...DEFAULT_PIXEL_CONFIG.transport,
|
|
458
|
+
apiEndpoint: endpoint || '',
|
|
459
|
+
timeoutMs: 15000,
|
|
460
|
+
},
|
|
461
|
+
modules: {
|
|
462
|
+
...DEFAULT_PIXEL_CONFIG.modules,
|
|
463
|
+
privacy: { ...DEFAULT_PIXEL_CONFIG.modules.privacy, enabled: false },
|
|
464
|
+
behavior: { ...DEFAULT_PIXEL_CONFIG.modules.behavior, enabled: false },
|
|
465
|
+
integrations: {
|
|
466
|
+
...DEFAULT_PIXEL_CONFIG.modules.integrations,
|
|
467
|
+
enabled: false,
|
|
468
|
+
},
|
|
469
|
+
core: {
|
|
470
|
+
...DEFAULT_PIXEL_CONFIG.modules.core,
|
|
471
|
+
enabled: true,
|
|
472
|
+
pageView: {
|
|
473
|
+
...DEFAULT_PIXEL_CONFIG.modules.core.pageView,
|
|
474
|
+
enabled: true,
|
|
475
|
+
trackInitialPageView: true,
|
|
476
|
+
spa: false,
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
conversion: {
|
|
480
|
+
...DEFAULT_PIXEL_CONFIG.modules.conversion,
|
|
481
|
+
enabled: true,
|
|
482
|
+
commerce: {
|
|
483
|
+
currency: 'BRL',
|
|
484
|
+
catalog: {
|
|
485
|
+
products: [
|
|
486
|
+
{
|
|
487
|
+
id: 'main_offer',
|
|
488
|
+
name: 'Oferta Principal RC',
|
|
489
|
+
type: 'main',
|
|
490
|
+
price: 197,
|
|
491
|
+
currency: 'BRL',
|
|
492
|
+
quantity: 1,
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
id: 'order_bump_01',
|
|
496
|
+
name: 'Order Bump RC',
|
|
497
|
+
type: 'order_bump',
|
|
498
|
+
price: 47,
|
|
499
|
+
currency: 'BRL',
|
|
500
|
+
quantity: 1,
|
|
501
|
+
},
|
|
502
|
+
],
|
|
503
|
+
},
|
|
504
|
+
checkout: {
|
|
505
|
+
mode: 'single_product',
|
|
506
|
+
selectedItems: [{ productId: 'main_offer', quantity: 1 }],
|
|
507
|
+
calculateValueFrom: 'selected_items',
|
|
508
|
+
allowDynamicItems: true,
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
manual: {
|
|
512
|
+
pageView: { enabled: false },
|
|
513
|
+
purchase: { enabled: true },
|
|
514
|
+
lead: { enabled: true },
|
|
515
|
+
addToCart: { enabled: true },
|
|
516
|
+
removeFromCart: { enabled: true },
|
|
517
|
+
initiateCheckout: { enabled: true },
|
|
518
|
+
addPaymentInfo: { enabled: true },
|
|
519
|
+
search: { enabled: true },
|
|
520
|
+
viewContent: { enabled: true },
|
|
521
|
+
},
|
|
522
|
+
auto: {
|
|
523
|
+
enabled: true,
|
|
524
|
+
detectors: {
|
|
525
|
+
lead: {
|
|
526
|
+
enabled: true,
|
|
527
|
+
selector: '#lead-email, #lead-phone',
|
|
528
|
+
selectorType: 'css',
|
|
529
|
+
selectorForm: {
|
|
530
|
+
fields: ['email', 'phone'],
|
|
531
|
+
mode: 'any',
|
|
532
|
+
trigger: 'auto',
|
|
533
|
+
fireOnce: true,
|
|
534
|
+
minRequired: 1,
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
addToCart: {
|
|
538
|
+
enabled: true,
|
|
539
|
+
// sem selectorForm → ConfiguredSelectorDetector (data-track + text)
|
|
540
|
+
selector: ['[data-track="add_to_cart"]', 'text:Comprar agora'],
|
|
541
|
+
selectorType: 'css',
|
|
542
|
+
},
|
|
543
|
+
initiateCheckout: {
|
|
544
|
+
enabled: true,
|
|
545
|
+
selector: ['#checkout-form', '[data-track="initiate_checkout"]'],
|
|
546
|
+
selectorType: 'css',
|
|
547
|
+
selectorForm: {
|
|
548
|
+
fields: ['email', 'phone'],
|
|
549
|
+
mode: 'all',
|
|
550
|
+
trigger: 'submit',
|
|
551
|
+
fireOnce: false,
|
|
552
|
+
minRequired: 2,
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
purchase: { enabled: false },
|
|
556
|
+
removeFromCart: { enabled: false },
|
|
557
|
+
addPaymentInfo: { enabled: false },
|
|
558
|
+
search: { enabled: false },
|
|
559
|
+
viewContent: { enabled: false },
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
rules: {
|
|
563
|
+
...DEFAULT_PIXEL_CONFIG.modules.conversion.rules,
|
|
564
|
+
enabled: false,
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
transport: {
|
|
568
|
+
...DEFAULT_PIXEL_CONFIG.modules.transport,
|
|
569
|
+
enabled: true,
|
|
570
|
+
mockSender: { enabled: !useHttp },
|
|
571
|
+
sender: { mode: useHttp ? 'http' : 'mock' },
|
|
572
|
+
batch: {
|
|
573
|
+
...DEFAULT_PIXEL_CONFIG.modules.transport.batch,
|
|
574
|
+
enabled: true,
|
|
575
|
+
batchSize: batchSize,
|
|
576
|
+
flushIntervalMs: batchMode === 'batch' ? 8000 : 200,
|
|
577
|
+
maxWaitMs: batchMode === 'batch' ? 8000 : 500,
|
|
578
|
+
},
|
|
579
|
+
flush: {
|
|
580
|
+
...DEFAULT_PIXEL_CONFIG.modules.transport.flush,
|
|
581
|
+
flushIntervalMs: batchMode === 'batch' ? 8000 : 200,
|
|
582
|
+
flushOnDestroy: true,
|
|
583
|
+
},
|
|
584
|
+
timeout: {
|
|
585
|
+
...DEFAULT_PIXEL_CONFIG.modules.transport.timeout,
|
|
586
|
+
timeoutMs: 15000,
|
|
587
|
+
},
|
|
588
|
+
coordination: { enabled: false },
|
|
589
|
+
},
|
|
590
|
+
},
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
async function destroyPixel() {
|
|
595
|
+
if (unsubscribe) {
|
|
596
|
+
unsubscribe();
|
|
597
|
+
unsubscribe = null;
|
|
598
|
+
}
|
|
599
|
+
if (pixel) {
|
|
600
|
+
await pixel.destroy();
|
|
601
|
+
destroyCount += 1;
|
|
602
|
+
pixel = null;
|
|
603
|
+
}
|
|
604
|
+
renderRuntime();
|
|
605
|
+
appendLog('destroy()');
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
async function initPixel() {
|
|
609
|
+
if (!hasPixelV2()) {
|
|
610
|
+
throw new Error('window.PixelV2 ausente — rode npm run build');
|
|
611
|
+
}
|
|
612
|
+
saveConn();
|
|
613
|
+
await destroyPixel();
|
|
614
|
+
|
|
615
|
+
Object.keys(counts).forEach(function (k) { delete counts[k]; });
|
|
616
|
+
lastEvent = null;
|
|
617
|
+
lastPayloadEl.textContent = '—';
|
|
618
|
+
renderCounts();
|
|
619
|
+
|
|
620
|
+
var Pixel = window.PixelV2.Pixel;
|
|
621
|
+
pixel = new Pixel(buildConfig());
|
|
622
|
+
await pixel.init();
|
|
623
|
+
initCount += 1;
|
|
624
|
+
|
|
625
|
+
var services = pixel.getDebugServices();
|
|
626
|
+
if (services) {
|
|
627
|
+
unsubscribe = services.dispatcher.subscribe(function (event) {
|
|
628
|
+
bump(event.type);
|
|
629
|
+
lastEvent = event;
|
|
630
|
+
lastPayloadEl.textContent = JSON.stringify(event, null, 2);
|
|
631
|
+
appendLog('dispatch ' + event.type);
|
|
632
|
+
renderRuntime();
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// PAGE_VIEW do Core dispara durante init (antes do subscribe do painel).
|
|
637
|
+
// Contabiliza via transport sentCount / log explícito.
|
|
638
|
+
appendLog(
|
|
639
|
+
'init ok · PAGE_VIEW inicial pode já ter sido enviado (ver Transport)'
|
|
640
|
+
);
|
|
641
|
+
|
|
642
|
+
appendLog(
|
|
643
|
+
'init ok · sender=' +
|
|
644
|
+
document.getElementById('sender-mode').value +
|
|
645
|
+
' · batch=' +
|
|
646
|
+
document.getElementById('batch-mode').value
|
|
647
|
+
);
|
|
648
|
+
renderRuntime();
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// UI bindings
|
|
652
|
+
document.getElementById('btn-init').onclick = function () {
|
|
653
|
+
initPixel().catch(function (err) {
|
|
654
|
+
appendLog('ERR ' + err.message);
|
|
655
|
+
alert(err.message);
|
|
656
|
+
});
|
|
657
|
+
};
|
|
658
|
+
document.getElementById('btn-reinit').onclick = function () {
|
|
659
|
+
initPixel().catch(function (err) {
|
|
660
|
+
appendLog('ERR ' + err.message);
|
|
661
|
+
alert(err.message);
|
|
662
|
+
});
|
|
663
|
+
};
|
|
664
|
+
document.getElementById('btn-destroy').onclick = function () {
|
|
665
|
+
destroyPixel();
|
|
666
|
+
};
|
|
667
|
+
document.getElementById('btn-flush').onclick = function () {
|
|
668
|
+
if (pixel && pixel.flushTransport) {
|
|
669
|
+
pixel.flushTransport();
|
|
670
|
+
appendLog('flushTransport()');
|
|
671
|
+
setTimeout(renderTransport, 300);
|
|
672
|
+
setTimeout(renderTransport, 1200);
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
document.getElementById('btn-clear').onclick = function () {
|
|
676
|
+
logsEl.textContent = '';
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
document.getElementById('btn-lead').onclick = function () {
|
|
680
|
+
if (!pixel) return;
|
|
681
|
+
pixel.lead({
|
|
682
|
+
email: 'rc+manual@example.com',
|
|
683
|
+
phone: '+5500000000000',
|
|
684
|
+
});
|
|
685
|
+
};
|
|
686
|
+
document.getElementById('btn-atc').onclick = function () {
|
|
687
|
+
if (!pixel) return;
|
|
688
|
+
pixel.addToCart({ productId: 'main_offer' });
|
|
689
|
+
};
|
|
690
|
+
document.getElementById('btn-rfc').onclick = function () {
|
|
691
|
+
if (!pixel) return;
|
|
692
|
+
pixel.removeFromCart({ productId: 'main_offer', quantity: 1 });
|
|
693
|
+
};
|
|
694
|
+
document.getElementById('btn-ic').onclick = function () {
|
|
695
|
+
if (!pixel) return;
|
|
696
|
+
pixel.initiateCheckout({});
|
|
697
|
+
};
|
|
698
|
+
document.getElementById('btn-purchase').onclick = function () {
|
|
699
|
+
if (!pixel) return;
|
|
700
|
+
pixel.purchase({
|
|
701
|
+
orderId: 'rc_order_' + Date.now(),
|
|
702
|
+
value: 197,
|
|
703
|
+
currency: 'BRL',
|
|
704
|
+
});
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
document.getElementById('checkout-form').addEventListener('submit', function (e) {
|
|
708
|
+
e.preventDefault();
|
|
709
|
+
appendLog('checkout-form submit (preventDefault playground)');
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
// Boot
|
|
713
|
+
if (hasPixelV2()) {
|
|
714
|
+
pixelv2Pill.textContent = 'PixelV2 OK';
|
|
715
|
+
pixelv2Pill.className = 'pill ok';
|
|
716
|
+
appendLog('window.PixelV2 detectado');
|
|
717
|
+
} else {
|
|
718
|
+
pixelv2Pill.textContent = 'PixelV2 MISSING';
|
|
719
|
+
pixelv2Pill.className = 'pill bad';
|
|
720
|
+
appendLog('ERRO: window.PixelV2 ausente — npm run build');
|
|
721
|
+
}
|
|
722
|
+
renderRuntime();
|
|
723
|
+
})();
|
|
724
|
+
</script>
|
|
725
|
+
</body>
|
|
726
|
+
</html>
|