@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,435 @@
|
|
|
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 — Behavior 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: #eff6ff;
|
|
17
|
+
border: 1px solid #bfdbfe;
|
|
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
|
+
#rage-target {
|
|
37
|
+
background: #fef3c7;
|
|
38
|
+
border: 2px dashed #f59e0b;
|
|
39
|
+
padding: 1rem;
|
|
40
|
+
margin: 1rem 0;
|
|
41
|
+
user-select: none;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#scroll-spacer {
|
|
45
|
+
height: 2400px;
|
|
46
|
+
background: linear-gradient(#f4f4f5, #e4e4e7);
|
|
47
|
+
margin-top: 2rem;
|
|
48
|
+
padding: 1rem;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.panels {
|
|
52
|
+
display: grid;
|
|
53
|
+
grid-template-columns: 1fr 1fr;
|
|
54
|
+
gap: 1rem;
|
|
55
|
+
margin: 1rem 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@media (max-width: 700px) {
|
|
59
|
+
.panels {
|
|
60
|
+
grid-template-columns: 1fr;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.panel {
|
|
65
|
+
font-family: ui-monospace, monospace;
|
|
66
|
+
font-size: 12px;
|
|
67
|
+
border-radius: 8px;
|
|
68
|
+
padding: 1rem;
|
|
69
|
+
background: #f4f4f5;
|
|
70
|
+
border: 1px solid #e4e4e7;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.panel h3 {
|
|
74
|
+
margin: 0 0 0.75rem;
|
|
75
|
+
font-size: 13px;
|
|
76
|
+
font-family: system-ui, sans-serif;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.panel pre {
|
|
80
|
+
margin: 0;
|
|
81
|
+
white-space: pre-wrap;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
#logs {
|
|
85
|
+
background: #18181b;
|
|
86
|
+
color: #fafafa;
|
|
87
|
+
min-height: 200px;
|
|
88
|
+
overflow: auto;
|
|
89
|
+
margin-top: 1rem;
|
|
90
|
+
border-radius: 8px;
|
|
91
|
+
padding: 1rem;
|
|
92
|
+
font-family: ui-monospace, monospace;
|
|
93
|
+
font-size: 12px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.exit-zone {
|
|
97
|
+
position: fixed;
|
|
98
|
+
top: 0;
|
|
99
|
+
left: 0;
|
|
100
|
+
right: 0;
|
|
101
|
+
height: 8px;
|
|
102
|
+
background: #fecaca;
|
|
103
|
+
font-size: 11px;
|
|
104
|
+
text-align: center;
|
|
105
|
+
line-height: 8px;
|
|
106
|
+
color: #7f1d1d;
|
|
107
|
+
z-index: 10;
|
|
108
|
+
}
|
|
109
|
+
</style>
|
|
110
|
+
</head>
|
|
111
|
+
<body>
|
|
112
|
+
<div class="exit-zone" title="Mova o mouse para o topo para EXIT_INTENT">
|
|
113
|
+
exit intent zone
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<h1>Pixel v2 — Behavior Tracking</h1>
|
|
117
|
+
|
|
118
|
+
<div class="hint">
|
|
119
|
+
SCROLL (thresholds + debounce), PAGE_CLICK, RAGE_CLICK (3 cliques / 500ms +
|
|
120
|
+
cooldown), VISIBILITY_CHANGE, USER_IDLE / USER_ACTIVE (5s), EXIT_INTENT.
|
|
121
|
+
Abra o console para ver cada evento.
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
<div class="actions">
|
|
125
|
+
<button id="reinit" type="button">Reinitialize</button>
|
|
126
|
+
<button id="destroy" type="button">Destroy</button>
|
|
127
|
+
<button id="scroll-bottom" type="button">Scroll to bottom</button>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<div id="rage-target">
|
|
131
|
+
Clique 3x rapidamente aqui para gerar <strong>RAGE_CLICK</strong>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<div class="panels">
|
|
135
|
+
<div class="panel">
|
|
136
|
+
<h3>Event Counts</h3>
|
|
137
|
+
<pre id="event-counts">Nenhum evento ainda</pre>
|
|
138
|
+
</div>
|
|
139
|
+
<div class="panel">
|
|
140
|
+
<h3>Runtime Debug</h3>
|
|
141
|
+
<pre id="runtime-debug">Aguardando...</pre>
|
|
142
|
+
</div>
|
|
143
|
+
<div class="panel" style="grid-column: 1 / -1">
|
|
144
|
+
<h3>Behavior State</h3>
|
|
145
|
+
<pre id="behavior-state">Aguardando eventos...</pre>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<pre id="logs"></pre>
|
|
150
|
+
|
|
151
|
+
<div id="scroll-spacer">Role a página para gerar eventos SCROLL</div>
|
|
152
|
+
|
|
153
|
+
<script src="../../dist/v2/global.global.js"></script>
|
|
154
|
+
<script>
|
|
155
|
+
const { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
|
|
156
|
+
|
|
157
|
+
const logsEl = document.getElementById('logs');
|
|
158
|
+
const eventCountsEl = document.getElementById('event-counts');
|
|
159
|
+
const runtimeDebugEl = document.getElementById('runtime-debug');
|
|
160
|
+
const behaviorStateEl = document.getElementById('behavior-state');
|
|
161
|
+
|
|
162
|
+
let pixel = null;
|
|
163
|
+
let unsubscribe = null;
|
|
164
|
+
let initCount = 0;
|
|
165
|
+
let destroyCount = 0;
|
|
166
|
+
|
|
167
|
+
const counts = {};
|
|
168
|
+
const behaviorState = {
|
|
169
|
+
scroll: { maxPercent: 0, events: 0, velocity: 0 },
|
|
170
|
+
click: { clicks: 0, rageClicks: 0 },
|
|
171
|
+
visibility: { visible: true, hiddenAt: null },
|
|
172
|
+
idle: { isIdle: false, lastActiveAt: null },
|
|
173
|
+
exitIntent: { triggered: false },
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
function appendLog(message) {
|
|
177
|
+
const line = '[' + new Date().toISOString() + '] ' + message;
|
|
178
|
+
logsEl.textContent = line + '\n' + logsEl.textContent;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function bump(type) {
|
|
182
|
+
counts[type] = (counts[type] || 0) + 1;
|
|
183
|
+
renderEventCounts();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function applyBehaviorState(event) {
|
|
187
|
+
switch (event.type) {
|
|
188
|
+
case 'SCROLL':
|
|
189
|
+
behaviorState.scroll.maxPercent = event.maxScrollPercent || 0;
|
|
190
|
+
behaviorState.scroll.events = event.scrollEvents || 0;
|
|
191
|
+
behaviorState.scroll.velocity = event.scrollVelocityAvg || 0;
|
|
192
|
+
break;
|
|
193
|
+
case 'PAGE_CLICK':
|
|
194
|
+
behaviorState.click.clicks = event.clickCount || 0;
|
|
195
|
+
behaviorState.click.rageClicks = event.rageClickCount || 0;
|
|
196
|
+
break;
|
|
197
|
+
case 'RAGE_CLICK':
|
|
198
|
+
behaviorState.click.rageClicks =
|
|
199
|
+
(behaviorState.click.rageClicks || 0) + 1;
|
|
200
|
+
break;
|
|
201
|
+
case 'VISIBILITY_CHANGE':
|
|
202
|
+
behaviorState.visibility.visible = event.isVisible;
|
|
203
|
+
behaviorState.visibility.hiddenAt = event.hiddenAt;
|
|
204
|
+
break;
|
|
205
|
+
case 'USER_IDLE':
|
|
206
|
+
behaviorState.idle.isIdle = true;
|
|
207
|
+
break;
|
|
208
|
+
case 'USER_ACTIVE':
|
|
209
|
+
behaviorState.idle.isIdle = false;
|
|
210
|
+
behaviorState.idle.lastActiveAt = event.activeAt;
|
|
211
|
+
break;
|
|
212
|
+
case 'EXIT_INTENT':
|
|
213
|
+
behaviorState.exitIntent.triggered = true;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
renderBehaviorState();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function renderEventCounts() {
|
|
220
|
+
const lines = Object.keys(counts)
|
|
221
|
+
.sort()
|
|
222
|
+
.map(function (type) {
|
|
223
|
+
return type + ': ' + counts[type];
|
|
224
|
+
});
|
|
225
|
+
eventCountsEl.textContent =
|
|
226
|
+
lines.length > 0 ? lines.join('\n') : 'Nenhum evento ainda';
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function renderBehaviorState() {
|
|
230
|
+
behaviorStateEl.textContent =
|
|
231
|
+
'Scroll\n' +
|
|
232
|
+
'- max %: ' +
|
|
233
|
+
behaviorState.scroll.maxPercent +
|
|
234
|
+
'\n' +
|
|
235
|
+
'- events: ' +
|
|
236
|
+
behaviorState.scroll.events +
|
|
237
|
+
'\n' +
|
|
238
|
+
'- velocity: ' +
|
|
239
|
+
behaviorState.scroll.velocity.toFixed(2) +
|
|
240
|
+
'\n\n' +
|
|
241
|
+
'Click\n' +
|
|
242
|
+
'- clicks: ' +
|
|
243
|
+
behaviorState.click.clicks +
|
|
244
|
+
'\n' +
|
|
245
|
+
'- rage clicks: ' +
|
|
246
|
+
behaviorState.click.rageClicks +
|
|
247
|
+
'\n\n' +
|
|
248
|
+
'Visibility\n' +
|
|
249
|
+
'- visible: ' +
|
|
250
|
+
behaviorState.visibility.visible +
|
|
251
|
+
'\n' +
|
|
252
|
+
'- hiddenAt: ' +
|
|
253
|
+
(behaviorState.visibility.hiddenAt || '-') +
|
|
254
|
+
'\n\n' +
|
|
255
|
+
'Idle\n' +
|
|
256
|
+
'- idle: ' +
|
|
257
|
+
behaviorState.idle.isIdle +
|
|
258
|
+
'\n' +
|
|
259
|
+
'- last active: ' +
|
|
260
|
+
(behaviorState.idle.lastActiveAt || '-') +
|
|
261
|
+
'\n\n' +
|
|
262
|
+
'Exit Intent\n' +
|
|
263
|
+
'- triggered: ' +
|
|
264
|
+
behaviorState.exitIntent.triggered;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function renderRuntimeDebug() {
|
|
268
|
+
const services = pixel ? pixel.getDebugServices() : null;
|
|
269
|
+
const initialized = pixel ? pixel.isInitialized() : false;
|
|
270
|
+
const listenerCount = services
|
|
271
|
+
? services.dispatcher.getListenerCount()
|
|
272
|
+
: 0;
|
|
273
|
+
|
|
274
|
+
runtimeDebugEl.textContent =
|
|
275
|
+
'initialized: ' +
|
|
276
|
+
initialized +
|
|
277
|
+
'\n' +
|
|
278
|
+
'init count: ' +
|
|
279
|
+
initCount +
|
|
280
|
+
'\n' +
|
|
281
|
+
'destroy count: ' +
|
|
282
|
+
destroyCount +
|
|
283
|
+
'\n' +
|
|
284
|
+
'dispatcher listeners: ' +
|
|
285
|
+
listenerCount +
|
|
286
|
+
'\n' +
|
|
287
|
+
'trackers: scroll, click, visibility, idle, exitIntent';
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function behaviorConfig() {
|
|
291
|
+
return {
|
|
292
|
+
...DEFAULT_PIXEL_CONFIG,
|
|
293
|
+
app: { ...DEFAULT_PIXEL_CONFIG.app, debug: true },
|
|
294
|
+
identity: {
|
|
295
|
+
...DEFAULT_PIXEL_CONFIG.identity,
|
|
296
|
+
pixelId: 'behavior-playground',
|
|
297
|
+
},
|
|
298
|
+
modules: {
|
|
299
|
+
...DEFAULT_PIXEL_CONFIG.modules,
|
|
300
|
+
core: {
|
|
301
|
+
...DEFAULT_PIXEL_CONFIG.modules.core,
|
|
302
|
+
enabled: true,
|
|
303
|
+
pageView: {
|
|
304
|
+
...DEFAULT_PIXEL_CONFIG.modules.core.pageView,
|
|
305
|
+
enabled: true,
|
|
306
|
+
trackInitialPageView: true,
|
|
307
|
+
spa: false,
|
|
308
|
+
},
|
|
309
|
+
session: {
|
|
310
|
+
...DEFAULT_PIXEL_CONFIG.modules.core.session,
|
|
311
|
+
enabled: true,
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
behavior: {
|
|
315
|
+
enabled: true,
|
|
316
|
+
trackers: {
|
|
317
|
+
scroll: {
|
|
318
|
+
enabled: true,
|
|
319
|
+
thresholds: [25, 50, 75, 100],
|
|
320
|
+
debounceMs: 100,
|
|
321
|
+
},
|
|
322
|
+
click: {
|
|
323
|
+
enabled: true,
|
|
324
|
+
rageClick: {
|
|
325
|
+
enabled: true,
|
|
326
|
+
threshold: 3,
|
|
327
|
+
windowMs: 500,
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
idle: {
|
|
331
|
+
enabled: true,
|
|
332
|
+
thresholdMs: 5000,
|
|
333
|
+
},
|
|
334
|
+
visibility: { enabled: true },
|
|
335
|
+
exitIntent: { enabled: true },
|
|
336
|
+
viewport: {
|
|
337
|
+
enabled: false,
|
|
338
|
+
selector: '',
|
|
339
|
+
selectorType: 'attribute',
|
|
340
|
+
visibilityThreshold: 0.5,
|
|
341
|
+
},
|
|
342
|
+
heartbeat: {
|
|
343
|
+
enabled: false,
|
|
344
|
+
intervalMs: 5000,
|
|
345
|
+
hiddenIntervalMs: 30000,
|
|
346
|
+
},
|
|
347
|
+
engagement: {
|
|
348
|
+
enabled: false,
|
|
349
|
+
weights: { scroll: 0.3, click: 0.3, time: 0.25 },
|
|
350
|
+
thresholds: { low: 30, medium: 70 },
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
async function initPixel() {
|
|
359
|
+
if (pixel) {
|
|
360
|
+
await pixel.destroy();
|
|
361
|
+
destroyCount += 1;
|
|
362
|
+
pixel = null;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (unsubscribe) {
|
|
366
|
+
unsubscribe();
|
|
367
|
+
unsubscribe = null;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
Object.keys(counts).forEach(function (key) {
|
|
371
|
+
delete counts[key];
|
|
372
|
+
});
|
|
373
|
+
behaviorState.scroll = { maxPercent: 0, events: 0, velocity: 0 };
|
|
374
|
+
behaviorState.click = { clicks: 0, rageClicks: 0 };
|
|
375
|
+
behaviorState.visibility = { visible: true, hiddenAt: null };
|
|
376
|
+
behaviorState.idle = { isIdle: false, lastActiveAt: null };
|
|
377
|
+
behaviorState.exitIntent = { triggered: false };
|
|
378
|
+
|
|
379
|
+
pixel = new Pixel(behaviorConfig());
|
|
380
|
+
await pixel.init();
|
|
381
|
+
initCount += 1;
|
|
382
|
+
|
|
383
|
+
const services = pixel.getDebugServices();
|
|
384
|
+
if (services) {
|
|
385
|
+
unsubscribe = services.dispatcher.subscribe(function (event) {
|
|
386
|
+
bump(event.type);
|
|
387
|
+
applyBehaviorState(event);
|
|
388
|
+
appendLog('Dispatcher: ' + event.type);
|
|
389
|
+
console.log('[Pixel v2 Behavior]', event.type, event);
|
|
390
|
+
renderRuntimeDebug();
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
appendLog('Pixel behavior playground initialized');
|
|
395
|
+
renderEventCounts();
|
|
396
|
+
renderBehaviorState();
|
|
397
|
+
renderRuntimeDebug();
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
document.getElementById('reinit').addEventListener('click', function () {
|
|
401
|
+
initPixel().catch(function (error) {
|
|
402
|
+
appendLog('Init error: ' + String(error));
|
|
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) {
|
|
414
|
+
unsubscribe();
|
|
415
|
+
unsubscribe = null;
|
|
416
|
+
}
|
|
417
|
+
appendLog('Pixel destroyed');
|
|
418
|
+
renderRuntimeDebug();
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
document
|
|
422
|
+
.getElementById('scroll-bottom')
|
|
423
|
+
.addEventListener('click', function () {
|
|
424
|
+
window.scrollTo({
|
|
425
|
+
top: document.body.scrollHeight,
|
|
426
|
+
behavior: 'smooth',
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
initPixel().catch(function (error) {
|
|
431
|
+
appendLog('Bootstrap error: ' + String(error));
|
|
432
|
+
});
|
|
433
|
+
</script>
|
|
434
|
+
</body>
|
|
435
|
+
</html>
|