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

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 (191) hide show
  1. package/CHANGELOG.md +311 -4
  2. package/README.md +90 -128
  3. package/RELEASE_CANDIDATE.md +218 -101
  4. package/dist/Pixel-BnN86r4X.d.ts +797 -0
  5. package/dist/Pixel-BoUGqCbP.d.mts +797 -0
  6. package/dist/{StorageFactory-CAkJJqVD.d.ts → StorageFactory-BfCArzMM.d.ts} +2 -2
  7. package/dist/{StorageFactory-BhpbB6Jj.d.mts → StorageFactory-C0prtNR7.d.mts} +2 -2
  8. package/dist/browser/index.cjs.js +3 -0
  9. package/dist/browser/index.cjs.js.map +1 -0
  10. package/dist/browser/index.d.mts +77 -0
  11. package/dist/browser/index.d.ts +77 -0
  12. package/dist/browser/index.esm.js +3 -0
  13. package/dist/browser/index.esm.js.map +1 -0
  14. package/dist/browser/pixel.buygoods-checkout.global.js +4 -0
  15. package/dist/browser/pixel.buygoods-checkout.global.js.map +1 -0
  16. package/dist/browser/pixel.buygoods-landing.global.js +4 -0
  17. package/dist/browser/pixel.buygoods-landing.global.js.map +1 -0
  18. package/dist/browser/pixel.global.js +4 -0
  19. package/dist/browser/pixel.global.js.map +1 -0
  20. package/dist/browser/pixel.internal-checkout.global.js +4 -0
  21. package/dist/browser/pixel.internal-checkout.global.js.map +1 -0
  22. package/dist/config/index.cjs.js +1 -1
  23. package/dist/config/index.cjs.js.map +1 -1
  24. package/dist/config/index.d.mts +16 -5
  25. package/dist/config/index.d.ts +16 -5
  26. package/dist/config/index.esm.js +1 -1
  27. package/dist/config/index.esm.js.map +1 -1
  28. package/dist/events/index.cjs.js +1 -1
  29. package/dist/events/index.cjs.js.map +1 -1
  30. package/dist/events/index.d.mts +2 -1
  31. package/dist/events/index.d.ts +2 -1
  32. package/dist/events/index.esm.js +1 -1
  33. package/dist/events/index.esm.js.map +1 -1
  34. package/dist/examples/html-script/README.md +21 -55
  35. package/dist/examples/html-script/RELEASE_CANDIDATE.md +39 -26
  36. package/dist/examples/html-script/add-payment-info/README.md +3 -3
  37. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-autocomplete.html +107 -96
  38. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-disabled.html +107 -96
  39. package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-fields.html +106 -95
  40. package/dist/examples/html-script/add-payment-info/example-add-payment-info-data-track.html +114 -95
  41. package/dist/examples/html-script/add-payment-info/example-add-payment-info-dedupe.html +106 -95
  42. package/dist/examples/html-script/add-payment-info/example-add-payment-info-manual.html +97 -95
  43. package/dist/examples/html-script/add-payment-info/example-add-payment-info-rules-card.html +106 -95
  44. package/dist/examples/html-script/add-payment-info/example-add-payment-info-security.html +106 -95
  45. package/dist/examples/html-script/add-to-cart/README.md +9 -6
  46. package/dist/examples/html-script/add-to-cart/example-add-to-cart-attribute.html +133 -119
  47. package/dist/examples/html-script/add-to-cart/example-add-to-cart-auto.html +146 -130
  48. package/dist/examples/html-script/add-to-cart/example-add-to-cart-click.html +144 -127
  49. package/dist/examples/html-script/add-to-cart/example-add-to-cart-dedupe.html +133 -119
  50. package/dist/examples/html-script/add-to-cart/example-add-to-cart-link.html +590 -0
  51. package/dist/examples/html-script/add-to-cart/example-add-to-cart-manual.html +124 -116
  52. package/dist/examples/html-script/add-to-cart/example-add-to-cart-order-bump.html +133 -119
  53. package/dist/examples/html-script/add-to-cart/example-add-to-cart-text.html +147 -130
  54. package/dist/examples/html-script/behavior/example-behavior-engagement.html +489 -0
  55. package/dist/examples/html-script/behavior/example-behavior-heartbeat.html +350 -0
  56. package/dist/examples/html-script/behavior/example-behavior-runtime-intelligence.html +433 -0
  57. package/dist/examples/html-script/behavior/example-behavior-viewport.html +397 -0
  58. package/dist/examples/html-script/{example-behavior.html → behavior/example-behavior.html} +23 -17
  59. package/dist/examples/html-script/buygoods/example-buygoods-checkout.html +50 -0
  60. package/dist/examples/html-script/buygoods/ladding.html +184 -0
  61. package/dist/examples/html-script/example-basic.html +1 -1
  62. package/dist/examples/html-script/example-checkout-commerce.html +826 -0
  63. package/dist/examples/html-script/example-conversion.html +42 -49
  64. package/dist/examples/html-script/example-global-factory-classic.html +45 -0
  65. package/dist/examples/html-script/example-global-factory.html +40 -0
  66. package/dist/examples/html-script/example-integration.html +45 -51
  67. package/dist/examples/html-script/example-landing-commerce.html +416 -0
  68. package/dist/examples/html-script/example-runtime-diagnostics.html +108 -0
  69. package/dist/examples/html-script/example-transport.html +70 -63
  70. package/dist/examples/html-script/full-funnel/README.md +64 -0
  71. package/dist/examples/html-script/full-funnel/checkout.html +118 -0
  72. package/dist/examples/html-script/full-funnel/downsell.html +60 -0
  73. package/dist/examples/html-script/full-funnel/landing.html +153 -0
  74. package/dist/examples/html-script/full-funnel/thank-you.html +87 -0
  75. package/dist/examples/html-script/full-funnel/upsell.html +66 -0
  76. package/dist/examples/html-script/initiate-checkout/README.md +6 -6
  77. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-attribute.html +135 -122
  78. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-auto.html +143 -128
  79. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-click.html +144 -128
  80. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-manual.html +127 -120
  81. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-snapshot.html +136 -123
  82. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-submit.html +144 -131
  83. package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-text.html +146 -130
  84. package/dist/examples/html-script/internal-checkout/example-cardioclear-checkout.html +57 -0
  85. package/dist/examples/html-script/internal-checkout/example-slimsoda-checkout.html +53 -0
  86. package/dist/examples/html-script/lead/README.md +9 -7
  87. package/dist/examples/html-script/lead/example-lead-trigger-attribute.html +107 -94
  88. package/dist/examples/html-script/lead/example-lead-trigger-auto.html +118 -103
  89. package/dist/examples/html-script/lead/example-lead-trigger-click.html +118 -102
  90. package/dist/examples/html-script/release-candidate.html +219 -107
  91. package/dist/examples/html-script/remove-from-cart/README.md +4 -4
  92. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-attribute.html +134 -121
  93. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-css.html +134 -121
  94. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-dedupe.html +141 -128
  95. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-manual.html +125 -118
  96. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-multi.html +135 -122
  97. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-state.html +136 -123
  98. package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-text.html +139 -124
  99. package/dist/examples/html-script/search/README.md +1 -1
  100. package/dist/examples/html-script/search/example-search-attribute.html +107 -99
  101. package/dist/examples/html-script/search/example-search-button-sync.html +107 -99
  102. package/dist/examples/html-script/search/example-search-dedupe.html +107 -99
  103. package/dist/examples/html-script/search/example-search-input.html +108 -99
  104. package/dist/examples/html-script/search/example-search-manual.html +98 -96
  105. package/dist/examples/html-script/search/example-search-submit.html +107 -99
  106. package/dist/examples/html-script/search/example-search-text.html +112 -99
  107. package/dist/examples/html-script/url-context/example-url-context-allowed-domains.html +92 -0
  108. package/dist/examples/html-script/url-context/example-url-context-landing.html +110 -0
  109. package/dist/examples/html-script/url-context/example-url-context-upsell.html +105 -0
  110. package/dist/examples/html-script/url-context/example-url-context.html +205 -0
  111. package/dist/examples/html-script/view-content/README.md +1 -1
  112. package/dist/examples/html-script/view-content/example-view-content-attribute.html +126 -118
  113. package/dist/examples/html-script/view-content/example-view-content-css.html +126 -118
  114. package/dist/examples/html-script/view-content/example-view-content-dedupe.html +126 -118
  115. package/dist/examples/html-script/view-content/example-view-content-empty.html +126 -118
  116. package/dist/examples/html-script/view-content/example-view-content-manual.html +117 -115
  117. package/dist/examples/html-script/view-content/example-view-content-product-card.html +126 -118
  118. package/dist/examples/html-script/view-content/example-view-content-text.html +131 -121
  119. package/dist/examples/release-candidate/README.md +2 -1
  120. package/dist/examples/v2/README.md +16 -13
  121. package/dist/index-B8u_3PGG.d.ts +460 -0
  122. package/dist/index-BxT2d-TK.d.mts +460 -0
  123. package/dist/index.cjs.js +1 -1
  124. package/dist/index.cjs.js.map +1 -1
  125. package/dist/index.d.mts +23 -361
  126. package/dist/index.d.ts +23 -361
  127. package/dist/index.esm.js +1 -1
  128. package/dist/index.esm.js.map +1 -1
  129. package/dist/pixel-DNGbAN5C.d.ts +871 -0
  130. package/dist/pixel-_BSDpx4M.d.mts +871 -0
  131. package/dist/pixel-default-config-BMYaqs7i.d.ts +21 -0
  132. package/dist/pixel-default-config-DLRya1tl.d.mts +21 -0
  133. package/dist/pixel-settings-D-t9zQb4.d.ts +40 -0
  134. package/dist/pixel-settings-DGxl0MVm.d.mts +40 -0
  135. package/dist/runtime/index.cjs.js +1 -1
  136. package/dist/runtime/index.cjs.js.map +1 -1
  137. package/dist/runtime/index.d.mts +19 -26
  138. package/dist/runtime/index.d.ts +19 -26
  139. package/dist/runtime/index.esm.js +1 -1
  140. package/dist/runtime/index.esm.js.map +1 -1
  141. package/dist/services/index.cjs.js +1 -1
  142. package/dist/services/index.cjs.js.map +1 -1
  143. package/dist/services/index.d.mts +14 -6
  144. package/dist/services/index.d.ts +14 -6
  145. package/dist/services/index.esm.js +1 -1
  146. package/dist/services/index.esm.js.map +1 -1
  147. package/dist/types-B-Nzagpk.d.mts +19 -0
  148. package/dist/types-D0KVsgzs.d.mts +293 -0
  149. package/dist/types-D3kJ9bfT.d.ts +293 -0
  150. package/dist/types-Dfi9C49l.d.ts +19 -0
  151. package/dist/url-context-Ck2LK18V.d.mts +87 -0
  152. package/dist/url-context-Ck2LK18V.d.ts +87 -0
  153. package/dist/v2/global.global.js +1 -1
  154. package/dist/v2/global.global.js.map +1 -1
  155. package/dist/v2/index.cjs.js +1 -1
  156. package/dist/v2/index.cjs.js.map +1 -1
  157. package/dist/v2/index.d.mts +26 -6
  158. package/dist/v2/index.d.ts +26 -6
  159. package/dist/v2/index.esm.js +1 -1
  160. package/dist/v2/index.esm.js.map +1 -1
  161. package/docs/public/README.md +80 -0
  162. package/docs/public/api/exports.md +56 -0
  163. package/docs/public/api/pixel.md +86 -0
  164. package/docs/public/configuration/commerce.md +44 -0
  165. package/docs/public/configuration/modules.md +63 -0
  166. package/docs/public/configuration/overview.md +85 -0
  167. package/docs/public/configuration/transport.md +127 -0
  168. package/docs/public/events/catalog.md +67 -0
  169. package/docs/public/getting-started/installation.md +88 -0
  170. package/docs/public/getting-started/quick-start.md +142 -0
  171. package/docs/public/getting-started/react-nextjs.md +78 -0
  172. package/docs/public/getting-started/script-tag.md +102 -0
  173. package/docs/public/guides/funnel-checkout.md +52 -0
  174. package/docs/public/guides/funnel-downsell.md +53 -0
  175. package/docs/public/guides/funnel-full.md +64 -0
  176. package/docs/public/guides/funnel-landing.md +70 -0
  177. package/docs/public/guides/funnel-thank-you.md +48 -0
  178. package/docs/public/guides/funnel-upsell.md +72 -0
  179. package/docs/public/limitations.md +33 -0
  180. package/docs/public/privacy/limitations.md +33 -0
  181. package/docs/public/release-candidate/validation.md +42 -0
  182. package/docs/public/troubleshooting.md +56 -0
  183. package/package.json +41 -20
  184. package/dist/index-DUfFzniE.d.mts +0 -274
  185. package/dist/index-DUfFzniE.d.ts +0 -274
  186. package/dist/pixel-CbeF25mD.d.mts +0 -555
  187. package/dist/pixel-CbeF25mD.d.ts +0 -555
  188. package/dist/pixel-default-config-1VgLFOiL.d.mts +0 -5
  189. package/dist/pixel-default-config-Bxb-Vdd8.d.ts +0 -5
  190. package/dist/types-CTpRvFKZ.d.ts +0 -71
  191. package/dist/types-DGlBdsAy.d.mts +0 -71
@@ -0,0 +1,80 @@
1
+ # Pixel v2 — Documentação pública (RC)
2
+
3
+ Documentação para desenvolvedores que implementam funis e páginas com `@beworke/pixel`.
4
+
5
+ A versão publicada está em `package.json` do pacote. Instale `@beworke/pixel@rc`.
6
+
7
+ > Esta pasta é a documentação **pública**. Arquitetura interna, prompts de etapas e relatórios de engenharia ficam em `PLAN_PIXEL/` (`ARCHITECTURE.md`, `PIXEL_V2_*`).
8
+
9
+ > Esta pasta é a documentação **pública**. Arquitetura interna, prompts de etapas e relatórios de engenharia ficam em `PLAN_PIXEL/` (`ARCHITECTURE.md`, `PIXEL_V2_*`).
10
+
11
+ ## Onde ler (importante)
12
+
13
+ | Contexto | URL / caminho |
14
+ |----------|----------------|
15
+ | **GitHub (browser)** | https://github.com/techionext/Pixel-Global/tree/main/packages/pixel/docs/public |
16
+ | **Pacote npm instalado** | `node_modules/@beworke/pixel/docs/public/` |
17
+ | **npmjs.com** | Só renderiza o `README.md` do pacote — **não** abre `.md` individuais |
18
+
19
+ Instalação: `npm install @beworke/pixel@rc` (público, sem token).
20
+
21
+ ## Começar
22
+
23
+ | Guia | Descrição |
24
+ |------|-----------|
25
+ | [Instalação](./getting-started/installation.md) | npm, tarball local, validação do pacote |
26
+ | [Quick start](./getting-started/quick-start.md) | Factory, classe e bootstrap |
27
+ | [Script tag (IIFE)](./getting-started/script-tag.md) | `@beworke/pixel/global` → `window.Pixel`; presets BuyGoods sem config |
28
+ | [React / Next.js](./getting-started/react-nextjs.md) | `@beworke/pixel-react` (`PixelProvider` / `usePixel`) |
29
+
30
+ ## Referência
31
+
32
+ | Documento | Conteúdo |
33
+ |-----------|----------|
34
+ | [API — Pixel](./api/pixel.md) | Métodos públicos estáveis |
35
+ | [Package exports](./api/exports.md) | Subpaths do `package.json` |
36
+ | [Catálogo de eventos](./events/catalog.md) | Tipos `PixelEvent` por categoria |
37
+ | [Configuração — visão geral](./configuration/overview.md) | `PixelConfig` e defaults |
38
+ | [Transport](./configuration/transport.md) | Config única e senders `test`, `internal`, `external` |
39
+ | [Módulos](./configuration/modules.md) | `modules.core`, `behavior`, `conversion`, etc. |
40
+ | [Commerce (root)](./configuration/commerce.md) | `commerce.catalog`, `cart`, `enrichment` |
41
+
42
+ ## Funis
43
+
44
+ | Página | Guia |
45
+ |--------|------|
46
+ | Landing | [guides/funnel-landing.md](./guides/funnel-landing.md) |
47
+ | Checkout | [guides/funnel-checkout.md](./guides/funnel-checkout.md) |
48
+ | Upsell | [guides/funnel-upsell.md](./guides/funnel-upsell.md) |
49
+ | Downsell | [guides/funnel-downsell.md](./guides/funnel-downsell.md) |
50
+ | Thank-you | [guides/funnel-thank-you.md](./guides/funnel-thank-you.md) |
51
+ | Funil completo | [guides/funnel-full.md](./guides/funnel-full.md) |
52
+
53
+ ## Exemplos públicos
54
+
55
+ Exemplos em `apps/playground-html/public/` usam **somente API pública** (sem `getDebugServices`, sem hooks de debug).
56
+
57
+ | Exemplo | Caminho no monorepo |
58
+ |---------|---------------------|
59
+ | Landing (HTML) | `apps/playground-html/public/html/landing.html` |
60
+ | Checkout (HTML) | `apps/playground-html/public/html/checkout.html` |
61
+ | Next.js (App Router) | `apps/playground-next/` (hooks locais, não exportados pelo SDK) |
62
+
63
+ Playgrounds internos de engenharia: `apps/playground-html/` (podem usar APIs `@internal`).
64
+
65
+ > **Legado:** na estrutura anterior ao monorepo, estes caminhos eram `examples/public/`, `examples/nextjs/` e `examples/html-script/`.
66
+
67
+ ## Privacidade e limitações
68
+
69
+ | Documento | Conteúdo |
70
+ |-----------|----------|
71
+ | [Privacidade e consentimento](./privacy/limitations.md) | RC sem CMP completo; responsabilidade da aplicação |
72
+ | [Limitações conhecidas do RC](./limitations.md) | O que não está pronto para produção pública |
73
+ | [Troubleshooting](./troubleshooting.md) | Erros comuns |
74
+
75
+ ## Release Candidate
76
+
77
+ | Documento | Conteúdo |
78
+ |-----------|----------|
79
+ | [Validação do pacote](./release-candidate/validation.md) | `pack:pixel`, smoke, checklist |
80
+ | [RELEASE_CANDIDATE.md](../../RELEASE_CANDIDATE.md) | Notas oficiais do RC |
@@ -0,0 +1,56 @@
1
+ # Package exports
2
+
3
+ Auditado contra `package.json`. Não pinamos o número da RC neste documento.
4
+
5
+ ## Entry principal
6
+
7
+ | Subpath | Import | Conteúdo principal |
8
+ |---------|--------|-------------------|
9
+ | `@beworke/pixel` | ESM / CJS | `Pixel`, `createPixel`, `resolvePixelConfig`, `DEFAULT_PIXEL_CONFIG`, `PixelSettings`, `PixelConfig`, `PixelConfigurationError`, `PixelDebugSnapshot`, `resolveStorageAdapterName`, `SDK_VERSION` |
10
+ | `@beworke/pixel/v2` | ESM / CJS | Alias do entry principal (mesmos exports) |
11
+ | `@beworke/pixel/browser` | ESM / CJS | `bootstrapPixel`, `getBootstrappedPixel`, `getBootstrappedPixelPending`, `destroyBootstrappedPixel`, `PixelBootstrapError`, settings dos presets BuyGoods |
12
+
13
+ ## Global (IIFE)
14
+
15
+ | Subpath | Formato | Global |
16
+ |---------|---------|--------|
17
+ | `@beworke/pixel/global` | IIFE | `window.Pixel` (factory) + `window.PixelV2` (compat) |
18
+ | `@beworke/pixel/buygoods-landing` | IIFE | Auto-init landing BuyGoods (sem settings) |
19
+ | `@beworke/pixel/buygoods-checkout` | IIFE | Auto-init checkout BuyGoods (sem settings; sobe para `window.top`) |
20
+ | `@beworke/pixel/internal-checkout` | IIFE | Auto-init checkout interno; `pixelId` só na query do script |
21
+
22
+ Arquivo build recomendado: `dist/browser/pixel.global.js`
23
+
24
+ Presets drop-in: `dist/browser/pixel.buygoods-landing.global.js`, `dist/browser/pixel.buygoods-checkout.global.js` e `dist/browser/pixel.internal-checkout.global.js`
25
+
26
+ O artifact legado `dist/v2/global.global.js` continua gerado para consumidores que ainda apontam para `window.PixelV2` via caminho antigo.
27
+
28
+ ## Subpaths avançados
29
+
30
+ Úteis para tipos, eventos ou integrações custom — **não** necessários para funis básicos.
31
+
32
+ | Subpath | Uso típico |
33
+ |---------|------------|
34
+ | `@beworke/pixel/config` | Tipos, `PixelSettings`, `resolvePixelConfig`, `DEFAULT_TRANSPORT_CONFIG` e demais helpers de config |
35
+ | `@beworke/pixel/events` | Tipos `PixelEvent`, payloads de conversão |
36
+ | `@beworke/pixel/runtime` | Runtime interno (uso avançado) |
37
+ | `@beworke/pixel/services` | Serviços compartilhados |
38
+ | `@beworke/pixel/logger` | Logger do SDK |
39
+
40
+ ## Não exportado
41
+
42
+ | Subpath | Status |
43
+ |---------|--------|
44
+ | `@beworke/pixel/diagnostics` | **Não existe** no `package.json` RC |
45
+
46
+ `PixelDebugSnapshot` é exportado pelo entry principal, não por subpath separado.
47
+
48
+ ## Validar tarball
49
+
50
+ ```bash
51
+ pnpm pack:pixel
52
+ pnpm validate:pixel-package
53
+ pnpm smoke:pixel-package
54
+ ```
55
+
56
+ Arquivos publicados (`files`): `dist/`, `docs/public/`, `README.md`, `CHANGELOG.md`, `RELEASE_CANDIDATE.md`.
@@ -0,0 +1,86 @@
1
+ # API — classe `Pixel`
2
+
3
+ Superfície pública estável. A versão publicada está em `package.json`. Métodos marcados `@internal` no código **não** fazem parte desta referência.
4
+
5
+ ## Construtor e factory
6
+
7
+ ```typescript
8
+ import { Pixel, createPixel, type PixelConfig, type PixelSettings } from '@beworke/pixel';
9
+
10
+ const manual = new Pixel({ identity: { pixelId: 'pix_YOUR_ID' } });
11
+ await manual.init();
12
+
13
+ const pixel = await createPixel({ identity: { pixelId: 'pix_YOUR_ID' } });
14
+ ```
15
+
16
+ `createPixel` e o construtor aceitam `PixelSettings` (parcial). Um `PixelConfig` completo continua válido. O merge acontece uma única vez no construtor de `Pixel`.
17
+
18
+ `createPixel` cria uma instância independente, chama `init()` e só resolve depois. Se `init()` falhar, tenta `destroy()` e relança o erro original.
19
+
20
+ ## Bootstrap (`@beworke/pixel/browser`)
21
+
22
+ ```typescript
23
+ import { bootstrapPixel } from '@beworke/pixel/browser';
24
+
25
+ const pixel = await bootstrapPixel(config, { waitForConsent, force });
26
+ ```
27
+
28
+ ## Ciclo de vida
29
+
30
+ | Método | Retorno | Descrição |
31
+ |--------|---------|-----------|
32
+ | `init()` | `Promise<void>` | Inicializa runtime, módulos e emite `PAGE_VIEW` quando core habilitado |
33
+ | `destroy()` | `Promise<void>` | Remove listeners, flush parcial e marca snapshot como destruído |
34
+ | `isInitialized()` | `boolean` | `true` após `init()` concluir com sucesso |
35
+
36
+ ## Diagnóstico (público)
37
+
38
+ | Método | Retorno | Descrição |
39
+ |--------|---------|-----------|
40
+ | `getDebugSnapshot()` | `Readonly<PixelDebugSnapshot>` | Snapshot read-only sanitizado; seguro antes/depois de init e após destroy |
41
+
42
+ Use em desenvolvimento para validar sessão, fila de transport e módulos. Não substitui observabilidade de produção.
43
+
44
+ ## Conversão (manual)
45
+
46
+ Todos retornam `void`. Dados opcionais enriquecem payload; commerce config pode calcular `value`/`items`.
47
+
48
+ | Método | Dados | Evento emitido |
49
+ |--------|-------|----------------|
50
+ | `purchase(data?)` | `PurchaseData` | `PURCHASE` |
51
+ | `lead(data)` | `LeadData` (obrigatório) | `LEAD` |
52
+ | `addToCart(data?)` | `AddToCartData` | `ADD_TO_CART` |
53
+ | `removeFromCart(data?)` | `RemoveFromCartData` | `REMOVE_FROM_CART` |
54
+ | `initiateCheckout(data?)` | `InitiateCheckoutData` | `INITIATE_CHECKOUT` |
55
+ | `addPaymentInfo(data?)` | `AddPaymentInfoEvent` | `ADD_PAYMENT_INFO` |
56
+ | `viewContent(data?)` | `ViewContentData` | `VIEW_CONTENT` |
57
+ | `search(data)` | `SearchData` (obrigatório) | `SEARCH` |
58
+
59
+ Tipos de dados: importe de `@beworke/pixel/events` se necessário.
60
+
61
+ ## Exports relacionados (entry principal)
62
+
63
+ | Export | Uso |
64
+ |--------|-----|
65
+ | `Pixel` | Classe pública |
66
+ | `createPixel` | Factory assíncrona (instâncias independentes) |
67
+ | `resolvePixelConfig` | Resolve `PixelSettings` → `PixelConfig` |
68
+ | `DEFAULT_PIXEL_CONFIG` | Defaults auditados — inspeção / avançado |
69
+ | `PixelSettings` | Tipo do input público (parcial) |
70
+ | `PixelConfig` | Tipo da configuração resolvida |
71
+ | `PixelConfigurationError` | Erro de `pixelId` / settings inválidos |
72
+ | `PixelDebugSnapshot` | Tipo do snapshot |
73
+ | `resolveStorageAdapterName` | Resolve nome do adapter de persistência |
74
+ | `SDK_VERSION` | Versão runtime alinhada a `package.json` |
75
+
76
+ ## Não usar em produção / exemplos públicos
77
+
78
+ Estes existem no código para playgrounds internos:
79
+
80
+ - `getDebugServices()`
81
+ - `debugPublishBehaviorSignal()`
82
+ - `flushBehaviorBuffer()`
83
+ - `simulateTransport*`, `manualTransportReplay`, etc.
84
+ - `getDebugDedupeKeys`, `getDebugIntegrationState`, …
85
+
86
+ Veja `apps/playground-html/` apenas para engenharia interna.
@@ -0,0 +1,44 @@
1
+ # Commerce (`commerce`)
2
+
3
+ Configuração root-level (não dentro de `modules`).
4
+
5
+ ## Campos principais
6
+
7
+ | Campo | Default | Descrição |
8
+ |-------|---------|-----------|
9
+ | `enabled` | `true` | Habilita enrichment commerce (catálogo vazio é no-op) |
10
+ | `currency` | conforme `DEFAULT_COMMERCE_CONFIG` | Moeda padrão |
11
+ | `catalog.products` | `[]` | Produtos da oferta (main, bump, upsell) |
12
+ | `cart.mode` | `'custom'` | Carrinho gerenciado pelo app |
13
+ | `cart.allowDynamicItems` | `true` | Itens dinâmicos no carrinho |
14
+ | `cart.calculateValueFrom` | `'cart'` | Cálculo de `value` |
15
+ | `mappings` | `{}` | Mapeamento de atributos/campos |
16
+ | `enrichment` | pageView/viewContent/cart events on | Completa value/items a partir do catálogo e do carrinho |
17
+
18
+ ## Quando usar
19
+
20
+ - **Checkout:** catálogo com produto principal + order bumps
21
+ - **Upsell/downsell:** produtos adicionais no `catalog`; dispare `viewContent` / `purchase` manualmente
22
+ - **Thank-you:** `purchase` com `transactionId` do pedido
23
+
24
+ ## Exemplo (checkout)
25
+
26
+ ```typescript
27
+ commerce: {
28
+ enabled: true,
29
+ currency: 'BRL',
30
+ catalog: {
31
+ products: [
32
+ { id: 'main', name: 'Oferta', type: 'main', price: 197, currency: 'BRL', quantity: 1 },
33
+ ],
34
+ },
35
+ cart: {
36
+ mode: 'custom',
37
+ initialItems: [],
38
+ allowDynamicItems: true,
39
+ calculateValueFrom: 'cart',
40
+ },
41
+ },
42
+ ```
43
+
44
+ Referência completa: `apps/playground-next/lib/pixel-config.ts`.
@@ -0,0 +1,63 @@
1
+ # Módulos (`modules.*`)
2
+
3
+ Referência resumida auditada contra `DEFAULT_PIXEL_CONFIG`.
4
+
5
+ ## `modules.core`
6
+
7
+ | Campo | Default | Descrição |
8
+ |-------|---------|-----------|
9
+ | `enabled` | `true` | Módulo core ativo |
10
+ | `pageView.enabled` | `true` | Emite `PAGE_VIEW` |
11
+ | `pageView.trackInitialPageView` | `true` | No `init()` |
12
+ | `pageView.spa` | `true` | Suporte SPA |
13
+ | `visitor.enabled` | `true` | Gera/persiste visitor |
14
+ | `session.enabled` | `true` | Sessão com TTL 3h |
15
+ | `consent.enabled` | `false` | Gate de consentimento **off** no default |
16
+
17
+ **Quando usar:** sempre em páginas web. Desligue apenas em testes headless sem DOM.
18
+
19
+ ## `modules.behavior`
20
+
21
+ | Campo | Default | Descrição |
22
+ |-------|---------|-----------|
23
+ | `enabled` | `false` | Behavior off por default |
24
+ | `trackers.scroll/click/...` | `enabled: false` | Habilitar por tracker |
25
+ | `heartbeat.enabled` | `false` | `BEHAVIOR_HEARTBEAT` |
26
+ | `engagement.enabled` | `false` | Score + `ENGAGEMENT_*` |
27
+ | `rateLimit/buffer/stateMachine/sessionSummary` | `enabled: false` | Runtime intelligence (Etapa 20) |
28
+
29
+ **Quando usar:** landing e páginas de conteúdo para scroll, cliques, engagement.
30
+
31
+ **Limitação RC:** muitos sub-recursos exigem config explícita; defaults conservadores.
32
+
33
+ ## `modules.conversion`
34
+
35
+ | Campo | Default | Descrição |
36
+ |-------|---------|-----------|
37
+ | `enabled` | `true` | Flag do módulo |
38
+ | `manual.*` | `enabled: true` | API manual pública |
39
+ | `auto.enabled` | `true` | AutoTrack on |
40
+ | `auto.detectors.*` | `data-track` | clique em todos; `view_content` também **hover** e **visível** |
41
+ | `auto.detectors.viewContent` | click + hover + visible | `[data-track="view_content"]` |
42
+ | `rules.enabled` | `false` | Regras extras por seletor/URL/texto |
43
+
44
+ **Quando usar:** coloque `data-track="<evento>"` no HTML (e `data-product-id` / `data-email` / `data-query` quando o evento precisar). `view_content` dispara no clique, hover e visível; restrinja com `data-trigger="hover"` (ou `click` / `visible`, ou lista `hover,click`). Sem `data-trigger`, valem os 3. Para desligar: `auto.enabled: false`.
45
+
46
+ ## Transport
47
+
48
+ Transport não é módulo. Configure somente `config.transport`, usando os modos
49
+ `test`, `internal` ou `external`. Consulte a
50
+ [referência de Transport](./transport.md).
51
+
52
+ ## `modules.integrations`
53
+
54
+ Destinos browser (GA, Meta, etc.) — ver defaults em `@beworke/pixel/config`. Off por default no RC de funil API-first.
55
+
56
+ ## `modules.privacy`
57
+
58
+ | Campo | Default | Descrição |
59
+ |-------|---------|-----------|
60
+ | `enabled` | `false` | Módulo privacy off |
61
+ | `consent.enabled` | `false` | Sem CMP integrado |
62
+
63
+ **Limitação RC:** consentimento completo previsto para Etapa 25. Ver [privacidade](../privacy/limitations.md).
@@ -0,0 +1,85 @@
1
+ # Configuração — visão geral
2
+
3
+ O input público é `PixelSettings`. Somente `identity.pixelId` é obrigatório.
4
+ O construtor de `Pixel` chama `resolvePixelConfig(settings)` e entrega um
5
+ `PixelConfig` completo ao Runtime.
6
+
7
+ ```ts
8
+ import { createPixel, type PixelSettings } from '@beworke/pixel';
9
+
10
+ const settings = {
11
+ identity: { pixelId: 'pix_YOUR_ID' },
12
+ app: { debug: true },
13
+ } satisfies PixelSettings;
14
+
15
+ const pixel = await createPixel(settings);
16
+ ```
17
+
18
+ `DEFAULT_PIXEL_CONFIG` continua disponível para inspeção e casos avançados.
19
+ Não é necessário espalhá-lo numa integração comum.
20
+
21
+ ## Semântica do merge
22
+
23
+ | Caso | Comportamento |
24
+ |------|----------------|
25
+ | Objetos plain | mescla profunda |
26
+ | Arrays | substituem o default (não concatenam) |
27
+ | `transport.sender` | substitui a variante inteira (`test` / `internal` / `external`) |
28
+ | `undefined` | ausência — o default permanece |
29
+ | `false` / `0` / `''` | valores válidos, preservados |
30
+ | Records (`mappings`, etc.) | mescla por chave |
31
+
32
+ ## Top-level
33
+
34
+ | Seção | Descrição |
35
+ |-------|-----------|
36
+ | `app` | Ambiente, debug, source/target/platform. Vai no payload HTTP em `app` e `meta` |
37
+ | `identity` | `pixelId` (obrigatório no input), IDs de funil |
38
+ | `transport` | Sender, batch, timeout, retry e flush |
39
+ | `storage` | Prefixo, namespace, fila, persistência |
40
+ | `attribution` | UTM, cookies, persistência de atribuição |
41
+ | `commerce` | Catálogo, carrinho, enrichment |
42
+ | `modules` | Feature flags por módulo |
43
+
44
+ ## Defaults críticos (`DEFAULT_PIXEL_CONFIG`)
45
+
46
+ | Campo | Default | Nota |
47
+ |-------|---------|------|
48
+ | `app.environment` | `'production'` | Use `'development'` + `debug: true` localmente |
49
+ | `app.debug` | `false` | |
50
+ | `app.source` | `'custom'` | Conhecidos: `pageus`, `gomarke`, `bemony`, `custom`. **Qualquer outra string é válida** (ex.: `hwaffiliate`) |
51
+ | `app.target` | `'custom'` | `landing` \| `checkout` \| `editor` \| `preview` \| `dashboard` \| `custom` |
52
+ | `app.platform` | `''` | Vendor da página. Conhecido: `buygoods`. String livre ok |
53
+ | `identity.pixelId` | `''` | Obrigatório no input; o resolvedor valida e faz trim |
54
+ | `transport.enabled` | `true` | Envia para a API interna pública |
55
+ | `transport.sender.mode` | `'internal'` | Sem segredo no browser; `baseUrl` público |
56
+ | `transport.timeout.timeoutMs` | `10000` | |
57
+ | `storage.prefix` | `'__gmk'` | |
58
+ | `storage.namespace` | `'pixel'` | |
59
+ | `storage.persistence.visitor` | `'localStorage'` | |
60
+ | `storage.persistence.session` | `'sessionStorage'` | |
61
+ | `storage.persistence.attribution` | `'localStorage'` | |
62
+ | `storage.queue.enabled` | `true` | |
63
+ | `storage.queue.persistence` | `'memory'` | |
64
+ | `commerce.cart.mode` | `'custom'` | |
65
+ | `modules.core.enabled` | `true` | Emite `PAGE_VIEW` |
66
+ | `modules.behavior.enabled` | `false` | Trackers off por default |
67
+ | `modules.conversion.enabled` | `true` | Métodos manuais on; AutoTrack `data-track` on; rules off |
68
+ | `commerce.enabled` | `true` | Enrichment on; catálogo vazio não altera payloads |
69
+ | `modules.privacy.enabled` | ver modules | Sem CMP completo no RC |
70
+
71
+ `identity.pixelId` aceita no máximo 128 caracteres após trim, sem caracteres de controle. O prefixo `pix_` não é exigido.
72
+
73
+ ## Identity para funis
74
+
75
+ Campos úteis em `identity`:
76
+
77
+ - `pixelId` — ID do pixel na API
78
+ - `funnelId`, `funnelStepId` — etapa do funil
79
+ - `pageId`, `offerId`, `checkoutId`
80
+
81
+ ## Próximo
82
+
83
+ - [Módulos](./modules.md)
84
+ - [Transport](./transport.md)
85
+ - [Commerce](./commerce.md)
@@ -0,0 +1,127 @@
1
+ # Transport
2
+
3
+ O Transport possui uma única configuração top-level: `config.transport`.
4
+
5
+ Use `DEFAULT_TRANSPORT_CONFIG` como base avançada. No input público, basta
6
+ omitir `transport` para usar o sender `internal` default, ou substituir a
7
+ variante inteira:
8
+
9
+ ```typescript
10
+ import { Pixel } from '@beworke/pixel';
11
+
12
+ const pixel = new Pixel({
13
+ identity: { pixelId: 'pix_test' },
14
+ transport: {
15
+ sender: {
16
+ mode: 'test',
17
+ capture: true,
18
+ response: 'success',
19
+ delayMs: 0,
20
+ },
21
+ },
22
+ });
23
+ ```
24
+
25
+ Playgrounds podem ajustar o sender após `init()`:
26
+
27
+ ```typescript
28
+ pixel.configureTransportTestSender({
29
+ capture: true,
30
+ response: 'success',
31
+ delayMs: 0,
32
+ });
33
+ ```
34
+
35
+ `configureTransportTestSender()` é uma API interna para playground e
36
+ desenvolvimento; não a use como contrato de produção.
37
+
38
+ ## Internal sender com endpoint padrão
39
+
40
+ O modo `internal` envia para os endpoints públicos oficiais do Pixel. Sem
41
+ `baseUrl`, o SDK usa `DEFAULT_INTERNAL_TRANSPORT_BASE_URL`.
42
+
43
+ ```typescript
44
+ const pixel = new Pixel({
45
+ identity: { pixelId: 'pix_xxx' },
46
+ transport: {
47
+ sender: { mode: 'internal' },
48
+ },
49
+ });
50
+ ```
51
+
52
+ Os caminhos resolvidos são:
53
+
54
+ ```text
55
+ POST {baseUrl}/pixels/public/event
56
+ POST {baseUrl}/pixels/public/event/batch
57
+ ```
58
+
59
+ ## Internal sender com `baseUrl`
60
+
61
+ Use um `baseUrl` aprovado para staging, proxy próprio ou outra implantação
62
+ compatível com os endpoints internos:
63
+
64
+ ```typescript
65
+ transport: {
66
+ ...DEFAULT_TRANSPORT_CONFIG,
67
+ enabled: true,
68
+ sender: {
69
+ mode: 'internal',
70
+ baseUrl: 'https://pixel-api.example.com',
71
+ },
72
+ },
73
+ ```
74
+
75
+ ## External sender
76
+
77
+ Use `external` quando os endpoints não seguem os caminhos internos:
78
+
79
+ ```typescript
80
+ transport: {
81
+ ...DEFAULT_TRANSPORT_CONFIG,
82
+ enabled: true,
83
+ sender: {
84
+ mode: 'external',
85
+ endpoints: {
86
+ event: 'https://events.example.com/v1/event',
87
+ batch: 'https://events.example.com/v1/batch',
88
+ },
89
+ batchFallback: 'single',
90
+ headers: {
91
+ 'X-Public-Client': 'checkout-web',
92
+ },
93
+ },
94
+ },
95
+ ```
96
+
97
+ > Os headers são públicos e visíveis no browser. Nunca coloque token privado,
98
+ > API key secreta, credencial backend ou dado equivalente em
99
+ > `sender.headers`. Segredos devem ficar atrás de um servidor ou proxy
100
+ > confiável.
101
+
102
+ Se `endpoints.batch` não for informado, `batchFallback: 'single'` envia cada
103
+ evento pelo endpoint individual; `'error'` rejeita o envio em lote.
104
+
105
+ ## Batch, timeout e flush
106
+
107
+ `batch.maxWaitMs` controla a espera do lote. O intervalo periódico pertence a
108
+ `transport.flush.flushIntervalMs`.
109
+
110
+ ```typescript
111
+ transport: {
112
+ ...DEFAULT_TRANSPORT_CONFIG,
113
+ enabled: true,
114
+ sender: { mode: 'test', capture: true },
115
+ batch: {
116
+ ...DEFAULT_TRANSPORT_CONFIG.batch,
117
+ enabled: true,
118
+ batchSize: 10,
119
+ maxWaitMs: 5_000,
120
+ },
121
+ flush: {
122
+ ...DEFAULT_TRANSPORT_CONFIG.flush,
123
+ enabled: true,
124
+ flushIntervalMs: 2_000,
125
+ },
126
+ },
127
+ ```
@@ -0,0 +1,67 @@
1
+ # Catálogo de eventos
2
+
3
+ Fonte: union `PixelEvent` (`src/events/types.ts`) — **24 tipos** no RC.
4
+
5
+ Todos os eventos listados abaixo passam pelo pipeline quando
6
+ `transport.enabled` está ativo. Os modos `internal` e `external` enviam pela
7
+ rede; `test` captura eventos sem requisição.
8
+
9
+ > `ApiEventType` (HTTP) inclui tipos legados/históricos que **não** fazem parte de `PixelEvent`. Use esta tabela como catálogo público.
10
+
11
+ ## Core
12
+
13
+ | Tipo | Disparo | Transport |
14
+ |------|---------|-----------|
15
+ | `PAGE_VIEW` | Automático no `init()` (core habilitado) | Sim |
16
+
17
+ ## Session
18
+
19
+ | Tipo | Disparo | Transport |
20
+ |------|---------|-----------|
21
+ | `SESSION_RENEWED` | Renovação de sessão | Sim |
22
+ | `SESSION_EXPIRED` | Expiração de sessão | Sim |
23
+
24
+ ## Behavior
25
+
26
+ Requer `modules.behavior.enabled` e trackers/config correspondentes.
27
+
28
+ | Tipo | Disparo típico | Transport |
29
+ |------|----------------|-----------|
30
+ | `SCROLL` | Thresholds de scroll | Sim |
31
+ | `PAGE_CLICK` | Clique na página | Sim |
32
+ | `RAGE_CLICK` | Cliques repetidos (rage detector) | Sim |
33
+ | `VISIBILITY_CHANGE` | Tab hidden/visible | Sim |
34
+ | `USER_IDLE` | Usuário inativo | Sim |
35
+ | `USER_ACTIVE` | Retorno da inatividade | Sim |
36
+ | `EXIT_INTENT` | Intenção de saída | Sim |
37
+ | `BEHAVIOR_HEARTBEAT` | Intervalo configurado | Sim |
38
+ | `VIEWPORT_ENTER` | Elemento entra no viewport | Sim |
39
+ | `VIEWPORT_EXIT` | Elemento sai do viewport | Sim |
40
+ | `ENGAGEMENT_UPDATE` | Score de engagement muda | Sim |
41
+ | `ENGAGEMENT_SUMMARY` | Resumo (ex.: destroy) | Sim |
42
+ | `BEHAVIOR_SESSION_SUMMARY` | Resumo agregado da sessão (Etapa 20) | Sim |
43
+
44
+ ## Conversion
45
+
46
+ Disparados por métodos públicos `pixel.*` ou auto-detectors quando habilitados.
47
+
48
+ | Tipo | API manual | Transport |
49
+ |------|------------|-----------|
50
+ | `PURCHASE` | `purchase()` | Sim |
51
+ | `LEAD` | `lead()` | Sim |
52
+ | `ADD_TO_CART` | `addToCart()` | Sim |
53
+ | `REMOVE_FROM_CART` | `removeFromCart()` | Sim |
54
+ | `INITIATE_CHECKOUT` | `initiateCheckout()` | Sim |
55
+ | `ADD_PAYMENT_INFO` | `addPaymentInfo()` | Sim |
56
+ | `VIEW_CONTENT` | `viewContent()` | Sim |
57
+ | `SEARCH` | `search()` | Sim |
58
+
59
+ ## Eventos inexistentes (RC)
60
+
61
+ Não há tipos dedicados `UPSELL_*` ou `DOWNSELL_*`. Use `VIEW_CONTENT`, `PAGE_VIEW` e conversões commerce (`PURCHASE`, etc.) conforme [guias de funil](../guides/funnel-upsell.md).
62
+
63
+ ## Importar tipos
64
+
65
+ ```typescript
66
+ import type { PixelEvent, PurchaseEvent } from '@beworke/pixel/events';
67
+ ```