@beworke/pixel 0.1.0-rc.1 → 0.1.0-rc.5

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.
Files changed (135) hide show
  1. package/CHANGELOG.md +251 -4
  2. package/README.md +89 -111
  3. package/RELEASE_CANDIDATE.md +181 -36
  4. package/dist/{StorageFactory-BhpbB6Jj.d.mts → StorageFactory-CPghDPBj.d.mts} +2 -2
  5. package/dist/{StorageFactory-CAkJJqVD.d.ts → StorageFactory-tjfzk57c.d.ts} +2 -2
  6. package/dist/config/index.cjs.js +1 -1
  7. package/dist/config/index.cjs.js.map +1 -1
  8. package/dist/config/index.d.mts +4 -3
  9. package/dist/config/index.d.ts +4 -3
  10. package/dist/config/index.esm.js +1 -1
  11. package/dist/config/index.esm.js.map +1 -1
  12. package/dist/events/index.cjs.js +1 -1
  13. package/dist/events/index.cjs.js.map +1 -1
  14. package/dist/events/index.d.mts +2 -1
  15. package/dist/events/index.d.ts +2 -1
  16. package/dist/events/index.esm.js +1 -1
  17. package/dist/events/index.esm.js.map +1 -1
  18. package/dist/examples/html-script/README.md +24 -2
  19. package/dist/examples/html-script/RELEASE_CANDIDATE.md +20 -6
  20. package/dist/examples/html-script/add-payment-info/README.md +3 -3
  21. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-autocomplete.html +66 -48
  22. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-disabled.html +66 -48
  23. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-fields.html +65 -47
  24. package/dist/examples/html-script/add-payment-info/example-add-payment-info-data-track.html +73 -47
  25. package/dist/examples/html-script/add-payment-info/example-add-payment-info-dedupe.html +65 -47
  26. package/dist/examples/html-script/add-payment-info/example-add-payment-info-manual.html +56 -47
  27. package/dist/examples/html-script/add-payment-info/example-add-payment-info-rules-card.html +65 -47
  28. package/dist/examples/html-script/add-payment-info/example-add-payment-info-security.html +65 -47
  29. package/dist/examples/html-script/add-to-cart/README.md +3 -3
  30. package/dist/examples/html-script/add-to-cart/example-add-to-cart-attribute.html +90 -70
  31. package/dist/examples/html-script/add-to-cart/example-add-to-cart-auto.html +103 -81
  32. package/dist/examples/html-script/add-to-cart/example-add-to-cart-click.html +101 -78
  33. package/dist/examples/html-script/add-to-cart/example-add-to-cart-dedupe.html +90 -70
  34. package/dist/examples/html-script/add-to-cart/example-add-to-cart-manual.html +81 -67
  35. package/dist/examples/html-script/add-to-cart/example-add-to-cart-order-bump.html +90 -70
  36. package/dist/examples/html-script/add-to-cart/example-add-to-cart-text.html +104 -81
  37. package/dist/examples/html-script/behavior/example-behavior-engagement.html +489 -0
  38. package/dist/examples/html-script/behavior/example-behavior-heartbeat.html +350 -0
  39. package/dist/examples/html-script/behavior/example-behavior-runtime-intelligence.html +433 -0
  40. package/dist/examples/html-script/behavior/example-behavior-viewport.html +397 -0
  41. package/dist/examples/html-script/{example-behavior.html → behavior/example-behavior.html} +23 -17
  42. package/dist/examples/html-script/example-checkout-commerce.html +825 -0
  43. package/dist/examples/html-script/example-integration.html +5 -5
  44. package/dist/examples/html-script/example-landing-commerce.html +380 -0
  45. package/dist/examples/html-script/example-runtime-diagnostics.html +108 -0
  46. package/dist/examples/html-script/example-transport.html +5 -5
  47. package/dist/examples/html-script/full-funnel/README.md +64 -0
  48. package/dist/examples/html-script/full-funnel/checkout.html +116 -0
  49. package/dist/examples/html-script/full-funnel/downsell.html +58 -0
  50. package/dist/examples/html-script/full-funnel/landing.html +99 -0
  51. package/dist/examples/html-script/full-funnel/thank-you.html +85 -0
  52. package/dist/examples/html-script/full-funnel/upsell.html +64 -0
  53. package/dist/examples/html-script/initiate-checkout/README.md +6 -6
  54. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-attribute.html +94 -74
  55. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-auto.html +102 -80
  56. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-click.html +103 -80
  57. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-manual.html +86 -72
  58. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-snapshot.html +95 -75
  59. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-submit.html +103 -83
  60. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-text.html +105 -82
  61. package/dist/examples/html-script/lead/README.md +9 -7
  62. package/dist/examples/html-script/lead/example-lead-trigger-attribute.html +67 -47
  63. package/dist/examples/html-script/lead/example-lead-trigger-auto.html +78 -56
  64. package/dist/examples/html-script/lead/example-lead-trigger-click.html +78 -55
  65. package/dist/examples/html-script/release-candidate.html +187 -76
  66. package/dist/examples/html-script/remove-from-cart/README.md +1 -1
  67. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-attribute.html +93 -73
  68. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-css.html +93 -73
  69. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-dedupe.html +93 -73
  70. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-manual.html +84 -70
  71. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-multi.html +94 -74
  72. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-state.html +95 -75
  73. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-text.html +98 -76
  74. package/dist/examples/html-script/search/README.md +1 -1
  75. package/dist/examples/html-script/search/example-search-attribute.html +66 -51
  76. package/dist/examples/html-script/search/example-search-button-sync.html +66 -51
  77. package/dist/examples/html-script/search/example-search-dedupe.html +66 -51
  78. package/dist/examples/html-script/search/example-search-input.html +67 -51
  79. package/dist/examples/html-script/search/example-search-manual.html +57 -48
  80. package/dist/examples/html-script/search/example-search-submit.html +66 -51
  81. package/dist/examples/html-script/search/example-search-text.html +71 -51
  82. package/dist/examples/html-script/url-context/example-url-context-allowed-domains.html +63 -0
  83. package/dist/examples/html-script/url-context/example-url-context-landing.html +70 -0
  84. package/dist/examples/html-script/url-context/example-url-context-upsell.html +67 -0
  85. package/dist/examples/html-script/url-context/example-url-context.html +171 -0
  86. package/dist/examples/html-script/view-content/README.md +1 -1
  87. package/dist/examples/html-script/view-content/example-view-content-attribute.html +85 -70
  88. package/dist/examples/html-script/view-content/example-view-content-css.html +85 -70
  89. package/dist/examples/html-script/view-content/example-view-content-dedupe.html +85 -70
  90. package/dist/examples/html-script/view-content/example-view-content-empty.html +85 -70
  91. package/dist/examples/html-script/view-content/example-view-content-manual.html +76 -67
  92. package/dist/examples/html-script/view-content/example-view-content-product-card.html +85 -70
  93. package/dist/examples/html-script/view-content/example-view-content-text.html +90 -73
  94. package/dist/examples/v2/README.md +4 -1
  95. package/dist/{index-DUfFzniE.d.ts → index-CQAyT5Od.d.ts} +170 -3
  96. package/dist/{index-DUfFzniE.d.mts → index-JlKPz4pp.d.mts} +170 -3
  97. package/dist/index.cjs.js +1 -1
  98. package/dist/index.cjs.js.map +1 -1
  99. package/dist/index.d.mts +435 -12
  100. package/dist/index.d.ts +435 -12
  101. package/dist/index.esm.js +1 -1
  102. package/dist/index.esm.js.map +1 -1
  103. package/dist/{pixel-CbeF25mD.d.mts → pixel-BxZZx8l5.d.ts} +248 -72
  104. package/dist/{pixel-CbeF25mD.d.ts → pixel-CKc4OQUx.d.mts} +248 -72
  105. package/dist/{pixel-default-config-1VgLFOiL.d.mts → pixel-default-config-CJl-eypl.d.mts} +1 -1
  106. package/dist/{pixel-default-config-Bxb-Vdd8.d.ts → pixel-default-config-aAOujzwp.d.ts} +1 -1
  107. package/dist/runtime/index.cjs.js +1 -1
  108. package/dist/runtime/index.cjs.js.map +1 -1
  109. package/dist/runtime/index.d.mts +19 -26
  110. package/dist/runtime/index.d.ts +19 -26
  111. package/dist/runtime/index.esm.js +1 -1
  112. package/dist/runtime/index.esm.js.map +1 -1
  113. package/dist/services/index.cjs.js +1 -1
  114. package/dist/services/index.cjs.js.map +1 -1
  115. package/dist/services/index.d.mts +14 -6
  116. package/dist/services/index.d.ts +14 -6
  117. package/dist/services/index.esm.js +1 -1
  118. package/dist/services/index.esm.js.map +1 -1
  119. package/dist/types-BP8dz1gP.d.mts +19 -0
  120. package/dist/types-C75pQP31.d.ts +19 -0
  121. package/dist/types-DMhzHSVC.d.mts +293 -0
  122. package/dist/types-D_SsCur9.d.ts +293 -0
  123. package/dist/url-context-BjAsQoVl.d.mts +85 -0
  124. package/dist/url-context-BjAsQoVl.d.ts +85 -0
  125. package/dist/v2/global.global.js +1 -1
  126. package/dist/v2/global.global.js.map +1 -1
  127. package/dist/v2/index.cjs.js +1 -1
  128. package/dist/v2/index.cjs.js.map +1 -1
  129. package/dist/v2/index.d.mts +8 -6
  130. package/dist/v2/index.d.ts +8 -6
  131. package/dist/v2/index.esm.js +1 -1
  132. package/dist/v2/index.esm.js.map +1 -1
  133. package/package.json +12 -1
  134. package/dist/types-CTpRvFKZ.d.ts +0 -71
  135. package/dist/types-DGlBdsAy.d.mts +0 -71
@@ -1,3 +1,5 @@
1
+ import { c as UrlContextPayload, U as UrlContextConfig, d as UrlContextSnapshot } from './url-context-BjAsQoVl.mjs';
2
+
1
3
  type AttributionIdentifiers = {
2
4
  readonly fbclid?: string;
3
5
  readonly fbp?: string;
@@ -38,6 +40,21 @@ interface AttributionService {
38
40
  clear(): void;
39
41
  }
40
42
 
43
+ interface StorageAdapter {
44
+ get(key: string): string | null;
45
+ set(key: string, value: string): void;
46
+ remove(key: string): void;
47
+ clear(): void;
48
+ }
49
+ interface StorageService {
50
+ get<T>(key: string): T | null;
51
+ set<T>(key: string, value: T): void;
52
+ remove(key: string): void;
53
+ has(key: string): boolean;
54
+ clear(): void;
55
+ createKey(key: string): string;
56
+ }
57
+
41
58
  interface BasePixelEvent {
42
59
  readonly type: string;
43
60
  readonly timestamp: number;
@@ -48,6 +65,10 @@ interface BasePixelEvent {
48
65
  readonly timezone?: string;
49
66
  /** Attribution click IDs / cookies — anexados pelo BaseEventBuilder. */
50
67
  readonly identifiers?: AttributionIdentifiers;
68
+ /** Snapshot sanitizado dos query params da URL — Core UrlContext. */
69
+ readonly queryParams?: Record<string, string>;
70
+ /** Auditoria operacional UrlContext (managed / forwarded / source). */
71
+ readonly urlContext?: UrlContextPayload;
51
72
  }
52
73
 
53
74
  interface PageViewEvent extends BasePixelEvent {
@@ -131,6 +152,125 @@ interface ExitIntentEvent extends BasePixelEvent {
131
152
  readonly clientY?: number;
132
153
  }
133
154
 
155
+ /**
156
+ * Evento público de presença periódica (Etapa 17).
157
+ * Representa estado, não transporte.
158
+ */
159
+ interface BehaviorHeartbeatEvent extends BasePixelEvent {
160
+ readonly type: 'BEHAVIOR_HEARTBEAT';
161
+ readonly category: EngagementEventCategory;
162
+ readonly sequence: number;
163
+ readonly active: boolean;
164
+ readonly idle: boolean;
165
+ readonly visible: boolean;
166
+ readonly elapsedMs: number;
167
+ readonly lastActivityAt?: number;
168
+ readonly idleSince?: number;
169
+ readonly visibleSince?: number;
170
+ readonly hiddenSince?: number;
171
+ }
172
+
173
+ interface ViewportEnterEvent extends BasePixelEvent {
174
+ readonly type: 'VIEWPORT_ENTER';
175
+ readonly category: EngagementEventCategory;
176
+ readonly key: string;
177
+ readonly selector: string;
178
+ readonly elementId: string;
179
+ readonly visibilityRatio: number;
180
+ readonly enterThreshold: number;
181
+ readonly exitThreshold: number;
182
+ readonly enteredAt: number;
183
+ readonly minVisibleMs: number;
184
+ readonly element?: ElementDescriptor;
185
+ }
186
+
187
+ type ViewportExitReason = 'threshold' | 'not_intersecting' | 'removed';
188
+ interface ViewportExitEvent extends BasePixelEvent {
189
+ readonly type: 'VIEWPORT_EXIT';
190
+ readonly category: EngagementEventCategory;
191
+ readonly key: string;
192
+ readonly selector: string;
193
+ readonly elementId: string;
194
+ readonly visibilityRatio: number;
195
+ readonly enterThreshold: number;
196
+ readonly exitThreshold: number;
197
+ readonly enteredAt: number;
198
+ readonly exitedAt: number;
199
+ readonly visibleDurationMs: number;
200
+ readonly reason: ViewportExitReason;
201
+ readonly element?: ElementDescriptor;
202
+ }
203
+
204
+ type EngagementLevel = 'low' | 'medium' | 'high';
205
+ type EngagementUpdateReason = 'initial' | 'interval' | 'signal_threshold' | 'manual_evaluation';
206
+ /**
207
+ * Evento público de atualização de engajamento (Etapa 19).
208
+ * Score determinístico 0..100. Não carrega a explicação completa do cálculo.
209
+ */
210
+ interface EngagementUpdateEvent extends BasePixelEvent {
211
+ readonly type: 'ENGAGEMENT_UPDATE';
212
+ readonly category: EngagementEventCategory;
213
+ readonly score: number;
214
+ readonly previousScore: number;
215
+ readonly delta: number;
216
+ readonly level: EngagementLevel;
217
+ readonly evaluatedAt: number;
218
+ readonly reason: EngagementUpdateReason;
219
+ }
220
+
221
+ /**
222
+ * Evento público de resumo de engajamento (Etapa 19).
223
+ * Sem PII, sem DOM. Emitido no máximo uma vez no destroy quando configurado.
224
+ */
225
+ interface EngagementSummaryEvent extends BasePixelEvent {
226
+ readonly type: 'ENGAGEMENT_SUMMARY';
227
+ readonly category: EngagementEventCategory;
228
+ readonly score: number;
229
+ readonly peakScore: number;
230
+ readonly averageScore: number;
231
+ readonly level: EngagementLevel;
232
+ readonly activeDurationMs: number;
233
+ readonly idleDurationMs: number;
234
+ readonly visibleDurationMs: number;
235
+ readonly hiddenDurationMs: number;
236
+ readonly maxScrollPercent: number;
237
+ readonly clickCount: number;
238
+ readonly rageClickCount: number;
239
+ readonly viewportEntryCount: number;
240
+ readonly heartbeatCount: number;
241
+ readonly startedAt: number;
242
+ readonly endedAt: number;
243
+ }
244
+
245
+ type BehaviorState = 'NOT_INITIALIZED' | 'INITIALIZING' | 'ACTIVE' | 'IDLE' | 'HIDDEN' | 'PAUSED' | 'DESTROYING' | 'DESTROYED';
246
+ type BehaviorSessionSummaryReason = 'hidden' | 'destroy';
247
+ /**
248
+ * Evento público de resumo de sessão de comportamento (Etapa 20).
249
+ * Sem PII, sem DOM, sem sinais brutos. Emitido no máximo uma vez por
250
+ * fechamento lógico (hidden/destroy), conforme config.
251
+ */
252
+ interface BehaviorSessionSummaryEvent extends BasePixelEvent {
253
+ readonly type: 'BEHAVIOR_SESSION_SUMMARY';
254
+ readonly category: EngagementEventCategory;
255
+ readonly activeDurationMs: number;
256
+ readonly idleDurationMs: number;
257
+ readonly visibleDurationMs: number;
258
+ readonly hiddenDurationMs: number;
259
+ readonly maxScrollPercent: number;
260
+ readonly clickCount: number;
261
+ readonly rageClickCount: number;
262
+ readonly viewportEntryCount: number;
263
+ readonly viewportVisibleDurationMs: number;
264
+ readonly heartbeatCount: number;
265
+ readonly engagementScore: number;
266
+ readonly engagementPeakScore: number;
267
+ readonly startedAt: number;
268
+ readonly endedAt: number;
269
+ readonly finalState: BehaviorState;
270
+ readonly generation: number;
271
+ readonly reason: BehaviorSessionSummaryReason;
272
+ }
273
+
134
274
  interface SessionRenewedEvent extends BasePixelEvent {
135
275
  readonly type: 'SESSION_RENEWED';
136
276
  readonly sessionId: string;
@@ -241,7 +381,7 @@ interface SearchEvent extends BasePixelEvent {
241
381
  readonly data: SearchData;
242
382
  }
243
383
 
244
- type PixelEvent = PageViewEvent | SessionRenewedEvent | SessionExpiredEvent | ScrollEvent | PageClickEvent | RageClickEvent | VisibilityChangeEvent | UserIdleEvent | UserActiveEvent | ExitIntentEvent | PurchaseEvent | LeadEvent | AddToCartEvent | RemoveFromCartEvent | InitiateCheckoutEvent | AddPaymentInfoEvent | ViewContentEvent | SearchEvent;
384
+ type PixelEvent = PageViewEvent | SessionRenewedEvent | SessionExpiredEvent | ScrollEvent | PageClickEvent | RageClickEvent | VisibilityChangeEvent | UserIdleEvent | UserActiveEvent | ExitIntentEvent | BehaviorHeartbeatEvent | ViewportEnterEvent | ViewportExitEvent | EngagementUpdateEvent | EngagementSummaryEvent | BehaviorSessionSummaryEvent | PurchaseEvent | LeadEvent | AddToCartEvent | RemoveFromCartEvent | InitiateCheckoutEvent | AddPaymentInfoEvent | ViewContentEvent | SearchEvent;
245
385
 
246
386
  interface BrowserMetadata {
247
387
  readonly url?: string;
@@ -262,13 +402,40 @@ interface BrowserMetadataService {
262
402
  getMetadata(): BrowserMetadata;
263
403
  }
264
404
 
405
+ /**
406
+ * Orquestra UrlContext: collect → manage → forward → decorate → snapshot.
407
+ * SSR-safe; init/destroy idempotentes.
408
+ */
409
+ declare class UrlContextService {
410
+ private readonly storage;
411
+ private readonly rawConfig;
412
+ private readonly collector;
413
+ private readonly forwardResolver;
414
+ private store;
415
+ private managedResolver;
416
+ private decorator;
417
+ private snapshot;
418
+ private initialized;
419
+ private enabled;
420
+ constructor(config: UrlContextConfig | undefined, storage?: StorageService | null);
421
+ init(): void;
422
+ destroy(): void;
423
+ /** Alias de destroy — cleanup completo sem listeners/refs. */
424
+ dispose(): void;
425
+ isEnabled(): boolean;
426
+ getSnapshot(): UrlContextSnapshot;
427
+ getQueryParams(): Record<string, string>;
428
+ getUrlContext(): UrlContextPayload;
429
+ }
430
+
265
431
  declare class BaseEventBuilder {
266
432
  private readonly metadataService;
267
433
  private readonly attribution;
268
- constructor(metadataService: BrowserMetadataService, attribution?: AttributionService | null);
434
+ private readonly urlContext;
435
+ constructor(metadataService: BrowserMetadataService, attribution?: AttributionService | null, urlContext?: UrlContextService | null);
269
436
  build<T extends {
270
437
  type: string;
271
438
  }>(event: T): T & BasePixelEvent;
272
439
  }
273
440
 
274
- export { type AttributionService as A, type BrowserMetadataService as B, type ConversionEventData as C, DEFAULT_ATTRIBUTION_CONFIG as D, type ExitIntentEvent as E, type PixelEventCategory as F, type EngagementEventCategory as G, type ConversionEventCategory as H, type InitiateCheckoutData as I, type ElementDescriptor as J, type LeadData as L, type PixelEvent as P, type RemoveFromCartData as R, type SessionRenewedEvent as S, type UserIdleEvent as U, type ViewContentData as V, BaseEventBuilder as a, type AttributionConfig as b, type AttributionIdentifiers as c, type BrowserMetadata as d, type BasePixelEvent as e, type PageViewEvent as f, type SessionExpiredEvent as g, ATTRIBUTION_STORAGE_KEY as h, type PurchaseData as i, type AddToCartData as j, type AddPaymentInfoData as k, type SearchData as l, type ScrollEvent as m, type PageClickEvent as n, type RageClickEvent as o, type VisibilityChangeEvent as p, type UserActiveEvent as q, type PurchaseEvent as r, type LeadEvent as s, type AddToCartEvent as t, type RemoveFromCartEvent as u, type InitiateCheckoutEvent as v, type AddPaymentInfoEvent as w, type ViewContentEvent as x, type SearchEvent as y, type PixelItem as z };
441
+ export { type EngagementEventCategory as $, type AttributionService as A, type BrowserMetadataService as B, type EngagementSummaryEvent as C, DEFAULT_ATTRIBUTION_CONFIG as D, type ExitIntentEvent as E, type BehaviorSessionSummaryEvent as F, type BehaviorSessionSummaryReason as G, type BehaviorState as H, type InitiateCheckoutData as I, type EngagementLevel as J, type EngagementUpdateReason as K, type LeadData as L, type PurchaseEvent as M, type LeadEvent as N, type AddToCartEvent as O, type PixelEvent as P, type RemoveFromCartEvent as Q, type RemoveFromCartData as R, type StorageAdapter as S, type InitiateCheckoutEvent as T, UrlContextService as U, type ViewContentData as V, type AddPaymentInfoEvent as W, type ViewContentEvent as X, type SearchEvent as Y, type ConversionEventData as Z, type PixelEventCategory as _, type PixelItem as a, type ConversionEventCategory as a0, type ElementDescriptor as a1, type StorageService as b, BaseEventBuilder as c, type AttributionConfig as d, type AttributionIdentifiers as e, type BrowserMetadata as f, type BasePixelEvent as g, type PageViewEvent as h, type SessionRenewedEvent as i, type SessionExpiredEvent as j, ATTRIBUTION_STORAGE_KEY as k, type PurchaseData as l, type AddToCartData as m, type AddPaymentInfoData as n, type SearchData as o, type ScrollEvent as p, type PageClickEvent as q, type RageClickEvent as r, type VisibilityChangeEvent as s, type UserIdleEvent as t, type UserActiveEvent as u, type BehaviorHeartbeatEvent as v, type ViewportEnterEvent as w, type ViewportExitEvent as x, type ViewportExitReason as y, type EngagementUpdateEvent as z };