@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,479 @@
|
|
|
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 — Conversion Playground</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
font-family: system-ui, sans-serif;
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 2rem;
|
|
12
|
+
max-width: 960px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.hint {
|
|
16
|
+
background: #ecfdf5;
|
|
17
|
+
border: 1px solid #a7f3d0;
|
|
18
|
+
border-radius: 8px;
|
|
19
|
+
padding: 1rem;
|
|
20
|
+
margin-bottom: 1rem;
|
|
21
|
+
font-size: 14px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.actions {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
gap: 0.5rem;
|
|
28
|
+
margin: 1rem 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
button {
|
|
32
|
+
padding: 0.5rem 1rem;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.panels {
|
|
37
|
+
display: grid;
|
|
38
|
+
grid-template-columns: 1fr 1fr;
|
|
39
|
+
gap: 1rem;
|
|
40
|
+
margin: 1rem 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@media (max-width: 700px) {
|
|
44
|
+
.panels {
|
|
45
|
+
grid-template-columns: 1fr;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.panel {
|
|
50
|
+
font-family: ui-monospace, monospace;
|
|
51
|
+
font-size: 12px;
|
|
52
|
+
border-radius: 8px;
|
|
53
|
+
padding: 1rem;
|
|
54
|
+
background: #f4f4f5;
|
|
55
|
+
border: 1px solid #e4e4e7;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.panel h3 {
|
|
59
|
+
margin: 0 0 0.75rem;
|
|
60
|
+
font-size: 13px;
|
|
61
|
+
font-family: system-ui, sans-serif;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.panel pre {
|
|
65
|
+
margin: 0;
|
|
66
|
+
white-space: pre-wrap;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#logs {
|
|
70
|
+
background: #18181b;
|
|
71
|
+
color: #fafafa;
|
|
72
|
+
min-height: 200px;
|
|
73
|
+
overflow: auto;
|
|
74
|
+
margin-top: 1rem;
|
|
75
|
+
border-radius: 8px;
|
|
76
|
+
padding: 1rem;
|
|
77
|
+
font-family: ui-monospace, monospace;
|
|
78
|
+
font-size: 12px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.auto-zone {
|
|
82
|
+
border: 2px dashed #86efac;
|
|
83
|
+
padding: 1rem;
|
|
84
|
+
margin: 1rem 0;
|
|
85
|
+
border-radius: 8px;
|
|
86
|
+
}
|
|
87
|
+
</style>
|
|
88
|
+
</head>
|
|
89
|
+
<body>
|
|
90
|
+
<h1>Pixel v2 — Conversion Tracking</h1>
|
|
91
|
+
|
|
92
|
+
<div class="hint">
|
|
93
|
+
Manual tracks via API pública + auto detectors (selector, text, url,
|
|
94
|
+
checkout). Eventos publicados somente no Dispatcher — sem envio à API.
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<div class="actions">
|
|
98
|
+
<button id="reinit" type="button">Reinitialize</button>
|
|
99
|
+
<button id="destroy" type="button">Destroy</button>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<h2>Manual Tracks</h2>
|
|
103
|
+
<div class="actions">
|
|
104
|
+
<button id="btn-purchase" type="button">purchase()</button>
|
|
105
|
+
<button id="btn-lead" type="button">lead()</button>
|
|
106
|
+
<button id="btn-cart" type="button">addToCart()</button>
|
|
107
|
+
<button id="btn-remove" type="button">removeFromCart()</button>
|
|
108
|
+
<button id="btn-checkout" type="button">initiateCheckout()</button>
|
|
109
|
+
<button id="btn-payment" type="button">addPaymentInfo()</button>
|
|
110
|
+
<button id="btn-view" type="button">viewContent()</button>
|
|
111
|
+
<button id="btn-search" type="button">search()</button>
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
<div class="auto-zone">
|
|
115
|
+
<strong>Auto detectors</strong>
|
|
116
|
+
<div class="actions">
|
|
117
|
+
<button data-track="purchase" type="button">data-track=purchase</button>
|
|
118
|
+
<button type="button">Finalizar Compra</button>
|
|
119
|
+
<button id="btn-url" type="button">Simulate thank-you URL</button>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<div class="panels">
|
|
124
|
+
<div class="panel">
|
|
125
|
+
<h3>Event Counts</h3>
|
|
126
|
+
<pre id="event-counts">Nenhum evento ainda</pre>
|
|
127
|
+
</div>
|
|
128
|
+
<div class="panel">
|
|
129
|
+
<h3>Runtime Debug</h3>
|
|
130
|
+
<pre id="runtime-debug">Aguardando...</pre>
|
|
131
|
+
</div>
|
|
132
|
+
<div class="panel">
|
|
133
|
+
<h3>Dedupe State</h3>
|
|
134
|
+
<pre id="dedupe-state">Nenhuma chave deduplicada</pre>
|
|
135
|
+
</div>
|
|
136
|
+
<div class="panel">
|
|
137
|
+
<h3>Active Detectors</h3>
|
|
138
|
+
<pre id="detector-state">Nenhum detector ativo</pre>
|
|
139
|
+
</div>
|
|
140
|
+
<div class="panel">
|
|
141
|
+
<h3>Detector Status</h3>
|
|
142
|
+
<pre id="detector-status">Aguardando init...</pre>
|
|
143
|
+
</div>
|
|
144
|
+
<div class="panel" style="grid-column: 1 / -1">
|
|
145
|
+
<h3>Conversion State</h3>
|
|
146
|
+
<pre id="conversion-state">Aguardando eventos...</pre>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
<pre id="logs"></pre>
|
|
151
|
+
|
|
152
|
+
<script src="../../dist/v2/global.global.js"></script>
|
|
153
|
+
<script>
|
|
154
|
+
const { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
|
|
155
|
+
|
|
156
|
+
const API_ENDPOINT =
|
|
157
|
+
'https://micro-service-pixel-production-4826.up.railway.app';
|
|
158
|
+
const PIXEL_ID = 'pix_7315610';
|
|
159
|
+
|
|
160
|
+
const logsEl = document.getElementById('logs');
|
|
161
|
+
const eventCountsEl = document.getElementById('event-counts');
|
|
162
|
+
const runtimeDebugEl = document.getElementById('runtime-debug');
|
|
163
|
+
const conversionStateEl = document.getElementById('conversion-state');
|
|
164
|
+
const dedupeStateEl = document.getElementById('dedupe-state');
|
|
165
|
+
const detectorStateEl = document.getElementById('detector-state');
|
|
166
|
+
const detectorStatusEl = document.getElementById('detector-status');
|
|
167
|
+
|
|
168
|
+
let pixel = null;
|
|
169
|
+
let unsubscribe = null;
|
|
170
|
+
let initCount = 0;
|
|
171
|
+
let destroyCount = 0;
|
|
172
|
+
const counts = {};
|
|
173
|
+
const lastEvents = {};
|
|
174
|
+
|
|
175
|
+
function appendLog(message) {
|
|
176
|
+
const line = '[' + new Date().toISOString() + '] ' + message;
|
|
177
|
+
logsEl.textContent = line + '\n' + logsEl.textContent;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function bump(type) {
|
|
181
|
+
counts[type] = (counts[type] || 0) + 1;
|
|
182
|
+
renderEventCounts();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function renderEventCounts() {
|
|
186
|
+
const lines = Object.keys(counts)
|
|
187
|
+
.sort()
|
|
188
|
+
.map(function (type) {
|
|
189
|
+
return type + ': ' + counts[type];
|
|
190
|
+
});
|
|
191
|
+
eventCountsEl.textContent =
|
|
192
|
+
lines.length > 0 ? lines.join('\n') : 'Nenhum evento ainda';
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function renderConversionState() {
|
|
196
|
+
const lines = Object.keys(lastEvents)
|
|
197
|
+
.sort()
|
|
198
|
+
.map(function (type) {
|
|
199
|
+
return type + ':\n' + JSON.stringify(lastEvents[type], null, 2);
|
|
200
|
+
});
|
|
201
|
+
conversionStateEl.textContent =
|
|
202
|
+
lines.length > 0 ? lines.join('\n\n') : 'Aguardando eventos...';
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function renderDetectorState() {
|
|
206
|
+
const detectors =
|
|
207
|
+
pixel && pixel.getDebugActiveDetectors
|
|
208
|
+
? pixel.getDebugActiveDetectors()
|
|
209
|
+
: [];
|
|
210
|
+
detectorStateEl.textContent =
|
|
211
|
+
detectors.length > 0
|
|
212
|
+
? 'active (' + detectors.length + '):\n' + detectors.join('\n')
|
|
213
|
+
: 'Nenhum detector ativo';
|
|
214
|
+
detectorStatusEl.textContent =
|
|
215
|
+
'engine active: ' +
|
|
216
|
+
(pixel && pixel.isInitialized ? pixel.isInitialized() : false) +
|
|
217
|
+
'\nauto.enabled: true\nrules.enabled: true';
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function renderDedupeState() {
|
|
221
|
+
const keys =
|
|
222
|
+
pixel && pixel.getDebugDedupeKeys ? pixel.getDebugDedupeKeys() : [];
|
|
223
|
+
dedupeStateEl.textContent =
|
|
224
|
+
keys.length > 0
|
|
225
|
+
? 'keys (' + keys.length + '):\n' + keys.join('\n')
|
|
226
|
+
: 'Nenhuma chave deduplicada';
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function renderRuntimeDebug() {
|
|
230
|
+
const services = pixel ? pixel.getDebugServices() : null;
|
|
231
|
+
runtimeDebugEl.textContent =
|
|
232
|
+
'initialized: ' +
|
|
233
|
+
(pixel ? pixel.isInitialized() : false) +
|
|
234
|
+
'\ninit count: ' +
|
|
235
|
+
initCount +
|
|
236
|
+
'\ndestroy count: ' +
|
|
237
|
+
destroyCount +
|
|
238
|
+
'\ndispatcher listeners: ' +
|
|
239
|
+
(services ? services.dispatcher.getListenerCount() : 0);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function conversionConfig() {
|
|
243
|
+
const cfg = {
|
|
244
|
+
senderMode: 'http',
|
|
245
|
+
timeoutMs: 10000,
|
|
246
|
+
maxAttempts: 4,
|
|
247
|
+
batchSize: 3,
|
|
248
|
+
};
|
|
249
|
+
const useHttp = cfg.senderMode === 'http';
|
|
250
|
+
return {
|
|
251
|
+
...DEFAULT_PIXEL_CONFIG,
|
|
252
|
+
app: { ...DEFAULT_PIXEL_CONFIG.app, debug: true },
|
|
253
|
+
identity: {
|
|
254
|
+
...DEFAULT_PIXEL_CONFIG.identity,
|
|
255
|
+
pixelId: PIXEL_ID,
|
|
256
|
+
},
|
|
257
|
+
transport: {
|
|
258
|
+
...DEFAULT_PIXEL_CONFIG.transport,
|
|
259
|
+
apiEndpoint: API_ENDPOINT,
|
|
260
|
+
timeoutMs: cfg.timeoutMs,
|
|
261
|
+
},
|
|
262
|
+
modules: {
|
|
263
|
+
...DEFAULT_PIXEL_CONFIG.modules,
|
|
264
|
+
core: { ...DEFAULT_PIXEL_CONFIG.modules.core, enabled: false },
|
|
265
|
+
behavior: {
|
|
266
|
+
...DEFAULT_PIXEL_CONFIG.modules.behavior,
|
|
267
|
+
enabled: false,
|
|
268
|
+
},
|
|
269
|
+
conversion: {
|
|
270
|
+
enabled: true,
|
|
271
|
+
manual: {
|
|
272
|
+
pageView: { enabled: false },
|
|
273
|
+
purchase: { enabled: true },
|
|
274
|
+
lead: { enabled: true },
|
|
275
|
+
addToCart: { enabled: true },
|
|
276
|
+
removeFromCart: { enabled: true },
|
|
277
|
+
initiateCheckout: { enabled: true },
|
|
278
|
+
addPaymentInfo: { enabled: true },
|
|
279
|
+
search: { enabled: true },
|
|
280
|
+
viewContent: { enabled: true },
|
|
281
|
+
},
|
|
282
|
+
auto: {
|
|
283
|
+
enabled: true,
|
|
284
|
+
detectors:
|
|
285
|
+
DEFAULT_PIXEL_CONFIG.modules.conversion.auto.detectors,
|
|
286
|
+
},
|
|
287
|
+
rules: {
|
|
288
|
+
enabled: true,
|
|
289
|
+
selectors: ['[data-track]'],
|
|
290
|
+
texts: [
|
|
291
|
+
'Comprar',
|
|
292
|
+
'Comprar Agora',
|
|
293
|
+
'Finalizar Compra',
|
|
294
|
+
'Checkout',
|
|
295
|
+
],
|
|
296
|
+
urlPatterns: [
|
|
297
|
+
'thank-you',
|
|
298
|
+
'purchase',
|
|
299
|
+
'success',
|
|
300
|
+
'order',
|
|
301
|
+
'checkout',
|
|
302
|
+
],
|
|
303
|
+
checkout: { enabled: true },
|
|
304
|
+
card: { enabled: false },
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
transport: {
|
|
308
|
+
enabled: true,
|
|
309
|
+
mockSender: { enabled: false },
|
|
310
|
+
sender: { mode: 'http' },
|
|
311
|
+
persistence: { enabled: true },
|
|
312
|
+
replay: { enabled: true },
|
|
313
|
+
ordering: { enabled: true },
|
|
314
|
+
coordination: { enabled: true },
|
|
315
|
+
circuitBreaker: {
|
|
316
|
+
enabled: true,
|
|
317
|
+
failureThreshold: 5,
|
|
318
|
+
resetTimeoutMs: 30000,
|
|
319
|
+
halfOpenMaxAttempts: 2,
|
|
320
|
+
},
|
|
321
|
+
backpressure: {
|
|
322
|
+
enabled: true,
|
|
323
|
+
maxQueueSize: 500,
|
|
324
|
+
policy: 'drop_oldest',
|
|
325
|
+
sampleRate: 0.5,
|
|
326
|
+
},
|
|
327
|
+
deadLetter: { enabled: true, maxEntries: 200 },
|
|
328
|
+
compression: { enabled: true, strategy: 'identity' },
|
|
329
|
+
retry: {
|
|
330
|
+
enabled: true,
|
|
331
|
+
maxAttempts: cfg.maxAttempts,
|
|
332
|
+
baseDelayMs: 500,
|
|
333
|
+
maxDelayMs: 4000,
|
|
334
|
+
multiplier: 2,
|
|
335
|
+
},
|
|
336
|
+
batch: {
|
|
337
|
+
enabled: true,
|
|
338
|
+
batchSize: cfg.batchSize,
|
|
339
|
+
flushIntervalMs: 2000,
|
|
340
|
+
maxWaitMs: 5000,
|
|
341
|
+
},
|
|
342
|
+
timeout: { enabled: true, timeoutMs: cfg.timeoutMs },
|
|
343
|
+
offline: { enabled: true },
|
|
344
|
+
flush: {
|
|
345
|
+
enabled: true,
|
|
346
|
+
flushIntervalMs: 2000,
|
|
347
|
+
flushOnDestroy: true,
|
|
348
|
+
prepareUnloadHooks: true,
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
async function initPixel() {
|
|
356
|
+
if (pixel) {
|
|
357
|
+
await pixel.destroy();
|
|
358
|
+
destroyCount += 1;
|
|
359
|
+
pixel = null;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (unsubscribe) {
|
|
363
|
+
unsubscribe();
|
|
364
|
+
unsubscribe = null;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
Object.keys(counts).forEach(function (key) {
|
|
368
|
+
delete counts[key];
|
|
369
|
+
});
|
|
370
|
+
Object.keys(lastEvents).forEach(function (key) {
|
|
371
|
+
delete lastEvents[key];
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
pixel = new Pixel(conversionConfig());
|
|
375
|
+
await pixel.init();
|
|
376
|
+
initCount += 1;
|
|
377
|
+
|
|
378
|
+
const services = pixel.getDebugServices();
|
|
379
|
+
if (services) {
|
|
380
|
+
unsubscribe = services.dispatcher.subscribe(function (event) {
|
|
381
|
+
bump(event.type);
|
|
382
|
+
lastEvents[event.type] = event;
|
|
383
|
+
appendLog('Dispatcher: ' + event.type);
|
|
384
|
+
console.log('[Pixel v2 Conversion]', event.type, event);
|
|
385
|
+
renderConversionState();
|
|
386
|
+
renderRuntimeDebug();
|
|
387
|
+
renderDedupeState();
|
|
388
|
+
renderDetectorState();
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
appendLog('Conversion playground initialized');
|
|
393
|
+
renderEventCounts();
|
|
394
|
+
renderConversionState();
|
|
395
|
+
renderRuntimeDebug();
|
|
396
|
+
renderDedupeState();
|
|
397
|
+
renderDetectorState();
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
document.getElementById('reinit').addEventListener('click', function () {
|
|
401
|
+
initPixel().catch(function (e) {
|
|
402
|
+
appendLog('Init error: ' + String(e));
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
document
|
|
407
|
+
.getElementById('destroy')
|
|
408
|
+
.addEventListener('click', async function () {
|
|
409
|
+
if (!pixel) return;
|
|
410
|
+
await pixel.destroy();
|
|
411
|
+
destroyCount += 1;
|
|
412
|
+
pixel = null;
|
|
413
|
+
if (unsubscribe) unsubscribe();
|
|
414
|
+
appendLog('Pixel destroyed');
|
|
415
|
+
renderRuntimeDebug();
|
|
416
|
+
renderDedupeState();
|
|
417
|
+
renderDetectorState();
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
document
|
|
421
|
+
.getElementById('btn-purchase')
|
|
422
|
+
.addEventListener('click', function () {
|
|
423
|
+
pixel?.purchase({
|
|
424
|
+
value: 199.9,
|
|
425
|
+
currency: 'BRL',
|
|
426
|
+
orderId: 'ORD-' + Date.now(),
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
document
|
|
430
|
+
.getElementById('btn-lead')
|
|
431
|
+
.addEventListener('click', function () {
|
|
432
|
+
pixel?.lead({ email: 'lead@example.com', name: 'Lead Test' });
|
|
433
|
+
});
|
|
434
|
+
document
|
|
435
|
+
.getElementById('btn-cart')
|
|
436
|
+
.addEventListener('click', function () {
|
|
437
|
+
pixel?.addToCart({
|
|
438
|
+
productId: 'sku-1',
|
|
439
|
+
productName: 'Produto',
|
|
440
|
+
quantity: 1,
|
|
441
|
+
price: 49,
|
|
442
|
+
});
|
|
443
|
+
});
|
|
444
|
+
document
|
|
445
|
+
.getElementById('btn-remove')
|
|
446
|
+
.addEventListener('click', function () {
|
|
447
|
+
pixel?.removeFromCart({ productId: 'sku-1', quantity: 1 });
|
|
448
|
+
});
|
|
449
|
+
document
|
|
450
|
+
.getElementById('btn-checkout')
|
|
451
|
+
.addEventListener('click', function () {
|
|
452
|
+
pixel?.initiateCheckout({ value: 149, currency: 'BRL' });
|
|
453
|
+
});
|
|
454
|
+
document
|
|
455
|
+
.getElementById('btn-payment')
|
|
456
|
+
.addEventListener('click', function () {
|
|
457
|
+
pixel?.addPaymentInfo({ paymentMethod: 'CREDIT_CARD' });
|
|
458
|
+
});
|
|
459
|
+
document
|
|
460
|
+
.getElementById('btn-view')
|
|
461
|
+
.addEventListener('click', function () {
|
|
462
|
+
pixel?.viewContent({ contentId: 'page-home', contentType: 'page' });
|
|
463
|
+
});
|
|
464
|
+
document
|
|
465
|
+
.getElementById('btn-search')
|
|
466
|
+
.addEventListener('click', function () {
|
|
467
|
+
pixel?.search({ query: 'tenis corrida' });
|
|
468
|
+
});
|
|
469
|
+
document.getElementById('btn-url').addEventListener('click', function () {
|
|
470
|
+
history.pushState({}, '', '/thank-you?order=123');
|
|
471
|
+
appendLog('URL changed to /thank-you');
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
initPixel().catch(function (e) {
|
|
475
|
+
appendLog('Bootstrap error: ' + String(e));
|
|
476
|
+
});
|
|
477
|
+
</script>
|
|
478
|
+
</body>
|
|
479
|
+
</html>
|