@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.
Files changed (123) hide show
  1. package/CHANGELOG.md +194 -0
  2. package/README.md +163 -0
  3. package/RELEASE_CANDIDATE.md +256 -0
  4. package/dist/PixelLogger-B21lEjep.d.mts +8 -0
  5. package/dist/PixelLogger-B21lEjep.d.ts +8 -0
  6. package/dist/StorageFactory-BhpbB6Jj.d.mts +8 -0
  7. package/dist/StorageFactory-CAkJJqVD.d.ts +8 -0
  8. package/dist/config/index.cjs.js +3 -0
  9. package/dist/config/index.cjs.js.map +1 -0
  10. package/dist/config/index.d.mts +19 -0
  11. package/dist/config/index.d.ts +19 -0
  12. package/dist/config/index.esm.js +3 -0
  13. package/dist/config/index.esm.js.map +1 -0
  14. package/dist/events/index.cjs.js +3 -0
  15. package/dist/events/index.cjs.js.map +1 -0
  16. package/dist/events/index.d.mts +1 -0
  17. package/dist/events/index.d.ts +1 -0
  18. package/dist/events/index.esm.js +3 -0
  19. package/dist/events/index.esm.js.map +1 -0
  20. package/dist/examples/html-script/README.md +71 -0
  21. package/dist/examples/html-script/RELEASE_CANDIDATE.md +121 -0
  22. package/dist/examples/html-script/add-payment-info/README.md +46 -0
  23. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-autocomplete.html +494 -0
  24. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-disabled.html +478 -0
  25. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-fields.html +486 -0
  26. package/dist/examples/html-script/add-payment-info/example-add-payment-info-data-track.html +479 -0
  27. package/dist/examples/html-script/add-payment-info/example-add-payment-info-dedupe.html +492 -0
  28. package/dist/examples/html-script/add-payment-info/example-add-payment-info-manual.html +495 -0
  29. package/dist/examples/html-script/add-payment-info/example-add-payment-info-rules-card.html +469 -0
  30. package/dist/examples/html-script/add-payment-info/example-add-payment-info-security.html +489 -0
  31. package/dist/examples/html-script/add-to-cart/README.md +36 -0
  32. package/dist/examples/html-script/add-to-cart/example-add-to-cart-attribute.html +517 -0
  33. package/dist/examples/html-script/add-to-cart/example-add-to-cart-auto.html +512 -0
  34. package/dist/examples/html-script/add-to-cart/example-add-to-cart-click.html +519 -0
  35. package/dist/examples/html-script/add-to-cart/example-add-to-cart-dedupe.html +514 -0
  36. package/dist/examples/html-script/add-to-cart/example-add-to-cart-manual.html +517 -0
  37. package/dist/examples/html-script/add-to-cart/example-add-to-cart-order-bump.html +527 -0
  38. package/dist/examples/html-script/add-to-cart/example-add-to-cart-text.html +524 -0
  39. package/dist/examples/html-script/example-basic.html +350 -0
  40. package/dist/examples/html-script/example-behavior.html +435 -0
  41. package/dist/examples/html-script/example-conversion.html +479 -0
  42. package/dist/examples/html-script/example-integration.html +709 -0
  43. package/dist/examples/html-script/example-transport.html +748 -0
  44. package/dist/examples/html-script/initiate-checkout/README.md +38 -0
  45. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-attribute.html +485 -0
  46. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-auto.html +491 -0
  47. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-click.html +493 -0
  48. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-manual.html +494 -0
  49. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-snapshot.html +497 -0
  50. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-submit.html +502 -0
  51. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-text.html +496 -0
  52. package/dist/examples/html-script/lead/README.md +25 -0
  53. package/dist/examples/html-script/lead/example-lead-trigger-attribute.html +594 -0
  54. package/dist/examples/html-script/lead/example-lead-trigger-auto.html +431 -0
  55. package/dist/examples/html-script/lead/example-lead-trigger-click.html +587 -0
  56. package/dist/examples/html-script/release-candidate.html +726 -0
  57. package/dist/examples/html-script/remove-from-cart/README.md +36 -0
  58. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-attribute.html +532 -0
  59. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-css.html +524 -0
  60. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-dedupe.html +540 -0
  61. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-manual.html +533 -0
  62. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-multi.html +557 -0
  63. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-state.html +539 -0
  64. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-text.html +524 -0
  65. package/dist/examples/html-script/search/README.md +41 -0
  66. package/dist/examples/html-script/search/example-search-attribute.html +454 -0
  67. package/dist/examples/html-script/search/example-search-button-sync.html +455 -0
  68. package/dist/examples/html-script/search/example-search-dedupe.html +466 -0
  69. package/dist/examples/html-script/search/example-search-input.html +456 -0
  70. package/dist/examples/html-script/search/example-search-manual.html +473 -0
  71. package/dist/examples/html-script/search/example-search-submit.html +450 -0
  72. package/dist/examples/html-script/search/example-search-text.html +441 -0
  73. package/dist/examples/html-script/view-content/README.md +48 -0
  74. package/dist/examples/html-script/view-content/example-view-content-attribute.html +488 -0
  75. package/dist/examples/html-script/view-content/example-view-content-css.html +467 -0
  76. package/dist/examples/html-script/view-content/example-view-content-dedupe.html +485 -0
  77. package/dist/examples/html-script/view-content/example-view-content-empty.html +469 -0
  78. package/dist/examples/html-script/view-content/example-view-content-manual.html +496 -0
  79. package/dist/examples/html-script/view-content/example-view-content-product-card.html +478 -0
  80. package/dist/examples/html-script/view-content/example-view-content-text.html +473 -0
  81. package/dist/examples/release-candidate/README.md +14 -0
  82. package/dist/examples/v2/README.md +33 -0
  83. package/dist/index-DUfFzniE.d.mts +274 -0
  84. package/dist/index-DUfFzniE.d.ts +274 -0
  85. package/dist/index.cjs.js +3 -0
  86. package/dist/index.cjs.js.map +1 -0
  87. package/dist/index.d.mts +364 -0
  88. package/dist/index.d.ts +364 -0
  89. package/dist/index.esm.js +3 -0
  90. package/dist/index.esm.js.map +1 -0
  91. package/dist/logger/index.cjs.js +3 -0
  92. package/dist/logger/index.cjs.js.map +1 -0
  93. package/dist/logger/index.d.mts +12 -0
  94. package/dist/logger/index.d.ts +12 -0
  95. package/dist/logger/index.esm.js +3 -0
  96. package/dist/logger/index.esm.js.map +1 -0
  97. package/dist/pixel-CbeF25mD.d.mts +555 -0
  98. package/dist/pixel-CbeF25mD.d.ts +555 -0
  99. package/dist/pixel-default-config-1VgLFOiL.d.mts +5 -0
  100. package/dist/pixel-default-config-Bxb-Vdd8.d.ts +5 -0
  101. package/dist/runtime/index.cjs.js +3 -0
  102. package/dist/runtime/index.cjs.js.map +1 -0
  103. package/dist/runtime/index.d.mts +48 -0
  104. package/dist/runtime/index.d.ts +48 -0
  105. package/dist/runtime/index.esm.js +3 -0
  106. package/dist/runtime/index.esm.js.map +1 -0
  107. package/dist/services/index.cjs.js +3 -0
  108. package/dist/services/index.cjs.js.map +1 -0
  109. package/dist/services/index.d.mts +169 -0
  110. package/dist/services/index.d.ts +169 -0
  111. package/dist/services/index.esm.js +3 -0
  112. package/dist/services/index.esm.js.map +1 -0
  113. package/dist/types-CTpRvFKZ.d.ts +71 -0
  114. package/dist/types-DGlBdsAy.d.mts +71 -0
  115. package/dist/v2/global.global.js +3 -0
  116. package/dist/v2/global.global.js.map +1 -0
  117. package/dist/v2/index.cjs.js +3 -0
  118. package/dist/v2/index.cjs.js.map +1 -0
  119. package/dist/v2/index.d.mts +7 -0
  120. package/dist/v2/index.d.ts +7 -0
  121. package/dist/v2/index.esm.js +3 -0
  122. package/dist/v2/index.esm.js.map +1 -0
  123. package/package.json +101 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,194 @@
1
+ # @agenus-io/pixel
2
+
3
+ ## Unreleased
4
+
5
+ ### Release Candidate (0.0.15)
6
+
7
+ - Etapas 12A–12N Commerce + AutoTrack + docs/release readiness
8
+ - Etapa 13A — validação consumidor real (`PixelV2` + Transport Event/Batch)
9
+ - Etapa 13B — pack, instalação limpa (`validate:rc-package`), release notes
10
+ - Fix: match `text:` leaf-only (não dispara ADD_TO_CART em ancestrais)
11
+ - README: PAGE_VIEW via Core (`trackInitialPageView`); removido `pixel.pageView()` inexistente
12
+
13
+ ### Minor Changes
14
+
15
+ - **ADD_PAYMENT_INFO**: Novo evento de conversão com suporte nativo no pixel
16
+ - `AddPaymentInfoTracker` e interface `IAddPaymentInfoData`
17
+ - Método público `trackAddPaymentInfo({ value?, currency?, paymentMethod?, items?, metadata? })`
18
+ - Integração completa com ConversionEngine, fila (prioridade medium) e tipagens
19
+ - `AutoAddPaymentInfoTracker`: detecção automática de campos de cartão (id, name, autocomplete, label)
20
+ - Disparo único por sessão via `sessionStorage` (`ag_add_payment_info_tracked`)
21
+ - Ativo por padrão em `autoTracks.addPaymentInfo`
22
+
23
+ ## 0.0.4
24
+
25
+ ### Patch Changes
26
+
27
+ - updated readme
28
+
29
+ ## 0.0.3
30
+
31
+ ### Patch Changes
32
+
33
+ - add changelog md
34
+ - adjustment
35
+ - 7aba198: adjustment
36
+
37
+ ## 0.0.2
38
+
39
+ ### Patch Changes
40
+
41
+ - **Sessão Persistente**: Implementação completa de sessão persistente com `GetSession`
42
+ - Persistência dupla usando localStorage e cookies
43
+ - Recuperação automática de sessão entre recarregamentos
44
+ - Rastreamento automático de atividade do usuário
45
+ - Contador de visitas e timestamp de primeira visita
46
+ - Renovação automática de sessão com timeout de 30 minutos
47
+ - Métodos públicos para gerenciar sessão: `getSessionData()`, `isSessionActive()`, `renewSession()`, `clearSession()`
48
+
49
+ - **Integração com API Agenus**: Configuração para buscar settings da API e carregar pixels do Facebook automaticamente
50
+ - Busca automática de configurações via `getSetting()`
51
+ - Carregamento automático do Facebook Pixel baseado em `pixelMeta`
52
+ - Configuração dinâmica de auto-tracks baseada em settings da API
53
+
54
+ ## 0.0.1
55
+
56
+ ### Initial Release
57
+
58
+ #### 🎯 **Sistema de Tracking Manual**
59
+
60
+ - **Arquitetura Orientada a Objetos**: Sistema completo baseado em classes com máxima escalabilidade
61
+ - **BaseTracker**: Classe base abstrata para todos os trackers com funcionalidades comuns
62
+ - **TrackerFactory**: Factory pattern para gerenciar instâncias de trackers (Singleton)
63
+ - **Eventos de E-commerce**:
64
+ - `trackPageView()`: Tracking de visualização de página
65
+ - `trackPurchase()`: Tracking de compras com suporte a múltiplos itens
66
+ - `trackAddToCart()`: Tracking de adicionar ao carrinho
67
+ - `trackRemoveToCart()`: Tracking de remover do carrinho
68
+ - `trackInitiateCheckout()`: Tracking de início de checkout
69
+ - `trackLead()`: Tracking de leads com validação de formulários
70
+ - `trackSearch()`: Tracking de buscas
71
+ - `trackViewItem()`: Tracking de visualização de produtos
72
+
73
+ #### 🚀 **Sistema de Auto-Tracking Inteligente**
74
+
75
+ - **BaseAutoTracker**: Classe base para auto-trackers com funcionalidades avançadas
76
+ - Gerenciamento de listeners com debounce/throttle
77
+ - Observação de mudanças no DOM (MutationObserver)
78
+ - Sistema de retry automático
79
+ - Limpeza automática de listeners
80
+
81
+ - **AutoTracks Básicos**:
82
+ - **AutoAddToCart**: Detecção automática de cliques em botões "Adicionar ao Carrinho"
83
+ - Extração automática de dados do produto
84
+ - Suporte a seletores configuráveis
85
+ - Extrator customizado de dados
86
+ - **AutoInitiateCheckout**: Detecção automática de cliques em botões "Finalizar Compra"
87
+ - Extração de dados do carrinho
88
+ - Tracking de navegação para checkout
89
+ - Cálculo automático de valores
90
+ - **AutoLead**: Detecção automática de submissões de formulários
91
+ - Extração de dados de formulários
92
+ - Validação de campos obrigatórios
93
+ - Tracking de interações com campos (focus, blur, change)
94
+ - Regras de validação customizáveis
95
+
96
+ - **AutoTracks Avançados**:
97
+ - **ScrollTracker**: Rastreamento de profundidade de scroll e tempo na página
98
+ - Thresholds configuráveis (25%, 50%, 75%, 90%)
99
+ - Tracking de tempo na página
100
+ - Debouncing configurável
101
+ - **ViewportTracker**: Detecção de elementos entrando/saindo do viewport
102
+ - Tracking de interseção de elementos
103
+ - Tracking de cliques e hovers em elementos visíveis
104
+ - Threshold de visibilidade configurável
105
+ - Limite máximo de elementos rastreados
106
+
107
+ - **AutoTrackerFactory**: Factory pattern para gerenciar auto-trackers
108
+ - Criação lazy de auto-trackers
109
+ - Estatísticas de uso
110
+ - Reconstrução de auto-trackers para DOM dinâmico
111
+ - Limpeza de memória
112
+
113
+ #### 🛠️ **Utilitários e Ferramentas**
114
+
115
+ - **SelectorUtils**: Utilitários avançados para seleção DOM
116
+ - Validação de seletores CSS
117
+ - Busca de elementos com retry automático
118
+ - Verificação de visibilidade e viewport
119
+ - Extração de dados de elementos
120
+ - Suporte a múltiplos tipos de seletores (class, id, attribute, tag, text, url, data-attribute, custom)
121
+
122
+ - **EventManager**: Gerenciador de eventos otimizado
123
+ - Sistema de filas com debounce/throttle
124
+ - Estatísticas de performance
125
+ - Retry automático com backoff
126
+ - Limpeza de memória
127
+
128
+ - **Enriquecimento de Eventos**:
129
+ - `enrichEventPayload()`: Adiciona metadados automáticos aos eventos
130
+ - Fingerprint de dispositivo
131
+ - Informações de dispositivo (user agent, screen, timezone, etc.)
132
+ - Cookies de tracking (\_fbp, \_fbc, \_ga, \_gcl_au)
133
+ - Informações da página (URL, title, referrer, path, hostname)
134
+
135
+ - **Envio de Eventos**:
136
+ - `sendEvent()`: Envio otimizado usando `sendBeacon` com fallback para `fetch`
137
+ - Suporte a múltiplos formatos de payload
138
+ - Tratamento de erros robusto
139
+ - Timeout configurável
140
+
141
+ #### 📦 **Integração e Build**
142
+
143
+ - **Múltiplos Formatos de Build**:
144
+ - **IIFE** (`.global.js`): Para uso via CDN
145
+ - **CommonJS** (`.cjs.js`): Para Node.js
146
+ - **ES Modules** (`.esm.js`): Para bundlers modernos
147
+ - **TypeScript** (`.d.ts`): Definições de tipos completas
148
+
149
+ - **Auto-inicialização via Script Tag**: Suporte a inicialização automática via atributos data
150
+ - **Suporte a CDN**: Pronto para uso via unpkg, jsDelivr, etc.
151
+
152
+ #### 🔧 **Configuração e Flexibilidade**
153
+
154
+ - **Configuração Flexível**: Interface TypeScript completa com todas as opções
155
+ - **Debug Mode**: Logs detalhados para desenvolvimento
156
+ - **Configuração Dinâmica**: Atualização de configuração em runtime
157
+ - **Múltiplos Seletores**: Suporte a class, id, attribute, tag, text, url, data-attribute, custom
158
+ - **Extração de Dados**: Seletores configuráveis para extrair dados de produtos/carrinho
159
+ - **Validação**: Sistema de validação de formulários com regras customizadas
160
+ - **Callbacks Customizados**: Funções de callback para processamento customizado
161
+
162
+ #### 📊 **Monitoramento e Estatísticas**
163
+
164
+ - **Estatísticas Detalhadas**: Contadores de eventos, performance, erros
165
+ - **Debug Avançado**: Logs detalhados para desenvolvimento
166
+ - **Health Checks**: Verificação de saúde dos trackers
167
+ - **Métodos de Estatísticas**: `getTrackerStats()`, `getAutoTrackerStats()`
168
+
169
+ #### 🎨 **Características Técnicas**
170
+
171
+ - **TypeScript**: Tipagem completa e type safety
172
+ - **Performance Otimizada**: Debouncing, throttling e lazy loading
173
+ - **DOM Dinâmico**: Suporte a elementos adicionados dinamicamente via MutationObserver
174
+ - **Retry Logic**: Sistema de retry automático para elementos que ainda não carregaram
175
+ - **Memory Management**: Limpeza automática de listeners
176
+ - **Bundle Optimization**: Tree-shaking para reduzir tamanho do bundle
177
+ - **Source Maps**: Mapeamento de código fonte para debug
178
+
179
+ #### 🔐 **Integração com Pixels Externos**
180
+
181
+ - **Facebook Pixel**: Carregamento automático do Facebook Pixel
182
+ - Suporte a múltiplos pixels
183
+ - Inicialização automática
184
+ - Integração com eventos de e-commerce
185
+
186
+ - **Google Tag**: Preparado para integração com Google Analytics
187
+ - Estrutura pronta para carregamento de Google Tag
188
+ - Suporte a eventos de conversão
189
+
190
+ #### 📚 **Documentação e Exemplos**
191
+
192
+ - **README Completo**: Documentação detalhada com exemplos
193
+ - **Exemplos de Uso**: Múltiplos exemplos para diferentes casos de uso
194
+ - **TypeScript Definitions**: Tipos completos para melhor DX
package/README.md ADDED
@@ -0,0 +1,163 @@
1
+ # Pixel v2
2
+
3
+ SDK de analytics e conversão para web — arquitetura modular v2.
4
+
5
+ **Documentação:** [`ARCHITECTURE.md`](./ARCHITECTURE.md) · [`README_LEGACY_AUDIT.md`](./README_LEGACY_AUDIT.md) · [`RELEASE_CANDIDATE.md`](./RELEASE_CANDIDATE.md)
6
+
7
+ ## Arquitetura
8
+
9
+ ```txt
10
+ Pixel → PixelRuntime → Services → Modules → BaseEventBuilder → Dispatcher
11
+ ├── TransportModule → API própria
12
+ └── IntegrationsModule → PAGE_VIEW browser (Meta / Google / TikTok)
13
+ ```
14
+
15
+ Attribution é independente: `AttributionService` → `event.identifiers` → Transport/API.
16
+
17
+ O legado `GomarkePixel` (v1) foi **removido na Etapa 11**.
18
+
19
+ ## Instalação
20
+
21
+ ```bash
22
+ pnpm add @agenus-io/pixel
23
+ ```
24
+
25
+ Tarball local (RC):
26
+
27
+ ```bash
28
+ npm pack
29
+ npm install ./agenus-io-pixel-0.0.15.tgz
30
+ npm run validate:rc-package
31
+ ```
32
+
33
+ ## Uso (ESM / CJS)
34
+
35
+ ```ts
36
+ import { Pixel, DEFAULT_PIXEL_CONFIG } from '@agenus-io/pixel';
37
+
38
+ const pixel = new Pixel({
39
+ ...DEFAULT_PIXEL_CONFIG,
40
+ identity: {
41
+ ...DEFAULT_PIXEL_CONFIG.identity,
42
+ pixelId: 'pix_123',
43
+ },
44
+ transport: {
45
+ ...DEFAULT_PIXEL_CONFIG.transport,
46
+ apiEndpoint: 'https://sua-api.example.com',
47
+ },
48
+ modules: {
49
+ ...DEFAULT_PIXEL_CONFIG.modules,
50
+ core: {
51
+ ...DEFAULT_PIXEL_CONFIG.modules.core,
52
+ enabled: true,
53
+ pageView: {
54
+ ...DEFAULT_PIXEL_CONFIG.modules.core.pageView,
55
+ enabled: true,
56
+ trackInitialPageView: true, // PAGE_VIEW no init — não há pixel.pageView()
57
+ },
58
+ },
59
+ conversion: {
60
+ ...DEFAULT_PIXEL_CONFIG.modules.conversion,
61
+ enabled: true,
62
+ manual: {
63
+ ...DEFAULT_PIXEL_CONFIG.modules.conversion.manual,
64
+ purchase: { enabled: true },
65
+ },
66
+ },
67
+ transport: {
68
+ ...DEFAULT_PIXEL_CONFIG.modules.transport,
69
+ enabled: true,
70
+ mockSender: { enabled: false },
71
+ sender: { mode: 'http' },
72
+ },
73
+ },
74
+ });
75
+
76
+ await pixel.init();
77
+ pixel.purchase({ orderId: '1', value: 99.9, currency: 'BRL' });
78
+ await pixel.destroy();
79
+ ```
80
+
81
+ ```js
82
+ const { Pixel, DEFAULT_PIXEL_CONFIG } = require('@agenus-io/pixel');
83
+ ```
84
+
85
+ ## CDN (bundle global)
86
+
87
+ ```html
88
+ <script src="https://unpkg.com/@agenus-io/pixel@latest/dist/v2/global.global.js"></script>
89
+ <script>
90
+ const { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
91
+ const pixel = new Pixel({
92
+ ...DEFAULT_PIXEL_CONFIG,
93
+ identity: { ...DEFAULT_PIXEL_CONFIG.identity, pixelId: 'pix_123' },
94
+ transport: {
95
+ ...DEFAULT_PIXEL_CONFIG.transport,
96
+ apiEndpoint: 'https://sua-api.example.com',
97
+ },
98
+ modules: {
99
+ ...DEFAULT_PIXEL_CONFIG.modules,
100
+ core: {
101
+ ...DEFAULT_PIXEL_CONFIG.modules.core,
102
+ enabled: true,
103
+ pageView: {
104
+ ...DEFAULT_PIXEL_CONFIG.modules.core.pageView,
105
+ enabled: true,
106
+ trackInitialPageView: true,
107
+ },
108
+ },
109
+ },
110
+ });
111
+ pixel.init();
112
+ </script>
113
+ ```
114
+
115
+ Nome global oficial: **`PixelV2`**.
116
+
117
+ ## Package exports
118
+
119
+ | Export | Descrição |
120
+ |--------|-----------|
121
+ | `@agenus-io/pixel` | `Pixel`, `DEFAULT_PIXEL_CONFIG`, `PixelConfig` |
122
+ | `@agenus-io/pixel/global` | IIFE `window.PixelV2` |
123
+ | `@agenus-io/pixel/v2` | Alias do entry principal |
124
+ | `@agenus-io/pixel/config` | Tipos e defaults de configuração |
125
+ | `@agenus-io/pixel/events` | Eventos tipados |
126
+ | `@agenus-io/pixel/services` | Services (attribution, session, etc.) |
127
+ | `@agenus-io/pixel/runtime` | Runtime e bootstrap |
128
+ | `@agenus-io/pixel/logger` | Logger |
129
+
130
+ ## Playgrounds
131
+
132
+ Exemplos oficiais em `examples/html-script/` (copiados para `dist/examples/html-script/` no build):
133
+
134
+ - `release-candidate.html` — consumidor real (`window.PixelV2` + Transport)
135
+ - `RELEASE_CANDIDATE.md` — como testar o playground RC
136
+ - `example-basic.html`, `example-behavior.html`, `example-conversion.html`, …
137
+ - pastas por evento: `lead/`, `add-to-cart/`, …
138
+
139
+ Índice: [`examples/html-script/README.md`](./examples/html-script/README.md)
140
+ Release notes: [`RELEASE_CANDIDATE.md`](./RELEASE_CANDIDATE.md)
141
+
142
+ ## Scripts
143
+
144
+ ```bash
145
+ pnpm build # dist/
146
+ pnpm test # testes v2
147
+ pnpm type-check # tsc --noEmit
148
+ pnpm test:smoke:real # smoke Event/Batch (skip sem .env)
149
+ pnpm validate:rc-package # instalação limpa do .tgz
150
+ ```
151
+
152
+ ## Migração v1 → v2
153
+
154
+ | v1 (removido) | v2 |
155
+ |---------------|-----|
156
+ | `GomarkePixel` | `Pixel` |
157
+ | `window.gomarkePixel` | `window.PixelV2` |
158
+ | `dist/index.global.js` | `dist/v2/global.global.js` |
159
+ | `src/core/**` | `modules/core` + `transport` |
160
+ | `src/behavior/**` | `modules/behavior` |
161
+ | `src/conversion/**` | `modules/conversion` |
162
+ | `getTrackingCookies` | `AttributionService` |
163
+ | `loadFacebookPixel` / `loadGoogleTag` | `IntegrationEngine` browser destinations |
@@ -0,0 +1,256 @@
1
+ # Pixel v2 — Release Candidate Notes
2
+
3
+ **Pacote:** `@agenus-io/pixel`
4
+ **Versão:** `0.0.15` (release candidate)
5
+ **Data:** 2026-07-11
6
+ **Status:** Pronto para publicar RC — **nenhuma pendência P0 conhecida**
7
+
8
+ > Guia do playground consumidor: [`examples/html-script/RELEASE_CANDIDATE.md`](./examples/html-script/RELEASE_CANDIDATE.md)
9
+ > Backlog: [`PIXEL_V2_BACKLOG_PENDENCIAS_ISOLADO.md`](./PIXEL_V2_BACKLOG_PENDENCIAS_ISOLADO.md)
10
+
11
+ ---
12
+
13
+ ## 1. Status do RC
14
+
15
+ ```txt
16
+ Pixel v2 está pronto para release candidate.
17
+ Nenhuma pendência P0 conhecida.
18
+ npm publish NÃO foi executado nesta etapa (13B).
19
+ ```
20
+
21
+ Validado em 13A (consumidor real) + 13B (pacote / instalação limpa).
22
+
23
+ ---
24
+
25
+ ## 2. O que foi implementado
26
+
27
+ ```txt
28
+ Runtime v2 + bootstrap
29
+ Core services (visitor, session, fingerprint, storage)
30
+ Behavior tracking
31
+ Conversion tracking (manual + auto)
32
+ Transport real Event + Batch (HttpSender)
33
+ Resiliência (retry, offline, circuit breaker, DLQ, …)
34
+ Replay / Ordering / Coordination
35
+ Browser destinations (Meta / Google / TikTok)
36
+ Attribution
37
+ Commerce + AutoTrack avançado (12A–12M)
38
+ Playgrounds examples/html-script/*
39
+ Smoke real opcional (env)
40
+ Release candidate HTML + pack validation (13A–13B)
41
+ ```
42
+
43
+ Correção recente (pré-13B): match `text:` leaf-only — evita ADD_TO_CART em cliques em ancestrais.
44
+
45
+ ---
46
+
47
+ ## 3. Como instalar
48
+
49
+ ### Registry (quando publicado)
50
+
51
+ ```bash
52
+ pnpm add @agenus-io/pixel
53
+ # ou
54
+ npm install @agenus-io/pixel
55
+ ```
56
+
57
+ ### Tarball local (RC sem publish)
58
+
59
+ ```bash
60
+ npm run build
61
+ npm pack
62
+ npm install ./agenus-io-pixel-0.0.15.tgz
63
+ ```
64
+
65
+ Validar tarball:
66
+
67
+ ```bash
68
+ npm run validate:rc-package
69
+ # ou
70
+ node scripts/validate-rc-package.mjs ./agenus-io-pixel-0.0.15.tgz
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 4. Como usar via import (ESM)
76
+
77
+ ```ts
78
+ import { Pixel, DEFAULT_PIXEL_CONFIG } from '@agenus-io/pixel';
79
+
80
+ const pixel = new Pixel({
81
+ ...DEFAULT_PIXEL_CONFIG,
82
+ identity: {
83
+ ...DEFAULT_PIXEL_CONFIG.identity,
84
+ pixelId: 'pix_xxx',
85
+ },
86
+ transport: {
87
+ ...DEFAULT_PIXEL_CONFIG.transport,
88
+ apiEndpoint: 'https://sua-api.example.com',
89
+ },
90
+ modules: {
91
+ ...DEFAULT_PIXEL_CONFIG.modules,
92
+ core: {
93
+ ...DEFAULT_PIXEL_CONFIG.modules.core,
94
+ enabled: true,
95
+ pageView: {
96
+ ...DEFAULT_PIXEL_CONFIG.modules.core.pageView,
97
+ enabled: true,
98
+ trackInitialPageView: true,
99
+ },
100
+ },
101
+ conversion: {
102
+ ...DEFAULT_PIXEL_CONFIG.modules.conversion,
103
+ enabled: true,
104
+ manual: {
105
+ ...DEFAULT_PIXEL_CONFIG.modules.conversion.manual,
106
+ lead: { enabled: true },
107
+ purchase: { enabled: true },
108
+ },
109
+ },
110
+ transport: {
111
+ ...DEFAULT_PIXEL_CONFIG.modules.transport,
112
+ enabled: true,
113
+ mockSender: { enabled: false },
114
+ sender: { mode: 'http' },
115
+ },
116
+ },
117
+ });
118
+
119
+ await pixel.init();
120
+ // PAGE_VIEW: emitido pelo Core (trackInitialPageView) — não existe pixel.pageView()
121
+ pixel.lead({ email: 'user@example.com' });
122
+ pixel.purchase({ orderId: '1', value: 99.9, currency: 'BRL' });
123
+ await pixel.destroy();
124
+ ```
125
+
126
+ ### CJS
127
+
128
+ ```js
129
+ const { Pixel, DEFAULT_PIXEL_CONFIG } = require('@agenus-io/pixel');
130
+ ```
131
+
132
+ ### Subpath `/v2`
133
+
134
+ ```ts
135
+ import { Pixel } from '@agenus-io/pixel/v2';
136
+ ```
137
+
138
+ ---
139
+
140
+ ## 5. Como usar via script tag
141
+
142
+ Bundle IIFE: `dist/v2/global.global.js` → **`window.PixelV2`**
143
+
144
+ ```html
145
+ <script src="./node_modules/@agenus-io/pixel/dist/v2/global.global.js"></script>
146
+ <script>
147
+ const { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
148
+ const pixel = new Pixel({
149
+ ...DEFAULT_PIXEL_CONFIG,
150
+ identity: { ...DEFAULT_PIXEL_CONFIG.identity, pixelId: 'pix_xxx' },
151
+ transport: {
152
+ ...DEFAULT_PIXEL_CONFIG.transport,
153
+ apiEndpoint: 'https://sua-api.example.com',
154
+ },
155
+ });
156
+ pixel.init();
157
+ </script>
158
+ ```
159
+
160
+ Export npm: `@agenus-io/pixel/global`.
161
+
162
+ ---
163
+
164
+ ## 6. Transport real
165
+
166
+ ```ts
167
+ modules: {
168
+ transport: {
169
+ enabled: true,
170
+ mockSender: { enabled: false },
171
+ sender: { mode: 'http' },
172
+ batch: { enabled: true, batchSize: 1 }, // Event
173
+ // batchSize: 10 → Batch
174
+ },
175
+ },
176
+ transport: {
177
+ apiEndpoint: process.env.PIXEL_API_ENDPOINT, // não hardcodar em produção
178
+ },
179
+ ```
180
+
181
+ Endpoints oficiais do SDK:
182
+
183
+ ```txt
184
+ POST {apiEndpoint}/pixels/public/event
185
+ POST {apiEndpoint}/pixels/public/event/batch
186
+ ```
187
+
188
+ ---
189
+
190
+ ## 7. Commerce (resumo)
191
+
192
+ ```ts
193
+ modules.conversion.commerce = {
194
+ currency: 'BRL',
195
+ catalog: { products: [{ id: 'main_offer', name: '…', price: 197, … }] },
196
+ checkout: {
197
+ selectedItems: [{ productId: 'main_offer', quantity: 1 }],
198
+ calculateValueFrom: 'selected_items',
199
+ allowDynamicItems: true,
200
+ },
201
+ };
202
+ ```
203
+
204
+ Detalhes: `PIXEL_V2_COMMERCE_AUTOTRACK_PLAN.md` · playgrounds em `examples/html-script/`.
205
+
206
+ ---
207
+
208
+ ## 8. Smoke real
209
+
210
+ ```bash
211
+ # skip seguro sem .env
212
+ npm run test:smoke:real
213
+
214
+ # com .env local (NÃO commitar):
215
+ # PIXEL_REAL_API_SMOKE=true
216
+ # PIXEL_API_ENDPOINT=https://...
217
+ # PIXEL_ID=pix_...
218
+ npm run test:smoke:real
219
+ ```
220
+
221
+ ---
222
+
223
+ ## 9. Checklist de validação / publicação
224
+
225
+ ```txt
226
+ [x] npm run type-check
227
+ [x] npm test
228
+ [x] npm run build
229
+ [x] npm run test:smoke:real (skip sem env / ACK com env)
230
+ [x] npm pack --dry-run
231
+ [x] npm pack → agenus-io-pixel-0.0.15.tgz
232
+ [x] npm run validate:rc-package
233
+ [x] dist/v2/global.global.js no tarball
234
+ [x] types .d.ts no tarball
235
+ [x] sem .env / credenciais no tarball
236
+ [ ] npm publish --tag rc # manual, fora da 13B
237
+ [ ] git tag # manual, fora da 13B
238
+ ```
239
+
240
+ ---
241
+
242
+ ## 10. Pendências conhecidas (não bloqueiam RC)
243
+
244
+ **P1:** PrivacyModule/Consent · Behavior P1 · debug snapshot · limpeza CommerceState pós-purchase · docs públicas
245
+
246
+ **P2:** destinations extras · CAPI/server-side (**backend**, não SDK) · sampling · observabilidade
247
+
248
+ ---
249
+
250
+ ## 11. Fora do SDK
251
+
252
+ ```txt
253
+ CAPI / enrichments server-side
254
+ Consent gate completo (PrivacyModule ainda stub)
255
+ Publicação automática npm / CDN
256
+ ```
@@ -0,0 +1,8 @@
1
+ interface PixelLogger {
2
+ debug(...args: unknown[]): void;
3
+ info(...args: unknown[]): void;
4
+ warn(...args: unknown[]): void;
5
+ error(...args: unknown[]): void;
6
+ }
7
+
8
+ export type { PixelLogger as P };
@@ -0,0 +1,8 @@
1
+ interface PixelLogger {
2
+ debug(...args: unknown[]): void;
3
+ info(...args: unknown[]): void;
4
+ warn(...args: unknown[]): void;
5
+ error(...args: unknown[]): void;
6
+ }
7
+
8
+ export type { PixelLogger as P };
@@ -0,0 +1,8 @@
1
+ import { V as VisitorStoragePersistence, S as SessionStoragePersistence, A as AttributionStoragePersistence, Q as QueueStoragePersistence } from './pixel-CbeF25mD.mjs';
2
+ import { S as StorageAdapter } from './types-DGlBdsAy.mjs';
3
+
4
+ type StoragePersistence = VisitorStoragePersistence | SessionStoragePersistence | AttributionStoragePersistence | QueueStoragePersistence;
5
+ declare function createStorageAdapter(persistence?: StoragePersistence): StorageAdapter;
6
+ declare function resolveStorageAdapterName(persistence?: StoragePersistence): string;
7
+
8
+ export { type StoragePersistence as S, createStorageAdapter as c, resolveStorageAdapterName as r };
@@ -0,0 +1,8 @@
1
+ import { V as VisitorStoragePersistence, S as SessionStoragePersistence, A as AttributionStoragePersistence, Q as QueueStoragePersistence } from './pixel-CbeF25mD.js';
2
+ import { S as StorageAdapter } from './types-CTpRvFKZ.js';
3
+
4
+ type StoragePersistence = VisitorStoragePersistence | SessionStoragePersistence | AttributionStoragePersistence | QueueStoragePersistence;
5
+ declare function createStorageAdapter(persistence?: StoragePersistence): StorageAdapter;
6
+ declare function resolveStorageAdapterName(persistence?: StoragePersistence): string;
7
+
8
+ export { type StoragePersistence as S, createStorageAdapter as c, resolveStorageAdapterName as r };
@@ -0,0 +1,3 @@
1
+ /* Pixel v2 — SDK de analytics e conversão */
2
+ "use strict";var m=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},I=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!_.call(e,n)&&n!==o&&m(e,n,{get:()=>t[n],enumerable:!(r=b(t,n))||r.enumerable});return e};var h=e=>I(m({},"__esModule",{value:!0}),e);var F={};E(F,{DEFAULT_ATTRIBUTION_CONFIG:()=>a,DEFAULT_BEHAVIOR_MODULE_CONFIG:()=>l,DEFAULT_COMMERCE_CONFIG:()=>g,DEFAULT_CONVERSION_MODULE_CONFIG:()=>s,DEFAULT_CORE_MODULE_CONFIG:()=>u,DEFAULT_INTEGRATIONS_MODULE_CONFIG:()=>c,DEFAULT_PIXEL_CONFIG:()=>y,DEFAULT_PRIVACY_MODULE_CONFIG:()=>p,DEFAULT_SELECTOR_TYPE:()=>f,DEFAULT_TRANSPORT_MODULE_CONFIG:()=>d,getPrimarySelectorValue:()=>i,resolveSelectorTypeFallback:()=>C});module.exports=h(F);var f="css";function i(e){if(e==null)return null;if(typeof e=="string"){let o=e.trim();return o.length>0?o:null}if(Array.isArray(e)){for(let o of e){let r=i(o);if(r)return r}return null}let t=e.value?.trim();return t&&t.length>0?t:null}function C(e,t){if(t)return t;if(e!=null&&typeof e!="string")if(Array.isArray(e)){for(let o of e)if(typeof o!="string")return o.type}else return e.type;return"css"}var g={catalog:{products:[]},checkout:{selectedItems:[],allowDynamicItems:!0,calculateValueFrom:"selected_items"},mappings:{attributes:{},fields:{}}};var a={enabled:!0,ttlDays:90,persist:!0,captureUrlParams:!0,captureCookies:!0,customClickIdParams:[]};var l={enabled:!1,trackers:{scroll:{enabled:!1,thresholds:[25,50,75,100],debounceMs:100},click:{enabled:!1,rageClick:{enabled:!0,threshold:3,windowMs:500}},idle:{enabled:!1,thresholdMs:6e4},visibility:{enabled:!1},exitIntent:{enabled:!1},viewport:{enabled:!1,selector:"",selectorType:"attribute",visibilityThreshold:.5},heartbeat:{enabled:!1,intervalMs:5e3,hiddenIntervalMs:3e4},engagement:{enabled:!1,weights:{scroll:.3,click:.3,time:.25},thresholds:{low:30,medium:70}}}};var s={enabled:!1,commerce:{catalog:{products:[]},checkout:{selectedItems:[],allowDynamicItems:!0,calculateValueFrom:"selected_items"},mappings:{attributes:{},fields:{}}},manual:{pageView:{enabled:!1},purchase:{enabled:!1},lead:{enabled:!1},addToCart:{enabled:!1},removeFromCart:{enabled:!1},initiateCheckout:{enabled:!1},addPaymentInfo:{enabled:!1},search:{enabled:!1},viewContent:{enabled:!1}},auto:{enabled:!1,detectors:{lead:{enabled:!1},purchase:{enabled:!1},addToCart:{enabled:!1},removeFromCart:{enabled:!1},initiateCheckout:{enabled:!1},addPaymentInfo:{enabled:!1,paymentMethod:"CREDIT_CARD",cardDetection:!0,autoDispatch:!0},search:{enabled:!1},viewContent:{enabled:!1}}},rules:{enabled:!1,selectors:["[data-track]"],texts:["Comprar","Comprar Agora","Finalizar Compra","Checkout"],urlPatterns:["thank-you","purchase","success","order","checkout"],checkout:{enabled:!1},card:{enabled:!1}}};var u={enabled:!0,pageView:{enabled:!0,trackInitialPageView:!0,spa:!0,dedupeMs:2e3},visitor:{enabled:!0,persistence:"cookie_localStorage",renew:!1},session:{enabled:!0,ttlMs:108e5,renewOnActivity:!0,renewOnPageView:!0},fingerprint:{enabled:!0,mode:"light",cache:!0},consent:{enabled:!1,required:!1,waitForConsent:!1},dedupe:{enabled:!0,windowMs:2e3},coordination:{enabled:!0,leaderElection:!0,broadcastChannel:!0},ordering:{enabled:!0,preserveOrder:!0}};var c={enabled:!1,debug:!1,concurrency:3,timeoutMs:5e3,continueOnError:!0,destinations:{console:{enabled:!1},memory:{enabled:!1},mock:{enabled:!1},meta:{enabled:!1,pixelIds:[],autoPageView:!0,loadScript:!0},google:{enabled:!1,tagIds:[],autoPageView:!0,loadScript:!0},tiktok:{enabled:!1,pixelIds:[],autoPageView:!0,loadScript:!0}}};var p={enabled:!1,consent:{enabled:!1,required:!1},pii:{enabled:!1,hashEmail:!0,hashPhone:!0},anonymization:{enabled:!1,anonymizeIp:!0}};var d={enabled:!1,mockSender:{enabled:!0},sender:{mode:"mock"},persistence:{enabled:!0},replay:{enabled:!0},ordering:{enabled:!0},coordination:{enabled:!0},circuitBreaker:{enabled:!0,failureThreshold:5,resetTimeoutMs:3e4,halfOpenMaxAttempts:2},backpressure:{enabled:!0,maxQueueSize:500,policy:"drop_oldest",sampleRate:.5},deadLetter:{enabled:!0,maxEntries:200},compression:{enabled:!0,strategy:"identity"},retry:{enabled:!0,maxAttempts:4,baseDelayMs:500,maxDelayMs:4e3,multiplier:2},batch:{enabled:!0,batchSize:10,flushIntervalMs:2e3,maxWaitMs:5e3},timeout:{enabled:!0,timeoutMs:1e4},offline:{enabled:!0},flush:{enabled:!0,flushIntervalMs:2e3,flushOnDestroy:!0,prepareUnloadHooks:!0}};var y={app:{source:"custom",target:"custom",environment:"production",debug:!1},identity:{pixelId:""},transport:{apiEndpoint:"",timeoutMs:1e4},storage:{prefix:"__gmk",namespace:"pixel",queue:{enabled:!0,persistence:"memory",index:!0}},attribution:{...a},modules:{core:u,behavior:l,conversion:s,transport:d,integrations:c,privacy:p}};0&&(module.exports={DEFAULT_ATTRIBUTION_CONFIG,DEFAULT_BEHAVIOR_MODULE_CONFIG,DEFAULT_COMMERCE_CONFIG,DEFAULT_CONVERSION_MODULE_CONFIG,DEFAULT_CORE_MODULE_CONFIG,DEFAULT_INTEGRATIONS_MODULE_CONFIG,DEFAULT_PIXEL_CONFIG,DEFAULT_PRIVACY_MODULE_CONFIG,DEFAULT_SELECTOR_TYPE,DEFAULT_TRANSPORT_MODULE_CONFIG,getPrimarySelectorValue,resolveSelectorTypeFallback});
3
+ //# sourceMappingURL=index.cjs.js.map