@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,491 @@
|
|
|
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 — INITIATE_CHECKOUT auto + selectorForm</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
|
+
button:disabled { opacity: 0.55; cursor: not-allowed; }
|
|
51
|
+
label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.25rem; }
|
|
52
|
+
input {
|
|
53
|
+
width: 100%; border: 1px solid var(--border); border-radius: 8px;
|
|
54
|
+
padding: 0.55rem 0.7rem; font: inherit; background: #fff;
|
|
55
|
+
}
|
|
56
|
+
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
|
|
57
|
+
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }
|
|
58
|
+
.status, pre {
|
|
59
|
+
background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 0.75rem;
|
|
60
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
61
|
+
font-size: 0.78rem; white-space: pre-wrap; word-break: break-word;
|
|
62
|
+
max-height: 260px; overflow: auto;
|
|
63
|
+
}
|
|
64
|
+
.pill {
|
|
65
|
+
display: inline-block; border-radius: 999px; padding: 0.15rem 0.55rem;
|
|
66
|
+
font-size: 0.72rem; background: #e2e8f0; color: #334155; margin-left: 0.35rem;
|
|
67
|
+
}
|
|
68
|
+
.pill.ok { background: #bbf7d0; color: #166534; }
|
|
69
|
+
.checklist { margin: 0; padding-left: 1.1rem; font-size: 0.88rem; color: var(--muted); }
|
|
70
|
+
.checklist li { margin: 0.35rem 0; }
|
|
71
|
+
.ctx {
|
|
72
|
+
border-left: 3px solid var(--accent); padding-left: 0.75rem; margin-bottom: 0.85rem;
|
|
73
|
+
color: var(--muted); font-size: 0.88rem;
|
|
74
|
+
}
|
|
75
|
+
.product {
|
|
76
|
+
border: 1px dashed var(--border); border-radius: 10px; padding: 0.75rem; margin: 0.5rem 0;
|
|
77
|
+
}
|
|
78
|
+
.product strong { display: block; margin-bottom: 0.2rem; }
|
|
79
|
+
code { font-size: 0.85em; }
|
|
80
|
+
</style>
|
|
81
|
+
</head>
|
|
82
|
+
<body>
|
|
83
|
+
<div class="wrap">
|
|
84
|
+
<h1>INITIATE_CHECKOUT — trigger: auto · selectorForm</h1>
|
|
85
|
+
<p class="sub">
|
|
86
|
+
Cenário isolado para validação do Pixel v2.
|
|
87
|
+
<span class="pill" id="init-pill">offline</span>
|
|
88
|
+
</p>
|
|
89
|
+
<div class="nav"><a href="example-initiate-checkout-attribute.html" class="">1. Atributo</a>
|
|
90
|
+
<a href="example-initiate-checkout-click.html" class="">2. Click+Form</a>
|
|
91
|
+
<a href="example-initiate-checkout-submit.html" class="">3. Submit</a>
|
|
92
|
+
<a href="example-initiate-checkout-auto.html" class="active">4. Auto+Form</a>
|
|
93
|
+
<a href="example-initiate-checkout-text.html" class="">5. Text</a>
|
|
94
|
+
<a href="example-initiate-checkout-manual.html" class="">6. Manual API</a>
|
|
95
|
+
<a href="example-initiate-checkout-snapshot.html" class="">7. Snapshot/value</a></div>
|
|
96
|
+
<div class="hint"><strong>Contexto:</strong> ao completar contato, dispara checkout
|
|
97
|
+
automaticamente (input/change). <code>fireOnce: true</code>.</div>
|
|
98
|
+
|
|
99
|
+
<div class="card">
|
|
100
|
+
<h2>Lifecycle</h2>
|
|
101
|
+
<div class="actions">
|
|
102
|
+
<button id="btn-reinit" class="primary" type="button">Reinitialize</button>
|
|
103
|
+
<button id="btn-destroy" class="danger" type="button">Destroy</button>
|
|
104
|
+
<button id="btn-clear" type="button">Clear logs</button>
|
|
105
|
+
</div>
|
|
106
|
+
<div class="status" id="runtime-status">Aguardando init...</div>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<div class="grid">
|
|
110
|
+
<div>
|
|
111
|
+
<div class="card">
|
|
112
|
+
<h2>Contato → checkout auto <span class="pill">selectorForm · auto</span></h2>
|
|
113
|
+
<div class="ctx">Completar email+phone dispara sem clicar CTA.</div>
|
|
114
|
+
<form id="checkout-contact-form">
|
|
115
|
+
<div class="row">
|
|
116
|
+
<div>
|
|
117
|
+
<label for="auto-email">Email</label>
|
|
118
|
+
<input id="auto-email" name="email" type="email" placeholder="auto@test.com" />
|
|
119
|
+
</div>
|
|
120
|
+
<div>
|
|
121
|
+
<label for="auto-phone">Phone</label>
|
|
122
|
+
<input id="auto-phone" name="phone" type="tel" placeholder="11966665555" />
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
<div class="actions">
|
|
126
|
+
<button type="button" disabled>Continuar (demo)</button>
|
|
127
|
+
</div>
|
|
128
|
+
</form>
|
|
129
|
+
<p class="sub">2º campo preenchido → evento sozinho. Continuar digitando → sem duplicata.</p>
|
|
130
|
+
</div>
|
|
131
|
+
<div class="card">
|
|
132
|
+
<h2>Checklist</h2>
|
|
133
|
+
<ul class="checklist">
|
|
134
|
+
<li>[ ] Só email → não dispara</li>
|
|
135
|
+
<li>[ ] Só phone → não dispara</li>
|
|
136
|
+
<li>[ ] Ambos via input → dispara automático</li>
|
|
137
|
+
<li>[ ] fireOnce impede duplicata</li>
|
|
138
|
+
<li>[ ] Snapshot com selectedItems</li>
|
|
139
|
+
</ul>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
<div>
|
|
143
|
+
<div class="card">
|
|
144
|
+
<h2>Event counts</h2>
|
|
145
|
+
<div class="status" id="event-counts">Nenhum evento ainda</div>
|
|
146
|
+
</div>
|
|
147
|
+
<div class="card">
|
|
148
|
+
<h2>Checkout snapshot (último evento)</h2>
|
|
149
|
+
<div class="status" id="checkout-snapshot">null</div>
|
|
150
|
+
</div>
|
|
151
|
+
<div class="card">
|
|
152
|
+
<h2>Active detectors</h2>
|
|
153
|
+
<div class="status" id="detectors">—</div>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div class="card">
|
|
157
|
+
<h2>Last event JSON</h2>
|
|
158
|
+
<pre id="last-event">null</pre>
|
|
159
|
+
</div>
|
|
160
|
+
<div class="card">
|
|
161
|
+
<h2>Event log</h2>
|
|
162
|
+
<pre id="logs">Aguardando eventos...</pre>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
<script src="../../../dist/v2/global.global.js"></script>
|
|
169
|
+
<script>
|
|
170
|
+
const { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
|
|
171
|
+
const API_ENDPOINT =
|
|
172
|
+
'https://micro-service-pixel-production-4826.up.railway.app';
|
|
173
|
+
const PIXEL_ID = 'pix_7315610';
|
|
174
|
+
|
|
175
|
+
const els = {
|
|
176
|
+
logs: document.getElementById('logs'),
|
|
177
|
+
last: document.getElementById('last-event'),
|
|
178
|
+
counts: document.getElementById('event-counts'),
|
|
179
|
+
snapshot: document.getElementById('checkout-snapshot'),
|
|
180
|
+
detectors: document.getElementById('detectors'),
|
|
181
|
+
dedupe: document.getElementById('dedupe-keys'),
|
|
182
|
+
runtime: document.getElementById('runtime-status'),
|
|
183
|
+
pill: document.getElementById('init-pill'),
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
let pixel = null;
|
|
187
|
+
let unsubscribe = null;
|
|
188
|
+
let initCount = 0;
|
|
189
|
+
let destroyCount = 0;
|
|
190
|
+
const counts = {};
|
|
191
|
+
|
|
192
|
+
function initiateCheckoutDetectorConfig() {
|
|
193
|
+
return {
|
|
194
|
+
enabled: true,
|
|
195
|
+
selector: ['#checkout-contact-form'],
|
|
196
|
+
selectorType: 'css',
|
|
197
|
+
selectorForm: {
|
|
198
|
+
fields: ['email', 'phone'],
|
|
199
|
+
mode: 'all',
|
|
200
|
+
formSelector: '#checkout-contact-form',
|
|
201
|
+
trigger: 'auto',
|
|
202
|
+
debounceMs: 300,
|
|
203
|
+
fireOnce: true,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function buildConfig() {
|
|
209
|
+
const base = DEFAULT_PIXEL_CONFIG;
|
|
210
|
+
return {
|
|
211
|
+
...base,
|
|
212
|
+
app: {
|
|
213
|
+
...base.app,
|
|
214
|
+
source: 'custom',
|
|
215
|
+
environment: 'development',
|
|
216
|
+
debug: true,
|
|
217
|
+
},
|
|
218
|
+
transport: {
|
|
219
|
+
...DEFAULT_PIXEL_CONFIG.transport,
|
|
220
|
+
apiEndpoint: API_ENDPOINT,
|
|
221
|
+
timeoutMs: 10000,
|
|
222
|
+
},
|
|
223
|
+
identity: { ...base.identity, pixelId: PIXEL_ID },
|
|
224
|
+
modules: {
|
|
225
|
+
...base.modules,
|
|
226
|
+
core: {
|
|
227
|
+
...base.modules.core,
|
|
228
|
+
enabled: false,
|
|
229
|
+
pageView: {
|
|
230
|
+
...base.modules.core.pageView,
|
|
231
|
+
enabled: false,
|
|
232
|
+
trackInitialPageView: false,
|
|
233
|
+
spa: false,
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
behavior: { ...base.modules.behavior, enabled: false },
|
|
237
|
+
privacy: { ...base.modules.privacy, enabled: false },
|
|
238
|
+
transport: {
|
|
239
|
+
enabled: true,
|
|
240
|
+
mockSender: { enabled: false },
|
|
241
|
+
sender: { mode: 'http' },
|
|
242
|
+
persistence: { enabled: true },
|
|
243
|
+
replay: { enabled: true },
|
|
244
|
+
ordering: { enabled: true },
|
|
245
|
+
coordination: { enabled: true },
|
|
246
|
+
circuitBreaker: {
|
|
247
|
+
enabled: true,
|
|
248
|
+
failureThreshold: 5,
|
|
249
|
+
resetTimeoutMs: 30000,
|
|
250
|
+
halfOpenMaxAttempts: 2,
|
|
251
|
+
},
|
|
252
|
+
backpressure: {
|
|
253
|
+
enabled: true,
|
|
254
|
+
maxQueueSize: 500,
|
|
255
|
+
policy: 'drop_oldest',
|
|
256
|
+
sampleRate: 0.5,
|
|
257
|
+
},
|
|
258
|
+
deadLetter: { enabled: true, maxEntries: 200 },
|
|
259
|
+
compression: { enabled: true, strategy: 'identity' },
|
|
260
|
+
retry: {
|
|
261
|
+
enabled: true,
|
|
262
|
+
maxAttempts: 4,
|
|
263
|
+
baseDelayMs: 500,
|
|
264
|
+
maxDelayMs: 4000,
|
|
265
|
+
multiplier: 2,
|
|
266
|
+
},
|
|
267
|
+
batch: {
|
|
268
|
+
enabled: true,
|
|
269
|
+
batchSize: 10,
|
|
270
|
+
flushIntervalMs: 2000,
|
|
271
|
+
maxWaitMs: 5000,
|
|
272
|
+
},
|
|
273
|
+
timeout: { enabled: true, timeoutMs: 10000 },
|
|
274
|
+
offline: { enabled: true },
|
|
275
|
+
flush: {
|
|
276
|
+
enabled: true,
|
|
277
|
+
flushIntervalMs: 2000,
|
|
278
|
+
flushOnDestroy: true,
|
|
279
|
+
prepareUnloadHooks: true,
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
integrations: { ...base.modules.integrations, enabled: false },
|
|
283
|
+
conversion: {
|
|
284
|
+
enabled: true,
|
|
285
|
+
commerce: {
|
|
286
|
+
currency: 'BRL',
|
|
287
|
+
catalog: { products: [
|
|
288
|
+
{
|
|
289
|
+
id: 'main_offer',
|
|
290
|
+
name: 'Oferta Principal',
|
|
291
|
+
type: 'main',
|
|
292
|
+
price: 197,
|
|
293
|
+
currency: 'BRL',
|
|
294
|
+
quantity: 1,
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
id: 'order_bump_01',
|
|
298
|
+
name: 'Order Bump Especial',
|
|
299
|
+
type: 'order_bump',
|
|
300
|
+
price: 47,
|
|
301
|
+
currency: 'BRL',
|
|
302
|
+
quantity: 1,
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
id: 'upsell_01',
|
|
306
|
+
name: 'Upsell 01',
|
|
307
|
+
type: 'upsell',
|
|
308
|
+
price: 97,
|
|
309
|
+
currency: 'BRL',
|
|
310
|
+
quantity: 1,
|
|
311
|
+
},
|
|
312
|
+
] },
|
|
313
|
+
checkout: {
|
|
314
|
+
mode: 'single_product',
|
|
315
|
+
selectedItems: [{ productId: "main_offer", quantity: 1 }],
|
|
316
|
+
calculateValueFrom: 'selected_items',
|
|
317
|
+
allowDynamicItems: true,
|
|
318
|
+
},
|
|
319
|
+
mappings: {
|
|
320
|
+
attributes: {
|
|
321
|
+
productId: ['data-product-id', 'data-sku', 'data-offer-id'],
|
|
322
|
+
productName: ['data-product-name', 'data-name'],
|
|
323
|
+
price: ['data-product-price', 'data-price'],
|
|
324
|
+
quantity: ['data-quantity', 'data-qty'],
|
|
325
|
+
currency: ['data-currency'],
|
|
326
|
+
},
|
|
327
|
+
fields: {
|
|
328
|
+
productId: ['productId', 'product_id', 'offerId', 'sku'],
|
|
329
|
+
productName: ['productName', 'product_name'],
|
|
330
|
+
price: ['price', 'amount'],
|
|
331
|
+
quantity: ['quantity', 'qty'],
|
|
332
|
+
currency: ['currency'],
|
|
333
|
+
email: ['email', 'customerEmail'],
|
|
334
|
+
phone: ['phone', 'telefone', 'customerPhone'],
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
manual: {
|
|
339
|
+
pageView: { enabled: false },
|
|
340
|
+
purchase: { enabled: false },
|
|
341
|
+
lead: { enabled: false },
|
|
342
|
+
addToCart: { enabled: false },
|
|
343
|
+
removeFromCart: { enabled: false },
|
|
344
|
+
initiateCheckout: { enabled: true },
|
|
345
|
+
addPaymentInfo: { enabled: false },
|
|
346
|
+
search: { enabled: false },
|
|
347
|
+
viewContent: { enabled: false },
|
|
348
|
+
},
|
|
349
|
+
auto: {
|
|
350
|
+
enabled: true,
|
|
351
|
+
detectors: {
|
|
352
|
+
lead: { enabled: false },
|
|
353
|
+
purchase: { enabled: false },
|
|
354
|
+
addToCart: { enabled: false },
|
|
355
|
+
removeFromCart: { enabled: false },
|
|
356
|
+
initiateCheckout: initiateCheckoutDetectorConfig(),
|
|
357
|
+
addPaymentInfo: { enabled: false },
|
|
358
|
+
search: { enabled: false },
|
|
359
|
+
viewContent: { enabled: false },
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
rules: {
|
|
363
|
+
enabled: false,
|
|
364
|
+
selectors: [],
|
|
365
|
+
texts: [],
|
|
366
|
+
urlPatterns: [],
|
|
367
|
+
checkout: { enabled: false },
|
|
368
|
+
card: { enabled: false },
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function appendLog(message) {
|
|
376
|
+
const line = '[' + new Date().toISOString() + '] ' + message;
|
|
377
|
+
const prev = els.logs.textContent;
|
|
378
|
+
els.logs.textContent =
|
|
379
|
+
prev === 'Aguardando eventos...' ? line : line + '\n' + prev;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function renderCounts() {
|
|
383
|
+
const lines = Object.keys(counts)
|
|
384
|
+
.sort()
|
|
385
|
+
.map(function (type) { return type + ': ' + counts[type]; });
|
|
386
|
+
els.counts.textContent =
|
|
387
|
+
lines.length > 0 ? lines.join('\n') : 'Nenhum evento ainda';
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function renderSnapshot(event) {
|
|
391
|
+
if (!els.snapshot) return;
|
|
392
|
+
if (!event || event.type !== 'INITIATE_CHECKOUT') {
|
|
393
|
+
els.snapshot.textContent = 'null';
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
var d = event.data || {};
|
|
397
|
+
els.snapshot.textContent = JSON.stringify(
|
|
398
|
+
{
|
|
399
|
+
value: d.value,
|
|
400
|
+
currency: d.currency,
|
|
401
|
+
numItems: d.numItems,
|
|
402
|
+
items: d.items,
|
|
403
|
+
},
|
|
404
|
+
null,
|
|
405
|
+
2
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function renderDebug() {
|
|
410
|
+
const detectors =
|
|
411
|
+
pixel && pixel.getDebugActiveDetectors
|
|
412
|
+
? pixel.getDebugActiveDetectors()
|
|
413
|
+
: [];
|
|
414
|
+
els.detectors.textContent =
|
|
415
|
+
detectors.length > 0 ? detectors.join('\n') : 'Nenhum detector ativo';
|
|
416
|
+
if (els.dedupe) {
|
|
417
|
+
const keys =
|
|
418
|
+
pixel && pixel.getDebugDedupeKeys ? pixel.getDebugDedupeKeys() : [];
|
|
419
|
+
els.dedupe.textContent =
|
|
420
|
+
keys.length > 0 ? keys.join('\n') : 'Nenhuma chave';
|
|
421
|
+
}
|
|
422
|
+
els.runtime.textContent =
|
|
423
|
+
'initialized: ' +
|
|
424
|
+
(pixel ? pixel.isInitialized() : false) +
|
|
425
|
+
'\ninit count: ' +
|
|
426
|
+
initCount +
|
|
427
|
+
'\ndestroy count: ' +
|
|
428
|
+
destroyCount +
|
|
429
|
+
'\npixelId: ' +
|
|
430
|
+
PIXEL_ID +
|
|
431
|
+
'\nscenario: trigger: auto · selectorForm';
|
|
432
|
+
els.pill.textContent =
|
|
433
|
+
pixel && pixel.isInitialized() ? 'ready' : 'offline';
|
|
434
|
+
els.pill.className =
|
|
435
|
+
'pill' + (pixel && pixel.isInitialized() ? ' ok' : '');
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function onEvent(event) {
|
|
439
|
+
counts[event.type] = (counts[event.type] || 0) + 1;
|
|
440
|
+
renderCounts();
|
|
441
|
+
renderSnapshot(event);
|
|
442
|
+
els.last.textContent = JSON.stringify(event, null, 2);
|
|
443
|
+
appendLog(event.type + ' ' + JSON.stringify(event.data || {}));
|
|
444
|
+
renderDebug();
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
async function boot() {
|
|
448
|
+
if (unsubscribe) { unsubscribe(); unsubscribe = null; }
|
|
449
|
+
if (pixel) {
|
|
450
|
+
await pixel.destroy();
|
|
451
|
+
destroyCount += 1;
|
|
452
|
+
pixel = null;
|
|
453
|
+
}
|
|
454
|
+
pixel = new Pixel(buildConfig());
|
|
455
|
+
await pixel.init();
|
|
456
|
+
initCount += 1;
|
|
457
|
+
const services = pixel.getDebugServices();
|
|
458
|
+
if (services && services.dispatcher) {
|
|
459
|
+
unsubscribe = services.dispatcher.subscribe(onEvent);
|
|
460
|
+
}
|
|
461
|
+
appendLog('Pixel initialized — trigger: auto · selectorForm');
|
|
462
|
+
renderDebug();
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
async function destroyPixel() {
|
|
466
|
+
if (unsubscribe) { unsubscribe(); unsubscribe = null; }
|
|
467
|
+
if (pixel) {
|
|
468
|
+
await pixel.destroy();
|
|
469
|
+
destroyCount += 1;
|
|
470
|
+
pixel = null;
|
|
471
|
+
}
|
|
472
|
+
appendLog('Pixel destroyed');
|
|
473
|
+
renderDebug();
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
document.getElementById('btn-reinit').onclick = function () { boot(); };
|
|
477
|
+
document.getElementById('btn-destroy').onclick = function () { destroyPixel(); };
|
|
478
|
+
document.getElementById('btn-clear').onclick = function () {
|
|
479
|
+
els.logs.textContent = 'Aguardando eventos...';
|
|
480
|
+
els.last.textContent = 'null';
|
|
481
|
+
if (els.snapshot) els.snapshot.textContent = 'null';
|
|
482
|
+
Object.keys(counts).forEach(function (k) { delete counts[k]; });
|
|
483
|
+
renderCounts();
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
boot();
|
|
489
|
+
</script>
|
|
490
|
+
</body>
|
|
491
|
+
</html>
|