@beworke/pixel-bemony 0.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +157 -0
- package/README.md +176 -0
- package/RELEASE_CANDIDATE.md +37 -0
- package/dist/browser/index.cjs.js +2598 -0
- package/dist/browser/index.cjs.js.map +1 -0
- package/dist/browser/index.d.mts +184 -0
- package/dist/browser/index.d.ts +184 -0
- package/dist/browser/index.esm.js +2557 -0
- package/dist/browser/index.esm.js.map +1 -0
- package/dist/browser/pixel-bemony.global.js +9848 -0
- package/dist/browser/pixel-bemony.global.js.map +1 -0
- package/dist/createBemonyPixel-BGRD66p-.d.mts +474 -0
- package/dist/createBemonyPixel-BGRD66p-.d.ts +474 -0
- package/dist/index.cjs.js +2154 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.mts +320 -0
- package/dist/index.d.ts +320 -0
- package/dist/index.esm.js +2081 -0
- package/dist/index.esm.js.map +1 -0
- package/docs/BACKEND_PURCHASE_AND_REDIRECTS.md +125 -0
- package/docs/BROWSER_EVENT_ENRICHMENT.md +116 -0
- package/docs/SCENARIOS.md +92 -0
- package/docs/SECURITY_LIMITATIONS.md +45 -0
- package/docs/TEST_MATRIX.md +39 -0
- package/docs/TROUBLESHOOTING.md +81 -0
- package/examples/README.md +73 -0
- package/examples/browser-bootstrap.html +47 -0
- package/examples/checkout-price-code.html +37 -0
- package/examples/funnel/donsell/downsell_1.html +130 -0
- package/examples/funnel/donsell/downsell_2.html +130 -0
- package/examples/funnel/donsell/downsell_3.html +130 -0
- package/examples/funnel/offer-page.html +105 -0
- package/examples/funnel/upsell/upsell_1.html +130 -0
- package/examples/funnel/upsell/upsell_2.html +130 -0
- package/examples/funnel/upsell/upsell_3.html +139 -0
- package/examples/offer-page-price-code.html +22 -0
- package/examples/one-click-price-code.html +38 -0
- package/examples/security/checkout-sim.css +408 -0
- package/examples/security/checkout-sim.js +414 -0
- package/examples/security/one-click/pri_downsell_1.html +85 -0
- package/examples/security/one-click/pri_downsell_1a.html +85 -0
- package/examples/security/one-click/pri_downsell_1b.html +78 -0
- package/examples/security/one-click/pri_downsell_2.html +78 -0
- package/examples/security/one-click/pri_downsell_2a.html +78 -0
- package/examples/security/one-click/pri_downsell_2b.html +78 -0
- package/examples/security/one-click/pri_downsell_3.html +78 -0
- package/examples/security/one-click/pri_downsell_3a.html +78 -0
- package/examples/security/one-click/pri_downsell_3b.html +78 -0
- package/examples/security/one-click/pri_upsell_1.html +78 -0
- package/examples/security/one-click/pri_upsell_1a.html +78 -0
- package/examples/security/one-click/pri_upsell_1b.html +78 -0
- package/examples/security/one-click/pri_upsell_2.html +78 -0
- package/examples/security/one-click/pri_upsell_2a.html +78 -0
- package/examples/security/one-click/pri_upsell_2b.html +78 -0
- package/examples/security/one-click/pri_upsell_3.html +78 -0
- package/examples/security/one-click/pri_upsell_3a.html +78 -0
- package/examples/security/one-click/pri_upsell_3b.html +78 -0
- package/examples/security/one-click/pri_upsell_3c.html +78 -0
- package/examples/security/pri1766322.html +333 -0
- package/examples/security/pri5529930.html +333 -0
- package/examples/security/pri6670988.html +334 -0
- package/examples/security/thank-you.html +65 -0
- package/examples/sim/funnel-flow.js +258 -0
- package/examples/sim/one-click-sim.js +167 -0
- package/examples/upsell-price-code.html +41 -0
- package/examples/url-context-navigation.html +96 -0
- package/package.json +63 -0
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import { PixelConfig, PixelDebugSnapshot } from '@beworke/pixel';
|
|
2
|
+
import { ViewContentData, AddToCartData, RemoveFromCartData, LeadData, InitiateCheckoutData, AddPaymentInfoData } from '@beworke/pixel/events';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Contexto público da página — pode ir para identity/navigation.
|
|
6
|
+
* Nunca inclui segredos (token one-click, cartão, etc.).
|
|
7
|
+
*/
|
|
8
|
+
interface BemonyPublicPageContext {
|
|
9
|
+
pageId?: string;
|
|
10
|
+
funnelId?: string;
|
|
11
|
+
funnelStepId?: string;
|
|
12
|
+
offerId?: string;
|
|
13
|
+
productId?: string;
|
|
14
|
+
/** Código público do price (`pri*`). Identidade comercial canônica. */
|
|
15
|
+
priceCode?: string;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use priceCode.
|
|
18
|
+
*/
|
|
19
|
+
priceId?: string;
|
|
20
|
+
checkoutId?: string;
|
|
21
|
+
affiliateId?: string;
|
|
22
|
+
/** Correlação app/backend; sem campo dedicado no Core identity. */
|
|
23
|
+
publicOrderId?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Input completo de contexto público da página.
|
|
27
|
+
*/
|
|
28
|
+
interface BemonyPageContextInput {
|
|
29
|
+
public: BemonyPublicPageContext;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Commerce mínimo para a factory de config (sem checkout completo).
|
|
33
|
+
* Opcional — Bemony não exige catálogo para emitir eventos com priceCode.
|
|
34
|
+
*/
|
|
35
|
+
interface BemonyCommerceInput {
|
|
36
|
+
currency?: string;
|
|
37
|
+
cartMode?: 'landing_page' | 'single_product' | 'checkout' | 'upsell' | 'custom';
|
|
38
|
+
products?: ReadonlyArray<{
|
|
39
|
+
id: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
type?: string;
|
|
42
|
+
price?: number;
|
|
43
|
+
currency?: string;
|
|
44
|
+
quantity?: number;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
type BemonyValidationErrorCode = 'MISSING_REQUIRED_FIELD' | 'MISSING_ENDPOINT' | 'INVALID_FIELD' | 'INVALID_ENVIRONMENT';
|
|
48
|
+
type BemonyValidationErrorOptions = {
|
|
49
|
+
code: BemonyValidationErrorCode;
|
|
50
|
+
message: string;
|
|
51
|
+
field?: string;
|
|
52
|
+
scenario?: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Erro tipado de validação. Mensagens nunca devem incluir valores sensíveis.
|
|
56
|
+
*/
|
|
57
|
+
declare class BemonyValidationError extends Error {
|
|
58
|
+
readonly code: BemonyValidationErrorCode;
|
|
59
|
+
readonly field?: string;
|
|
60
|
+
readonly scenario?: string;
|
|
61
|
+
constructor(options: BemonyValidationErrorOptions);
|
|
62
|
+
}
|
|
63
|
+
declare function isBemonyPageContextInput(value: unknown): value is BemonyPageContextInput;
|
|
64
|
+
declare function normalizeBemonyPageContextInput(page?: BemonyPageContextInput | BemonyPublicPageContext): BemonyPageContextInput;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Defaults estáveis da plataforma Bemony (sem dados dinâmicos de página).
|
|
68
|
+
* Composição: DEFAULT_PIXEL_CONFIG → estes defaults → environment → scenario → page.
|
|
69
|
+
*/
|
|
70
|
+
declare const BEMONY_STORAGE_PREFIX = "__bemony_pixel";
|
|
71
|
+
declare const BEMONY_DEFAULT_NAMESPACE: "bemony-web";
|
|
72
|
+
/**
|
|
73
|
+
* Endpoint público padrão da API Pixel Bemony (infraestrutura, não credencial).
|
|
74
|
+
* O Core acrescenta `/pixels/public/event` e `/pixels/public/event/batch`.
|
|
75
|
+
*/
|
|
76
|
+
declare const BEMONY_DEFAULT_API_ENDPOINT: "https://micro-service-pixel-production-4826.up.railway.app";
|
|
77
|
+
declare const BEMONY_DEFAULT_PIXEL_ID: "pix_7704308";
|
|
78
|
+
/** Domínios Bemony permitidos por default para decoração de links. */
|
|
79
|
+
declare const BEMONY_DEFAULT_ALLOWED_DOMAINS: readonly ["security.bemony.com", "localhost", "127.0.0.1", "local"];
|
|
80
|
+
/** Ambiente padrão do auto-init do bundle global IIFE (não da factory programática). */
|
|
81
|
+
declare const BEMONY_DEFAULT_BROWSER_ENVIRONMENT: "production";
|
|
82
|
+
/** Cenário padrão do auto-init do bundle global IIFE. */
|
|
83
|
+
declare const BEMONY_DEFAULT_BROWSER_SCENARIO: "offer-page";
|
|
84
|
+
/**
|
|
85
|
+
* Defaults oficiais do auto-init browser (IIFE global).
|
|
86
|
+
* Imutável — merge deve clonar, nunca mutar.
|
|
87
|
+
*/
|
|
88
|
+
declare const BEMONY_BROWSER_AUTO_INIT_DEFAULTS: Readonly<{
|
|
89
|
+
environment: "production";
|
|
90
|
+
scenario: "offer-page";
|
|
91
|
+
platform: Readonly<{
|
|
92
|
+
pixelId: "pix_7704308";
|
|
93
|
+
apiEndpoint: "https://micro-service-pixel-production-4826.up.railway.app";
|
|
94
|
+
namespace: "bemony-web";
|
|
95
|
+
allowedDomains: readonly ("security.bemony.com" | "localhost" | "127.0.0.1" | "local")[];
|
|
96
|
+
}>;
|
|
97
|
+
}>;
|
|
98
|
+
type BemonyPlatformDefaults = {
|
|
99
|
+
app: {
|
|
100
|
+
source: 'bemony';
|
|
101
|
+
};
|
|
102
|
+
storage: {
|
|
103
|
+
prefix: typeof BEMONY_STORAGE_PREFIX;
|
|
104
|
+
namespace: typeof BEMONY_DEFAULT_NAMESPACE;
|
|
105
|
+
persistence: {
|
|
106
|
+
visitor: 'localStorage';
|
|
107
|
+
session: 'sessionStorage';
|
|
108
|
+
attribution: 'localStorage';
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
attribution: {
|
|
112
|
+
enabled: true;
|
|
113
|
+
persist: true;
|
|
114
|
+
captureUrlParams: true;
|
|
115
|
+
captureCookies: true;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
declare const BEMONY_PLATFORM_DEFAULTS: BemonyPlatformDefaults;
|
|
119
|
+
/**
|
|
120
|
+
* Opções de plataforma injetadas pelo app (sem hardcode de credenciais/endpoints).
|
|
121
|
+
*/
|
|
122
|
+
type BemonyPlatformOptions = {
|
|
123
|
+
/** Identidade obrigatória do pixel. */
|
|
124
|
+
pixelId: string;
|
|
125
|
+
/**
|
|
126
|
+
* Endpoint base da API Pixel.
|
|
127
|
+
* Obrigatório em staging/production; opcional em development (mock).
|
|
128
|
+
* Não inventar URL — injetar valor aprovado (env/provider).
|
|
129
|
+
*/
|
|
130
|
+
apiEndpoint?: string;
|
|
131
|
+
/** Namespace estável por aplicação (não por página/oferta). */
|
|
132
|
+
namespace?: string;
|
|
133
|
+
/** Domínios aprovados para link decoration. */
|
|
134
|
+
allowedDomains?: readonly string[];
|
|
135
|
+
/** Override explícito de debug (senão segue o ambiente). */
|
|
136
|
+
debug?: boolean;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
type BemonyEnvironment = 'development' | 'staging' | 'production';
|
|
140
|
+
declare const BEMONY_ENVIRONMENTS: readonly BemonyEnvironment[];
|
|
141
|
+
type BemonyEnvironmentResolution = {
|
|
142
|
+
environment: BemonyEnvironment;
|
|
143
|
+
debug: boolean;
|
|
144
|
+
/** Endpoint efetivo (pode ser '' em development com mock). */
|
|
145
|
+
apiEndpoint: string;
|
|
146
|
+
transportEnabled: boolean;
|
|
147
|
+
senderMode: 'mock' | 'http';
|
|
148
|
+
};
|
|
149
|
+
type ResolveBemonyEnvironmentOptions = {
|
|
150
|
+
environment: BemonyEnvironment;
|
|
151
|
+
apiEndpoint?: string;
|
|
152
|
+
debugOverride?: boolean;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Resolve comportamento por ambiente.
|
|
156
|
+
* Staging/production exigem endpoint injetado — nenhum URL inventado.
|
|
157
|
+
*/
|
|
158
|
+
declare function resolveBemonyEnvironment(options: ResolveBemonyEnvironmentOptions): BemonyEnvironmentResolution;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Cenários de domínio Bemony (V1).
|
|
162
|
+
* Determinam comportamentos locais (eventos, detectores, params).
|
|
163
|
+
* Nenhum cenário consulta catálogo no bootstrap.
|
|
164
|
+
*/
|
|
165
|
+
type BemonyScenario = 'offer-page' | 'checkout' | 'upsell-offer' | 'one-click-checkout' | 'thank-you';
|
|
166
|
+
declare const BEMONY_SCENARIOS: readonly BemonyScenario[];
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Overrides restritos e tipados (não expor Partial<PixelConfig>).
|
|
170
|
+
*/
|
|
171
|
+
type BemonyConfigOverrides = {
|
|
172
|
+
debug?: boolean;
|
|
173
|
+
apiEndpoint?: string;
|
|
174
|
+
allowedDomains?: readonly string[];
|
|
175
|
+
};
|
|
176
|
+
type CreateBemonyPixelConfigOptions = {
|
|
177
|
+
environment: BemonyEnvironment;
|
|
178
|
+
scenario: BemonyScenario;
|
|
179
|
+
platform: BemonyPlatformOptions;
|
|
180
|
+
page?: BemonyPageContextInput | BemonyPublicPageContext;
|
|
181
|
+
commerce?: BemonyCommerceInput;
|
|
182
|
+
/** Params públicos já filtrados da URL (sem token). */
|
|
183
|
+
urlParams?: Readonly<Record<string, string>>;
|
|
184
|
+
pageMetadata?: BemonyPublicPageContext;
|
|
185
|
+
scenarioDefaults?: BemonyPublicPageContext;
|
|
186
|
+
overrides?: BemonyConfigOverrides;
|
|
187
|
+
/**
|
|
188
|
+
* Quando false, desativa auto `startCheckout` no init (checkout).
|
|
189
|
+
* Default: true no cenário checkout.
|
|
190
|
+
*/
|
|
191
|
+
autoInitiateCheckout?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* URL de “No Thanks” para upsell/downsell (`data-no-thanks` no script).
|
|
194
|
+
*/
|
|
195
|
+
noThanksUrl?: string;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Compõe um PixelConfig válido para Bemony.
|
|
199
|
+
*
|
|
200
|
+
* Ordem: DEFAULT_PIXEL_CONFIG → platform → environment → scenario → page → overrides.
|
|
201
|
+
* Nunca inclui token efêmero. Não muta o input. Clona arrays.
|
|
202
|
+
*/
|
|
203
|
+
declare function createBemonyPixelConfig(options: CreateBemonyPixelConfigOptions): PixelConfig;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Input opcional para `startCheckout` → `Pixel.initiateCheckout()`.
|
|
207
|
+
* Valor/itens podem ser enriquecidos pelo commerce do Core.
|
|
208
|
+
*/
|
|
209
|
+
interface BemonyCheckoutInput {
|
|
210
|
+
value?: number;
|
|
211
|
+
currency?: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Opções de `declineUpsell`.
|
|
216
|
+
*
|
|
217
|
+
* GAP explícito: o Core não possui evento público de recusa.
|
|
218
|
+
* Este método NÃO emite conversion falsa (não usa viewContent/addToCart/lead/etc.).
|
|
219
|
+
*/
|
|
220
|
+
type BemonyDeclineUpsellOptions = {
|
|
221
|
+
/** Callback do app (analytics próprio, UI, etc.). */
|
|
222
|
+
onDecline?: () => void;
|
|
223
|
+
/**
|
|
224
|
+
* URL da próxima etapa. Se definida, navega via `location.assign`.
|
|
225
|
+
* O backend/302 deve preservar `sid` / params públicos quando aplicável.
|
|
226
|
+
*/
|
|
227
|
+
navigateTo?: string;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Normaliza a identidade comercial pública Bemony (`priceCode`).
|
|
232
|
+
*
|
|
233
|
+
* `priceId` permanece como alias deprecated de compatibilidade.
|
|
234
|
+
* Não inventa valor a partir de offerId/productId.
|
|
235
|
+
*/
|
|
236
|
+
type BemonyCommerceIdentityInput = {
|
|
237
|
+
priceCode?: string;
|
|
238
|
+
/** @deprecated Use priceCode. */
|
|
239
|
+
priceId?: string;
|
|
240
|
+
};
|
|
241
|
+
type ResolvePriceCodeResult = {
|
|
242
|
+
priceCode: string | null;
|
|
243
|
+
/** True quando priceCode e priceId divergem (usa priceCode). */
|
|
244
|
+
conflict: boolean;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Resolve o priceCode canônico.
|
|
248
|
+
*
|
|
249
|
+
* 1. `priceCode` tem prioridade
|
|
250
|
+
* 2. `priceId` é fallback de compatibilidade
|
|
251
|
+
* 3. trim; vazio → null
|
|
252
|
+
* 4. conflito → preferir priceCode e sinalizar `conflict`
|
|
253
|
+
*/
|
|
254
|
+
declare function resolvePriceCode(input: BemonyCommerceIdentityInput | null | undefined): ResolvePriceCodeResult;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Input mínimo de oferta no browser.
|
|
258
|
+
*
|
|
259
|
+
* Identidade canônica: `priceCode`.
|
|
260
|
+
* Valor/moeda observados são opcionais e não são autoridade financeira.
|
|
261
|
+
* productId/offerId reais NÃO são inventados no browser.
|
|
262
|
+
*/
|
|
263
|
+
interface BemonyOfferInput extends BemonyCommerceIdentityInput {
|
|
264
|
+
quantity?: number;
|
|
265
|
+
/** Valor observado na UI (opcional; backend valida). */
|
|
266
|
+
observedValue?: number;
|
|
267
|
+
/** Moeda observada na UI (opcional; backend valida). */
|
|
268
|
+
observedCurrency?: string;
|
|
269
|
+
/**
|
|
270
|
+
* @deprecated Preferir observedValue. Mantido para hosts legados.
|
|
271
|
+
*/
|
|
272
|
+
price?: number;
|
|
273
|
+
/**
|
|
274
|
+
* @deprecated Preferir observedCurrency.
|
|
275
|
+
*/
|
|
276
|
+
currency?: string;
|
|
277
|
+
/**
|
|
278
|
+
* Tipo observado (upsell/downsell) — não resolve catálogo.
|
|
279
|
+
*/
|
|
280
|
+
productType?: 'main' | 'order_bump' | 'upsell' | 'downsell' | 'cross_sell' | 'addon' | 'subscription' | 'custom' | 'other';
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Oferta completa exige `priceCode` (ou `priceId` legado).
|
|
284
|
+
*/
|
|
285
|
+
declare function isCompleteBemonyOffer(input: BemonyOfferInput | null | undefined): input is BemonyOfferInput;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Input de confirmação one-click (intenção no Pixel).
|
|
289
|
+
* Não processa pagamento e não emite PURCHASE.
|
|
290
|
+
* Identidade mínima: priceCode.
|
|
291
|
+
*/
|
|
292
|
+
type BemonyOneClickConfirmationInput = BemonyOfferInput;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Input de lead para `captureLead` → `Pixel.lead()`.
|
|
296
|
+
* Não dispara ADD_TO_CART.
|
|
297
|
+
*/
|
|
298
|
+
interface BemonyLeadInput {
|
|
299
|
+
email?: string;
|
|
300
|
+
phone?: string;
|
|
301
|
+
name?: string;
|
|
302
|
+
fields?: Record<string, unknown>;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Validação mínima: email válido e/ou telefone com ao menos 8 dígitos.
|
|
306
|
+
*/
|
|
307
|
+
declare function isValidBemonyLead(input: BemonyLeadInput): boolean;
|
|
308
|
+
declare function leadFingerprint(input: BemonyLeadInput): string;
|
|
309
|
+
/**
|
|
310
|
+
* Remove campos sensíveis (cartão etc.) de `fields` antes de enviar ao Core.
|
|
311
|
+
*/
|
|
312
|
+
declare function sanitizeLeadFields(fields: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Métodos de pagamento alinhados ao Core (`AddPaymentInfoData.paymentMethod`).
|
|
316
|
+
* `PaymentMethod` não é reexportado por `@beworke/pixel/events` — espelhamos o union.
|
|
317
|
+
*/
|
|
318
|
+
type BemonyPaymentMethod = 'CREDIT_CARD' | 'PIX' | 'BOLETO' | 'PAYPAL' | 'OTHER';
|
|
319
|
+
/**
|
|
320
|
+
* Input de método de pagamento — somente enum, sem dados de cartão.
|
|
321
|
+
*/
|
|
322
|
+
interface BemonyPaymentMethodInput {
|
|
323
|
+
paymentMethod: BemonyPaymentMethod;
|
|
324
|
+
}
|
|
325
|
+
declare const BEMONY_PAYMENT_METHODS: readonly BemonyPaymentMethod[];
|
|
326
|
+
declare function isValidBemonyPaymentMethod(input: BemonyPaymentMethodInput | null | undefined): input is BemonyPaymentMethodInput;
|
|
327
|
+
|
|
328
|
+
type BemonyPixelState = 'created' | 'initializing' | 'ready' | 'destroying' | 'destroyed' | 'failed';
|
|
329
|
+
/**
|
|
330
|
+
* Superfície pública do Core usada pelo wrapper.
|
|
331
|
+
* Não inclui métodos @internal nem purchase (fora do fluxo browser Bemony).
|
|
332
|
+
*/
|
|
333
|
+
type BemonyCorePixel = {
|
|
334
|
+
init(): Promise<void>;
|
|
335
|
+
destroy(): Promise<void>;
|
|
336
|
+
isInitialized(): boolean;
|
|
337
|
+
getDebugSnapshot(): Readonly<PixelDebugSnapshot>;
|
|
338
|
+
viewContent(data?: ViewContentData): void;
|
|
339
|
+
addToCart(data?: AddToCartData): void;
|
|
340
|
+
removeFromCart(data?: RemoveFromCartData): void;
|
|
341
|
+
lead(data: LeadData): void;
|
|
342
|
+
initiateCheckout(data?: InitiateCheckoutData): void;
|
|
343
|
+
addPaymentInfo(data?: AddPaymentInfoData): void;
|
|
344
|
+
setManagedUrlParam?(param: string, value: string): boolean;
|
|
345
|
+
};
|
|
346
|
+
type BemonyPixelConstructOptions = {
|
|
347
|
+
config: PixelConfig;
|
|
348
|
+
scenario: BemonyScenario;
|
|
349
|
+
createCorePixel?: (config: PixelConfig) => BemonyCorePixel;
|
|
350
|
+
/** Default true no cenário checkout / one-click. */
|
|
351
|
+
autoInitiateCheckout?: boolean;
|
|
352
|
+
publicOrderId?: string;
|
|
353
|
+
publicContext?: BemonyPublicPageContext;
|
|
354
|
+
/**
|
|
355
|
+
* URL de “No Thanks” (`data-no-thanks` no script).
|
|
356
|
+
* O link de recusa é o `<a href>` que coincide com esta URL.
|
|
357
|
+
*/
|
|
358
|
+
noThanksUrl?: string;
|
|
359
|
+
};
|
|
360
|
+
type BemonyLifecycleErrorCode = 'INIT_FAILED' | 'INVALID_STATE' | 'DESTROY_FAILED';
|
|
361
|
+
declare class BemonyLifecycleError extends Error {
|
|
362
|
+
readonly code: BemonyLifecycleErrorCode;
|
|
363
|
+
readonly state: BemonyPixelState;
|
|
364
|
+
readonly cause?: unknown;
|
|
365
|
+
constructor(options: {
|
|
366
|
+
code: BemonyLifecycleErrorCode;
|
|
367
|
+
message: string;
|
|
368
|
+
state: BemonyPixelState;
|
|
369
|
+
cause?: unknown;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Identidade comercial do CTA de aceite: pathname do href (`/pri*`).
|
|
374
|
+
* Útil para hosts que resolvem o CTA manualmente; o cenário upsell usa LinkAuto.
|
|
375
|
+
*/
|
|
376
|
+
declare function resolvePriceCodeFromAcceptElement(el: Element): string | null;
|
|
377
|
+
/**
|
|
378
|
+
* Wrapper de lifecycle e domínio Bemony sobre `Pixel`.
|
|
379
|
+
*
|
|
380
|
+
* Sem consulta de catálogo. Sem auto VIEW_CONTENT.
|
|
381
|
+
* Identidade comercial no browser: priceCode observado.
|
|
382
|
+
*/
|
|
383
|
+
declare class BemonyPixel {
|
|
384
|
+
private state;
|
|
385
|
+
private readonly scenario;
|
|
386
|
+
private readonly config;
|
|
387
|
+
private readonly core;
|
|
388
|
+
private initPromise;
|
|
389
|
+
private destroyPromise;
|
|
390
|
+
private readonly wrapperListeners;
|
|
391
|
+
private readonly autoInitiateCheckoutEnabled;
|
|
392
|
+
private publicOrderId;
|
|
393
|
+
private readonly publicContext;
|
|
394
|
+
private readonly noThanksUrl;
|
|
395
|
+
private checkoutStarted;
|
|
396
|
+
private lastLeadFingerprint;
|
|
397
|
+
private readonly selectedBumpIds;
|
|
398
|
+
constructor(options: BemonyPixelConstructOptions);
|
|
399
|
+
getScenario(): BemonyScenario;
|
|
400
|
+
getConfig(): Readonly<PixelConfig>;
|
|
401
|
+
getState(): BemonyPixelState;
|
|
402
|
+
isInitialized(): boolean;
|
|
403
|
+
getDebugSnapshot(): Readonly<PixelDebugSnapshot>;
|
|
404
|
+
/**
|
|
405
|
+
* `publicOrderId` do domínio do app (não mapeado para identity do Core).
|
|
406
|
+
* Fallback opcional: param `oid` da URL atual.
|
|
407
|
+
*/
|
|
408
|
+
getPublicOrderId(): string | null;
|
|
409
|
+
/**
|
|
410
|
+
* Define `publicOrderId` e propaga para managed param `oid` quando suportado.
|
|
411
|
+
*/
|
|
412
|
+
setPublicOrderId(orderId: string): void;
|
|
413
|
+
getPublicSessionId(): string | null;
|
|
414
|
+
selectOffer(input: BemonyOfferInput): void;
|
|
415
|
+
/**
|
|
416
|
+
* Inicia checkout → `Pixel.initiateCheckout()`.
|
|
417
|
+
* Idempotente: no máximo uma vez por lifecycle da instância.
|
|
418
|
+
*/
|
|
419
|
+
startCheckout(input?: BemonyCheckoutInput): void;
|
|
420
|
+
/**
|
|
421
|
+
* Captura lead → `Pixel.lead()`.
|
|
422
|
+
* Campos incompletos não disparam. Mesmo fingerprint não reenvia (debounce).
|
|
423
|
+
*/
|
|
424
|
+
captureLead(input: BemonyLeadInput): boolean;
|
|
425
|
+
selectOrderBump(input: BemonyOfferInput): void;
|
|
426
|
+
removeOrderBump(input: BemonyOfferInput): void;
|
|
427
|
+
trackPaymentMethod(input: BemonyPaymentMethodInput): void;
|
|
428
|
+
viewUpsell(input: BemonyOfferInput): void;
|
|
429
|
+
acceptUpsell(input: BemonyOfferInput): void;
|
|
430
|
+
/**
|
|
431
|
+
* Recusa de upsell/downsell — callback/navegação apenas.
|
|
432
|
+
* Destino: `navigateTo` explícito, senão `noThanksUrl` (data-no-thanks).
|
|
433
|
+
*/
|
|
434
|
+
declineUpsell(options?: BemonyDeclineUpsellOptions): void;
|
|
435
|
+
/**
|
|
436
|
+
* Intenção de confirmação one-click → `Pixel.addToCart()`.
|
|
437
|
+
* Não processa pagamento e **não** emite PURCHASE.
|
|
438
|
+
*/
|
|
439
|
+
trackOneClickConfirmation(input: BemonyOneClickConfirmationInput): void;
|
|
440
|
+
init(): Promise<void>;
|
|
441
|
+
destroy(): Promise<void>;
|
|
442
|
+
addWrapperListener(cleanup: () => void): () => void;
|
|
443
|
+
private assertReady;
|
|
444
|
+
private assertOneClickReady;
|
|
445
|
+
private applyPublicOrderIdToManagedParam;
|
|
446
|
+
private decorateNavigateUrl;
|
|
447
|
+
private maybeAutoInitiateCheckout;
|
|
448
|
+
private resetDomainState;
|
|
449
|
+
private startInit;
|
|
450
|
+
private startDestroy;
|
|
451
|
+
private safeCoreDestroy;
|
|
452
|
+
private clearWrapperListeners;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Opções da factory de lifecycle.
|
|
457
|
+
* Sem contextResolver / catálogo remoto.
|
|
458
|
+
*/
|
|
459
|
+
type BemonyPixelOptions = CreateBemonyPixelConfigOptions & {
|
|
460
|
+
createCorePixel?: (config: PixelConfig) => BemonyCorePixel;
|
|
461
|
+
};
|
|
462
|
+
type CreateBemonyPixelOptions = BemonyPixelOptions;
|
|
463
|
+
/**
|
|
464
|
+
* Bootstrap local (sem consulta de catálogo):
|
|
465
|
+
* 1. Normalizar cenário e contexto público
|
|
466
|
+
* 2. Journey UrlContext + managed params
|
|
467
|
+
* 3. PixelConfig
|
|
468
|
+
* 4. Core init + detectores
|
|
469
|
+
*
|
|
470
|
+
* O browser captura priceCode observado; o backend enriquece o evento.
|
|
471
|
+
*/
|
|
472
|
+
declare function createBemonyPixel(options: CreateBemonyPixelOptions): Promise<BemonyPixel>;
|
|
473
|
+
|
|
474
|
+
export { BEMONY_PAYMENT_METHODS as A, type BemonyPublicPageContext as B, type CreateBemonyPixelConfigOptions as C, isValidBemonyPaymentMethod as D, type BemonyCheckoutInput as E, type BemonyEnvironment as F, BEMONY_ENVIRONMENTS as G, resolveBemonyEnvironment as H, type BemonyPlatformOptions as I, BEMONY_BROWSER_AUTO_INIT_DEFAULTS as J, BEMONY_DEFAULT_ALLOWED_DOMAINS as K, BEMONY_DEFAULT_API_ENDPOINT as L, BEMONY_DEFAULT_BROWSER_ENVIRONMENT as M, BEMONY_DEFAULT_BROWSER_SCENARIO as N, BEMONY_DEFAULT_NAMESPACE as O, BEMONY_DEFAULT_PIXEL_ID as P, BEMONY_PLATFORM_DEFAULTS as Q, type ResolvePriceCodeResult as R, BEMONY_STORAGE_PREFIX as S, type BemonyCommerceInput as T, type BemonyPageContextInput as U, type BemonyValidationErrorCode as V, BemonyValidationError as W, isBemonyPageContextInput as X, normalizeBemonyPageContextInput as Y, type BemonyScenario as a, type BemonyConfigOverrides as b, createBemonyPixelConfig as c, createBemonyPixel as d, type BemonyPixelOptions as e, type CreateBemonyPixelOptions as f, BemonyLifecycleError as g, BemonyPixel as h, type BemonyCorePixel as i, type BemonyLifecycleErrorCode as j, type BemonyPixelConstructOptions as k, type BemonyPixelState as l, BEMONY_SCENARIOS as m, type BemonyDeclineUpsellOptions as n, type BemonyOneClickConfirmationInput as o, type BemonyOfferInput as p, isCompleteBemonyOffer as q, resolvePriceCodeFromAcceptElement as r, type BemonyCommerceIdentityInput as s, resolvePriceCode as t, type BemonyLeadInput as u, isValidBemonyLead as v, leadFingerprint as w, sanitizeLeadFields as x, type BemonyPaymentMethodInput as y, type BemonyPaymentMethod as z };
|