@beworke/pixel 0.1.0-rc.7 → 0.1.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +71 -56
- package/RELEASE_CANDIDATE.md +28 -62
- package/dist/Pixel-BnN86r4X.d.ts +797 -0
- package/dist/Pixel-BoUGqCbP.d.mts +797 -0
- package/dist/{StorageFactory-DeMaZ8wk.d.ts → StorageFactory-BfCArzMM.d.ts} +1 -1
- package/dist/{StorageFactory-Cq29vF32.d.mts → StorageFactory-C0prtNR7.d.mts} +1 -1
- package/dist/browser/index.cjs.js +3 -0
- package/dist/browser/index.cjs.js.map +1 -0
- package/dist/browser/index.d.mts +55 -0
- package/dist/browser/index.d.ts +55 -0
- package/dist/browser/index.esm.js +3 -0
- package/dist/browser/index.esm.js.map +1 -0
- package/dist/browser/pixel.global.js +4 -0
- package/dist/browser/pixel.global.js.map +1 -0
- package/dist/config/index.cjs.js +1 -1
- package/dist/config/index.cjs.js.map +1 -1
- package/dist/config/index.d.mts +15 -5
- package/dist/config/index.d.ts +15 -5
- package/dist/config/index.esm.js +1 -1
- package/dist/config/index.esm.js.map +1 -1
- package/dist/examples/html-script/RELEASE_CANDIDATE.md +6 -8
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-autocomplete.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-disabled.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-fields.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-data-track.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-dedupe.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-manual.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-rules-card.html +40 -47
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-security.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-attribute.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-auto.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-click.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-dedupe.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-link.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-manual.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-order-bump.html +40 -47
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-text.html +40 -47
- package/dist/examples/html-script/behavior/example-behavior-engagement.html +4 -4
- package/dist/examples/html-script/behavior/example-behavior-heartbeat.html +4 -4
- package/dist/examples/html-script/behavior/example-behavior-runtime-intelligence.html +4 -4
- package/dist/examples/html-script/behavior/example-behavior-viewport.html +4 -4
- package/dist/examples/html-script/buygoods/example-buygoods-checkout.html +156 -0
- package/dist/examples/html-script/example-checkout-commerce.html +31 -30
- package/dist/examples/html-script/example-conversion.html +41 -48
- package/dist/examples/html-script/example-global-factory-classic.html +45 -0
- package/dist/examples/html-script/example-global-factory.html +40 -0
- package/dist/examples/html-script/example-integration.html +39 -45
- package/dist/examples/html-script/example-landing-commerce.html +3 -8
- package/dist/examples/html-script/example-runtime-diagnostics.html +4 -4
- package/dist/examples/html-script/example-transport.html +59 -57
- package/dist/examples/html-script/full-funnel/checkout.html +3 -1
- package/dist/examples/html-script/full-funnel/downsell.html +3 -1
- package/dist/examples/html-script/full-funnel/landing.html +3 -1
- package/dist/examples/html-script/full-funnel/thank-you.html +3 -1
- package/dist/examples/html-script/full-funnel/upsell.html +3 -1
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-attribute.html +40 -47
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-auto.html +40 -47
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-click.html +40 -47
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-manual.html +40 -47
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-snapshot.html +40 -47
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-submit.html +40 -47
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-text.html +40 -47
- package/dist/examples/html-script/lead/example-lead-trigger-attribute.html +40 -47
- package/dist/examples/html-script/lead/example-lead-trigger-auto.html +40 -47
- package/dist/examples/html-script/lead/example-lead-trigger-click.html +40 -47
- package/dist/examples/html-script/release-candidate.html +31 -30
- package/dist/examples/html-script/remove-from-cart/README.md +3 -3
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-attribute.html +40 -47
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-css.html +40 -47
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-dedupe.html +47 -54
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-manual.html +40 -47
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-multi.html +40 -47
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-state.html +40 -47
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-text.html +40 -47
- package/dist/examples/html-script/search/example-search-attribute.html +40 -47
- package/dist/examples/html-script/search/example-search-button-sync.html +40 -47
- package/dist/examples/html-script/search/example-search-dedupe.html +40 -47
- package/dist/examples/html-script/search/example-search-input.html +40 -47
- package/dist/examples/html-script/search/example-search-manual.html +40 -47
- package/dist/examples/html-script/search/example-search-submit.html +40 -47
- package/dist/examples/html-script/search/example-search-text.html +40 -47
- package/dist/examples/html-script/url-context/example-url-context-allowed-domains.html +4 -4
- package/dist/examples/html-script/url-context/example-url-context-landing.html +4 -4
- package/dist/examples/html-script/url-context/example-url-context-upsell.html +4 -4
- package/dist/examples/html-script/url-context/example-url-context.html +4 -4
- package/dist/examples/html-script/view-content/example-view-content-attribute.html +40 -47
- package/dist/examples/html-script/view-content/example-view-content-css.html +40 -47
- package/dist/examples/html-script/view-content/example-view-content-dedupe.html +40 -47
- package/dist/examples/html-script/view-content/example-view-content-empty.html +40 -47
- package/dist/examples/html-script/view-content/example-view-content-manual.html +40 -47
- package/dist/examples/html-script/view-content/example-view-content-product-card.html +40 -47
- package/dist/examples/html-script/view-content/example-view-content-text.html +40 -47
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/{pixel-2uL4LSyC.d.ts → pixel-DNGbAN5C.d.ts} +117 -98
- package/dist/{pixel-DMwpppf_.d.mts → pixel-_BSDpx4M.d.mts} +117 -98
- package/dist/pixel-default-config-BMYaqs7i.d.ts +21 -0
- package/dist/pixel-default-config-DLRya1tl.d.mts +21 -0
- package/dist/pixel-settings-D-t9zQb4.d.ts +40 -0
- package/dist/pixel-settings-DGxl0MVm.d.mts +40 -0
- package/dist/runtime/index.cjs.js +1 -1
- package/dist/runtime/index.cjs.js.map +1 -1
- package/dist/runtime/index.d.mts +4 -4
- package/dist/runtime/index.d.ts +4 -4
- package/dist/runtime/index.esm.js +1 -1
- package/dist/runtime/index.esm.js.map +1 -1
- package/dist/services/index.cjs.js +1 -1
- package/dist/services/index.cjs.js.map +1 -1
- package/dist/services/index.d.mts +4 -4
- package/dist/services/index.d.ts +4 -4
- package/dist/services/index.esm.js +1 -1
- package/dist/services/index.esm.js.map +1 -1
- package/dist/{types-6HF3UlsL.d.mts → types-B-Nzagpk.d.mts} +2 -2
- package/dist/{types-CgrabttM.d.mts → types-D0KVsgzs.d.mts} +1 -1
- package/dist/{types-fFcQ1apy.d.ts → types-D3kJ9bfT.d.ts} +1 -1
- package/dist/{types-BqUEoZo0.d.ts → types-Dfi9C49l.d.ts} +2 -2
- package/dist/v2/global.global.js +1 -1
- package/dist/v2/global.global.js.map +1 -1
- package/dist/v2/index.cjs.js +1 -1
- package/dist/v2/index.cjs.js.map +1 -1
- package/dist/v2/index.d.mts +21 -787
- package/dist/v2/index.d.ts +21 -787
- package/dist/v2/index.esm.js +1 -1
- package/dist/v2/index.esm.js.map +1 -1
- package/docs/public/README.md +7 -4
- package/docs/public/api/exports.md +12 -8
- package/docs/public/api/pixel.md +27 -6
- package/docs/public/configuration/commerce.md +2 -2
- package/docs/public/configuration/modules.md +11 -14
- package/docs/public/configuration/overview.md +45 -26
- package/docs/public/configuration/transport.md +127 -0
- package/docs/public/events/catalog.md +3 -1
- package/docs/public/getting-started/installation.md +14 -12
- package/docs/public/getting-started/quick-start.md +95 -30
- package/docs/public/getting-started/react-nextjs.md +57 -34
- package/docs/public/getting-started/script-tag.md +55 -32
- package/docs/public/guides/funnel-checkout.md +1 -1
- package/docs/public/guides/funnel-landing.md +9 -7
- package/docs/public/limitations.md +5 -4
- package/docs/public/privacy/limitations.md +6 -6
- package/docs/public/release-candidate/validation.md +4 -4
- package/docs/public/troubleshooting.md +7 -6
- package/package.json +8 -3
- package/dist/pixel-default-config-BDPUVHse.d.ts +0 -5
- package/dist/pixel-default-config-C5uLt52W.d.mts +0 -5
package/docs/public/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Documentação para desenvolvedores que implementam funis e páginas com `@beworke/pixel`.
|
|
4
4
|
|
|
5
|
-
|
|
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_*`).
|
|
6
8
|
|
|
7
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_*`).
|
|
8
10
|
|
|
@@ -21,9 +23,9 @@ Instalação: `npm install @beworke/pixel@rc` (público, sem token).
|
|
|
21
23
|
| Guia | Descrição |
|
|
22
24
|
|------|-----------|
|
|
23
25
|
| [Instalação](./getting-started/installation.md) | npm, tarball local, validação do pacote |
|
|
24
|
-
| [Quick start](./getting-started/quick-start.md) |
|
|
25
|
-
| [Script tag (IIFE)](./getting-started/script-tag.md) | `@beworke/pixel/global` → `window.
|
|
26
|
-
| [React / Next.js](./getting-started/react-nextjs.md) |
|
|
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` |
|
|
28
|
+
| [React / Next.js](./getting-started/react-nextjs.md) | `@beworke/pixel-react` (`PixelProvider` / `usePixel`) |
|
|
27
29
|
|
|
28
30
|
## Referência
|
|
29
31
|
|
|
@@ -33,6 +35,7 @@ Instalação: `npm install @beworke/pixel@rc` (público, sem token).
|
|
|
33
35
|
| [Package exports](./api/exports.md) | Subpaths do `package.json` |
|
|
34
36
|
| [Catálogo de eventos](./events/catalog.md) | Tipos `PixelEvent` por categoria |
|
|
35
37
|
| [Configuração — visão geral](./configuration/overview.md) | `PixelConfig` e defaults |
|
|
38
|
+
| [Transport](./configuration/transport.md) | Config única e senders `test`, `internal`, `external` |
|
|
36
39
|
| [Módulos](./configuration/modules.md) | `modules.core`, `behavior`, `conversion`, etc. |
|
|
37
40
|
| [Commerce (root)](./configuration/commerce.md) | `commerce.catalog`, `cart`, `enrichment` |
|
|
38
41
|
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
# Package exports
|
|
2
2
|
|
|
3
|
-
Auditado contra `package.json
|
|
3
|
+
Auditado contra `package.json`. Não pinamos o número da RC neste documento.
|
|
4
4
|
|
|
5
5
|
## Entry principal
|
|
6
6
|
|
|
7
7
|
| Subpath | Import | Conteúdo principal |
|
|
8
8
|
|---------|--------|-------------------|
|
|
9
|
-
| `@beworke/pixel` | ESM / CJS | `Pixel`, `DEFAULT_PIXEL_CONFIG`, `PixelConfig`, `PixelDebugSnapshot`, `resolveStorageAdapterName` |
|
|
9
|
+
| `@beworke/pixel` | ESM / CJS | `Pixel`, `createPixel`, `resolvePixelConfig`, `DEFAULT_PIXEL_CONFIG`, `PixelSettings`, `PixelConfig`, `PixelConfigurationError`, `PixelDebugSnapshot`, `resolveStorageAdapterName`, `SDK_VERSION` |
|
|
10
10
|
| `@beworke/pixel/v2` | ESM / CJS | Alias do entry principal (mesmos exports) |
|
|
11
|
+
| `@beworke/pixel/browser` | ESM / CJS | `bootstrapPixel`, `getBootstrappedPixel`, `getBootstrappedPixelPending`, `destroyBootstrappedPixel`, `PixelBootstrapError` |
|
|
11
12
|
|
|
12
13
|
## Global (IIFE)
|
|
13
14
|
|
|
14
15
|
| Subpath | Formato | Global |
|
|
15
16
|
|---------|---------|--------|
|
|
16
|
-
| `@beworke/pixel/global` | IIFE | `window.PixelV2` |
|
|
17
|
+
| `@beworke/pixel/global` | IIFE | `window.Pixel` (factory) + `window.PixelV2` (compat) |
|
|
17
18
|
|
|
18
|
-
Arquivo build: `dist/
|
|
19
|
+
Arquivo build recomendado: `dist/browser/pixel.global.js`
|
|
20
|
+
|
|
21
|
+
O artifact legado `dist/v2/global.global.js` continua gerado para consumidores que ainda apontam para `window.PixelV2` via caminho antigo.
|
|
19
22
|
|
|
20
23
|
## Subpaths avançados
|
|
21
24
|
|
|
@@ -23,7 +26,7 @@ Arquivo build: `dist/v2/global.global.js`
|
|
|
23
26
|
|
|
24
27
|
| Subpath | Uso típico |
|
|
25
28
|
|---------|------------|
|
|
26
|
-
| `@beworke/pixel/config` | Tipos e helpers de config |
|
|
29
|
+
| `@beworke/pixel/config` | Tipos, `PixelSettings`, `resolvePixelConfig`, `DEFAULT_TRANSPORT_CONFIG` e demais helpers de config |
|
|
27
30
|
| `@beworke/pixel/events` | Tipos `PixelEvent`, payloads de conversão |
|
|
28
31
|
| `@beworke/pixel/runtime` | Runtime interno (uso avançado) |
|
|
29
32
|
| `@beworke/pixel/services` | Serviços compartilhados |
|
|
@@ -40,8 +43,9 @@ Arquivo build: `dist/v2/global.global.js`
|
|
|
40
43
|
## Validar tarball
|
|
41
44
|
|
|
42
45
|
```bash
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
pnpm pack:pixel
|
|
47
|
+
pnpm validate:pixel-package
|
|
48
|
+
pnpm smoke:pixel-package
|
|
45
49
|
```
|
|
46
50
|
|
|
47
|
-
Arquivos publicados (`files`): `dist/`, `README.md`, `CHANGELOG.md`, `RELEASE_CANDIDATE.md`.
|
|
51
|
+
Arquivos publicados (`files`): `dist/`, `docs/public/`, `README.md`, `CHANGELOG.md`, `RELEASE_CANDIDATE.md`.
|
package/docs/public/api/pixel.md
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
# API — classe `Pixel`
|
|
2
2
|
|
|
3
|
-
Superfície pública estável
|
|
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
4
|
|
|
5
|
-
## Construtor
|
|
5
|
+
## Construtor e factory
|
|
6
6
|
|
|
7
7
|
```typescript
|
|
8
|
-
import { Pixel, type PixelConfig } from '@beworke/pixel';
|
|
8
|
+
import { Pixel, createPixel, type PixelConfig, type PixelSettings } from '@beworke/pixel';
|
|
9
9
|
|
|
10
|
-
const
|
|
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 });
|
|
11
26
|
```
|
|
12
27
|
|
|
13
28
|
## Ciclo de vida
|
|
@@ -47,10 +62,16 @@ Tipos de dados: importe de `@beworke/pixel/events` se necessário.
|
|
|
47
62
|
|
|
48
63
|
| Export | Uso |
|
|
49
64
|
|--------|-----|
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
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 |
|
|
52
72
|
| `PixelDebugSnapshot` | Tipo do snapshot |
|
|
53
73
|
| `resolveStorageAdapterName` | Resolve nome do adapter de persistência |
|
|
74
|
+
| `SDK_VERSION` | Versão runtime alinhada a `package.json` |
|
|
54
75
|
|
|
55
76
|
## Não usar em produção / exemplos públicos
|
|
56
77
|
|
|
@@ -6,14 +6,14 @@ Configuração root-level (não dentro de `modules`).
|
|
|
6
6
|
|
|
7
7
|
| Campo | Default | Descrição |
|
|
8
8
|
|-------|---------|-----------|
|
|
9
|
-
| `enabled` | `
|
|
9
|
+
| `enabled` | `true` | Habilita enrichment commerce (catálogo vazio é no-op) |
|
|
10
10
|
| `currency` | conforme `DEFAULT_COMMERCE_CONFIG` | Moeda padrão |
|
|
11
11
|
| `catalog.products` | `[]` | Produtos da oferta (main, bump, upsell) |
|
|
12
12
|
| `cart.mode` | `'custom'` | Carrinho gerenciado pelo app |
|
|
13
13
|
| `cart.allowDynamicItems` | `true` | Itens dinâmicos no carrinho |
|
|
14
14
|
| `cart.calculateValueFrom` | `'cart'` | Cálculo de `value` |
|
|
15
15
|
| `mappings` | `{}` | Mapeamento de atributos/campos |
|
|
16
|
-
| `enrichment` |
|
|
16
|
+
| `enrichment` | pageView/viewContent/cart events on | Completa value/items a partir do catálogo e do carrinho |
|
|
17
17
|
|
|
18
18
|
## Quando usar
|
|
19
19
|
|
|
@@ -34,23 +34,20 @@ Referência resumida auditada contra `DEFAULT_PIXEL_CONFIG`.
|
|
|
34
34
|
|
|
35
35
|
| Campo | Default | Descrição |
|
|
36
36
|
|-------|---------|-----------|
|
|
37
|
-
| `enabled` | `
|
|
38
|
-
| `manual.*` | `enabled:
|
|
39
|
-
| `auto.enabled` | `
|
|
40
|
-
| `
|
|
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 |
|
|
41
43
|
|
|
42
|
-
**Quando usar:**
|
|
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`.
|
|
43
45
|
|
|
44
|
-
##
|
|
46
|
+
## Transport
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
| `sender.mode` | `'mock'` | RC local usa mock até configurar API |
|
|
50
|
-
| `batch.enabled` | `true` | Agrupa envios |
|
|
51
|
-
| `retry`, `circuitBreaker`, `offline` | habilitados | Resiliência |
|
|
52
|
-
|
|
53
|
-
**Quando usar:** produção/staging com `transport.apiEndpoint` e `sender.mode: 'api'`.
|
|
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).
|
|
54
51
|
|
|
55
52
|
## `modules.integrations`
|
|
56
53
|
|
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
# Configuração — visão geral
|
|
2
2
|
|
|
3
|
-
|
|
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.
|
|
4
6
|
|
|
5
|
-
|
|
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 |
|
|
6
31
|
|
|
7
32
|
## Top-level
|
|
8
33
|
|
|
9
34
|
| Seção | Descrição |
|
|
10
35
|
|-------|-----------|
|
|
11
|
-
| `app` | Ambiente, debug, source/target |
|
|
12
|
-
| `identity` | `pixelId
|
|
13
|
-
| `transport` |
|
|
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 |
|
|
14
39
|
| `storage` | Prefixo, namespace, fila, persistência |
|
|
15
40
|
| `attribution` | UTM, cookies, persistência de atribuição |
|
|
16
41
|
| `commerce` | Catálogo, carrinho, enrichment |
|
|
@@ -22,34 +47,28 @@ Use `DEFAULT_PIXEL_CONFIG` como base e sobrescreva apenas o necessário.
|
|
|
22
47
|
|-------|---------|------|
|
|
23
48
|
| `app.environment` | `'production'` | Use `'development'` + `debug: true` localmente |
|
|
24
49
|
| `app.debug` | `false` | |
|
|
25
|
-
| `
|
|
26
|
-
| `
|
|
27
|
-
| `
|
|
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` | |
|
|
28
57
|
| `storage.prefix` | `'__gmk'` | |
|
|
29
58
|
| `storage.namespace` | `'pixel'` | |
|
|
59
|
+
| `storage.persistence.visitor` | `'localStorage'` | |
|
|
60
|
+
| `storage.persistence.session` | `'sessionStorage'` | |
|
|
61
|
+
| `storage.persistence.attribution` | `'localStorage'` | |
|
|
30
62
|
| `storage.queue.enabled` | `true` | |
|
|
31
63
|
| `storage.queue.persistence` | `'memory'` | |
|
|
32
64
|
| `commerce.cart.mode` | `'custom'` | |
|
|
33
|
-
| `modules.core.enabled` |
|
|
65
|
+
| `modules.core.enabled` | `true` | Emite `PAGE_VIEW` |
|
|
34
66
|
| `modules.behavior.enabled` | `false` | Trackers off por default |
|
|
35
|
-
| `modules.conversion.enabled` | `
|
|
36
|
-
| `
|
|
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 |
|
|
37
69
|
| `modules.privacy.enabled` | ver modules | Sem CMP completo no RC |
|
|
38
70
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
storage: {
|
|
43
|
-
...DEFAULT_PIXEL_CONFIG.storage,
|
|
44
|
-
persistence: {
|
|
45
|
-
visitor: 'localStorage',
|
|
46
|
-
session: 'sessionStorage',
|
|
47
|
-
attribution: 'localStorage',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Sem `persistence.session`, a sessão usa `memory` e some em reload/destroy React.
|
|
71
|
+
`identity.pixelId` aceita no máximo 128 caracteres após trim, sem caracteres de controle. O prefixo `pix_` não é exigido.
|
|
53
72
|
|
|
54
73
|
## Identity para funis
|
|
55
74
|
|
|
@@ -58,9 +77,9 @@ Campos úteis em `identity`:
|
|
|
58
77
|
- `pixelId` — ID do pixel na API
|
|
59
78
|
- `funnelId`, `funnelStepId` — etapa do funil
|
|
60
79
|
- `pageId`, `offerId`, `checkoutId`
|
|
61
|
-
- `visitorId`, `userId` — opcionais se gerenciados pelo backend
|
|
62
80
|
|
|
63
81
|
## Próximo
|
|
64
82
|
|
|
65
83
|
- [Módulos](./modules.md)
|
|
84
|
+
- [Transport](./transport.md)
|
|
66
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
|
+
```
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Fonte: union `PixelEvent` (`src/events/types.ts`) — **24 tipos** no RC.
|
|
4
4
|
|
|
5
|
-
Todos os eventos listados abaixo passam pelo pipeline
|
|
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.
|
|
6
8
|
|
|
7
9
|
> `ApiEventType` (HTTP) inclui tipos legados/históricos que **não** fazem parte de `PixelEvent`. Use esta tabela como catálogo público.
|
|
8
10
|
|
|
@@ -13,19 +13,13 @@ Pacote **público** — **não precisa de token** nem login npm para instalar:
|
|
|
13
13
|
npm install @beworke/pixel@rc
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Versão fixa:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm install @beworke/pixel@0.1.0-rc.6
|
|
20
|
-
```
|
|
21
|
-
|
|
22
16
|
Confirme a versão instalada:
|
|
23
17
|
|
|
24
18
|
```bash
|
|
25
19
|
node -e "console.log(require('@beworke/pixel/package.json').version)"
|
|
26
20
|
```
|
|
27
21
|
|
|
28
|
-
> Evite `npm install @beworke/pixel` sem tag até a tag `latest` apontar para a RC atual. Use `@rc
|
|
22
|
+
> Evite `npm install @beworke/pixel` sem tag até a tag `latest` apontar para a RC atual. Use `@rc`.
|
|
29
23
|
|
|
30
24
|
## Onde ler a documentação
|
|
31
25
|
|
|
@@ -39,9 +33,12 @@ O site **npmjs.com não abre** arquivos `.md` individuais (ex.: `npmjs.com/packa
|
|
|
39
33
|
## Tarball local (opcional)
|
|
40
34
|
|
|
41
35
|
```bash
|
|
42
|
-
|
|
36
|
+
pnpm pack:pixel
|
|
37
|
+
npm install ./artifacts/beworke-pixel-<versão>.tgz
|
|
43
38
|
```
|
|
44
39
|
|
|
40
|
+
A versão exata está em `package.json` / `artifacts/latest-package.json`.
|
|
41
|
+
|
|
45
42
|
## Validar instalação limpa
|
|
46
43
|
|
|
47
44
|
Na raiz do monorepo:
|
|
@@ -49,6 +46,7 @@ Na raiz do monorepo:
|
|
|
49
46
|
```bash
|
|
50
47
|
pnpm pack:pixel
|
|
51
48
|
pnpm validate:pixel-package
|
|
49
|
+
pnpm smoke:pixel-package
|
|
52
50
|
```
|
|
53
51
|
|
|
54
52
|
O tarball fica em `artifacts/` (não use `pnpm --filter @beworke/pixel pack` como fluxo principal).
|
|
@@ -56,7 +54,8 @@ O tarball fica em `artifacts/` (não use `pnpm --filter @beworke/pixel pack` com
|
|
|
56
54
|
## Imports recomendados
|
|
57
55
|
|
|
58
56
|
```typescript
|
|
59
|
-
import { Pixel, DEFAULT_PIXEL_CONFIG, type PixelConfig } from '@beworke/pixel';
|
|
57
|
+
import { Pixel, createPixel, DEFAULT_PIXEL_CONFIG, type PixelConfig } from '@beworke/pixel';
|
|
58
|
+
import { bootstrapPixel } from '@beworke/pixel/browser';
|
|
60
59
|
```
|
|
61
60
|
|
|
62
61
|
Subpaths adicionais: [Package exports](../api/exports.md).
|
|
@@ -64,9 +63,12 @@ Subpaths adicionais: [Package exports](../api/exports.md).
|
|
|
64
63
|
## CDN / script tag
|
|
65
64
|
|
|
66
65
|
```html
|
|
67
|
-
<script src="https://unpkg.com/@beworke/pixel@rc/dist/
|
|
68
|
-
<script>
|
|
69
|
-
const
|
|
66
|
+
<script src="https://unpkg.com/@beworke/pixel@rc/dist/browser/pixel.global.js"></script>
|
|
67
|
+
<script type="module">
|
|
68
|
+
const pixel = await Pixel({
|
|
69
|
+
...Pixel.DEFAULT_PIXEL_CONFIG,
|
|
70
|
+
identity: { pixelId: 'pix_YOUR_ID' },
|
|
71
|
+
});
|
|
70
72
|
</script>
|
|
71
73
|
```
|
|
72
74
|
|