@metodokorexmk/tracking 1.0.0 → 1.2.0

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/dist/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  /**
2
- * Tipos e interfaces compartidas para @metodokorexmk/tracking
2
+ * Shared types and interfaces for @metodokorexmk/tracking.
3
3
  */
4
4
  /**
5
- * Configuración principal del tracking.
6
- * Se pasa a `initGA()` para inicializar el sistema.
5
+ * Main tracking configuration.
6
+ * Passed to `initGA()` to initialize the tracking system.
7
7
  */
8
8
  interface TrackingConfig {
9
- /** ID de Google Analytics 4 (ej: 'G-XXXXXXX') */
9
+ /** Google Analytics 4 Measurement ID (e.g., 'G-XXXXXXX') */
10
10
  trackingId?: string;
11
11
  /**
12
- * Función personalizada para resolver el GA Tracking ID dinámicamente.
13
- * Recibe la URL actual y debe devolver el ID correspondiente.
14
- * Si se proporciona, tiene prioridad sobre `trackingId`.
12
+ * Custom resolver for the GA Tracking ID.
13
+ * Receives the current path and must return the corresponding ID.
14
+ * Takes priority over `trackingId` when provided.
15
15
  *
16
16
  * @example
17
17
  * ```ts
@@ -22,40 +22,40 @@ interface TrackingConfig {
22
22
  * ```
23
23
  */
24
24
  resolveTrackingId?: (currentPath: string) => string;
25
- /** ID de Google Tag Manager (ej: 'GTM-XXXXXXX'). Si se proporciona, se inyecta GTM automáticamente. */
25
+ /** Google Tag Manager container ID (e.g., 'GTM-XXXXXXX'). If provided, GTM is injected automatically. */
26
26
  gtmId?: string;
27
- /** Habilitar anonimización de IP en GA4 */
27
+ /** Enable IP anonymization in GA4 */
28
28
  anonymizeIp?: boolean;
29
- /** Modo debug: imprime eventos en consola */
29
+ /** Debug mode: logs events to the console */
30
30
  debug?: boolean;
31
31
  }
32
32
  /**
33
- * Configuración del LandingTracker (orquestador de sesión).
33
+ * LandingTracker configuration (session orchestrator).
34
34
  */
35
35
  interface LandingTrackerConfig {
36
- /** Ruta de la landing page (ej: '/kin', '/racha') */
36
+ /** Landing page path (e.g., '/kin', '/racha') */
37
37
  pagePath: string;
38
- /** Nombre legible de la landing (ej: 'Kin Landing Page') */
38
+ /** Human-readable landing page name (e.g., 'Kin Landing Page') */
39
39
  pageName: string;
40
- /** ID de Google Tag Manager (opcional) */
40
+ /** Google Tag Manager container ID (optional) */
41
41
  gtmId?: string;
42
- /** Habilitar tracking de scroll (milestones 25/50/75/100%). Default: true */
42
+ /** Enable scroll tracking (milestones 25/50/75/100%). Default: true */
43
43
  enableScrollTracking?: boolean;
44
- /** Habilitar tracking automático de clicks en CTAs. Default: true */
44
+ /** Enable automatic CTA click tracking. Default: true */
45
45
  enableCTATracking?: boolean;
46
- /** Habilitar tracking de tiempo en página. Default: true */
46
+ /** Enable page dwell time tracking. Default: true */
47
47
  enableTimeTracking?: boolean;
48
- /** Habilitar tracking de tiempo por sección (IntersectionObserver). Default: true */
48
+ /** Enable per-section dwell time via IntersectionObserver. Default: true */
49
49
  enableSectionTracking?: boolean;
50
- /** Habilitar auto-tracking de formularios. Default: true */
50
+ /** Enable automatic form interaction tracking. Default: true */
51
51
  enableFormTracking?: boolean;
52
- /** Habilitar heatmap de clicks (coordenadas X/Y). Default: false */
52
+ /** Enable click heatmap (X/Y coordinates). Default: false */
53
53
  enableHeatmap?: boolean;
54
- /** Sufijo personalizado para eventos (ej: '_kin' para 'cta_click_kin'). Default: '' */
54
+ /** Custom event suffix (e.g., '_kin' produces 'cta_click_kin'). Default: '' */
55
55
  eventSuffix?: string;
56
56
  }
57
57
  /**
58
- * Parámetros UTM capturados de la URL.
58
+ * UTM parameters captured from the URL.
59
59
  */
60
60
  interface UTMParams {
61
61
  utm_source?: string;
@@ -65,7 +65,7 @@ interface UTMParams {
65
65
  utm_content?: string;
66
66
  }
67
67
  /**
68
- * Datos de identificación del visitante capturados.
68
+ * Captured visitor identification data.
69
69
  */
70
70
  interface VisitorData {
71
71
  userId?: string;
@@ -75,20 +75,20 @@ interface VisitorData {
75
75
  entryUrl: string;
76
76
  }
77
77
  /**
78
- * Estadísticas de reproducción de un video.
79
- * Compartido entre todos los adaptadores (Wistia, Voomly, HTML5).
78
+ * Video playback statistics.
79
+ * Shared across all adapters (Wistia, Voomly, HTML5).
80
80
  */
81
81
  interface VideoStats {
82
- /** Tiempo total reproducido en segundos */
82
+ /** Total time watched in seconds */
83
83
  timeWatched: number;
84
- /** Si el video fue completado (90-95%) */
84
+ /** Whether the video was completed (>=90-95%) */
85
85
  completed: boolean;
86
- /** Timestamp de la última actualización */
86
+ /** Timestamp of the last stats update */
87
87
  lastUpdate: number;
88
88
  }
89
89
  /**
90
- * Estado interno detallado de tracking de un video.
91
- * Usado internamente por VideoTracker.
90
+ * Detailed internal video tracking state.
91
+ * Used internally by VideoTracker.
92
92
  */
93
93
  interface VideoTrackingState {
94
94
  videoId: string;
@@ -111,41 +111,41 @@ interface VideoTrackingState {
111
111
  playbackSpeed: number;
112
112
  }
113
113
  /**
114
- * Opciones para los hooks de video en React.
114
+ * Options for React video tracking hooks.
115
115
  */
116
116
  interface UseVideoTrackingOptions {
117
- /** ID único del video */
117
+ /** Unique video identifier */
118
118
  videoId: string;
119
- /** Referencia al elemento <video> HTML (solo para HTML5) */
119
+ /** Reference to the HTML <video> element (HTML5 only) */
120
120
  videoElement?: HTMLVideoElement | null;
121
- /** Callback cuando el video se completa */
121
+ /** Callback when the video completes */
122
122
  onComplete?: () => void;
123
- /** Callback en milestones de progreso (25, 50, 75) */
123
+ /** Callback on progress milestones (25, 50, 75) */
124
124
  onProgress?: (percentage: number) => void;
125
125
  }
126
126
  /**
127
- * Callback para actualizaciones de video.
127
+ * Callback for video stats updates.
128
128
  */
129
129
  type VideoUpdateCallback = (stats: VideoStats) => void;
130
130
  /**
131
- * Objeto retornado por los adaptadores de video (Wistia, Voomly).
131
+ * Handle returned by video adapters (Wistia, Voomly, HTML5).
132
132
  */
133
133
  interface VideoTrackerHandle {
134
- /** Obtener estadísticas actuales */
134
+ /** Get current playback stats */
135
135
  getStats: () => VideoStats;
136
- /** Registrar callback de actualización. Retorna función para desregistrar. */
136
+ /** Register an update callback. Returns an unsubscribe function. */
137
137
  onUpdate: (cb: VideoUpdateCallback) => () => void;
138
- /** Detener tracking y limpiar listeners */
138
+ /** Stop tracking and clean up listeners */
139
139
  stop: () => void;
140
140
  }
141
141
  /**
142
- * Payload genérico de un evento de tracking.
142
+ * Generic tracking event payload.
143
143
  */
144
144
  interface TrackingEventData {
145
145
  [key: string]: unknown;
146
146
  }
147
147
  /**
148
- * Datos de un click capturado para heatmap.
148
+ * Captured click data for heatmap visualization.
149
149
  */
150
150
  interface ClickData {
151
151
  x: number;
@@ -157,7 +157,7 @@ interface ClickData {
157
157
  viewportHeight: number;
158
158
  }
159
159
  /**
160
- * Resumen de sesión al salir de la página.
160
+ * Session summary emitted on page exit.
161
161
  */
162
162
  interface SessionSummary {
163
163
  duration: number;
@@ -168,19 +168,19 @@ interface SessionSummary {
168
168
  formInteractions: number;
169
169
  }
170
170
  /**
171
- * Configuración del cliente HTTP para persistencia.
172
- * Se pasa a `initTrackingAPI()`.
171
+ * HTTP client configuration for the persistence layer.
172
+ * Passed to `initTrackingAPI()`.
173
173
  */
174
174
  interface TrackingAPIConfig {
175
- /** URL base del API (ej: 'https://api.korex.com/api/v1') */
175
+ /** API base URL (e.g., 'https://api.korex.com/api/v1') */
176
176
  baseUrl: string;
177
- /** Función que retorna el token de autenticación (ej: de localStorage) */
177
+ /** Function that returns the auth token (e.g., from localStorage) */
178
178
  getAuthToken?: () => string | null;
179
- /** Headers adicionales para cada petición */
179
+ /** Additional headers for each request */
180
180
  getCustomHeaders?: () => Record<string, string>;
181
181
  }
182
182
  /**
183
- * Modelo de tracking lead del backend.
183
+ * Backend tracking lead model.
184
184
  */
185
185
  interface TrackingLead {
186
186
  id: number;
@@ -210,7 +210,7 @@ interface TrackingLead {
210
210
  dwellTime?: number;
211
211
  }
212
212
  /**
213
- * Datos procesados de lead con tracking (respuesta de GET /leads/{id}/with-tracking).
213
+ * Processed lead data with tracking info (response from GET /leads/{id}/with-tracking).
214
214
  */
215
215
  interface LeadTrackingData {
216
216
  videoVisto: boolean;
@@ -226,7 +226,7 @@ interface LeadTrackingData {
226
226
  dwellTime?: number;
227
227
  }
228
228
  /**
229
- * Datos de formulario para enviar con un lead.
229
+ * Form data submitted with a lead.
230
230
  */
231
231
  interface LeadFormData {
232
232
  nombre: string;
@@ -236,11 +236,15 @@ interface LeadFormData {
236
236
  [key: string]: unknown;
237
237
  }
238
238
  /**
239
- * Parámetros extraídos de la URL para detección de origen.
239
+ * URL parameters extracted for lead origin detection.
240
240
  */
241
241
  interface UrlParams {
242
242
  userId: string;
243
243
  idCampana: string;
244
+ /** Meta Ads: ad set identifier (adset_id) — ad traceability */
245
+ adsetId: string;
246
+ /** Meta Ads: individual ad identifier (ad_id) — ad traceability */
247
+ adId: string;
244
248
  utmContent: string;
245
249
  fbclid: string;
246
250
  nombreNetworker: string;
@@ -251,11 +255,14 @@ interface UrlParams {
251
255
  utmSource?: string;
252
256
  utmMedium?: string;
253
257
  utmCampaign?: string;
258
+ /** Spelling correction of leadCampaing */
259
+ leadCampaign?: string;
260
+ /** @deprecated Use leadCampaign instead */
254
261
  leadCampaing?: string;
255
262
  isOrganico?: boolean;
256
263
  }
257
264
  /**
258
- * Resultado de la detección de origen de un lead.
265
+ * Result of lead origin detection.
259
266
  */
260
267
  interface LeadOrigin {
261
268
  type: 'facebook' | 'organic';
@@ -264,7 +271,7 @@ interface LeadOrigin {
264
271
  hasCampaign: boolean;
265
272
  }
266
273
  /**
267
- * Respuesta del API al crear/enviar un tracking lead.
274
+ * API response when creating/submitting a tracking lead.
268
275
  */
269
276
  interface TrackingLeadResponse {
270
277
  colaboradorAsignado?: {
@@ -277,7 +284,7 @@ interface TrackingLeadResponse {
277
284
  [key: string]: unknown;
278
285
  }
279
286
  /**
280
- * Respuesta procesada de submitTrackingLead.
287
+ * Processed response from submitTrackingLead.
281
288
  */
282
289
  interface SubmitTrackingLeadResponse {
283
290
  ok: boolean;
@@ -285,7 +292,7 @@ interface SubmitTrackingLeadResponse {
285
292
  data: TrackingLeadResponse | null;
286
293
  }
287
294
  /**
288
- * Opciones adicionales al construir el body de la petición de lead.
295
+ * Additional options for building the lead request body.
289
296
  */
290
297
  interface BuildRequestBodyOptions {
291
298
  nameForm?: string;
@@ -298,16 +305,16 @@ interface BuildRequestBodyOptions {
298
305
  additionalFields?: Record<string, unknown>;
299
306
  }
300
307
  /**
301
- * Configuración del DwellTimeTracker.
308
+ * DwellTimeTracker configuration.
302
309
  */
303
310
  interface DwellTimeConfig {
304
- /** ID del tracking data en el backend */
311
+ /** Backend tracking data ID */
305
312
  trackingDataId: number | string;
306
- /** Habilitar tracking (default: true) */
313
+ /** Enable tracking (default: true) */
307
314
  enabled?: boolean;
308
- /** Callback al enviar exitosamente */
315
+ /** Callback on successful send */
309
316
  onSuccess?: () => void;
310
- /** Callback en caso de error */
317
+ /** Callback on error */
311
318
  onError?: (error: Error) => void;
312
319
  }
313
320
  declare global {
@@ -322,26 +329,25 @@ declare global {
322
329
  }
323
330
 
324
331
  /**
325
- * Core de Google Analytics 4
326
- * Inicialización, tracking de eventos y captura de datos del visitante.
327
- * Desacoplado de cualquier framework (Next.js, React, etc.)
332
+ * Google Analytics 4 core module.
333
+ * Initialization, event tracking, and visitor data capture.
334
+ * Framework-agnostic (no Next.js, React, etc. dependency).
328
335
  */
329
336
 
330
337
  /**
331
- * Obtiene el GA Tracking ID actual.
332
- * Si se configuró un `resolveTrackingId`, lo usa dinámicamente.
333
- * Si no, usa el `trackingId` fijo de la config.
338
+ * Returns the current GA Tracking ID.
339
+ * Uses `resolveTrackingId` dynamically if configured, otherwise falls back to the static `trackingId`.
334
340
  */
335
341
  declare const getGATrackingId: () => string;
336
342
  /**
337
- * Inicializa Google Analytics con la configuración proporcionada.
343
+ * Initializes Google Analytics with the provided configuration.
338
344
  *
339
345
  * @example
340
346
  * ```ts
341
- * // Con ID fijo
347
+ * // With a fixed ID
342
348
  * initGA({ trackingId: 'G-XXXXXXX' })
343
349
  *
344
- * // Con resolución dinámica
350
+ * // With dynamic resolution
345
351
  * initGA({
346
352
  * resolveTrackingId: (path) => {
347
353
  * if (path.startsWith('/kin')) return 'G-KIN-ID'
@@ -352,70 +358,70 @@ declare const getGATrackingId: () => string;
352
358
  */
353
359
  declare const initGA: (config?: TrackingConfig) => void;
354
360
  /**
355
- * Reinicializa GA con un nuevo Tracking ID.
356
- * Útil cuando el ID cambia dinámicamente (ej. login del usuario).
361
+ * Reinitializes GA with a new Tracking ID.
362
+ * Useful when the ID changes dynamically (e.g., after user login).
357
363
  */
358
364
  declare const reinitGA: (newTrackingId: string) => void;
359
365
  /**
360
- * Verificar si GA está inicializado
366
+ * Returns whether GA has been initialized.
361
367
  */
362
368
  declare const isGAInitialized: () => boolean;
363
369
  /**
364
- * Extrae los parámetros UTM de la URL actual.
370
+ * Extracts UTM parameters from the current URL.
365
371
  */
366
372
  declare const captureUTMParams: () => UTMParams | null;
367
373
  /**
368
- * Captura el `user_id` desde la URL (?user_id=xxx).
369
- * Lo cachea internamente para enviarlo en todos los eventos.
374
+ * Captures the `user_id` from the URL query string (?user_id=xxx).
375
+ * Caches it internally to include in all subsequent events.
370
376
  */
371
377
  declare const captureUserIdFromURL: () => string | null;
372
378
  /**
373
- * Resuelve el nombre del usuario desde múltiples fuentes.
374
- * Prioridad: URL > localStorage > null
379
+ * Resolves the user name from multiple sources.
380
+ * Priority: URL > in-memory cache > localStorage > null
375
381
  */
376
382
  declare const getUserName: () => string | null;
377
383
  /**
378
- * Obtiene el user_id cacheado.
384
+ * Returns the cached user_id.
379
385
  */
380
386
  declare const getUserId: () => string | null;
381
387
  /**
382
- * Establece manualmente el user_id (ej. después de login).
388
+ * Manually sets the user_id (e.g., after login).
383
389
  */
384
390
  declare const setUserId: (userId: string) => void;
385
391
  /**
386
- * Establece manualmente el user_name.
392
+ * Manually sets the user_name.
387
393
  */
388
394
  declare const setUserName: (userName: string) => void;
389
395
  /**
390
- * Envía un pageview a GA4.
391
- * Automáticamente incluye UTM params y user_id si están disponibles.
396
+ * Sends a pageview to GA4.
397
+ * Automatically includes UTM params and user_id if available.
392
398
  */
393
399
  declare const trackPageView: (path: string) => void;
394
400
  /**
395
- * Envía un evento personalizado a GA4.
396
- * Usa envío dual: `window.gtag()` + `ReactGA.event()`.
397
- * Siempre incluye `user_id` y `user_name` como parámetros.
401
+ * Sends a custom event to GA4.
402
+ * Uses dual dispatch: `window.gtag()` + `ReactGA.event()`.
403
+ * Always includes `user_id` and `user_name` as parameters.
398
404
  *
399
405
  * @example
400
406
  * ```ts
401
- * trackEvent('CTA', 'click', 'Botón Hero', undefined, { section: 'hero' })
407
+ * trackEvent('CTA', 'click', 'Hero Button', undefined, { section: 'hero' })
402
408
  * ```
403
409
  */
404
410
  declare const trackEvent: (category: string, action: string, label?: string, value?: number, additionalData?: TrackingEventData) => void;
405
411
  /**
406
- * Resetea el estado interno (útil para tests y re-inicialización).
412
+ * Resets all internal state (useful for tests and reinitialization).
407
413
  */
408
414
  declare const resetAnalytics: () => void;
409
415
 
410
416
  /**
411
- * Google Tag Manager — Carga e inyección vanilla (sin Next.js)
412
- * Proporciona pushToDataLayer e injectGTMScript.
417
+ * Google Tag Manager — Vanilla injection (no Next.js dependency).
418
+ * Provides pushToDataLayer and injectGTMScript.
413
419
  */
414
420
  /**
415
- * Inyecta el script de Google Tag Manager en el <head> del documento.
416
- * Equivalente al componente <Script> de Next.js, pero framework-agnostic.
421
+ * Injects the Google Tag Manager script into the document <head>.
422
+ * Framework-agnostic equivalent of Next.js <Script> component.
417
423
  *
418
- * @param gtmId - ID de GTM (ej: 'GTM-5GMQNFMN')
424
+ * @param gtmId - GTM container ID (e.g., 'GTM-5GMQNFMN')
419
425
  *
420
426
  * @example
421
427
  * ```ts
@@ -424,78 +430,78 @@ declare const resetAnalytics: () => void;
424
430
  */
425
431
  declare const injectGTMScript: (gtmId: string) => void;
426
432
  /**
427
- * Envía un evento al dataLayer de GTM.
433
+ * Pushes an event to the GTM dataLayer.
428
434
  *
429
- * @param eventName - Nombre del evento
430
- * @param data - Datos adicionales del evento
435
+ * @param eventName - Name of the event
436
+ * @param data - Additional event data
431
437
  *
432
438
  * @example
433
439
  * ```ts
434
440
  * pushToDataLayer('page_view', { page_path: '/kin' })
435
- * pushToDataLayer('cta_click', { button_text: 'Únete', section: 'hero' })
441
+ * pushToDataLayer('cta_click', { button_text: 'Join Now', section: 'hero' })
436
442
  * ```
437
443
  */
438
444
  declare const pushToDataLayer: (eventName: string, data?: Record<string, unknown>) => void;
439
445
 
440
446
  /**
441
- * VideoTracker — Tracking avanzado de video para GA4
442
- * Gestiona el estado de reproducción por video y emite eventos a Google Analytics.
443
- * Framework-agnostic (no requiere React).
447
+ * VideoTracker — Advanced video tracking for GA4.
448
+ * Manages per-video playback state and emits events to Google Analytics.
449
+ * Framework-agnostic (no React dependency).
444
450
  */
445
451
 
446
452
  declare class VideoTracker {
447
453
  private videos;
448
454
  private watchTimeIntervals;
449
455
  /**
450
- * Inicializa el tracking para un video.
456
+ * Initializes tracking for a video.
451
457
  */
452
458
  initVideo(videoId: string): void;
453
459
  /**
454
- * Tracking de evento play.
460
+ * Tracks a play event.
455
461
  */
456
462
  trackPlay(videoId: string, currentTime?: number): void;
457
463
  /**
458
- * Tracking de evento pause.
464
+ * Tracks a pause event.
459
465
  */
460
466
  trackPause(videoId: string, currentTime: number, duration?: number): void;
461
467
  /**
462
- * Tracking de evento seek (saltar en el timeline).
468
+ * Tracks a seek event (timeline jump).
463
469
  */
464
470
  trackSeek(videoId: string, fromTime: number, toTime: number): void;
465
471
  /**
466
- * Tracking de progreso (milestones: 25%, 50%, 75%).
472
+ * Tracks progress milestones (25%, 50%, 75%).
467
473
  */
468
474
  trackProgress(videoId: string, percentage: number, currentTime: number): void;
469
475
  /**
470
- * Tracking de completación del video (95%).
476
+ * Tracks video completion (>=95%).
471
477
  */
472
478
  trackComplete(videoId: string, totalDuration: number): void;
473
479
  /**
474
- * Tracking de fin del video (evento ended nativo).
480
+ * Tracks video end (native ended event).
475
481
  */
476
482
  trackEnd(videoId: string): void;
477
483
  /**
478
- * Tracking de cambio de velocidad de reproducción.
484
+ * Tracks playback speed change.
479
485
  */
480
486
  trackSpeedChange(videoId: string, speed: number): void;
481
487
  /**
482
- * Tracking de pantalla completa.
488
+ * Tracks fullscreen toggle.
483
489
  */
484
490
  trackFullscreen(videoId: string, isFullscreen: boolean): void;
485
491
  /**
486
- * Tracking de no interacción (el usuario está en la página pero no interactúa con el video).
492
+ * Tracks no interaction (user is on the page but not interacting with the video).
487
493
  */
488
494
  trackNoInteraction(videoId: string, timeOnPage: number): void;
489
495
  /**
490
- * Obtiene el estado actual de un video.
496
+ * Returns the current state of a video.
491
497
  */
492
498
  getState(videoId: string): VideoTrackingState | undefined;
493
499
  /**
494
- * Limpia el tracking de un video específico.
500
+ * Cleans up tracking for a specific video.
495
501
  */
496
502
  cleanup(videoId: string): void;
497
503
  /**
498
- * Limpia todo el tracking.
504
+ * Cleans up all video tracking.
499
505
  */
500
506
  cleanupAll(): void;
501
507
  private getOrCreateState;
@@ -503,14 +509,14 @@ declare class VideoTracker {
503
509
  private stopWatchTimeTracking;
504
510
  }
505
511
  /**
506
- * Instancia singleton del VideoTracker.
507
- * Usar cuando se necesita una sola instancia global.
512
+ * Singleton VideoTracker instance.
513
+ * Use when a single global instance is needed.
508
514
  */
509
515
  declare const videoTracker: VideoTracker;
510
516
 
511
517
  /**
512
- * Funciones genéricas de tracking de eventos para GA4.
513
- * Cada función es una abstracción de `trackEvent()` con categoría y acción predefinidas.
518
+ * Generic GA4 event tracking functions.
519
+ * Each function wraps `trackEvent()` with a predefined category and action.
514
520
  */
515
521
 
516
522
  declare const trackCTAClick: (buttonName: string, section: string, additionalData?: TrackingEventData) => void;
@@ -529,17 +535,40 @@ declare const trackPricingCardClick: (productName: string, price: number | strin
529
535
  declare const trackContactClick: (method: string) => void;
530
536
  declare const trackShare: (platform: string, content: string) => void;
531
537
  declare const trackDownload: (fileName: string, fileType: string) => void;
538
+ /**
539
+ * Tracks quiz start (funnel stage 5).
540
+ * The quiz serves as an implicit lead scoring mechanism.
541
+ */
542
+ declare const trackQuizStart: (quizName: string) => void;
543
+ /**
544
+ * Tracks an individual quiz answer.
545
+ */
546
+ declare const trackQuizAnswer: (quizName: string, questionIndex: number, answer: string) => void;
547
+ /**
548
+ * Tracks quiz completion (funnel stage 5).
549
+ */
550
+ declare const trackQuizComplete: (quizName: string, totalQuestions?: number, score?: number) => void;
551
+ /**
552
+ * Tracks a Thank You Page visit (funnel stage 6).
553
+ * Confirms the lead completed the funnel flow.
554
+ */
555
+ declare const trackThankYouPageVisit: (source?: string) => void;
556
+ /**
557
+ * Tracks a WhatsApp link click (funnel stage 7).
558
+ * Complements markWhatsAppSent() which marks post-hoc.
559
+ */
560
+ declare const trackWhatsAppClick: (phoneNumber?: string, section?: string) => void;
532
561
 
533
562
  /**
534
- * Adaptador de video Wistia
535
- * Detecta automáticamente el SDK de Wistia y se enlaza a sus eventos.
563
+ * Wistia video adapter.
564
+ * Auto-detects the Wistia SDK and binds to its events.
536
565
  * Framework-agnostic.
537
566
  */
538
567
 
539
568
  /**
540
- * Inicia tracking de un video Wistia por su Media ID.
541
- * Detecta si el player es Wistia nativo o un <video> HTML5.
542
- * Retorna un handle con getStats(), onUpdate() y stop().
569
+ * Starts tracking a Wistia video by its Media ID.
570
+ * Detects whether to use the native Wistia player or an HTML5 <video> fallback.
571
+ * Returns a handle with getStats(), onUpdate(), and stop().
543
572
  *
544
573
  * @example
545
574
  * ```ts
@@ -547,59 +576,59 @@ declare const trackDownload: (fileName: string, fileType: string) => void;
547
576
  * tracker.onUpdate((stats) => {
548
577
  * console.log(stats.timeWatched, stats.completed)
549
578
  * })
550
- * // Al desmontar:
579
+ * // On unmount:
551
580
  * tracker.stop()
552
581
  * ```
553
582
  */
554
583
  declare const trackWistiaByMediaId: (mediaId: string) => Promise<VideoTrackerHandle | null>;
555
584
 
556
585
  /**
557
- * Adaptador de video Voomly
558
- * Usa 3 estrategias complementarias para trackear videos embebidos de Voomly.
586
+ * Voomly video adapter.
587
+ * Uses 3 complementary strategies to track embedded Voomly videos.
559
588
  * Framework-agnostic.
560
589
  */
561
590
 
562
591
  /**
563
- * Inicia tracking de un video Voomly por su Embed ID.
564
- * Usa 3 estrategias complementarias:
565
- * 1. Scan periódico del DOM (cada 2s) buscando <video> dentro del embed
566
- * 2. Polling de respaldo (cada 1s) leyendo .currentTime
567
- * 3. Eventos globales de window (voomly:video:*)
592
+ * Starts tracking a Voomly video by its Embed ID.
593
+ * Uses 3 complementary strategies:
594
+ * 1. Periodic DOM scan (every 2s) searching for <video> inside the embed
595
+ * 2. Fallback polling (every 1s) reading .currentTime
596
+ * 3. Global window events (voomly:video:*)
568
597
  *
569
598
  * @example
570
599
  * ```ts
571
600
  * const tracker = await trackVoomlyByEmbedId('my-voomly-id')
572
601
  * tracker.onUpdate((stats) => console.log(stats))
573
- * // IMPORTANTE: llamar stop() al desmontar para evitar memory leaks
602
+ * // IMPORTANT: call stop() on unmount to prevent memory leaks
574
603
  * tracker.stop()
575
604
  * ```
576
605
  */
577
606
  declare const trackVoomlyByEmbedId: (embedId: string) => Promise<VideoTrackerHandle | null>;
578
607
 
579
608
  /**
580
- * Adaptador de video HTML5 nativo
581
- * Tracking puro de elementos <video> sin dependencia de React.
609
+ * Native HTML5 video adapter.
610
+ * Pure tracking for <video> elements with no React dependency.
582
611
  */
583
612
 
584
613
  /**
585
- * Inicia tracking de un elemento <video> HTML5 nativo.
586
- * Escucha eventos estándar del Video API del navegador.
614
+ * Starts tracking a native HTML5 <video> element.
615
+ * Listens to standard browser Video API events.
587
616
  *
588
617
  * @example
589
618
  * ```ts
590
619
  * const video = document.querySelector('video')
591
620
  * const tracker = trackHTML5Video('hero-video', video)
592
621
  * tracker.onUpdate((stats) => console.log(stats))
593
- * // Al desmontar:
622
+ * // On unmount:
594
623
  * tracker.stop()
595
624
  * ```
596
625
  */
597
626
  declare const trackHTML5Video: (videoId: string, videoElement: HTMLVideoElement) => VideoTrackerHandle;
598
627
 
599
628
  /**
600
- * LandingTracker — Orquestador de sesión completa
601
- * Inicializa y gestiona scroll tracking, click heatmap, section dwell time,
602
- * form auto-tracking y sesión start/end.
629
+ * LandingTracker — Full session orchestrator.
630
+ * Initializes and manages scroll tracking, click heatmap, section dwell time,
631
+ * form auto-tracking, and session start/end.
603
632
  * Framework-agnostic.
604
633
  */
605
634
 
@@ -613,30 +642,30 @@ declare class LandingTracker {
613
642
  private observers;
614
643
  private listeners;
615
644
  /**
616
- * Inicializa el tracking de la landing con la configuración dada.
645
+ * Initializes landing page tracking with the given configuration.
617
646
  */
618
647
  init(config: LandingTrackerConfig): void;
619
648
  /**
620
- * Destruye el tracker y limpia todos los observers y listeners.
649
+ * Destroys the tracker and cleans up all observers and listeners.
621
650
  */
622
651
  destroy(): void;
623
- /** Trackear click en un CTA */
652
+ /** Track a CTA click */
624
653
  trackCTAClick(buttonName: string, section: string, additionalData?: Record<string, unknown>): void;
625
- /** Trackear conversión */
654
+ /** Track a conversion */
626
655
  trackConversion(type: string, value?: number, additionalData?: Record<string, unknown>): void;
627
- /** Trackear click en FAQs */
656
+ /** Track FAQ expansion */
628
657
  trackFAQExpand(question: string, index: number): void;
629
- /** Trackear click social */
658
+ /** Track social link click */
630
659
  trackSocialClick(platform: string, action: string): void;
631
- /** Trackear click en imagen */
660
+ /** Track image click */
632
661
  trackImageClick(imageName: string, section: string): void;
633
- /** Trackear scroll a sección */
662
+ /** Track scroll to a section */
634
663
  trackScrollTo(section: string): void;
635
- /** Trackear share */
664
+ /** Track content share */
636
665
  trackShare(platform: string, content: string): void;
637
- /** Trackear descarga */
666
+ /** Track file download */
638
667
  trackDownload(fileName: string, fileType: string): void;
639
- /** Obtener datos de la sesión actual */
668
+ /** Get current session data */
640
669
  getSessionData(): {
641
670
  duration: number;
642
671
  clicks: number;
@@ -655,7 +684,7 @@ declare class LandingTracker {
655
684
  private initClickHeatmap;
656
685
  }
657
686
  /**
658
- * Factory function para crear un LandingTracker.
687
+ * Factory function to create a LandingTracker.
659
688
  *
660
689
  * @example
661
690
  * ```ts
@@ -664,15 +693,15 @@ declare class LandingTracker {
664
693
  * pageName: 'Kin Landing Page',
665
694
  * gtmId: 'GTM-5GMQNFMN',
666
695
  * })
667
- * // Al desmontar:
696
+ * // On unmount:
668
697
  * tracker.destroy()
669
698
  * ```
670
699
  */
671
700
  declare const createLandingTracker: (config: LandingTrackerConfig) => LandingTracker;
672
701
 
673
702
  /**
674
- * API Client — Cliente HTTP configurable para persistencia al backend.
675
- * Framework-agnostic. Usa fetch nativo.
703
+ * API Client — Configurable HTTP client for backend persistence.
704
+ * Framework-agnostic. Uses native fetch.
676
705
  *
677
706
  * @example
678
707
  * ```ts
@@ -686,82 +715,81 @@ declare const createLandingTracker: (config: LandingTrackerConfig) => LandingTra
686
715
  */
687
716
 
688
717
  /**
689
- * Inicializa el cliente HTTP para la capa de persistencia.
690
- * Debe llamarse antes de usar funciones de lead submission, dwell time o queries.
718
+ * Initializes the HTTP client for the persistence layer.
719
+ * Must be called before using lead submission, dwell time, or query functions.
691
720
  */
692
721
  declare const initTrackingAPI: (config: TrackingAPIConfig) => void;
693
722
  /**
694
- * Verifica si el API client ha sido inicializado.
723
+ * Returns whether the API client has been initialized.
695
724
  */
696
725
  declare const isTrackingAPIInitialized: () => boolean;
697
726
 
698
727
  /**
699
- * Lead Submission — Creación y actualización de leads en el backend.
700
- * Migrado de lead-origin-detector.ts, framework-agnostic.
728
+ * Lead Submission — Lead creation and update against the backend.
729
+ * Migrated from lead-origin-detector.ts, framework-agnostic.
701
730
  */
702
731
 
703
732
  /**
704
- * Extrae todos los parámetros relevantes de la URL.
733
+ * Extracts all relevant parameters from the URL.
705
734
  *
706
- * @param url - URL opcional (si no se proporciona, usa window.location)
707
- * @returns Objeto con todos los parámetros extraídos
735
+ * @param url - Optional URL (defaults to window.location if omitted)
736
+ * @returns Object containing all extracted parameters
708
737
  */
709
738
  declare const extractUrlParams: (url?: string) => UrlParams;
710
739
  /**
711
- * Detecta el origen del lead basándose en los parámetros de la URL.
712
- * Facebook Ads: tiene fbclid O campaign_id
713
- * Orgánico: tiene whatsapp Y NO tiene fbclid Y NO tiene campaign_id
740
+ * Detects the lead origin based on URL parameters.
741
+ * Facebook Ads: has fbclid OR campaign_id
742
+ * Organic: has whatsapp AND does NOT have fbclid AND does NOT have campaign_id
714
743
  */
715
744
  declare const detectLeadOrigin: (url?: string) => LeadOrigin;
716
745
  /**
717
- * Construye el body de la petición según el tipo de origen.
746
+ * Builds the request body based on the lead origin type.
718
747
  */
719
748
  declare const buildTrackingRequestBody: (params: UrlParams, formData: LeadFormData, origin: LeadOrigin, options?: BuildRequestBodyOptions) => Record<string, unknown>;
720
749
  /**
721
- * Envía el lead al endpoint correcto según su origen.
750
+ * Submits the lead to the correct endpoint based on its origin.
722
751
  */
723
752
  declare const submitTrackingLead: (body: Record<string, unknown>, origin: LeadOrigin) => Promise<SubmitTrackingLeadResponse>;
724
753
  /**
725
- * Función completa: detecta origen, construye body y envía el lead.
754
+ * End-to-end function: detects origin, builds body, and submits the lead.
726
755
  *
727
756
  * @example
728
757
  * ```ts
729
758
  * const result = await submitLead(
730
759
  * { nombre: 'Juan', correo: 'juan@mail.com', telefono: '+34600...' },
731
- * { nameForm: 'Formulario Kin', videoCompleted: true },
760
+ * { nameForm: 'Kin Form', videoCompleted: true },
732
761
  * );
733
762
  * ```
734
763
  */
735
764
  declare const submitLead: (formData: LeadFormData, options?: BuildRequestBodyOptions, url?: string) => Promise<SubmitTrackingLeadResponse>;
736
765
  /**
737
- * Actualiza un lead existente mediante PATCH.
766
+ * Updates an existing lead via PATCH.
738
767
  */
739
768
  declare const updateTrackingLead: (trackingId: number | string, updates: Record<string, unknown>) => Promise<boolean>;
740
769
  /**
741
- * Marca un lead como "WhatsApp enviado".
770
+ * Marks a lead as "WhatsApp sent".
742
771
  */
743
772
  declare const markWhatsAppSent: (leadId: number | string) => Promise<boolean>;
744
773
  /**
745
- * Construye un msgForm como JSON stringificado.
774
+ * Builds a msgForm as a JSON-stringified value.
746
775
  */
747
776
  declare const buildMsgFormJSON: (mensaje: string, datosAdicionales?: Record<string, unknown>) => string;
748
777
 
749
778
  /**
750
- * DwellTimeTracker — Tracking de tiempo de permanencia con envío periódico al backend.
751
- * Migrado de dwell-time.ts (~960 líneas ~280 líneas limpias).
779
+ * DwellTimeTracker — Dwell time tracking with periodic backend reporting.
780
+ * Migrated from dwell-time.ts (~960 lines -> ~280 clean lines).
752
781
  * Framework-agnostic.
753
782
  */
754
783
 
755
784
  /**
756
- * Clase que mide el tiempo de permanencia del usuario en una página
757
- * y lo envía periódicamente al backend de tracking.
785
+ * Measures user dwell time on a page and periodically sends it to the tracking backend.
758
786
  *
759
- * Características:
760
- * - Envío automático cada 30 segundos
761
- * - Pausa automática cuando la pestaña se oculta
762
- * - sendBeacon en beforeunload para máxima confiabilidad
763
- * - Retry de updates pendientes via sessionStorage
764
- * - Tracking de video integrado (videoTimeWatched, videoCompleted)
787
+ * Features:
788
+ * - Automatic send every 30 seconds
789
+ * - Auto-pause when tab is hidden
790
+ * - sendBeacon on beforeunload for maximum reliability
791
+ * - Retry pending updates via sessionStorage
792
+ * - Integrated video tracking (videoTimeWatched, videoCompleted)
765
793
  */
766
794
  declare class DwellTimeTracker {
767
795
  private startTime;
@@ -782,28 +810,28 @@ declare class DwellTimeTracker {
782
810
  private boundVisibilityChange;
783
811
  constructor();
784
812
  /**
785
- * Inicia el tracking del tiempo de permanencia.
813
+ * Starts dwell time tracking.
786
814
  */
787
815
  start(config: DwellTimeConfig): void;
788
816
  /**
789
- * Detiene el tracking y envía el tiempo acumulado.
817
+ * Stops tracking and sends accumulated time.
790
818
  */
791
819
  stop(): void;
792
820
  /**
793
- * Obtiene el tiempo transcurrido en segundos (restando tiempo pausado).
821
+ * Returns elapsed time in seconds (excluding paused time).
794
822
  */
795
823
  getElapsedTime(): number;
796
824
  /**
797
- * Actualiza manualmente el tiempo del video.
798
- * Llamar desde el VideoTracker u otros adaptadores.
825
+ * Manually updates video time.
826
+ * Called from VideoTracker or other adapters.
799
827
  */
800
828
  updateVideoTime(videoTimeWatched: number, videoCompleted?: boolean): void;
801
829
  /**
802
- * Actualiza el trackingDataId (útil cuando se obtiene después del registro).
830
+ * Updates the trackingDataId (useful when obtained after registration).
803
831
  */
804
832
  updateTrackingId(trackingDataId: number | string): void;
805
833
  /**
806
- * Limpia todos los listeners y timers.
834
+ * Cleans up all listeners and timers.
807
835
  */
808
836
  destroy(): void;
809
837
  private checkLocalStorageForId;
@@ -819,22 +847,22 @@ declare class DwellTimeTracker {
819
847
  }
820
848
  declare const dwellTimeTracker: DwellTimeTracker;
821
849
  /**
822
- * Inicia el tracking del tiempo de permanencia.
850
+ * Starts dwell time tracking.
823
851
  */
824
852
  declare const startDwellTimeTracking: (config: DwellTimeConfig) => void;
825
853
  /**
826
- * Detiene el tracking y envía el tiempo acumulado.
854
+ * Stops tracking and sends accumulated time.
827
855
  */
828
856
  declare const stopDwellTimeTracking: () => void;
829
857
 
830
858
  /**
831
- * Tracking Queries — Consultas GET al backend de tracking.
832
- * Migrado de TrackingService.ts y LeadTrackingService.ts.
859
+ * Tracking Queries — GET queries to the tracking backend.
860
+ * Migrated from TrackingService.ts and LeadTrackingService.ts.
833
861
  * Framework-agnostic.
834
862
  */
835
863
 
836
864
  /**
837
- * Obtiene los datos de un tracking lead por su ID.
865
+ * Retrieves tracking lead data by its ID.
838
866
  *
839
867
  * @example
840
868
  * ```ts
@@ -844,8 +872,8 @@ declare const stopDwellTimeTracking: () => void;
844
872
  */
845
873
  declare const getTrackingById: (trackingId: number | string) => Promise<TrackingLead>;
846
874
  /**
847
- * Obtiene un lead con sus datos de tracking asociados.
848
- * Procesa la respuesta para extraer videoVisto, tiempoReproducido, etc.
875
+ * Retrieves a lead with its associated tracking data.
876
+ * Processes the response to extract videoVisto, tiempoReproducido, etc.
849
877
  *
850
878
  * @example
851
879
  * ```ts
@@ -855,15 +883,15 @@ declare const getTrackingById: (trackingId: number | string) => Promise<Tracking
855
883
  */
856
884
  declare const getLeadWithTracking: (leadId: string) => Promise<LeadTrackingData>;
857
885
  /**
858
- * Genera un link de tracking para un funnel.
886
+ * Generates a tracking link for a funnel.
859
887
  *
860
888
  * @example
861
889
  * ```ts
862
- * const { link } = await generateTrackingLink(1, 'mi-dominio.com');
890
+ * const { link } = await generateTrackingLink(1, 'my-domain.com');
863
891
  * ```
864
892
  */
865
893
  declare const generateTrackingLink: (funnelId: number, customDomain: string) => Promise<{
866
894
  link: string;
867
895
  }>;
868
896
 
869
- export { type BuildRequestBodyOptions, type ClickData, type DwellTimeConfig, DwellTimeTracker, LandingTracker, type LandingTrackerConfig, type LeadFormData, type LeadOrigin, type LeadTrackingData, type SessionSummary, type SubmitTrackingLeadResponse, type TrackingAPIConfig, type TrackingConfig, type TrackingEventData, type TrackingLead, type TrackingLeadResponse, type UTMParams, type UrlParams, type UseVideoTrackingOptions, type VideoStats, VideoTracker, type VideoTrackerHandle, type VideoTrackingState, type VideoUpdateCallback, type VisitorData, buildMsgFormJSON, buildTrackingRequestBody, captureUTMParams, captureUserIdFromURL, createLandingTracker, detectLeadOrigin, dwellTimeTracker, extractUrlParams, generateTrackingLink, getGATrackingId, getLeadWithTracking, getTrackingById, getUserId, getUserName, initGA, initTrackingAPI, injectGTMScript, isGAInitialized, isTrackingAPIInitialized, markWhatsAppSent, pushToDataLayer, reinitGA, resetAnalytics, setUserId, setUserName, startDwellTimeTracking, stopDwellTimeTracking, submitLead, submitTrackingLead, trackCTAClick, trackContactClick, trackConversion, trackDownload, trackEvent, trackFAQExpand, trackFormFieldComplete, trackFormStart, trackFormSubmit, trackFormValidationError, trackHTML5Video, trackImageClick, trackPageView, trackPricingCardClick, trackScrollTo, trackSectionClick, trackShare, trackSocialClick, trackTimeInSection, trackVoomlyByEmbedId, trackWistiaByMediaId, updateTrackingLead, videoTracker };
897
+ export { type BuildRequestBodyOptions, type ClickData, type DwellTimeConfig, DwellTimeTracker, LandingTracker, type LandingTrackerConfig, type LeadFormData, type LeadOrigin, type LeadTrackingData, type SessionSummary, type SubmitTrackingLeadResponse, type TrackingAPIConfig, type TrackingConfig, type TrackingEventData, type TrackingLead, type TrackingLeadResponse, type UTMParams, type UrlParams, type UseVideoTrackingOptions, type VideoStats, VideoTracker, type VideoTrackerHandle, type VideoTrackingState, type VideoUpdateCallback, type VisitorData, buildMsgFormJSON, buildTrackingRequestBody, captureUTMParams, captureUserIdFromURL, createLandingTracker, detectLeadOrigin, dwellTimeTracker, extractUrlParams, generateTrackingLink, getGATrackingId, getLeadWithTracking, getTrackingById, getUserId, getUserName, initGA, initTrackingAPI, injectGTMScript, isGAInitialized, isTrackingAPIInitialized, markWhatsAppSent, pushToDataLayer, reinitGA, resetAnalytics, setUserId, setUserName, startDwellTimeTracking, stopDwellTimeTracking, submitLead, submitTrackingLead, trackCTAClick, trackContactClick, trackConversion, trackDownload, trackEvent, trackFAQExpand, trackFormFieldComplete, trackFormStart, trackFormSubmit, trackFormValidationError, trackHTML5Video, trackImageClick, trackPageView, trackPricingCardClick, trackQuizAnswer, trackQuizComplete, trackQuizStart, trackScrollTo, trackSectionClick, trackShare, trackSocialClick, trackThankYouPageVisit, trackTimeInSection, trackVoomlyByEmbedId, trackWhatsAppClick, trackWistiaByMediaId, updateTrackingLead, videoTracker };