@beworke/pixel 0.1.0-rc.5 → 0.1.0-rc.7
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 +9 -0
- package/README.md +38 -69
- package/RELEASE_CANDIDATE.md +19 -13
- package/dist/{StorageFactory-CPghDPBj.d.mts → StorageFactory-Cq29vF32.d.mts} +2 -2
- package/dist/{StorageFactory-tjfzk57c.d.ts → StorageFactory-DeMaZ8wk.d.ts} +2 -2
- package/dist/config/index.cjs.js +1 -1
- package/dist/config/index.cjs.js.map +1 -1
- package/dist/config/index.d.mts +4 -4
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.esm.js +1 -1
- package/dist/config/index.esm.js.map +1 -1
- package/dist/events/index.cjs.js.map +1 -1
- package/dist/events/index.d.mts +2 -2
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.esm.js.map +1 -1
- package/dist/examples/html-script/README.md +20 -76
- package/dist/examples/html-script/RELEASE_CANDIDATE.md +14 -13
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-autocomplete.html +1 -1
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-disabled.html +1 -1
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-card-fields.html +1 -1
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-data-track.html +1 -1
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-dedupe.html +1 -1
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-manual.html +1 -1
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-rules-card.html +1 -1
- package/dist/examples/html-script/add-payment-info/example-add-payment-info-security.html +1 -1
- package/dist/examples/html-script/add-to-cart/README.md +6 -3
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-attribute.html +3 -2
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-auto.html +3 -2
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-click.html +3 -2
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-dedupe.html +3 -2
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-link.html +597 -0
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-manual.html +3 -2
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-order-bump.html +3 -2
- package/dist/examples/html-script/add-to-cart/example-add-to-cart-text.html +3 -2
- package/dist/examples/html-script/behavior/example-behavior-engagement.html +1 -1
- package/dist/examples/html-script/behavior/example-behavior-heartbeat.html +1 -1
- package/dist/examples/html-script/behavior/example-behavior-runtime-intelligence.html +1 -1
- package/dist/examples/html-script/behavior/example-behavior-viewport.html +1 -1
- package/dist/examples/html-script/behavior/example-behavior.html +1 -1
- package/dist/examples/html-script/example-basic.html +1 -1
- package/dist/examples/html-script/example-checkout-commerce.html +1 -1
- package/dist/examples/html-script/example-conversion.html +1 -1
- package/dist/examples/html-script/example-integration.html +1 -1
- package/dist/examples/html-script/example-landing-commerce.html +42 -1
- package/dist/examples/html-script/example-runtime-diagnostics.html +1 -1
- package/dist/examples/html-script/example-transport.html +6 -1
- package/dist/examples/html-script/full-funnel/README.md +1 -1
- package/dist/examples/html-script/full-funnel/checkout.html +1 -1
- package/dist/examples/html-script/full-funnel/downsell.html +1 -1
- package/dist/examples/html-script/full-funnel/landing.html +54 -2
- package/dist/examples/html-script/full-funnel/thank-you.html +1 -1
- package/dist/examples/html-script/full-funnel/upsell.html +1 -1
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-attribute.html +1 -1
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-auto.html +1 -1
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-click.html +1 -1
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-manual.html +1 -1
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-snapshot.html +1 -1
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-submit.html +1 -1
- package/dist/examples/html-script/initiate-checkout/example-initiate-checkout-text.html +1 -1
- package/dist/examples/html-script/lead/example-lead-trigger-attribute.html +1 -1
- package/dist/examples/html-script/lead/example-lead-trigger-auto.html +1 -1
- package/dist/examples/html-script/lead/example-lead-trigger-click.html +1 -1
- package/dist/examples/html-script/release-candidate.html +1 -1
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-attribute.html +1 -1
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-css.html +1 -1
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-dedupe.html +1 -1
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-manual.html +1 -1
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-multi.html +1 -1
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-state.html +1 -1
- package/dist/examples/html-script/remove-from-cart/example-remove-from-cart-text.html +1 -1
- package/dist/examples/html-script/search/example-search-attribute.html +1 -1
- package/dist/examples/html-script/search/example-search-button-sync.html +1 -1
- package/dist/examples/html-script/search/example-search-dedupe.html +1 -1
- package/dist/examples/html-script/search/example-search-input.html +1 -1
- package/dist/examples/html-script/search/example-search-manual.html +1 -1
- package/dist/examples/html-script/search/example-search-submit.html +1 -1
- package/dist/examples/html-script/search/example-search-text.html +1 -1
- package/dist/examples/html-script/url-context/example-url-context-allowed-domains.html +38 -9
- package/dist/examples/html-script/url-context/example-url-context-landing.html +53 -13
- package/dist/examples/html-script/url-context/example-url-context-upsell.html +48 -10
- package/dist/examples/html-script/url-context/example-url-context.html +51 -17
- package/dist/examples/html-script/view-content/example-view-content-attribute.html +1 -1
- package/dist/examples/html-script/view-content/example-view-content-css.html +1 -1
- package/dist/examples/html-script/view-content/example-view-content-dedupe.html +1 -1
- package/dist/examples/html-script/view-content/example-view-content-empty.html +1 -1
- package/dist/examples/html-script/view-content/example-view-content-manual.html +1 -1
- package/dist/examples/html-script/view-content/example-view-content-product-card.html +1 -1
- package/dist/examples/html-script/view-content/example-view-content-text.html +1 -1
- package/dist/examples/release-candidate/README.md +2 -1
- package/dist/examples/v2/README.md +15 -15
- package/dist/{index-CQAyT5Od.d.ts → index-B8u_3PGG.d.ts} +21 -2
- package/dist/{index-JlKPz4pp.d.mts → index-BxT2d-TK.d.mts} +21 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +19 -782
- package/dist/index.d.ts +19 -782
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/{pixel-BxZZx8l5.d.ts → pixel-2uL4LSyC.d.ts} +126 -5
- package/dist/{pixel-CKc4OQUx.d.mts → pixel-DMwpppf_.d.mts} +126 -5
- package/dist/{pixel-default-config-aAOujzwp.d.ts → pixel-default-config-BDPUVHse.d.ts} +1 -1
- package/dist/{pixel-default-config-CJl-eypl.d.mts → pixel-default-config-C5uLt52W.d.mts} +1 -1
- package/dist/runtime/index.cjs.js +1 -1
- package/dist/runtime/index.cjs.js.map +1 -1
- package/dist/runtime/index.d.mts +6 -6
- package/dist/runtime/index.d.ts +6 -6
- 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 +7 -7
- package/dist/services/index.d.ts +7 -7
- package/dist/services/index.esm.js +1 -1
- package/dist/services/index.esm.js.map +1 -1
- package/dist/{types-BP8dz1gP.d.mts → types-6HF3UlsL.d.mts} +2 -2
- package/dist/{types-C75pQP31.d.ts → types-BqUEoZo0.d.ts} +2 -2
- package/dist/{types-DMhzHSVC.d.mts → types-CgrabttM.d.mts} +2 -2
- package/dist/{types-D_SsCur9.d.ts → types-fFcQ1apy.d.ts} +2 -2
- package/dist/{url-context-BjAsQoVl.d.mts → url-context-Ck2LK18V.d.mts} +4 -2
- package/dist/{url-context-BjAsQoVl.d.ts → url-context-Ck2LK18V.d.ts} +4 -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 +793 -9
- package/dist/v2/index.d.ts +793 -9
- package/dist/v2/index.esm.js +1 -1
- package/dist/v2/index.esm.js.map +1 -1
- package/docs/public/README.md +77 -0
- package/docs/public/api/exports.md +47 -0
- package/docs/public/api/pixel.md +65 -0
- package/docs/public/configuration/commerce.md +44 -0
- package/docs/public/configuration/modules.md +66 -0
- package/docs/public/configuration/overview.md +66 -0
- package/docs/public/events/catalog.md +65 -0
- package/docs/public/getting-started/installation.md +78 -0
- package/docs/public/getting-started/quick-start.md +77 -0
- package/docs/public/getting-started/react-nextjs.md +55 -0
- package/docs/public/getting-started/script-tag.md +57 -0
- package/docs/public/guides/funnel-checkout.md +52 -0
- package/docs/public/guides/funnel-downsell.md +53 -0
- package/docs/public/guides/funnel-full.md +64 -0
- package/docs/public/guides/funnel-landing.md +68 -0
- package/docs/public/guides/funnel-thank-you.md +48 -0
- package/docs/public/guides/funnel-upsell.md +72 -0
- package/docs/public/limitations.md +32 -0
- package/docs/public/privacy/limitations.md +33 -0
- package/docs/public/release-candidate/validation.md +42 -0
- package/docs/public/troubleshooting.md +55 -0
- package/package.json +10 -13
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Script tag (IIFE / global)
|
|
2
|
+
|
|
3
|
+
## Build
|
|
4
|
+
|
|
5
|
+
O subpath `@beworke/pixel/global` expõe um bundle IIFE que define `window.PixelV2`.
|
|
6
|
+
|
|
7
|
+
Após `npm run build`, o artefato está em `dist/global/` (nome conforme `tsup` / `package.json`).
|
|
8
|
+
|
|
9
|
+
## HTML mínimo
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!DOCTYPE html>
|
|
13
|
+
<html lang="pt-BR">
|
|
14
|
+
<head>
|
|
15
|
+
<meta charset="UTF-8" />
|
|
16
|
+
<title>Pixel — script tag</title>
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<script src="../../dist/global/pixel.global.js"></script>
|
|
20
|
+
<script>
|
|
21
|
+
(async function () {
|
|
22
|
+
const { Pixel, DEFAULT_PIXEL_CONFIG } = window.PixelV2;
|
|
23
|
+
|
|
24
|
+
const pixel = new Pixel({
|
|
25
|
+
...DEFAULT_PIXEL_CONFIG,
|
|
26
|
+
app: { ...DEFAULT_PIXEL_CONFIG.app, debug: true },
|
|
27
|
+
identity: { pixelId: 'pix_YOUR_ID' },
|
|
28
|
+
transport: {
|
|
29
|
+
...DEFAULT_PIXEL_CONFIG.transport,
|
|
30
|
+
apiEndpoint: 'https://your-pixel-api.example.com',
|
|
31
|
+
},
|
|
32
|
+
storage: {
|
|
33
|
+
...DEFAULT_PIXEL_CONFIG.storage,
|
|
34
|
+
persistence: {
|
|
35
|
+
visitor: 'localStorage',
|
|
36
|
+
session: 'sessionStorage',
|
|
37
|
+
attribution: 'localStorage',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
await pixel.init();
|
|
43
|
+
// Conversões manuais quando necessário
|
|
44
|
+
})();
|
|
45
|
+
</script>
|
|
46
|
+
</body>
|
|
47
|
+
</html>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Exemplo público
|
|
51
|
+
|
|
52
|
+
Veja `apps/playground-html/public/html/landing.html`.
|
|
53
|
+
|
|
54
|
+
## Limitações
|
|
55
|
+
|
|
56
|
+
- TypeScript/IDE não inferem tipos no global — use JSDoc ou migre para npm ESM em apps maiores.
|
|
57
|
+
- Mesmas regras de privacidade: a aplicação controla **quando** chamar `init()` após consentimento.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Funil — Checkout
|
|
2
|
+
|
|
3
|
+
## Objetivo
|
|
4
|
+
|
|
5
|
+
Rastrear início de checkout, carrinho, pagamento e compra.
|
|
6
|
+
|
|
7
|
+
## Config
|
|
8
|
+
|
|
9
|
+
- `commerce.enabled: true` + catálogo de produtos
|
|
10
|
+
- `identity.checkoutId`, `funnelStepId`
|
|
11
|
+
- Transport API habilitado
|
|
12
|
+
|
|
13
|
+
Ver `apps/playground-next/lib/pixel-config.ts` e `apps/playground-html/public/html/checkout.html`.
|
|
14
|
+
|
|
15
|
+
## API manual (ordem recomendada)
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
await pixel.init(); // PAGE_VIEW
|
|
19
|
+
|
|
20
|
+
pixel.addToCart({ productId: 'main' }); // opcional se carrinho já montado
|
|
21
|
+
pixel.initiateCheckout(); // início do checkout
|
|
22
|
+
pixel.addPaymentInfo({ paymentType: 'card' }); // antes de confirmar
|
|
23
|
+
pixel.purchase({ transactionId: 'ord_123' }); // após confirmação
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## AutoTrack
|
|
27
|
+
|
|
28
|
+
`modules.conversion.auto.detectors` para `addToCart`, `initiateCheckout`, `purchase` com seletores `[data-track]`.
|
|
29
|
+
|
|
30
|
+
## Eventos esperados
|
|
31
|
+
|
|
32
|
+
1. `PAGE_VIEW`
|
|
33
|
+
2. `ADD_TO_CART` (se aplicável)
|
|
34
|
+
3. `INITIATE_CHECKOUT`
|
|
35
|
+
4. `ADD_PAYMENT_INFO`
|
|
36
|
+
5. `PURCHASE`
|
|
37
|
+
|
|
38
|
+
## QA
|
|
39
|
+
|
|
40
|
+
- [ ] `value` / `currency` coerentes com `commerce.catalog`
|
|
41
|
+
- [ ] `transactionId` único por pedido
|
|
42
|
+
- [ ] Batch flush antes de redirect (aguardar rede ou `destroy()`)
|
|
43
|
+
|
|
44
|
+
## Erros comuns
|
|
45
|
+
|
|
46
|
+
| Problema | Causa | Solução |
|
|
47
|
+
|----------|-------|---------|
|
|
48
|
+
| `PURCHASE` sem valor | Catálogo vazio | Preencher `commerce.catalog` ou passar `value` em `purchase()` |
|
|
49
|
+
| Eventos fora de ordem | Chamadas antes do `init()` | Aguardar `init()` |
|
|
50
|
+
| Perda no redirect | Navegação imediata | `await pixel.destroy()` ou delay curto |
|
|
51
|
+
|
|
52
|
+
Guia Next.js: [React / Next.js](../getting-started/react-nextjs.md)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Funil — Downsell
|
|
2
|
+
|
|
3
|
+
## Objetivo
|
|
4
|
+
|
|
5
|
+
Oferta alternativa (menor preço) quando upsell é recusado.
|
|
6
|
+
|
|
7
|
+
## Importante (RC)
|
|
8
|
+
|
|
9
|
+
Sem evento `DOWNSELL_*`. Mesmo padrão do upsell:
|
|
10
|
+
|
|
11
|
+
- `PAGE_VIEW`
|
|
12
|
+
- `VIEW_CONTENT` — downsell apresentado
|
|
13
|
+
- `PURCHASE` — aceite
|
|
14
|
+
|
|
15
|
+
## Config
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
identity: {
|
|
19
|
+
funnelStepId: 'downsell_step_01',
|
|
20
|
+
offerId: 'downsell_basic',
|
|
21
|
+
},
|
|
22
|
+
commerce: {
|
|
23
|
+
catalog: {
|
|
24
|
+
products: [
|
|
25
|
+
{ id: 'downsell_01', name: 'Plano básico', type: 'downsell', price: 47, currency: 'BRL', quantity: 1 },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API manual
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
pixel.viewContent({ contentId: 'downsell_01' });
|
|
35
|
+
|
|
36
|
+
// Aceite
|
|
37
|
+
pixel.purchase({ transactionId: 'downsell_tx_789', value: 47, currency: 'BRL' });
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Eventos esperados
|
|
41
|
+
|
|
42
|
+
1. `PAGE_VIEW`
|
|
43
|
+
2. `VIEW_CONTENT`
|
|
44
|
+
3. `PURCHASE` ou abandono
|
|
45
|
+
|
|
46
|
+
## QA
|
|
47
|
+
|
|
48
|
+
- [ ] Step ID reflete posição no funil
|
|
49
|
+
- [ ] Valor menor que upsell/checkout refletido no payload
|
|
50
|
+
|
|
51
|
+
## Erros comuns
|
|
52
|
+
|
|
53
|
+
Documentar downsell como `VIEW_CONTENT` + `PURCHASE` na spec interna — não esperar tipo dedicado na API HTTP legada.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Funil completo
|
|
2
|
+
|
|
3
|
+
Fluxo de referência para landing → checkout → upsell → downsell → thank-you.
|
|
4
|
+
|
|
5
|
+
## Ordem das páginas
|
|
6
|
+
|
|
7
|
+
```txt
|
|
8
|
+
1. Landing → PAGE_VIEW, behavior, LEAD (opcional)
|
|
9
|
+
2. Checkout → INITIATE_CHECKOUT, ADD_PAYMENT_INFO, PURCHASE (principal)
|
|
10
|
+
3. Upsell → VIEW_CONTENT, PURCHASE (opcional)
|
|
11
|
+
4. Downsell → VIEW_CONTENT, PURCHASE (opcional)
|
|
12
|
+
5. Thank-you → PAGE_VIEW, PURCHASE (confirmação/dedupe)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Identity por etapa
|
|
16
|
+
|
|
17
|
+
Atualize em cada página (ou no router):
|
|
18
|
+
|
|
19
|
+
| Campo | Exemplo |
|
|
20
|
+
|-------|---------|
|
|
21
|
+
| `funnelId` | Constante do funil |
|
|
22
|
+
| `funnelStepId` | `landing`, `checkout`, `upsell`, … |
|
|
23
|
+
| `pageId` | ID da página no CMS |
|
|
24
|
+
| `offerId` | Oferta ativa |
|
|
25
|
+
|
|
26
|
+
## Persistência cross-page
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
storage: {
|
|
30
|
+
persistence: {
|
|
31
|
+
visitor: 'localStorage',
|
|
32
|
+
session: 'sessionStorage',
|
|
33
|
+
attribution: 'localStorage',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Visitor e sessão devem continuar entre steps no mesmo domínio.
|
|
39
|
+
|
|
40
|
+
## Commerce
|
|
41
|
+
|
|
42
|
+
Um `catalog` com todos os produtos (main, bumps, upsell, downsell) simplifica enrichment. Filtre por `productId` nas chamadas manuais.
|
|
43
|
+
|
|
44
|
+
## Transport
|
|
45
|
+
|
|
46
|
+
Uma instância `Pixel` por aba; `destroy()` ao desmontar componentes React entre rotas se recriar instância.
|
|
47
|
+
|
|
48
|
+
## QA end-to-end
|
|
49
|
+
|
|
50
|
+
1. Instalar tarball RC em app limpo
|
|
51
|
+
2. Percorrer funil completo em staging
|
|
52
|
+
3. Validar sequência na API backend
|
|
53
|
+
4. Confirmar attribution (UTM) na primeira landing
|
|
54
|
+
5. Verificar dedupe de `PURCHASE` duplicado na thank-you
|
|
55
|
+
|
|
56
|
+
## Exemplos
|
|
57
|
+
|
|
58
|
+
| Etapa | Exemplo |
|
|
59
|
+
|-------|---------|
|
|
60
|
+
| Landing | `apps/playground-html/public/html/landing.html` |
|
|
61
|
+
| Checkout | `apps/playground-html/public/html/checkout.html` |
|
|
62
|
+
| Full (Next) | `apps/playground-next/` |
|
|
63
|
+
|
|
64
|
+
Guias individuais: [landing](./funnel-landing.md), [checkout](./funnel-checkout.md), [upsell](./funnel-upsell.md), [downsell](./funnel-downsell.md), [thank-you](./funnel-thank-you.md).
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Funil — Landing
|
|
2
|
+
|
|
3
|
+
## Objetivo
|
|
4
|
+
|
|
5
|
+
Medir visita, comportamento na página e leads antes do checkout.
|
|
6
|
+
|
|
7
|
+
## Config recomendada
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
modules: {
|
|
11
|
+
...DEFAULT_PIXEL_CONFIG.modules,
|
|
12
|
+
core: { ...DEFAULT_PIXEL_CONFIG.modules.core, enabled: true },
|
|
13
|
+
behavior: {
|
|
14
|
+
...DEFAULT_PIXEL_CONFIG.modules.behavior,
|
|
15
|
+
enabled: true,
|
|
16
|
+
trackers: {
|
|
17
|
+
scroll: { enabled: true, thresholds: [25, 50, 75, 100], debounceMs: 100 },
|
|
18
|
+
click: { enabled: true, rageClick: { enabled: true } },
|
|
19
|
+
visibility: { enabled: true },
|
|
20
|
+
exitIntent: { enabled: true },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
transport: {
|
|
24
|
+
...DEFAULT_PIXEL_CONFIG.modules.transport,
|
|
25
|
+
enabled: true,
|
|
26
|
+
sender: { mode: 'api' },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Ajuste `identity.funnelStepId` / `pageId` para a landing.
|
|
32
|
+
|
|
33
|
+
## API manual
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
await pixel.init();
|
|
37
|
+
// PAGE_VIEW automático
|
|
38
|
+
|
|
39
|
+
pixel.lead({ email: 'user@example.com' }); // formulário enviado
|
|
40
|
+
pixel.viewContent({ contentId: 'hero-offer' }); // CTA / seção vista
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## AutoTrack
|
|
44
|
+
|
|
45
|
+
Opcional: `modules.conversion.auto` + detector `lead` com seletores do formulário.
|
|
46
|
+
|
|
47
|
+
## Eventos esperados (ordem típica)
|
|
48
|
+
|
|
49
|
+
1. `PAGE_VIEW`
|
|
50
|
+
2. `SCROLL`, `PAGE_CLICK`, … (behavior)
|
|
51
|
+
3. `LEAD` ou `VIEW_CONTENT` (conversão)
|
|
52
|
+
|
|
53
|
+
## QA
|
|
54
|
+
|
|
55
|
+
- [ ] `pixelId` e `apiEndpoint` corretos
|
|
56
|
+
- [ ] Persistência `sessionStorage` para sessão
|
|
57
|
+
- [ ] Um único `init()` por aba
|
|
58
|
+
- [ ] `getDebugSnapshot()` mostra transport enviando (dev)
|
|
59
|
+
|
|
60
|
+
## Erros comuns
|
|
61
|
+
|
|
62
|
+
| Problema | Causa | Solução |
|
|
63
|
+
|----------|-------|---------|
|
|
64
|
+
| Sem eventos na API | `transport.enabled: false` ou `sender.mode: 'mock'` | Habilitar transport + mode `api` |
|
|
65
|
+
| Sessão zera no reload | Sem `storage.persistence.session` | Configurar `sessionStorage` |
|
|
66
|
+
| Duplo `PAGE_VIEW` | Dois `init()` | Singleton / cleanup `destroy()` |
|
|
67
|
+
|
|
68
|
+
Exemplo: `apps/playground-html/public/html/landing.html`
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Funil — Thank-you
|
|
2
|
+
|
|
3
|
+
## Objetivo
|
|
4
|
+
|
|
5
|
+
Confirmar compra concluída e encerrar sessão de tracking da jornada.
|
|
6
|
+
|
|
7
|
+
## API manual
|
|
8
|
+
|
|
9
|
+
Se `PURCHASE` já foi enviado no checkout/upsell, thank-you pode ser apenas:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
await pixel.init(); // PAGE_VIEW na página de obrigado
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Opcional — reforço com dados do pedido:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
pixel.purchase({
|
|
19
|
+
transactionId: 'ord_123',
|
|
20
|
+
value: 197,
|
|
21
|
+
currency: 'BRL',
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
O módulo de conversão deduplica eventos repetidos dentro da janela configurada (`modules.core.dedupe`).
|
|
26
|
+
|
|
27
|
+
## AutoTrack
|
|
28
|
+
|
|
29
|
+
Detector `purchase` em URL patterns: `thank-you`, `success`, `order` (`modules.conversion.rules.urlPatterns`).
|
|
30
|
+
|
|
31
|
+
## Eventos esperados
|
|
32
|
+
|
|
33
|
+
1. `PAGE_VIEW`
|
|
34
|
+
2. `PURCHASE` (se disparado manualmente ou via auto)
|
|
35
|
+
3. `ENGAGEMENT_SUMMARY` / `BEHAVIOR_SESSION_SUMMARY` (se behavior + session summary habilitados no destroy)
|
|
36
|
+
|
|
37
|
+
## QA
|
|
38
|
+
|
|
39
|
+
- [ ] `transactionId` igual ao pedido real
|
|
40
|
+
- [ ] Sem PII em plain text se política exigir hashing (Etapa 25)
|
|
41
|
+
|
|
42
|
+
## Encerramento
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
await pixel.destroy();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Em SPA, ao sair da thank-you page.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Funil — Upsell
|
|
2
|
+
|
|
3
|
+
## Objetivo
|
|
4
|
+
|
|
5
|
+
Medir visualização e conversão de oferta adicional **após** compra inicial.
|
|
6
|
+
|
|
7
|
+
## Importante (RC)
|
|
8
|
+
|
|
9
|
+
**Não existe** evento `UPSELL_*` no SDK. Use:
|
|
10
|
+
|
|
11
|
+
- `PAGE_VIEW` — página carregou
|
|
12
|
+
- `VIEW_CONTENT` — oferta upsell exibida / vídeo assistido
|
|
13
|
+
- `PURCHASE` — aceite da oferta (novo `transactionId` ou mesmo pedido conforme regra de negócio)
|
|
14
|
+
|
|
15
|
+
## Config
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
identity: {
|
|
19
|
+
...identity,
|
|
20
|
+
funnelStepId: 'upsell_step_01',
|
|
21
|
+
offerId: 'upsell_premium',
|
|
22
|
+
},
|
|
23
|
+
commerce: {
|
|
24
|
+
enabled: true,
|
|
25
|
+
catalog: {
|
|
26
|
+
products: [
|
|
27
|
+
{ id: 'upsell_01', name: 'Upsell', type: 'upsell', price: 97, currency: 'BRL', quantity: 1 },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## API manual
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
await pixel.init();
|
|
37
|
+
|
|
38
|
+
pixel.viewContent({
|
|
39
|
+
contentId: 'upsell_01',
|
|
40
|
+
contentName: 'Oferta complementar',
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Botão "Sim, quero adicionar"
|
|
44
|
+
pixel.purchase({
|
|
45
|
+
transactionId: 'upsell_tx_456',
|
|
46
|
+
value: 97,
|
|
47
|
+
currency: 'BRL',
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## AutoTrack
|
|
52
|
+
|
|
53
|
+
Detector `viewContent` / `purchase` em botões da oferta (`data-track="upsell-accept"`).
|
|
54
|
+
|
|
55
|
+
## Eventos esperados
|
|
56
|
+
|
|
57
|
+
1. `PAGE_VIEW`
|
|
58
|
+
2. `VIEW_CONTENT`
|
|
59
|
+
3. `PURCHASE` (se aceito) ou saída sem conversão
|
|
60
|
+
|
|
61
|
+
## QA
|
|
62
|
+
|
|
63
|
+
- [ ] `funnelStepId` distinto do checkout principal
|
|
64
|
+
- [ ] Produto upsell no `catalog`
|
|
65
|
+
- [ ] Não reutilizar `transactionId` do pedido principal sem regra explícita
|
|
66
|
+
|
|
67
|
+
## Erros comuns
|
|
68
|
+
|
|
69
|
+
| Problema | Causa | Solução |
|
|
70
|
+
|----------|-------|---------|
|
|
71
|
+
| Upsell não aparece na API | Evento inventado | Usar `VIEW_CONTENT` / `PURCHASE` |
|
|
72
|
+
| Sessão quebrada | Novo domínio sem persistência | Mesmo `storage.persistence` cross-page |
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Limitações conhecidas do RC
|
|
2
|
+
|
|
3
|
+
Versão: `0.1.0-rc.5` · Etapas 1–20 concluídas.
|
|
4
|
+
|
|
5
|
+
## Produto
|
|
6
|
+
|
|
7
|
+
| Limitação | Detalhe |
|
|
8
|
+
|-----------|---------|
|
|
9
|
+
| Consent / CMP | Incompleto — Etapa 25 |
|
|
10
|
+
| Commerce Lifecycle | Etapa 21 não iniciada neste RC documental |
|
|
11
|
+
| Eventos upsell/downsell | Sem tipos dedicados; use `VIEW_CONTENT` + `PURCHASE` |
|
|
12
|
+
| `./diagnostics` | Não é export do pacote |
|
|
13
|
+
| APIs `@internal` | Playgrounds only — não suportadas publicamente |
|
|
14
|
+
|
|
15
|
+
## Config / defaults
|
|
16
|
+
|
|
17
|
+
| Limitação | Detalhe |
|
|
18
|
+
|-----------|---------|
|
|
19
|
+
| `modules.behavior.enabled` | `false` por default — habilitar explicitamente |
|
|
20
|
+
| `modules.transport.sender.mode` | `'mock'` por default — trocar para `'api'` |
|
|
21
|
+
| Sessão em memory | Sem `storage.persistence.session` |
|
|
22
|
+
|
|
23
|
+
## Distribuição
|
|
24
|
+
|
|
25
|
+
- Tarball local / npm privado — não há CDN público fixo documentado neste RC.
|
|
26
|
+
- Não altere versão sem política de release do time.
|
|
27
|
+
|
|
28
|
+
## Validação
|
|
29
|
+
|
|
30
|
+
670 testes automatizados (2 skipped). Smoke real requer endpoint configurado.
|
|
31
|
+
|
|
32
|
+
Veja também [RELEASE_CANDIDATE.md](../../RELEASE_CANDIDATE.md) e [PIXEL_V2_VALIDATION_MATRIX.md](../../../../PLAN_PIXEL/PIXEL_V2_VALIDATION_MATRIX.md).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Privacidade e consentimento (RC)
|
|
2
|
+
|
|
3
|
+
## Estado do RC `0.1.0-rc.5`
|
|
4
|
+
|
|
5
|
+
- **Não há Consent Gate / CMP completo** integrado ao SDK.
|
|
6
|
+
- `modules.core.consent` e `modules.privacy.consent` existem na config mas **defaults desligados**.
|
|
7
|
+
- Etapa **25 — Privacy/Consent** ainda não concluída.
|
|
8
|
+
|
|
9
|
+
## Responsabilidade da aplicação
|
|
10
|
+
|
|
11
|
+
1. **Quando inicializar** — só chame `pixel.init()` após obter consentimento do usuário, se exigido pela sua política.
|
|
12
|
+
2. **Banner / CMP** — implemente no app (React, HTML, tag manager). O Pixel não substitui ferramenta de consentimento.
|
|
13
|
+
3. **PII** — `modules.privacy.pii` (hash email/phone) off por default; você controla o que envia em `lead()` etc.
|
|
14
|
+
|
|
15
|
+
## O que NÃO declarar
|
|
16
|
+
|
|
17
|
+
- Não afirmar **GDPR**, **LGPD** ou **CCPA compliant** apenas por usar este RC.
|
|
18
|
+
- Não documentar fluxos de opt-out automáticos que ainda não existem no SDK.
|
|
19
|
+
|
|
20
|
+
## Padrão recomendado
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
async function onUserConsentGranted() {
|
|
24
|
+
const pixel = new Pixel(createConfig());
|
|
25
|
+
await pixel.init();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Antes do consentimento: não instanciar ou não chamar init()
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Próximos passos (roadmap)
|
|
32
|
+
|
|
33
|
+
Consentimento completo e políticas de retenção/anonymization na Etapa 25. Até lá, trate o RC como **distribuição controlada ao time** com revisão jurídica da aplicação host.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Validação do Release Candidate
|
|
2
|
+
|
|
3
|
+
## Comandos (raiz do monorepo)
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm type-check
|
|
7
|
+
pnpm test
|
|
8
|
+
pnpm build
|
|
9
|
+
pnpm --filter @beworke/pixel test:smoke:real
|
|
10
|
+
pnpm --filter @beworke/pixel test:transport
|
|
11
|
+
pnpm --filter @beworke/pixel test:integration
|
|
12
|
+
|
|
13
|
+
pnpm pack:pixel
|
|
14
|
+
pnpm validate:pixel-package
|
|
15
|
+
pnpm smoke:pixel-package
|
|
16
|
+
pnpm validate:public-docs
|
|
17
|
+
pnpm validate:public-examples
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
O fluxo oficial de empacotamento é **`pnpm pack:pixel`** (tarball em `artifacts/`).
|
|
21
|
+
Não use `pnpm --filter @beworke/pixel pack` como fluxo principal.
|
|
22
|
+
|
|
23
|
+
## Tarball
|
|
24
|
+
|
|
25
|
+
Nome esperado: `artifacts/beworke-pixel-0.1.0-rc.6.tgz`
|
|
26
|
+
Manifesto: `artifacts/latest-package.json` (caminho relativo portátil).
|
|
27
|
+
|
|
28
|
+
Instalação em projeto limpo:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install /caminho/para/artifacts/beworke-pixel-0.1.0-rc.6.tgz
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Checklist rápido
|
|
35
|
+
|
|
36
|
+
- [ ] Exports `.`, `./global`, `./v2`, `./config`, `./events`, `./services`, `./runtime`, `./logger`
|
|
37
|
+
- [ ] `window.PixelV2` no build global
|
|
38
|
+
- [ ] Exemplos públicos sem `@internal` / sem import de `src/`
|
|
39
|
+
- [ ] Links em `packages/pixel/docs/public/` válidos
|
|
40
|
+
- [ ] README aponta para `packages/pixel/docs/public/`
|
|
41
|
+
|
|
42
|
+
Documentos: [RELEASE_CANDIDATE.md](../../../RELEASE_CANDIDATE.md), [PIXEL_V2_PUBLIC_RC_RELEASE_CHECKLIST.md](../../../../../PLAN_PIXEL/PIXEL_V2_PUBLIC_RC_RELEASE_CHECKLIST.md).
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
## Nenhum evento chega na API
|
|
4
|
+
|
|
5
|
+
1. Confirme `transport.apiEndpoint` preenchido
|
|
6
|
+
2. `modules.transport.enabled: true`
|
|
7
|
+
3. `modules.transport.sender.mode: 'api'` (não `mock`)
|
|
8
|
+
4. `identity.pixelId` definido
|
|
9
|
+
5. DevTools → Network: requisições ao endpoint
|
|
10
|
+
|
|
11
|
+
## `init()` falha ou trava
|
|
12
|
+
|
|
13
|
+
- Verifique DOM disponível (browser only)
|
|
14
|
+
- Em SSR, não chame `init()` no servidor
|
|
15
|
+
- Confira CORS no endpoint da API
|
|
16
|
+
|
|
17
|
+
## Sessão / visitor inconsistentes
|
|
18
|
+
|
|
19
|
+
Configure persistência:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
storage: {
|
|
23
|
+
persistence: {
|
|
24
|
+
visitor: 'localStorage',
|
|
25
|
+
session: 'sessionStorage',
|
|
26
|
+
attribution: 'localStorage',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Duplicata de `PAGE_VIEW` ou `PURCHASE`
|
|
32
|
+
|
|
33
|
+
- Evite múltiplos `init()` sem `destroy()`
|
|
34
|
+
- Dedupe default: `modules.core.dedupe.windowMs: 2000`
|
|
35
|
+
- React Strict Mode pode montar duas vezes em dev — use singleton ou guard
|
|
36
|
+
|
|
37
|
+
## Snapshot para debug
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
console.log(pixel.getDebugSnapshot());
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Não use `getDebugServices()` em apps de funil.
|
|
44
|
+
|
|
45
|
+
## Instalação / tarball
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run validate:rc-package
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Links úteis
|
|
52
|
+
|
|
53
|
+
- [Configuração](./configuration/overview.md)
|
|
54
|
+
- [Transport module](./configuration/modules.md)
|
|
55
|
+
- [Validação RC](./release-candidate/validation.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beworke/pixel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.7",
|
|
4
4
|
"description": "Pixel v2 — SDK de analytics e conversão para API própria e destinos browser",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -47,21 +47,21 @@
|
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"dist",
|
|
50
|
+
"docs/public",
|
|
50
51
|
"README.md",
|
|
51
52
|
"CHANGELOG.md",
|
|
52
53
|
"RELEASE_CANDIDATE.md"
|
|
53
54
|
],
|
|
54
55
|
"scripts": {
|
|
55
56
|
"dev": "tsup --watch",
|
|
56
|
-
"build": "tsup",
|
|
57
|
+
"build": "tsup && node ../../scripts/copy-packaged-examples.mjs",
|
|
57
58
|
"test": "vitest run",
|
|
58
59
|
"test:watch": "vitest",
|
|
59
|
-
"test:smoke:real": "node
|
|
60
|
-
"validate:rc-package": "node
|
|
61
|
-
"validate:public-docs": "node
|
|
62
|
-
"validate:public-examples": "node
|
|
63
|
-
"publish:rc": "npm publish --tag rc",
|
|
64
|
-
"validate:15b": "node ./scripts/validate-15b.mjs",
|
|
60
|
+
"test:smoke:real": "node ../../scripts/run-smoke-real.mjs",
|
|
61
|
+
"validate:rc-package": "node ../../scripts/validate-rc-package.mjs",
|
|
62
|
+
"validate:public-docs": "node ../../scripts/validate-public-docs.mjs",
|
|
63
|
+
"validate:public-examples": "node ../../scripts/validate-public-examples.mjs",
|
|
64
|
+
"publish:rc": "npm publish --tag rc --tag latest",
|
|
65
65
|
"test:integration": "vitest run src/integration",
|
|
66
66
|
"test:transport": "vitest run src/transport",
|
|
67
67
|
"test:full-funnel": "vitest run src/modules/core/url-context src/integration/stage-15b-module-matrix.test.ts",
|
|
@@ -71,9 +71,7 @@
|
|
|
71
71
|
"format": "prettier --write src/**/*.{ts,tsx,js,jsx,json,css,md}",
|
|
72
72
|
"type-check": "tsc --noEmit",
|
|
73
73
|
"prepublishOnly": "pnpm build",
|
|
74
|
-
"
|
|
75
|
-
"version": "changeset version",
|
|
76
|
-
"release": "pnpm build && changeset publish"
|
|
74
|
+
"clean": "rimraf dist coverage"
|
|
77
75
|
},
|
|
78
76
|
"keywords": [
|
|
79
77
|
"pixel",
|
|
@@ -91,9 +89,7 @@
|
|
|
91
89
|
"publishConfig": {
|
|
92
90
|
"access": "public"
|
|
93
91
|
},
|
|
94
|
-
"packageManager": "pnpm@10.7.1",
|
|
95
92
|
"devDependencies": {
|
|
96
|
-
"@changesets/cli": "^2.29.7",
|
|
97
93
|
"@types/node": "^20.0.0",
|
|
98
94
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
99
95
|
"@typescript-eslint/parser": "^6.0.0",
|
|
@@ -102,6 +98,7 @@
|
|
|
102
98
|
"eslint-plugin-prettier": "^5.0.0",
|
|
103
99
|
"happy-dom": "^20.6.3",
|
|
104
100
|
"prettier": "^3.0.0",
|
|
101
|
+
"rimraf": "^6.0.1",
|
|
105
102
|
"tsup": "^8.5.0",
|
|
106
103
|
"typescript": "^5.0.0",
|
|
107
104
|
"vitest": "^4.0.18"
|