@beworke/pixel 0.1.0-rc.7 → 0.1.0-rc.9
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 +33 -0
- package/README.md +71 -56
- package/RELEASE_CANDIDATE.md +28 -62
- package/dist/Pixel-BnN86r4X.d.ts +797 -0
- package/dist/Pixel-BoUGqCbP.d.mts +797 -0
- package/dist/{StorageFactory-DeMaZ8wk.d.ts → StorageFactory-BfCArzMM.d.ts} +1 -1
- package/dist/{StorageFactory-Cq29vF32.d.mts → StorageFactory-C0prtNR7.d.mts} +1 -1
- package/dist/browser/index.cjs.js +3 -0
- package/dist/browser/index.cjs.js.map +1 -0
- package/dist/browser/index.d.mts +55 -0
- package/dist/browser/index.d.ts +55 -0
- package/dist/browser/index.esm.js +3 -0
- package/dist/browser/index.esm.js.map +1 -0
- package/dist/browser/pixel.global.js +4 -0
- package/dist/browser/pixel.global.js.map +1 -0
- package/dist/config/index.cjs.js +1 -1
- package/dist/config/index.cjs.js.map +1 -1
- package/dist/config/index.d.mts +15 -5
- package/dist/config/index.d.ts +15 -5
- package/dist/config/index.esm.js +1 -1
- package/dist/config/index.esm.js.map +1 -1
- package/dist/examples/html-script/RELEASE_CANDIDATE.md +6 -8
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-autocomplete.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-disabled.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-fields.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-data-track.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-dedupe.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-manual.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-rules-card.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-security.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-attribute.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-auto.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-click.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-dedupe.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-link.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-manual.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-order-bump.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-text.html +40 -47
- package/dist/examples/html-script/behavior/example-behavior-engagement.html +4 -4
- package/dist/examples/html-script/behavior/example-behavior-heartbeat.html +4 -4
- package/dist/examples/html-script/behavior/example-behavior-runtime-intelligence.html +4 -4
- package/dist/examples/html-script/behavior/example-behavior-viewport.html +4 -4
- package/dist/examples/html-script/buygoods/example-buygoods-checkout.html +156 -0
- package/dist/examples/html-script/example-checkout-commerce.html +31 -30
- package/dist/examples/html-script/example-conversion.html +41 -48
- package/dist/examples/html-script/example-global-factory-classic.html +45 -0
- package/dist/examples/html-script/example-global-factory.html +40 -0
- package/dist/examples/html-script/example-integration.html +39 -45
- package/dist/examples/html-script/example-landing-commerce.html +3 -8
- package/dist/examples/html-script/example-runtime-diagnostics.html +4 -4
- package/dist/examples/html-script/example-transport.html +59 -57
- package/dist/examples/html-script/full-funnel/checkout.html +3 -1
- package/dist/examples/html-script/full-funnel/downsell.html +3 -1
- package/dist/examples/html-script/full-funnel/landing.html +3 -1
- package/dist/examples/html-script/full-funnel/thank-you.html +3 -1
- package/dist/examples/html-script/full-funnel/upsell.html +3 -1
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-attribute.html +40 -47
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-auto.html +40 -47
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-click.html +40 -47
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-manual.html +40 -47
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-snapshot.html +40 -47
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-submit.html +40 -47
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-text.html +40 -47
- package/dist/examples/html-script/lead/example-lead-trigger-attribute.html +40 -47
- package/dist/examples/html-script/lead/example-lead-trigger-auto.html +40 -47
- package/dist/examples/html-script/lead/example-lead-trigger-click.html +40 -47
- package/dist/examples/html-script/release-candidate.html +31 -30
- package/dist/examples/html-script/remove-from-cart/README.md +3 -3
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-attribute.html +40 -47
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-css.html +40 -47
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-dedupe.html +47 -54
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-manual.html +40 -47
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-multi.html +40 -47
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-state.html +40 -47
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-text.html +40 -47
- package/dist/examples/html-script/search/example-search-attribute.html +40 -47
- package/dist/examples/html-script/search/example-search-button-sync.html +40 -47
- package/dist/examples/html-script/search/example-search-dedupe.html +40 -47
- package/dist/examples/html-script/search/example-search-input.html +40 -47
- package/dist/examples/html-script/search/example-search-manual.html +40 -47
- package/dist/examples/html-script/search/example-search-submit.html +40 -47
- package/dist/examples/html-script/search/example-search-text.html +40 -47
- package/dist/examples/html-script/url-context/example-url-context-allowed-domains.html +4 -4
- package/dist/examples/html-script/url-context/example-url-context-landing.html +4 -4
- package/dist/examples/html-script/url-context/example-url-context-upsell.html +4 -4
- package/dist/examples/html-script/url-context/example-url-context.html +4 -4
- package/dist/examples/html-script/view-content/example-view-content-attribute.html +40 -47
- package/dist/examples/html-script/view-content/example-view-content-css.html +40 -47
- package/dist/examples/html-script/view-content/example-view-content-dedupe.html +40 -47
- package/dist/examples/html-script/view-content/example-view-content-empty.html +40 -47
- package/dist/examples/html-script/view-content/example-view-content-manual.html +40 -47
- package/dist/examples/html-script/view-content/example-view-content-product-card.html +40 -47
- package/dist/examples/html-script/view-content/example-view-content-text.html +40 -47
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/{pixel-2uL4LSyC.d.ts → pixel-DNGbAN5C.d.ts} +117 -98
- package/dist/{pixel-DMwpppf_.d.mts → pixel-_BSDpx4M.d.mts} +117 -98
- package/dist/pixel-default-config-BMYaqs7i.d.ts +21 -0
- package/dist/pixel-default-config-DLRya1tl.d.mts +21 -0
- package/dist/pixel-settings-D-t9zQb4.d.ts +40 -0
- package/dist/pixel-settings-DGxl0MVm.d.mts +40 -0
- package/dist/runtime/index.cjs.js +1 -1
- package/dist/runtime/index.cjs.js.map +1 -1
- package/dist/runtime/index.d.mts +4 -4
- package/dist/runtime/index.d.ts +4 -4
- package/dist/runtime/index.esm.js +1 -1
- package/dist/runtime/index.esm.js.map +1 -1
- package/dist/services/index.cjs.js +1 -1
- package/dist/services/index.cjs.js.map +1 -1
- package/dist/services/index.d.mts +4 -4
- package/dist/services/index.d.ts +4 -4
- package/dist/services/index.esm.js +1 -1
- package/dist/services/index.esm.js.map +1 -1
- package/dist/{types-6HF3UlsL.d.mts → types-B-Nzagpk.d.mts} +2 -2
- package/dist/{types-CgrabttM.d.mts → types-D0KVsgzs.d.mts} +1 -1
- package/dist/{types-fFcQ1apy.d.ts → types-D3kJ9bfT.d.ts} +1 -1
- package/dist/{types-BqUEoZo0.d.ts → types-Dfi9C49l.d.ts} +2 -2
- package/dist/v2/global.global.js +1 -1
- package/dist/v2/global.global.js.map +1 -1
- package/dist/v2/index.cjs.js +1 -1
- package/dist/v2/index.cjs.js.map +1 -1
- package/dist/v2/index.d.mts +21 -787
- package/dist/v2/index.d.ts +21 -787
- package/dist/v2/index.esm.js +1 -1
- package/dist/v2/index.esm.js.map +1 -1
- package/docs/public/README.md +7 -4
- package/docs/public/api/exports.md +12 -8
- package/docs/public/api/pixel.md +27 -6
- package/docs/public/configuration/commerce.md +2 -2
- package/docs/public/configuration/modules.md +11 -14
- package/docs/public/configuration/overview.md +45 -26
- package/docs/public/configuration/transport.md +127 -0
- package/docs/public/events/catalog.md +3 -1
- package/docs/public/getting-started/installation.md +14 -12
- package/docs/public/getting-started/quick-start.md +95 -30
- package/docs/public/getting-started/react-nextjs.md +57 -34
- package/docs/public/getting-started/script-tag.md +55 -32
- package/docs/public/guides/funnel-checkout.md +1 -1
- package/docs/public/guides/funnel-landing.md +9 -7
- package/docs/public/limitations.md +5 -4
- package/docs/public/privacy/limitations.md +6 -6
- package/docs/public/release-candidate/validation.md +4 -4
- package/docs/public/troubleshooting.md +7 -6
- package/package.json +8 -3
- package/dist/pixel-default-config-BDPUVHse.d.ts +0 -5
- package/dist/pixel-default-config-C5uLt52W.d.mts +0 -5
|
@@ -163,8 +163,8 @@
|
|
|
163
163
|
<div>
|
|
164
164
|
<label for="sender-mode">Sender</label>
|
|
165
165
|
<select id="sender-mode">
|
|
166
|
-
<option value="
|
|
167
|
-
<option value="
|
|
166
|
+
<option value="internal">Internal (endpoint público)</option>
|
|
167
|
+
<option value="test">Test (sem rede)</option>
|
|
168
168
|
</select>
|
|
169
169
|
</div>
|
|
170
170
|
</div>
|
|
@@ -471,11 +471,11 @@
|
|
|
471
471
|
var pixelId = pixelIdInput.value.trim();
|
|
472
472
|
var batchMode = document.getElementById('batch-mode').value;
|
|
473
473
|
var senderMode = document.getElementById('sender-mode').value;
|
|
474
|
-
var
|
|
474
|
+
var useInternal = senderMode === 'internal';
|
|
475
475
|
var batchSize = batchMode === 'batch' ? 10 : 1;
|
|
476
476
|
|
|
477
|
-
if (
|
|
478
|
-
throw new Error('Preencha PIXEL_API_ENDPOINT e PIXEL_ID para sender
|
|
477
|
+
if (useInternal && (!endpoint || !pixelId)) {
|
|
478
|
+
throw new Error('Preencha PIXEL_API_ENDPOINT e PIXEL_ID para sender internal.');
|
|
479
479
|
}
|
|
480
480
|
|
|
481
481
|
return {
|
|
@@ -492,8 +492,25 @@
|
|
|
492
492
|
},
|
|
493
493
|
transport: {
|
|
494
494
|
...DEFAULT_PIXEL_CONFIG.transport,
|
|
495
|
-
|
|
496
|
-
|
|
495
|
+
enabled: true,
|
|
496
|
+
sender: useInternal
|
|
497
|
+
? { mode: 'internal', baseUrl: endpoint }
|
|
498
|
+
: { mode: 'test', capture: true },
|
|
499
|
+
batch: {
|
|
500
|
+
...DEFAULT_PIXEL_CONFIG.transport.batch,
|
|
501
|
+
enabled: true,
|
|
502
|
+
batchSize: batchSize,
|
|
503
|
+
maxWaitMs: batchMode === 'batch' ? 8000 : 500,
|
|
504
|
+
},
|
|
505
|
+
flush: {
|
|
506
|
+
...DEFAULT_PIXEL_CONFIG.transport.flush,
|
|
507
|
+
flushOnDestroy: true,
|
|
508
|
+
},
|
|
509
|
+
timeout: {
|
|
510
|
+
...DEFAULT_PIXEL_CONFIG.transport.timeout,
|
|
511
|
+
timeoutMs: 15000,
|
|
512
|
+
},
|
|
513
|
+
coordination: { enabled: false },
|
|
497
514
|
},
|
|
498
515
|
commerce: {
|
|
499
516
|
enabled: true,
|
|
@@ -663,29 +680,6 @@
|
|
|
663
680
|
enabled: false,
|
|
664
681
|
},
|
|
665
682
|
},
|
|
666
|
-
transport: {
|
|
667
|
-
...DEFAULT_PIXEL_CONFIG.modules.transport,
|
|
668
|
-
enabled: true,
|
|
669
|
-
mockSender: { enabled: !useHttp },
|
|
670
|
-
sender: { mode: useHttp ? 'http' : 'mock' },
|
|
671
|
-
batch: {
|
|
672
|
-
...DEFAULT_PIXEL_CONFIG.modules.transport.batch,
|
|
673
|
-
enabled: true,
|
|
674
|
-
batchSize: batchSize,
|
|
675
|
-
flushIntervalMs: batchMode === 'batch' ? 8000 : 200,
|
|
676
|
-
maxWaitMs: batchMode === 'batch' ? 8000 : 500,
|
|
677
|
-
},
|
|
678
|
-
flush: {
|
|
679
|
-
...DEFAULT_PIXEL_CONFIG.modules.transport.flush,
|
|
680
|
-
flushIntervalMs: batchMode === 'batch' ? 8000 : 200,
|
|
681
|
-
flushOnDestroy: true,
|
|
682
|
-
},
|
|
683
|
-
timeout: {
|
|
684
|
-
...DEFAULT_PIXEL_CONFIG.modules.transport.timeout,
|
|
685
|
-
timeoutMs: 15000,
|
|
686
|
-
},
|
|
687
|
-
coordination: { enabled: false },
|
|
688
|
-
},
|
|
689
683
|
},
|
|
690
684
|
};
|
|
691
685
|
}
|
|
@@ -719,6 +713,13 @@
|
|
|
719
713
|
var Pixel = window.PixelV2.Pixel;
|
|
720
714
|
pixel = new Pixel(buildConfig());
|
|
721
715
|
await pixel.init();
|
|
716
|
+
if (document.getElementById('sender-mode').value === 'test') {
|
|
717
|
+
pixel.configureTransportTestSender({
|
|
718
|
+
capture: true,
|
|
719
|
+
response: 'success',
|
|
720
|
+
delayMs: 0,
|
|
721
|
+
});
|
|
722
|
+
}
|
|
722
723
|
initCount += 1;
|
|
723
724
|
|
|
724
725
|
var services = pixel.getDebugServices();
|
|
@@ -241,12 +241,12 @@
|
|
|
241
241
|
|
|
242
242
|
function conversionConfig() {
|
|
243
243
|
const cfg = {
|
|
244
|
-
senderMode: '
|
|
244
|
+
senderMode: 'internal',
|
|
245
245
|
timeoutMs: 10000,
|
|
246
246
|
maxAttempts: 4,
|
|
247
247
|
batchSize: 3,
|
|
248
248
|
};
|
|
249
|
-
const useHttp = cfg.senderMode === '
|
|
249
|
+
const useHttp = cfg.senderMode === 'internal';
|
|
250
250
|
return {
|
|
251
251
|
...DEFAULT_PIXEL_CONFIG,
|
|
252
252
|
app: { ...DEFAULT_PIXEL_CONFIG.app, debug: true },
|
|
@@ -256,8 +256,45 @@
|
|
|
256
256
|
},
|
|
257
257
|
transport: {
|
|
258
258
|
...DEFAULT_PIXEL_CONFIG.transport,
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
enabled: true,
|
|
260
|
+
sender: { mode: 'internal', baseUrl: API_ENDPOINT },
|
|
261
|
+
persistence: { enabled: true },
|
|
262
|
+
replay: { enabled: true },
|
|
263
|
+
ordering: { enabled: true },
|
|
264
|
+
coordination: { enabled: true },
|
|
265
|
+
circuitBreaker: {
|
|
266
|
+
enabled: true,
|
|
267
|
+
failureThreshold: 5,
|
|
268
|
+
resetTimeoutMs: 30000,
|
|
269
|
+
halfOpenMaxAttempts: 2,
|
|
270
|
+
},
|
|
271
|
+
backpressure: {
|
|
272
|
+
enabled: true,
|
|
273
|
+
maxQueueSize: 500,
|
|
274
|
+
policy: 'drop_oldest',
|
|
275
|
+
sampleRate: 0.5,
|
|
276
|
+
},
|
|
277
|
+
deadLetter: { enabled: true, maxEntries: 200 },
|
|
278
|
+
compression: { enabled: true, strategy: 'identity' },
|
|
279
|
+
retry: {
|
|
280
|
+
enabled: true,
|
|
281
|
+
maxAttempts: cfg.maxAttempts,
|
|
282
|
+
baseDelayMs: 500,
|
|
283
|
+
maxDelayMs: 4000,
|
|
284
|
+
multiplier: 2,
|
|
285
|
+
},
|
|
286
|
+
batch: {
|
|
287
|
+
enabled: true,
|
|
288
|
+
batchSize: cfg.batchSize,
|
|
289
|
+
maxWaitMs: 5000,
|
|
290
|
+
},
|
|
291
|
+
timeout: { enabled: true, timeoutMs: cfg.timeoutMs },
|
|
292
|
+
offline: { enabled: true },
|
|
293
|
+
flush: {
|
|
294
|
+
enabled: true,
|
|
295
|
+
flushOnDestroy: true,
|
|
296
|
+
prepareUnloadHooks: true,
|
|
297
|
+
},
|
|
261
298
|
},
|
|
262
299
|
modules: {
|
|
263
300
|
...DEFAULT_PIXEL_CONFIG.modules,
|
|
@@ -304,50 +341,6 @@
|
|
|
304
341
|
card: { enabled: false },
|
|
305
342
|
},
|
|
306
343
|
},
|
|
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
344
|
},
|
|
352
345
|
};
|
|
353
346
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 base — script clássico</title>
|
|
7
|
+
<script src="../../browser/pixel.global.js"></script>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<h1>Pixel base — script clássico</h1>
|
|
12
|
+
<p>
|
|
13
|
+
Top-level <code>await</code> exige <code>type="module"</code> ou um IIFE
|
|
14
|
+
assíncrono. Este exemplo usa <code>.then()</code>.
|
|
15
|
+
</p>
|
|
16
|
+
<button id="lead-button" type="button" disabled>Enviar lead</button>
|
|
17
|
+
<pre id="status">aguardando init…</pre>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
(function () {
|
|
21
|
+
var status = document.getElementById('status');
|
|
22
|
+
var button = document.getElementById('lead-button');
|
|
23
|
+
|
|
24
|
+
Pixel({
|
|
25
|
+
identity: {
|
|
26
|
+
pixelId: 'pix_public_demo',
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
.then(function (pixel) {
|
|
30
|
+
status.textContent = 'Pixel inicializado';
|
|
31
|
+
button.disabled = false;
|
|
32
|
+
button.addEventListener('click', function () {
|
|
33
|
+
pixel.lead({ email: 'user@example.com' });
|
|
34
|
+
status.textContent = 'lead enviado';
|
|
35
|
+
});
|
|
36
|
+
})
|
|
37
|
+
.catch(function (error) {
|
|
38
|
+
console.error(error);
|
|
39
|
+
status.textContent =
|
|
40
|
+
error && error.message ? error.message : String(error);
|
|
41
|
+
});
|
|
42
|
+
})();
|
|
43
|
+
</script>
|
|
44
|
+
</body>
|
|
45
|
+
</html>
|
|
@@ -0,0 +1,40 @@
|
|
|
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 base — global factory</title>
|
|
7
|
+
<script src="../../browser/pixel.global.js"></script>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<h1>Pixel base — global factory</h1>
|
|
12
|
+
<p>
|
|
13
|
+
O bundle só registra <code>window.Pixel</code>. A inicialização acontece
|
|
14
|
+
quando <code>Pixel(settings)</code> resolve. Informe apenas
|
|
15
|
+
<code>identity.pixelId</code>; o SDK mescla o restante com os defaults.
|
|
16
|
+
</p>
|
|
17
|
+
<button id="lead-button" type="button">Enviar lead</button>
|
|
18
|
+
<pre id="status">aguardando init…</pre>
|
|
19
|
+
|
|
20
|
+
<script type="module">
|
|
21
|
+
const pixel = await Pixel({
|
|
22
|
+
identity: {
|
|
23
|
+
pixelId: 'pix_7315610',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const status = document.getElementById('status');
|
|
28
|
+
status.textContent = pixel.isInitialized()
|
|
29
|
+
? 'Pixel inicializado'
|
|
30
|
+
: 'Pixel não inicializado';
|
|
31
|
+
|
|
32
|
+
document.getElementById('lead-button').addEventListener('click', () => {
|
|
33
|
+
pixel.lead({
|
|
34
|
+
email: 'user@example.com',
|
|
35
|
+
});
|
|
36
|
+
status.textContent = 'lead enviado';
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
|
@@ -379,7 +379,45 @@
|
|
|
379
379
|
identity: { pixelId: PIXEL_ID },
|
|
380
380
|
transport: {
|
|
381
381
|
...DEFAULT_PIXEL_CONFIG.transport,
|
|
382
|
-
|
|
382
|
+
enabled: true,
|
|
383
|
+
sender: { mode: 'internal', baseUrl: API_ENDPOINT },
|
|
384
|
+
persistence: { enabled: true },
|
|
385
|
+
replay: { enabled: true },
|
|
386
|
+
ordering: { enabled: true },
|
|
387
|
+
coordination: { enabled: true },
|
|
388
|
+
circuitBreaker: {
|
|
389
|
+
enabled: true,
|
|
390
|
+
failureThreshold: 5,
|
|
391
|
+
resetTimeoutMs: 30000,
|
|
392
|
+
halfOpenMaxAttempts: 2,
|
|
393
|
+
},
|
|
394
|
+
backpressure: {
|
|
395
|
+
enabled: true,
|
|
396
|
+
maxQueueSize: 500,
|
|
397
|
+
policy: 'drop_oldest',
|
|
398
|
+
sampleRate: 0.5,
|
|
399
|
+
},
|
|
400
|
+
deadLetter: { enabled: true, maxEntries: 200 },
|
|
401
|
+
compression: { enabled: true, strategy: 'identity' },
|
|
402
|
+
retry: {
|
|
403
|
+
enabled: true,
|
|
404
|
+
maxAttempts: 4,
|
|
405
|
+
baseDelayMs: 500,
|
|
406
|
+
maxDelayMs: 4000,
|
|
407
|
+
multiplier: 2,
|
|
408
|
+
},
|
|
409
|
+
batch: {
|
|
410
|
+
enabled: true,
|
|
411
|
+
batchSize: 3,
|
|
412
|
+
maxWaitMs: 5000,
|
|
413
|
+
},
|
|
414
|
+
timeout: { enabled: true, timeoutMs: 10000 },
|
|
415
|
+
offline: { enabled: true },
|
|
416
|
+
flush: {
|
|
417
|
+
enabled: true,
|
|
418
|
+
flushOnDestroy: true,
|
|
419
|
+
prepareUnloadHooks: true,
|
|
420
|
+
},
|
|
383
421
|
},
|
|
384
422
|
attribution: { ...DEFAULT_PIXEL_CONFIG.attribution },
|
|
385
423
|
modules: {
|
|
@@ -415,50 +453,6 @@
|
|
|
415
453
|
enabled: false,
|
|
416
454
|
},
|
|
417
455
|
},
|
|
418
|
-
transport: {
|
|
419
|
-
enabled: true,
|
|
420
|
-
mockSender: { enabled: false },
|
|
421
|
-
sender: { mode: 'http' },
|
|
422
|
-
persistence: { enabled: true },
|
|
423
|
-
replay: { enabled: true },
|
|
424
|
-
ordering: { enabled: true },
|
|
425
|
-
coordination: { enabled: true },
|
|
426
|
-
circuitBreaker: {
|
|
427
|
-
enabled: true,
|
|
428
|
-
failureThreshold: 5,
|
|
429
|
-
resetTimeoutMs: 30000,
|
|
430
|
-
halfOpenMaxAttempts: 2,
|
|
431
|
-
},
|
|
432
|
-
backpressure: {
|
|
433
|
-
enabled: true,
|
|
434
|
-
maxQueueSize: 500,
|
|
435
|
-
policy: 'drop_oldest',
|
|
436
|
-
sampleRate: 0.5,
|
|
437
|
-
},
|
|
438
|
-
deadLetter: { enabled: true, maxEntries: 200 },
|
|
439
|
-
compression: { enabled: true, strategy: 'identity' },
|
|
440
|
-
retry: {
|
|
441
|
-
enabled: true,
|
|
442
|
-
maxAttempts: 4,
|
|
443
|
-
baseDelayMs: 500,
|
|
444
|
-
maxDelayMs: 4000,
|
|
445
|
-
multiplier: 2,
|
|
446
|
-
},
|
|
447
|
-
batch: {
|
|
448
|
-
enabled: true,
|
|
449
|
-
batchSize: 3,
|
|
450
|
-
flushIntervalMs: 2000,
|
|
451
|
-
maxWaitMs: 5000,
|
|
452
|
-
},
|
|
453
|
-
timeout: { enabled: true, timeoutMs: 10000 },
|
|
454
|
-
offline: { enabled: true },
|
|
455
|
-
flush: {
|
|
456
|
-
enabled: true,
|
|
457
|
-
flushIntervalMs: 2000,
|
|
458
|
-
flushOnDestroy: true,
|
|
459
|
-
prepareUnloadHooks: true,
|
|
460
|
-
},
|
|
461
|
-
},
|
|
462
456
|
integrations: {
|
|
463
457
|
enabled: true,
|
|
464
458
|
debug: true,
|
|
@@ -196,9 +196,9 @@
|
|
|
196
196
|
...base,
|
|
197
197
|
app: { ...base.app, environment: 'development', debug: true },
|
|
198
198
|
transport: {
|
|
199
|
-
...
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
...base.transport,
|
|
200
|
+
enabled: true,
|
|
201
|
+
sender: { mode: 'internal', baseUrl: API_ENDPOINT },
|
|
202
202
|
},
|
|
203
203
|
identity: { ...base.identity, pixelId: PIXEL_ID },
|
|
204
204
|
commerce: {
|
|
@@ -259,11 +259,6 @@
|
|
|
259
259
|
},
|
|
260
260
|
behavior: { ...base.modules.behavior, enabled: false },
|
|
261
261
|
privacy: { ...base.modules.privacy, enabled: false },
|
|
262
|
-
transport: {
|
|
263
|
-
enabled: true,
|
|
264
|
-
mockSender: { enabled: false },
|
|
265
|
-
sender: { mode: 'http' },
|
|
266
|
-
},
|
|
267
262
|
integrations: { ...base.modules.integrations, enabled: false },
|
|
268
263
|
conversion: {
|
|
269
264
|
enabled: true,
|
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
...DEFAULT_PIXEL_CONFIG.identity,
|
|
45
45
|
pixelId: 'pix_runtime_diag',
|
|
46
46
|
},
|
|
47
|
+
transport: {
|
|
48
|
+
...DEFAULT_PIXEL_CONFIG.transport,
|
|
49
|
+
enabled: false,
|
|
50
|
+
},
|
|
47
51
|
modules: {
|
|
48
52
|
...DEFAULT_PIXEL_CONFIG.modules,
|
|
49
53
|
core: {
|
|
@@ -55,10 +59,6 @@
|
|
|
55
59
|
...DEFAULT_PIXEL_CONFIG.modules.conversion,
|
|
56
60
|
enabled: true,
|
|
57
61
|
},
|
|
58
|
-
transport: {
|
|
59
|
-
...DEFAULT_PIXEL_CONFIG.modules.transport,
|
|
60
|
-
enabled: false,
|
|
61
|
-
},
|
|
62
62
|
integrations: {
|
|
63
63
|
...DEFAULT_PIXEL_CONFIG.modules.integrations,
|
|
64
64
|
enabled: false,
|
|
@@ -126,14 +126,14 @@
|
|
|
126
126
|
<div class="hint">
|
|
127
127
|
Endpoint oficial de testes:
|
|
128
128
|
<code>https://micro-service-pixel-production-4826.up.railway.app</code> ·
|
|
129
|
-
Pixel ID: <code>pix_8580907</code>. Alterne entre
|
|
129
|
+
Pixel ID: <code>pix_8580907</code>. Alterne entre TestSender e HttpSender,
|
|
130
130
|
storage adapters, replay, circuit breaker, DLQ e fila persistida.
|
|
131
131
|
</div>
|
|
132
132
|
|
|
133
133
|
<div class="flow">
|
|
134
134
|
Dispatcher → TransportEngine → Pipeline → PersistentQueue →
|
|
135
135
|
OrderingManager → BackpressureManager → BatchManager → CircuitBreaker →
|
|
136
|
-
RetryEngine → TimedSender → (
|
|
136
|
+
RetryEngine → TimedSender → (TestSender | HttpSender) → API → ACK → Replay
|
|
137
137
|
/ DLQ
|
|
138
138
|
</div>
|
|
139
139
|
|
|
@@ -142,8 +142,8 @@
|
|
|
142
142
|
<label>
|
|
143
143
|
Sender
|
|
144
144
|
<select id="cfg-sender-mode">
|
|
145
|
-
<option value="
|
|
146
|
-
<option value="
|
|
145
|
+
<option value="test">Test Sender</option>
|
|
146
|
+
<option value="internal">Internal Sender</option>
|
|
147
147
|
</select>
|
|
148
148
|
</label>
|
|
149
149
|
<label>
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
<button id="btn-import-queue" type="button">Importar fila</button>
|
|
194
194
|
<button id="btn-force-retry" type="button">Forçar retry</button>
|
|
195
195
|
<button id="btn-sim-timeout" type="button">Simular timeout</button>
|
|
196
|
-
<button id="btn-reset-sender" type="button">Reset
|
|
196
|
+
<button id="btn-reset-sender" type="button">Reset TestSender</button>
|
|
197
197
|
<button id="btn-burst" type="button">Burst (5 eventos)</button>
|
|
198
198
|
</div>
|
|
199
199
|
|
|
@@ -238,7 +238,7 @@
|
|
|
238
238
|
<pre id="compression-state">—</pre>
|
|
239
239
|
</div>
|
|
240
240
|
<div class="panel">
|
|
241
|
-
<h3>
|
|
241
|
+
<h3>Internal Sender / API</h3>
|
|
242
242
|
<pre id="http-state">—</pre>
|
|
243
243
|
</div>
|
|
244
244
|
<div class="panel">
|
|
@@ -330,7 +330,7 @@
|
|
|
330
330
|
|
|
331
331
|
function transportConfig() {
|
|
332
332
|
const cfg = readConfigInputs();
|
|
333
|
-
const
|
|
333
|
+
const useInternal = cfg.senderMode === 'internal';
|
|
334
334
|
|
|
335
335
|
return {
|
|
336
336
|
...DEFAULT_PIXEL_CONFIG,
|
|
@@ -338,8 +338,47 @@
|
|
|
338
338
|
identity: { pixelId: PIXEL_ID },
|
|
339
339
|
transport: {
|
|
340
340
|
...DEFAULT_PIXEL_CONFIG.transport,
|
|
341
|
-
|
|
342
|
-
|
|
341
|
+
enabled: true,
|
|
342
|
+
sender: useInternal
|
|
343
|
+
? { mode: 'internal', baseUrl: API_ENDPOINT }
|
|
344
|
+
: { mode: 'test', capture: true },
|
|
345
|
+
persistence: { enabled: true },
|
|
346
|
+
replay: { enabled: true },
|
|
347
|
+
ordering: { enabled: true },
|
|
348
|
+
coordination: { enabled: true },
|
|
349
|
+
circuitBreaker: {
|
|
350
|
+
enabled: true,
|
|
351
|
+
failureThreshold: 5,
|
|
352
|
+
resetTimeoutMs: 30000,
|
|
353
|
+
halfOpenMaxAttempts: 2,
|
|
354
|
+
},
|
|
355
|
+
backpressure: {
|
|
356
|
+
enabled: true,
|
|
357
|
+
maxQueueSize: 500,
|
|
358
|
+
policy: 'drop_oldest',
|
|
359
|
+
sampleRate: 0.5,
|
|
360
|
+
},
|
|
361
|
+
deadLetter: { enabled: true, maxEntries: 200 },
|
|
362
|
+
compression: { enabled: true, strategy: 'identity' },
|
|
363
|
+
retry: {
|
|
364
|
+
enabled: true,
|
|
365
|
+
maxAttempts: cfg.maxAttempts,
|
|
366
|
+
baseDelayMs: 500,
|
|
367
|
+
maxDelayMs: 4000,
|
|
368
|
+
multiplier: 2,
|
|
369
|
+
},
|
|
370
|
+
batch: {
|
|
371
|
+
enabled: true,
|
|
372
|
+
batchSize: cfg.batchSize,
|
|
373
|
+
maxWaitMs: 5000,
|
|
374
|
+
},
|
|
375
|
+
timeout: { enabled: true, timeoutMs: cfg.timeoutMs },
|
|
376
|
+
offline: { enabled: true },
|
|
377
|
+
flush: {
|
|
378
|
+
enabled: true,
|
|
379
|
+
flushOnDestroy: true,
|
|
380
|
+
prepareUnloadHooks: true,
|
|
381
|
+
},
|
|
343
382
|
},
|
|
344
383
|
storage: {
|
|
345
384
|
...DEFAULT_PIXEL_CONFIG.storage,
|
|
@@ -379,50 +418,6 @@
|
|
|
379
418
|
enabled: false,
|
|
380
419
|
},
|
|
381
420
|
},
|
|
382
|
-
transport: {
|
|
383
|
-
enabled: true,
|
|
384
|
-
mockSender: { enabled: !useHttp },
|
|
385
|
-
sender: { mode: useHttp ? 'http' : 'mock' },
|
|
386
|
-
persistence: { enabled: true },
|
|
387
|
-
replay: { enabled: true },
|
|
388
|
-
ordering: { enabled: true },
|
|
389
|
-
coordination: { enabled: true },
|
|
390
|
-
circuitBreaker: {
|
|
391
|
-
enabled: true,
|
|
392
|
-
failureThreshold: 5,
|
|
393
|
-
resetTimeoutMs: 30000,
|
|
394
|
-
halfOpenMaxAttempts: 2,
|
|
395
|
-
},
|
|
396
|
-
backpressure: {
|
|
397
|
-
enabled: true,
|
|
398
|
-
maxQueueSize: 500,
|
|
399
|
-
policy: 'drop_oldest',
|
|
400
|
-
sampleRate: 0.5,
|
|
401
|
-
},
|
|
402
|
-
deadLetter: { enabled: true, maxEntries: 200 },
|
|
403
|
-
compression: { enabled: true, strategy: 'identity' },
|
|
404
|
-
retry: {
|
|
405
|
-
enabled: true,
|
|
406
|
-
maxAttempts: cfg.maxAttempts,
|
|
407
|
-
baseDelayMs: 500,
|
|
408
|
-
maxDelayMs: 4000,
|
|
409
|
-
multiplier: 2,
|
|
410
|
-
},
|
|
411
|
-
batch: {
|
|
412
|
-
enabled: true,
|
|
413
|
-
batchSize: cfg.batchSize,
|
|
414
|
-
flushIntervalMs: 2000,
|
|
415
|
-
maxWaitMs: 5000,
|
|
416
|
-
},
|
|
417
|
-
timeout: { enabled: true, timeoutMs: cfg.timeoutMs },
|
|
418
|
-
offline: { enabled: true },
|
|
419
|
-
flush: {
|
|
420
|
-
enabled: true,
|
|
421
|
-
flushIntervalMs: 2000,
|
|
422
|
-
flushOnDestroy: true,
|
|
423
|
-
prepareUnloadHooks: true,
|
|
424
|
-
},
|
|
425
|
-
},
|
|
426
421
|
},
|
|
427
422
|
};
|
|
428
423
|
}
|
|
@@ -553,6 +548,13 @@
|
|
|
553
548
|
|
|
554
549
|
pixel = new Pixel(transportConfig());
|
|
555
550
|
await pixel.init();
|
|
551
|
+
if (readConfigInputs().senderMode === 'test') {
|
|
552
|
+
pixel.configureTransportTestSender({
|
|
553
|
+
capture: true,
|
|
554
|
+
response: 'success',
|
|
555
|
+
delayMs: 0,
|
|
556
|
+
});
|
|
557
|
+
}
|
|
556
558
|
initCount += 1;
|
|
557
559
|
|
|
558
560
|
const services = pixel.getDebugServices();
|
|
@@ -681,7 +683,7 @@
|
|
|
681
683
|
document
|
|
682
684
|
.getElementById('btn-force-retry')
|
|
683
685
|
.addEventListener('click', function () {
|
|
684
|
-
pixel?.
|
|
686
|
+
pixel?.configureTransportTestSender({
|
|
685
687
|
failUntilAttempt: 3,
|
|
686
688
|
delayMs: 0,
|
|
687
689
|
});
|
|
@@ -695,7 +697,7 @@
|
|
|
695
697
|
document
|
|
696
698
|
.getElementById('btn-sim-timeout')
|
|
697
699
|
.addEventListener('click', function () {
|
|
698
|
-
pixel?.
|
|
700
|
+
pixel?.configureTransportTestSender({ delayMs: 5000 });
|
|
699
701
|
pixel?.purchase({
|
|
700
702
|
value: 1,
|
|
701
703
|
currency: 'BRL',
|
|
@@ -706,11 +708,11 @@
|
|
|
706
708
|
document
|
|
707
709
|
.getElementById('btn-reset-sender')
|
|
708
710
|
.addEventListener('click', function () {
|
|
709
|
-
pixel?.
|
|
711
|
+
pixel?.configureTransportTestSender({
|
|
710
712
|
delayMs: 0,
|
|
711
713
|
failUntilAttempt: undefined,
|
|
712
714
|
});
|
|
713
|
-
appendLog('
|
|
715
|
+
appendLog('TestSender reset');
|
|
714
716
|
});
|
|
715
717
|
document
|
|
716
718
|
.getElementById('btn-burst')
|
|
@@ -70,6 +70,9 @@
|
|
|
70
70
|
initialItems: [{ productId: 'main_offer', quantity: 1 }],
|
|
71
71
|
},
|
|
72
72
|
},
|
|
73
|
+
transport: {
|
|
74
|
+
...DEFAULT_PIXEL_CONFIG.transport,
|
|
75
|
+
},
|
|
73
76
|
modules: {
|
|
74
77
|
...DEFAULT_PIXEL_CONFIG.modules,
|
|
75
78
|
core: {
|
|
@@ -86,7 +89,6 @@
|
|
|
86
89
|
},
|
|
87
90
|
conversion: { ...DEFAULT_PIXEL_CONFIG.modules.conversion, enabled: true },
|
|
88
91
|
behavior: { ...DEFAULT_PIXEL_CONFIG.modules.behavior, enabled: false },
|
|
89
|
-
transport: { ...DEFAULT_PIXEL_CONFIG.modules.transport, enabled: false },
|
|
90
92
|
integrations: { ...DEFAULT_PIXEL_CONFIG.modules.integrations, enabled: false },
|
|
91
93
|
},
|
|
92
94
|
});
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
...DEFAULT_PIXEL_CONFIG,
|
|
25
25
|
app: { ...DEFAULT_PIXEL_CONFIG.app, debug: true },
|
|
26
26
|
identity: { ...DEFAULT_PIXEL_CONFIG.identity, pixelId: 'pix_ff_downsell' },
|
|
27
|
+
transport: {
|
|
28
|
+
...DEFAULT_PIXEL_CONFIG.transport,
|
|
29
|
+
},
|
|
27
30
|
modules: {
|
|
28
31
|
...DEFAULT_PIXEL_CONFIG.modules,
|
|
29
32
|
core: {
|
|
@@ -39,7 +42,6 @@
|
|
|
39
42
|
},
|
|
40
43
|
},
|
|
41
44
|
conversion: { ...DEFAULT_PIXEL_CONFIG.modules.conversion, enabled: false },
|
|
42
|
-
transport: { ...DEFAULT_PIXEL_CONFIG.modules.transport, enabled: false },
|
|
43
45
|
integrations: { ...DEFAULT_PIXEL_CONFIG.modules.integrations, enabled: false },
|
|
44
46
|
behavior: { ...DEFAULT_PIXEL_CONFIG.modules.behavior, enabled: false },
|
|
45
47
|
},
|