@beworke/pixel 0.1.0-rc.11 → 0.1.0-rc.13
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 +15 -0
- package/dist/{Pixel-BnN86r4X.d.ts → Pixel-BKTvqIwz.d.ts} +4 -4
- package/dist/{Pixel-BoUGqCbP.d.mts → Pixel-DgVo0j7D.d.mts} +4 -4
- package/dist/{StorageFactory-C0prtNR7.d.mts → StorageFactory-BRtmy983.d.mts} +2 -2
- package/dist/{StorageFactory-BfCArzMM.d.ts → StorageFactory-BcOX0fsg.d.ts} +2 -2
- package/dist/browser/index.cjs.js +1 -1
- package/dist/browser/index.cjs.js.map +1 -1
- package/dist/browser/index.d.mts +6 -6
- package/dist/browser/index.d.ts +6 -6
- package/dist/browser/index.esm.js +1 -1
- package/dist/browser/index.esm.js.map +1 -1
- package/dist/browser/pixel.buygoods-checkout.global.js +1 -1
- package/dist/browser/pixel.buygoods-checkout.global.js.map +1 -1
- package/dist/browser/pixel.buygoods-landing.global.js +1 -1
- package/dist/browser/pixel.buygoods-landing.global.js.map +1 -1
- package/dist/browser/pixel.global.js +1 -1
- package/dist/browser/pixel.global.js.map +1 -1
- package/dist/browser/pixel.internal-checkout.global.js +1 -1
- package/dist/browser/pixel.internal-checkout.global.js.map +1 -1
- 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 +1 -1
- package/dist/events/index.cjs.js.map +1 -1
- package/dist/events/index.d.mts +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.esm.js +1 -1
- package/dist/events/index.esm.js.map +1 -1
- package/dist/{index-BxT2d-TK.d.mts → index-CKZeennc.d.mts} +36 -2
- package/dist/{index-B8u_3PGG.d.ts → index-YlvQBRzR.d.ts} +36 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/{pixel-_BSDpx4M.d.mts → pixel-CCHv_ror.d.mts} +17 -1
- package/dist/{pixel-DNGbAN5C.d.ts → pixel-CgKoaWS3.d.ts} +17 -1
- package/dist/{pixel-default-config-DLRya1tl.d.mts → pixel-default-config-CTtkGKh1.d.mts} +2 -2
- package/dist/{pixel-default-config-BMYaqs7i.d.ts → pixel-default-config-D0NZVzDZ.d.ts} +2 -2
- package/dist/{pixel-settings-DGxl0MVm.d.mts → pixel-settings-BlhqPyAS.d.mts} +1 -1
- package/dist/{pixel-settings-D-t9zQb4.d.ts → pixel-settings-CHyZHDO6.d.ts} +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 +7 -5
- package/dist/runtime/index.d.ts +7 -5
- 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 +46 -7
- package/dist/services/index.d.ts +46 -7
- package/dist/services/index.esm.js +1 -1
- package/dist/services/index.esm.js.map +1 -1
- package/dist/{types-B-Nzagpk.d.mts → types-9Uo3slwh.d.mts} +2 -2
- package/dist/{types-D3kJ9bfT.d.ts → types-CN1t3kwE.d.mts} +3 -2
- package/dist/{types-Dfi9C49l.d.ts → types-DaSPqzo_.d.ts} +2 -2
- package/dist/{types-D0KVsgzs.d.mts → types-DexAGG5B.d.ts} +3 -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 +11 -11
- package/dist/v2/index.d.ts +11 -11
- package/dist/v2/index.esm.js +1 -1
- package/dist/v2/index.esm.js.map +1 -1
- package/docs/public/configuration/commerce.md +20 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/events/index.ts","../../src/events/builder/BaseEventBuilder.ts"],"sourcesContent":["export type { BasePixelEvent } from './base';\nexport type { PageViewEvent } from './page-view';\nexport type {\n ScrollEvent,\n PageClickEvent,\n RageClickEvent,\n VisibilityChangeEvent,\n UserIdleEvent,\n UserActiveEvent,\n ExitIntentEvent,\n BehaviorHeartbeatEvent,\n ViewportEnterEvent,\n ViewportExitEvent,\n ViewportExitReason,\n EngagementUpdateEvent,\n EngagementSummaryEvent,\n BehaviorSessionSummaryEvent,\n BehaviorSessionSummaryReason,\n BehaviorState,\n EngagementLevel,\n EngagementUpdateReason,\n} from './behavior';\nexport type { SessionRenewedEvent, SessionExpiredEvent } from './session';\nexport type {\n PurchaseEvent,\n LeadEvent,\n AddToCartEvent,\n RemoveFromCartEvent,\n InitiateCheckoutEvent,\n AddPaymentInfoEvent,\n ViewContentEvent,\n SearchEvent,\n PurchaseData,\n LeadData,\n AddToCartData,\n RemoveFromCartData,\n InitiateCheckoutData,\n AddPaymentInfoData,\n ViewContentData,\n SearchData,\n PixelItem,\n ConversionEventData,\n} from './conversion';\nexport type {\n PixelEventCategory,\n EngagementEventCategory,\n ConversionEventCategory,\n} from './shared/category';\nexport type { ElementDescriptor } from './shared/ElementDescriptor';\nexport type { PixelEvent } from './types';\nexport { BaseEventBuilder } from './builder';\n","import type { AttributionService } from '@/services/attribution/types';\nimport type { BrowserMetadataService } from '@/services/browser-metadata';\nimport type { UrlContextService } from '@/modules/core/url-context';\n\nimport type { BasePixelEvent } from '../base';\n\nexport class BaseEventBuilder {\n private readonly metadataService: BrowserMetadataService;\n\n private readonly attribution: AttributionService | null;\n\n private readonly urlContext: UrlContextService | null;\n\n constructor(\n metadataService: BrowserMetadataService,\n attribution?: AttributionService | null,\n urlContext?: UrlContextService | null\n ) {\n this.metadataService = metadataService;\n this.attribution = attribution ?? null;\n this.urlContext = urlContext ?? null;\n }\n\n build<T extends { type: string }>(event: T): T & BasePixelEvent {\n const metadata = this.metadataService.getMetadata();\n const identifiers = this.attribution?.getSnapshot();\n const hasIdentifiers =\n identifiers !== undefined &&\n Object.keys(identifiers).some(key => {\n const value = identifiers[key as keyof typeof identifiers];\n return value !== undefined && value !== null && value !== '';\n });\n\n const urlSnapshot = this.urlContext?.isEnabled()\n ? this.urlContext.getSnapshot()\n : null;\n\n const hasQueryParams =\n urlSnapshot !== null && Object.keys(urlSnapshot.queryParams).length > 0;\n const hasUrlContext =\n urlSnapshot !== null &&\n ((urlSnapshot.urlContext.managed &&\n Object.keys(urlSnapshot.urlContext.managed).length > 0) ||\n (urlSnapshot.urlContext.forwarded &&\n Object.keys(urlSnapshot.urlContext.forwarded).length > 0) ||\n (urlSnapshot.urlContext.source &&\n Object.keys(urlSnapshot.urlContext.source).length > 0));\n\n return {\n ...event,\n timestamp: Date.now(),\n path: metadata.path,\n url: metadata.url,\n hostname: metadata.hostname,\n language: metadata.language,\n timezone: metadata.timezone,\n ...(hasIdentifiers ? { identifiers } : {}),\n ...(hasQueryParams\n ? { queryParams: { ...urlSnapshot!.queryParams } }\n : {}),\n ...(hasUrlContext\n ? {\n urlContext: {\n ...(urlSnapshot!.urlContext.managed\n ? { managed: { ...urlSnapshot!.urlContext.managed } }\n : {}),\n ...(urlSnapshot!.urlContext.forwarded\n ? { forwarded: { ...urlSnapshot!.urlContext.forwarded } }\n : {}),\n ...(urlSnapshot!.urlContext.source\n ? { source: { ...urlSnapshot!.urlContext.source } }\n : {}),\n },\n }\n : {}),\n };\n }\n}\n"],"mappings":";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,
|
|
1
|
+
{"version":3,"sources":["../../src/events/index.ts","../../src/services/customer/types.ts","../../src/events/builder/BaseEventBuilder.ts"],"sourcesContent":["export type { BasePixelEvent } from './base';\nexport type { PageViewEvent } from './page-view';\nexport type {\n ScrollEvent,\n PageClickEvent,\n RageClickEvent,\n VisibilityChangeEvent,\n UserIdleEvent,\n UserActiveEvent,\n ExitIntentEvent,\n BehaviorHeartbeatEvent,\n ViewportEnterEvent,\n ViewportExitEvent,\n ViewportExitReason,\n EngagementUpdateEvent,\n EngagementSummaryEvent,\n BehaviorSessionSummaryEvent,\n BehaviorSessionSummaryReason,\n BehaviorState,\n EngagementLevel,\n EngagementUpdateReason,\n} from './behavior';\nexport type { SessionRenewedEvent, SessionExpiredEvent } from './session';\nexport type {\n PurchaseEvent,\n LeadEvent,\n AddToCartEvent,\n RemoveFromCartEvent,\n InitiateCheckoutEvent,\n AddPaymentInfoEvent,\n ViewContentEvent,\n SearchEvent,\n PurchaseData,\n LeadData,\n AddToCartData,\n RemoveFromCartData,\n InitiateCheckoutData,\n AddPaymentInfoData,\n ViewContentData,\n SearchData,\n PixelItem,\n ConversionEventData,\n} from './conversion';\nexport type {\n PixelEventCategory,\n EngagementEventCategory,\n ConversionEventCategory,\n} from './shared/category';\nexport type { ElementDescriptor } from './shared/ElementDescriptor';\nexport type { PixelEvent } from './types';\nexport { BaseEventBuilder } from './builder';\n","/**\n * Snapshot de customer extraído do DOM / formulário.\n * Só campos preenchidos entram no evento.\n */\nexport type CustomerData = {\n email?: string;\n phone?: string;\n name?: string;\n firstName?: string;\n lastName?: string;\n address?: string;\n address2?: string;\n city?: string;\n state?: string;\n postalCode?: string;\n country?: string;\n};\n\nexport function hasCustomerData(\n customer: CustomerData | null | undefined\n): customer is CustomerData {\n if (!customer) return false;\n return Object.values(customer).some(\n value => typeof value === 'string' && value.trim().length > 0\n );\n}\n\nexport function cloneCustomerData(customer: CustomerData): CustomerData {\n return { ...customer };\n}\n","import type { AttributionService } from '@/services/attribution/types';\nimport type { BrowserMetadataService } from '@/services/browser-metadata';\nimport type { CustomerData } from '@/services/customer/types';\nimport type { CustomerIdentityService } from '@/services/customer';\nimport { hasCustomerData } from '@/services/customer';\nimport type { UrlContextService } from '@/modules/core/url-context';\n\nimport type { BasePixelEvent } from '../base';\n\nexport class BaseEventBuilder {\n private readonly metadataService: BrowserMetadataService;\n\n private readonly attribution: AttributionService | null;\n\n private readonly urlContext: UrlContextService | null;\n\n private readonly customerIdentity: CustomerIdentityService | null;\n\n constructor(\n metadataService: BrowserMetadataService,\n attribution?: AttributionService | null,\n urlContext?: UrlContextService | null,\n customerIdentity?: CustomerIdentityService | null\n ) {\n this.metadataService = metadataService;\n this.attribution = attribution ?? null;\n this.urlContext = urlContext ?? null;\n this.customerIdentity = customerIdentity ?? null;\n }\n\n build<T extends { type: string }>(event: T): T & BasePixelEvent {\n const metadata = this.metadataService.getMetadata();\n const identifiers = this.attribution?.getSnapshot();\n const hasIdentifiers =\n identifiers !== undefined &&\n Object.keys(identifiers).some(key => {\n const value = identifiers[key as keyof typeof identifiers];\n return value !== undefined && value !== null && value !== '';\n });\n\n const urlSnapshot = this.urlContext?.isEnabled()\n ? this.urlContext.getSnapshot()\n : null;\n\n const hasQueryParams =\n urlSnapshot !== null && Object.keys(urlSnapshot.queryParams).length > 0;\n const hasUrlContext =\n urlSnapshot !== null &&\n ((urlSnapshot.urlContext.managed &&\n Object.keys(urlSnapshot.urlContext.managed).length > 0) ||\n (urlSnapshot.urlContext.forwarded &&\n Object.keys(urlSnapshot.urlContext.forwarded).length > 0) ||\n (urlSnapshot.urlContext.source &&\n Object.keys(urlSnapshot.urlContext.source).length > 0));\n\n const customer = this.customerIdentity?.getSnapshot() ?? null;\n const incomingCustomer = (event as { customer?: CustomerData }).customer;\n const resolvedCustomer = incomingCustomer ?? customer;\n\n return {\n ...event,\n timestamp: Date.now(),\n path: metadata.path,\n url: metadata.url,\n hostname: metadata.hostname,\n language: metadata.language,\n timezone: metadata.timezone,\n ...(hasIdentifiers ? { identifiers } : {}),\n ...(hasQueryParams\n ? { queryParams: { ...urlSnapshot!.queryParams } }\n : {}),\n ...(hasUrlContext\n ? {\n urlContext: {\n ...(urlSnapshot!.urlContext.managed\n ? { managed: { ...urlSnapshot!.urlContext.managed } }\n : {}),\n ...(urlSnapshot!.urlContext.forwarded\n ? { forwarded: { ...urlSnapshot!.urlContext.forwarded } }\n : {}),\n ...(urlSnapshot!.urlContext.source\n ? { source: { ...urlSnapshot!.urlContext.source } }\n : {}),\n },\n }\n : {}),\n ...(hasCustomerData(resolvedCustomer)\n ? { customer: { ...resolvedCustomer } }\n : {}),\n };\n }\n}\n"],"mappings":";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GCkBO,SAASI,EACdC,EAC0B,CAC1B,OAAKA,EACE,OAAO,OAAOA,CAAQ,EAAE,KAC7BC,GAAS,OAAOA,GAAU,UAAYA,EAAM,KAAK,EAAE,OAAS,CAC9D,EAHsB,EAIxB,CChBO,IAAMC,EAAN,KAAuB,CAS5B,YACEC,EACAC,EACAC,EACAC,EACA,CACA,KAAK,gBAAkBH,EACvB,KAAK,YAAcC,GAAe,KAClC,KAAK,WAAaC,GAAc,KAChC,KAAK,iBAAmBC,GAAoB,IAC9C,CAEA,MAAkCC,EAA8B,CAC9D,IAAMC,EAAW,KAAK,gBAAgB,YAAY,EAC5CC,EAAc,KAAK,aAAa,YAAY,EAC5CC,EACJD,IAAgB,QAChB,OAAO,KAAKA,CAAW,EAAE,KAAKE,GAAO,CACnC,IAAMC,EAAQH,EAAYE,CAA+B,EACzD,OAA8BC,GAAU,MAAQA,IAAU,EAC5D,CAAC,EAEGC,EAAc,KAAK,YAAY,UAAU,EAC3C,KAAK,WAAW,YAAY,EAC5B,KAEEC,EACJD,IAAgB,MAAQ,OAAO,KAAKA,EAAY,WAAW,EAAE,OAAS,EAClEE,EACJF,IAAgB,OACdA,EAAY,WAAW,SACvB,OAAO,KAAKA,EAAY,WAAW,OAAO,EAAE,OAAS,GACpDA,EAAY,WAAW,WACtB,OAAO,KAAKA,EAAY,WAAW,SAAS,EAAE,OAAS,GACxDA,EAAY,WAAW,QACtB,OAAO,KAAKA,EAAY,WAAW,MAAM,EAAE,OAAS,GAEpDG,EAAW,KAAK,kBAAkB,YAAY,GAAK,KAEnDC,EADoBV,EAAsC,UACnBS,EAE7C,MAAO,CACL,GAAGT,EACH,UAAW,KAAK,IAAI,EACpB,KAAMC,EAAS,KACf,IAAKA,EAAS,IACd,SAAUA,EAAS,SACnB,SAAUA,EAAS,SACnB,SAAUA,EAAS,SACnB,GAAIE,EAAiB,CAAE,YAAAD,CAAY,EAAI,CAAC,EACxC,GAAIK,EACA,CAAE,YAAa,CAAE,GAAGD,EAAa,WAAY,CAAE,EAC/C,CAAC,EACL,GAAIE,EACA,CACE,WAAY,CACV,GAAIF,EAAa,WAAW,QACxB,CAAE,QAAS,CAAE,GAAGA,EAAa,WAAW,OAAQ,CAAE,EAClD,CAAC,EACL,GAAIA,EAAa,WAAW,UACxB,CAAE,UAAW,CAAE,GAAGA,EAAa,WAAW,SAAU,CAAE,EACtD,CAAC,EACL,GAAIA,EAAa,WAAW,OACxB,CAAE,OAAQ,CAAE,GAAGA,EAAa,WAAW,MAAO,CAAE,EAChD,CAAC,CACP,CACF,EACA,CAAC,EACL,GAAIK,EAAgBD,CAAgB,EAChC,CAAE,SAAU,CAAE,GAAGA,CAAiB,CAAE,EACpC,CAAC,CACP,CACF,CACF","names":["events_exports","__export","BaseEventBuilder","__toCommonJS","hasCustomerData","customer","value","BaseEventBuilder","metadataService","attribution","urlContext","customerIdentity","event","metadata","identifiers","hasIdentifiers","key","value","urlSnapshot","hasQueryParams","hasUrlContext","customer","resolvedCustomer","hasCustomerData"]}
|
package/dist/events/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { q as AddPaymentInfoData, _ as AddPaymentInfoEvent, p as AddToCartData, X as AddToCartEvent, c as BaseEventBuilder, h as BasePixelEvent, y as BehaviorHeartbeatEvent, K as BehaviorSessionSummaryEvent, M as BehaviorSessionSummaryReason, N as BehaviorState, a4 as ConversionEventCategory, a1 as ConversionEventData, a5 as ElementDescriptor, a3 as EngagementEventCategory, O as EngagementLevel, J as EngagementSummaryEvent, H as EngagementUpdateEvent, Q as EngagementUpdateReason, E as ExitIntentEvent, I as InitiateCheckoutData, Z as InitiateCheckoutEvent, L as LeadData, W as LeadEvent, t as PageClickEvent, i as PageViewEvent, P as PixelEvent, a2 as PixelEventCategory, b as PixelItem, o as PurchaseData, T as PurchaseEvent, u as RageClickEvent, R as RemoveFromCartData, Y as RemoveFromCartEvent, s as ScrollEvent, r as SearchData, a0 as SearchEvent, k as SessionExpiredEvent, j as SessionRenewedEvent, x as UserActiveEvent, w as UserIdleEvent, V as ViewContentData, $ as ViewContentEvent, z as ViewportEnterEvent, F as ViewportExitEvent, G as ViewportExitReason, v as VisibilityChangeEvent } from '../index-CKZeennc.mjs';
|
|
2
2
|
import '../url-context-Ck2LK18V.mjs';
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { q as AddPaymentInfoData, _ as AddPaymentInfoEvent, p as AddToCartData, X as AddToCartEvent, c as BaseEventBuilder, h as BasePixelEvent, y as BehaviorHeartbeatEvent, K as BehaviorSessionSummaryEvent, M as BehaviorSessionSummaryReason, N as BehaviorState, a4 as ConversionEventCategory, a1 as ConversionEventData, a5 as ElementDescriptor, a3 as EngagementEventCategory, O as EngagementLevel, J as EngagementSummaryEvent, H as EngagementUpdateEvent, Q as EngagementUpdateReason, E as ExitIntentEvent, I as InitiateCheckoutData, Z as InitiateCheckoutEvent, L as LeadData, W as LeadEvent, t as PageClickEvent, i as PageViewEvent, P as PixelEvent, a2 as PixelEventCategory, b as PixelItem, o as PurchaseData, T as PurchaseEvent, u as RageClickEvent, R as RemoveFromCartData, Y as RemoveFromCartEvent, s as ScrollEvent, r as SearchData, a0 as SearchEvent, k as SessionExpiredEvent, j as SessionRenewedEvent, x as UserActiveEvent, w as UserIdleEvent, V as ViewContentData, $ as ViewContentEvent, z as ViewportEnterEvent, F as ViewportExitEvent, G as ViewportExitReason, v as VisibilityChangeEvent } from '../index-YlvQBRzR.js';
|
|
2
2
|
import '../url-context-Ck2LK18V.js';
|
package/dist/events/index.esm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* Pixel v2 — SDK de analytics e conversão */
|
|
2
|
-
var
|
|
2
|
+
function a(o){return o?Object.values(o).some(t=>typeof t=="string"&&t.trim().length>0):!1}var s=class{constructor(t,n,r,i){this.metadataService=t,this.attribution=n??null,this.urlContext=r??null,this.customerIdentity=i??null}build(t){let n=this.metadataService.getMetadata(),r=this.attribution?.getSnapshot(),i=r!==void 0&&Object.keys(r).some(p=>{let u=r[p];return u!=null&&u!==""}),e=this.urlContext?.isEnabled()?this.urlContext.getSnapshot():null,m=e!==null&&Object.keys(e.queryParams).length>0,d=e!==null&&(e.urlContext.managed&&Object.keys(e.urlContext.managed).length>0||e.urlContext.forwarded&&Object.keys(e.urlContext.forwarded).length>0||e.urlContext.source&&Object.keys(e.urlContext.source).length>0),l=this.customerIdentity?.getSnapshot()??null,c=t.customer??l;return{...t,timestamp:Date.now(),path:n.path,url:n.url,hostname:n.hostname,language:n.language,timezone:n.timezone,...i?{identifiers:r}:{},...m?{queryParams:{...e.queryParams}}:{},...d?{urlContext:{...e.urlContext.managed?{managed:{...e.urlContext.managed}}:{},...e.urlContext.forwarded?{forwarded:{...e.urlContext.forwarded}}:{},...e.urlContext.source?{source:{...e.urlContext.source}}:{}}}:{},...a(c)?{customer:{...c}}:{}}}};export{s as BaseEventBuilder};
|
|
3
3
|
//# sourceMappingURL=index.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/events/builder/BaseEventBuilder.ts"],"sourcesContent":["import type { AttributionService } from '@/services/attribution/types';\nimport type { BrowserMetadataService } from '@/services/browser-metadata';\nimport type { UrlContextService } from '@/modules/core/url-context';\n\nimport type { BasePixelEvent } from '../base';\n\nexport class BaseEventBuilder {\n private readonly metadataService: BrowserMetadataService;\n\n private readonly attribution: AttributionService | null;\n\n private readonly urlContext: UrlContextService | null;\n\n constructor(\n metadataService: BrowserMetadataService,\n attribution?: AttributionService | null,\n urlContext?: UrlContextService | null\n ) {\n this.metadataService = metadataService;\n this.attribution = attribution ?? null;\n this.urlContext = urlContext ?? null;\n }\n\n build<T extends { type: string }>(event: T): T & BasePixelEvent {\n const metadata = this.metadataService.getMetadata();\n const identifiers = this.attribution?.getSnapshot();\n const hasIdentifiers =\n identifiers !== undefined &&\n Object.keys(identifiers).some(key => {\n const value = identifiers[key as keyof typeof identifiers];\n return value !== undefined && value !== null && value !== '';\n });\n\n const urlSnapshot = this.urlContext?.isEnabled()\n ? this.urlContext.getSnapshot()\n : null;\n\n const hasQueryParams =\n urlSnapshot !== null && Object.keys(urlSnapshot.queryParams).length > 0;\n const hasUrlContext =\n urlSnapshot !== null &&\n ((urlSnapshot.urlContext.managed &&\n Object.keys(urlSnapshot.urlContext.managed).length > 0) ||\n (urlSnapshot.urlContext.forwarded &&\n Object.keys(urlSnapshot.urlContext.forwarded).length > 0) ||\n (urlSnapshot.urlContext.source &&\n Object.keys(urlSnapshot.urlContext.source).length > 0));\n\n return {\n ...event,\n timestamp: Date.now(),\n path: metadata.path,\n url: metadata.url,\n hostname: metadata.hostname,\n language: metadata.language,\n timezone: metadata.timezone,\n ...(hasIdentifiers ? { identifiers } : {}),\n ...(hasQueryParams\n ? { queryParams: { ...urlSnapshot!.queryParams } }\n : {}),\n ...(hasUrlContext\n ? {\n urlContext: {\n ...(urlSnapshot!.urlContext.managed\n ? { managed: { ...urlSnapshot!.urlContext.managed } }\n : {}),\n ...(urlSnapshot!.urlContext.forwarded\n ? { forwarded: { ...urlSnapshot!.urlContext.forwarded } }\n : {}),\n ...(urlSnapshot!.urlContext.source\n ? { source: { ...urlSnapshot!.urlContext.source } }\n : {}),\n },\n }\n : {}),\n };\n }\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../src/services/customer/types.ts","../../src/events/builder/BaseEventBuilder.ts"],"sourcesContent":["/**\n * Snapshot de customer extraído do DOM / formulário.\n * Só campos preenchidos entram no evento.\n */\nexport type CustomerData = {\n email?: string;\n phone?: string;\n name?: string;\n firstName?: string;\n lastName?: string;\n address?: string;\n address2?: string;\n city?: string;\n state?: string;\n postalCode?: string;\n country?: string;\n};\n\nexport function hasCustomerData(\n customer: CustomerData | null | undefined\n): customer is CustomerData {\n if (!customer) return false;\n return Object.values(customer).some(\n value => typeof value === 'string' && value.trim().length > 0\n );\n}\n\nexport function cloneCustomerData(customer: CustomerData): CustomerData {\n return { ...customer };\n}\n","import type { AttributionService } from '@/services/attribution/types';\nimport type { BrowserMetadataService } from '@/services/browser-metadata';\nimport type { CustomerData } from '@/services/customer/types';\nimport type { CustomerIdentityService } from '@/services/customer';\nimport { hasCustomerData } from '@/services/customer';\nimport type { UrlContextService } from '@/modules/core/url-context';\n\nimport type { BasePixelEvent } from '../base';\n\nexport class BaseEventBuilder {\n private readonly metadataService: BrowserMetadataService;\n\n private readonly attribution: AttributionService | null;\n\n private readonly urlContext: UrlContextService | null;\n\n private readonly customerIdentity: CustomerIdentityService | null;\n\n constructor(\n metadataService: BrowserMetadataService,\n attribution?: AttributionService | null,\n urlContext?: UrlContextService | null,\n customerIdentity?: CustomerIdentityService | null\n ) {\n this.metadataService = metadataService;\n this.attribution = attribution ?? null;\n this.urlContext = urlContext ?? null;\n this.customerIdentity = customerIdentity ?? null;\n }\n\n build<T extends { type: string }>(event: T): T & BasePixelEvent {\n const metadata = this.metadataService.getMetadata();\n const identifiers = this.attribution?.getSnapshot();\n const hasIdentifiers =\n identifiers !== undefined &&\n Object.keys(identifiers).some(key => {\n const value = identifiers[key as keyof typeof identifiers];\n return value !== undefined && value !== null && value !== '';\n });\n\n const urlSnapshot = this.urlContext?.isEnabled()\n ? this.urlContext.getSnapshot()\n : null;\n\n const hasQueryParams =\n urlSnapshot !== null && Object.keys(urlSnapshot.queryParams).length > 0;\n const hasUrlContext =\n urlSnapshot !== null &&\n ((urlSnapshot.urlContext.managed &&\n Object.keys(urlSnapshot.urlContext.managed).length > 0) ||\n (urlSnapshot.urlContext.forwarded &&\n Object.keys(urlSnapshot.urlContext.forwarded).length > 0) ||\n (urlSnapshot.urlContext.source &&\n Object.keys(urlSnapshot.urlContext.source).length > 0));\n\n const customer = this.customerIdentity?.getSnapshot() ?? null;\n const incomingCustomer = (event as { customer?: CustomerData }).customer;\n const resolvedCustomer = incomingCustomer ?? customer;\n\n return {\n ...event,\n timestamp: Date.now(),\n path: metadata.path,\n url: metadata.url,\n hostname: metadata.hostname,\n language: metadata.language,\n timezone: metadata.timezone,\n ...(hasIdentifiers ? { identifiers } : {}),\n ...(hasQueryParams\n ? { queryParams: { ...urlSnapshot!.queryParams } }\n : {}),\n ...(hasUrlContext\n ? {\n urlContext: {\n ...(urlSnapshot!.urlContext.managed\n ? { managed: { ...urlSnapshot!.urlContext.managed } }\n : {}),\n ...(urlSnapshot!.urlContext.forwarded\n ? { forwarded: { ...urlSnapshot!.urlContext.forwarded } }\n : {}),\n ...(urlSnapshot!.urlContext.source\n ? { source: { ...urlSnapshot!.urlContext.source } }\n : {}),\n },\n }\n : {}),\n ...(hasCustomerData(resolvedCustomer)\n ? { customer: { ...resolvedCustomer } }\n : {}),\n };\n }\n}\n"],"mappings":";AAkBO,SAASA,EACdC,EAC0B,CAC1B,OAAKA,EACE,OAAO,OAAOA,CAAQ,EAAE,KAC7BC,GAAS,OAAOA,GAAU,UAAYA,EAAM,KAAK,EAAE,OAAS,CAC9D,EAHsB,EAIxB,CChBO,IAAMC,EAAN,KAAuB,CAS5B,YACEC,EACAC,EACAC,EACAC,EACA,CACA,KAAK,gBAAkBH,EACvB,KAAK,YAAcC,GAAe,KAClC,KAAK,WAAaC,GAAc,KAChC,KAAK,iBAAmBC,GAAoB,IAC9C,CAEA,MAAkCC,EAA8B,CAC9D,IAAMC,EAAW,KAAK,gBAAgB,YAAY,EAC5CC,EAAc,KAAK,aAAa,YAAY,EAC5CC,EACJD,IAAgB,QAChB,OAAO,KAAKA,CAAW,EAAE,KAAKE,GAAO,CACnC,IAAMC,EAAQH,EAAYE,CAA+B,EACzD,OAA8BC,GAAU,MAAQA,IAAU,EAC5D,CAAC,EAEGC,EAAc,KAAK,YAAY,UAAU,EAC3C,KAAK,WAAW,YAAY,EAC5B,KAEEC,EACJD,IAAgB,MAAQ,OAAO,KAAKA,EAAY,WAAW,EAAE,OAAS,EAClEE,EACJF,IAAgB,OACdA,EAAY,WAAW,SACvB,OAAO,KAAKA,EAAY,WAAW,OAAO,EAAE,OAAS,GACpDA,EAAY,WAAW,WACtB,OAAO,KAAKA,EAAY,WAAW,SAAS,EAAE,OAAS,GACxDA,EAAY,WAAW,QACtB,OAAO,KAAKA,EAAY,WAAW,MAAM,EAAE,OAAS,GAEpDG,EAAW,KAAK,kBAAkB,YAAY,GAAK,KAEnDC,EADoBV,EAAsC,UACnBS,EAE7C,MAAO,CACL,GAAGT,EACH,UAAW,KAAK,IAAI,EACpB,KAAMC,EAAS,KACf,IAAKA,EAAS,IACd,SAAUA,EAAS,SACnB,SAAUA,EAAS,SACnB,SAAUA,EAAS,SACnB,GAAIE,EAAiB,CAAE,YAAAD,CAAY,EAAI,CAAC,EACxC,GAAIK,EACA,CAAE,YAAa,CAAE,GAAGD,EAAa,WAAY,CAAE,EAC/C,CAAC,EACL,GAAIE,EACA,CACE,WAAY,CACV,GAAIF,EAAa,WAAW,QACxB,CAAE,QAAS,CAAE,GAAGA,EAAa,WAAW,OAAQ,CAAE,EAClD,CAAC,EACL,GAAIA,EAAa,WAAW,UACxB,CAAE,UAAW,CAAE,GAAGA,EAAa,WAAW,SAAU,CAAE,EACtD,CAAC,EACL,GAAIA,EAAa,WAAW,OACxB,CAAE,OAAQ,CAAE,GAAGA,EAAa,WAAW,MAAO,CAAE,EAChD,CAAC,CACP,CACF,EACA,CAAC,EACL,GAAIK,EAAgBD,CAAgB,EAChC,CAAE,SAAU,CAAE,GAAGA,CAAiB,CAAE,EACpC,CAAC,CACP,CACF,CACF","names":["hasCustomerData","customer","value","BaseEventBuilder","metadataService","attribution","urlContext","customerIdentity","event","metadata","identifiers","hasIdentifiers","key","value","urlSnapshot","hasQueryParams","hasUrlContext","customer","resolvedCustomer","hasCustomerData"]}
|
|
@@ -55,6 +55,26 @@ interface StorageService {
|
|
|
55
55
|
createKey(key: string): string;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Snapshot de customer extraído do DOM / formulário.
|
|
60
|
+
* Só campos preenchidos entram no evento.
|
|
61
|
+
*/
|
|
62
|
+
type CustomerData = {
|
|
63
|
+
email?: string;
|
|
64
|
+
phone?: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
firstName?: string;
|
|
67
|
+
lastName?: string;
|
|
68
|
+
address?: string;
|
|
69
|
+
address2?: string;
|
|
70
|
+
city?: string;
|
|
71
|
+
state?: string;
|
|
72
|
+
postalCode?: string;
|
|
73
|
+
country?: string;
|
|
74
|
+
};
|
|
75
|
+
declare function hasCustomerData(customer: CustomerData | null | undefined): customer is CustomerData;
|
|
76
|
+
declare function cloneCustomerData(customer: CustomerData): CustomerData;
|
|
77
|
+
|
|
58
78
|
interface BasePixelEvent {
|
|
59
79
|
readonly type: string;
|
|
60
80
|
readonly timestamp: number;
|
|
@@ -69,6 +89,8 @@ interface BasePixelEvent {
|
|
|
69
89
|
readonly queryParams?: Record<string, string>;
|
|
70
90
|
/** Auditoria operacional UrlContext (managed / forwarded / source). */
|
|
71
91
|
readonly urlContext?: UrlContextPayload;
|
|
92
|
+
/** Customer do formulário — anexado automaticamente quando disponível. */
|
|
93
|
+
readonly customer?: CustomerData;
|
|
72
94
|
}
|
|
73
95
|
|
|
74
96
|
interface PageViewEvent extends BasePixelEvent {
|
|
@@ -412,6 +434,17 @@ interface BrowserMetadataService {
|
|
|
412
434
|
getMetadata(): BrowserMetadata;
|
|
413
435
|
}
|
|
414
436
|
|
|
437
|
+
/**
|
|
438
|
+
* Store em memória do customer da página.
|
|
439
|
+
* Merge incremental: valores novos não-vazios sobrescrevem.
|
|
440
|
+
*/
|
|
441
|
+
declare class CustomerIdentityService {
|
|
442
|
+
private snapshot;
|
|
443
|
+
update(partial: CustomerData): void;
|
|
444
|
+
getSnapshot(): CustomerData | null;
|
|
445
|
+
clear(): void;
|
|
446
|
+
}
|
|
447
|
+
|
|
415
448
|
/**
|
|
416
449
|
* Orquestra UrlContext: collect → manage → forward → decorate → snapshot.
|
|
417
450
|
* SSR-safe; init/destroy idempotentes.
|
|
@@ -451,10 +484,11 @@ declare class BaseEventBuilder {
|
|
|
451
484
|
private readonly metadataService;
|
|
452
485
|
private readonly attribution;
|
|
453
486
|
private readonly urlContext;
|
|
454
|
-
|
|
487
|
+
private readonly customerIdentity;
|
|
488
|
+
constructor(metadataService: BrowserMetadataService, attribution?: AttributionService | null, urlContext?: UrlContextService | null, customerIdentity?: CustomerIdentityService | null);
|
|
455
489
|
build<T extends {
|
|
456
490
|
type: string;
|
|
457
491
|
}>(event: T): T & BasePixelEvent;
|
|
458
492
|
}
|
|
459
493
|
|
|
460
|
-
export { type
|
|
494
|
+
export { type ViewContentEvent as $, type AttributionService as A, type BrowserMetadataService as B, CustomerIdentityService as C, DEFAULT_ATTRIBUTION_CONFIG as D, type ExitIntentEvent as E, type ViewportExitEvent as F, type ViewportExitReason as G, type EngagementUpdateEvent as H, type InitiateCheckoutData as I, type EngagementSummaryEvent as J, type BehaviorSessionSummaryEvent as K, type LeadData as L, type BehaviorSessionSummaryReason as M, type BehaviorState as N, type EngagementLevel as O, type PixelEvent as P, type EngagementUpdateReason as Q, type RemoveFromCartData as R, type StorageService as S, type PurchaseEvent as T, UrlContextService as U, type ViewContentData as V, type LeadEvent as W, type AddToCartEvent as X, type RemoveFromCartEvent as Y, type InitiateCheckoutEvent as Z, type AddPaymentInfoEvent as _, type StorageAdapter as a, type SearchEvent as a0, type ConversionEventData as a1, type PixelEventCategory as a2, type EngagementEventCategory as a3, type ConversionEventCategory as a4, type ElementDescriptor as a5, type PixelItem as b, BaseEventBuilder as c, type AttributionConfig as d, type AttributionIdentifiers as e, type BrowserMetadata as f, type CustomerData as g, type BasePixelEvent as h, type PageViewEvent as i, type SessionRenewedEvent as j, type SessionExpiredEvent as k, ATTRIBUTION_STORAGE_KEY as l, cloneCustomerData as m, hasCustomerData as n, type PurchaseData as o, type AddToCartData as p, type AddPaymentInfoData as q, type SearchData as r, type ScrollEvent as s, type PageClickEvent as t, type RageClickEvent as u, type VisibilityChangeEvent as v, type UserIdleEvent as w, type UserActiveEvent as x, type BehaviorHeartbeatEvent as y, type ViewportEnterEvent as z };
|
|
@@ -55,6 +55,26 @@ interface StorageService {
|
|
|
55
55
|
createKey(key: string): string;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Snapshot de customer extraído do DOM / formulário.
|
|
60
|
+
* Só campos preenchidos entram no evento.
|
|
61
|
+
*/
|
|
62
|
+
type CustomerData = {
|
|
63
|
+
email?: string;
|
|
64
|
+
phone?: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
firstName?: string;
|
|
67
|
+
lastName?: string;
|
|
68
|
+
address?: string;
|
|
69
|
+
address2?: string;
|
|
70
|
+
city?: string;
|
|
71
|
+
state?: string;
|
|
72
|
+
postalCode?: string;
|
|
73
|
+
country?: string;
|
|
74
|
+
};
|
|
75
|
+
declare function hasCustomerData(customer: CustomerData | null | undefined): customer is CustomerData;
|
|
76
|
+
declare function cloneCustomerData(customer: CustomerData): CustomerData;
|
|
77
|
+
|
|
58
78
|
interface BasePixelEvent {
|
|
59
79
|
readonly type: string;
|
|
60
80
|
readonly timestamp: number;
|
|
@@ -69,6 +89,8 @@ interface BasePixelEvent {
|
|
|
69
89
|
readonly queryParams?: Record<string, string>;
|
|
70
90
|
/** Auditoria operacional UrlContext (managed / forwarded / source). */
|
|
71
91
|
readonly urlContext?: UrlContextPayload;
|
|
92
|
+
/** Customer do formulário — anexado automaticamente quando disponível. */
|
|
93
|
+
readonly customer?: CustomerData;
|
|
72
94
|
}
|
|
73
95
|
|
|
74
96
|
interface PageViewEvent extends BasePixelEvent {
|
|
@@ -412,6 +434,17 @@ interface BrowserMetadataService {
|
|
|
412
434
|
getMetadata(): BrowserMetadata;
|
|
413
435
|
}
|
|
414
436
|
|
|
437
|
+
/**
|
|
438
|
+
* Store em memória do customer da página.
|
|
439
|
+
* Merge incremental: valores novos não-vazios sobrescrevem.
|
|
440
|
+
*/
|
|
441
|
+
declare class CustomerIdentityService {
|
|
442
|
+
private snapshot;
|
|
443
|
+
update(partial: CustomerData): void;
|
|
444
|
+
getSnapshot(): CustomerData | null;
|
|
445
|
+
clear(): void;
|
|
446
|
+
}
|
|
447
|
+
|
|
415
448
|
/**
|
|
416
449
|
* Orquestra UrlContext: collect → manage → forward → decorate → snapshot.
|
|
417
450
|
* SSR-safe; init/destroy idempotentes.
|
|
@@ -451,10 +484,11 @@ declare class BaseEventBuilder {
|
|
|
451
484
|
private readonly metadataService;
|
|
452
485
|
private readonly attribution;
|
|
453
486
|
private readonly urlContext;
|
|
454
|
-
|
|
487
|
+
private readonly customerIdentity;
|
|
488
|
+
constructor(metadataService: BrowserMetadataService, attribution?: AttributionService | null, urlContext?: UrlContextService | null, customerIdentity?: CustomerIdentityService | null);
|
|
455
489
|
build<T extends {
|
|
456
490
|
type: string;
|
|
457
491
|
}>(event: T): T & BasePixelEvent;
|
|
458
492
|
}
|
|
459
493
|
|
|
460
|
-
export { type
|
|
494
|
+
export { type ViewContentEvent as $, type AttributionService as A, type BrowserMetadataService as B, CustomerIdentityService as C, DEFAULT_ATTRIBUTION_CONFIG as D, type ExitIntentEvent as E, type ViewportExitEvent as F, type ViewportExitReason as G, type EngagementUpdateEvent as H, type InitiateCheckoutData as I, type EngagementSummaryEvent as J, type BehaviorSessionSummaryEvent as K, type LeadData as L, type BehaviorSessionSummaryReason as M, type BehaviorState as N, type EngagementLevel as O, type PixelEvent as P, type EngagementUpdateReason as Q, type RemoveFromCartData as R, type StorageService as S, type PurchaseEvent as T, UrlContextService as U, type ViewContentData as V, type LeadEvent as W, type AddToCartEvent as X, type RemoveFromCartEvent as Y, type InitiateCheckoutEvent as Z, type AddPaymentInfoEvent as _, type StorageAdapter as a, type SearchEvent as a0, type ConversionEventData as a1, type PixelEventCategory as a2, type EngagementEventCategory as a3, type ConversionEventCategory as a4, type ElementDescriptor as a5, type PixelItem as b, BaseEventBuilder as c, type AttributionConfig as d, type AttributionIdentifiers as e, type BrowserMetadata as f, type CustomerData as g, type BasePixelEvent as h, type PageViewEvent as i, type SessionRenewedEvent as j, type SessionExpiredEvent as k, ATTRIBUTION_STORAGE_KEY as l, cloneCustomerData as m, hasCustomerData as n, type PurchaseData as o, type AddToCartData as p, type AddPaymentInfoData as q, type SearchData as r, type ScrollEvent as s, type PageClickEvent as t, type RageClickEvent as u, type VisibilityChangeEvent as v, type UserIdleEvent as w, type UserActiveEvent as x, type BehaviorHeartbeatEvent as y, type ViewportEnterEvent as z };
|