@magicfeedback/popup-sdk 1.1.3 → 1.1.4

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.mts CHANGED
@@ -431,6 +431,30 @@ declare class CrashReporter {
431
431
  _persistForTest(error: unknown): void;
432
432
  }
433
433
 
434
+ /**
435
+ * Messaging (#18–22): tracking de notificaciones del host (push / in-app).
436
+ * Un único evento reservado `deepdots_message` con un campo `stage` discriminador;
437
+ * el funnel se correlaciona por `message_id` y se agrupa por `message_title`.
438
+ */
439
+ type MessageStage = 'delivered' | 'clicked' | 'converted';
440
+ interface TrackMessageOptions {
441
+ /** Identificador del mensaje/notificación — correlaciona el funnel delivered→clicked→converted. */
442
+ id: string;
443
+ /** Título del mensaje — dimensión de agrupación de #18–22. */
444
+ title: string;
445
+ /** Canal de entrega. */
446
+ channel: 'push' | 'in_app';
447
+ /** Nombre de la campaña (opcional). */
448
+ campaign?: string;
449
+ /** Valor de conversión (opcional, típico en `stage: 'converted'`). */
450
+ value?: number;
451
+ currency?: string;
452
+ /** Parámetros libres adicionales. */
453
+ params?: Record<string, unknown>;
454
+ }
455
+ /** Construye los params del evento `deepdots_message` (omite opcionales ausentes). */
456
+ declare function buildMessageParams(stage: MessageStage, o: TrackMessageOptions): Record<string, unknown>;
457
+
434
458
  /**
435
459
  * Main class for managing survey popups
436
460
  */
@@ -502,6 +526,8 @@ declare class DeepdotsPopups {
502
526
  trackFindabilityFriction(frictionTopic: string, params?: Record<string, unknown>): void;
503
527
  /** Funnel: un paso del embudo, correlacionado por `taskId`. El backend reconstruye conversión/drop-off/tiempo. */
504
528
  trackFunnelStep(funnel: string, step: string, taskId: string, params?: Record<string, unknown>): void;
529
+ /** Messaging (#18–22): registra una etapa del funnel de una notificación (push/in-app). No-op si tracking off. */
530
+ trackMessage(stage: MessageStage, options: TrackMessageOptions): void;
505
531
  /**
506
532
  * Navegación MANUAL (entornos sin History API, p. ej. React Native con React Navigation).
507
533
  * El host la llama en cada cambio de pantalla; emite `page_view` al salir de la anterior.
@@ -709,4 +735,4 @@ declare function collectRnDevice(d: DeviceInfoLike): DeviceInfo;
709
735
  */
710
736
  declare function setupReactNative(sdk: DeepdotsPopups, config: DeepdotsInitParams, deps?: ReactNativeSetupDeps): () => void;
711
737
 
712
- export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, BrowserPopupRenderer, type ContactAttributeValue, type ContactAttributes, type ContactBody, ContactManager, type CrashRecord, CrashReporter, type CrashSeverity, type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, DeepdotsPopups, type DeviceInfo, type DeviceInfoLike, type DeviceSnapshot, type EventListener, type FeedbackKV, InMemoryStorage, type KeyValueStorage, type MmkvLike, NoopPopupRenderer, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupRenderer, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type ReportErrorOptions, type TriggerConfig, buildAnalyticsFeedbackBody, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, mmkvStorage, setupReactNative };
738
+ export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, BrowserPopupRenderer, type ContactAttributeValue, type ContactAttributes, type ContactBody, ContactManager, type CrashRecord, CrashReporter, type CrashSeverity, type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, DeepdotsPopups, type DeviceInfo, type DeviceInfoLike, type DeviceSnapshot, type EventListener, type FeedbackKV, InMemoryStorage, type KeyValueStorage, type MessageStage, type MmkvLike, NoopPopupRenderer, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupRenderer, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type ReportErrorOptions, type TrackMessageOptions, type TriggerConfig, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, mmkvStorage, setupReactNative };
package/dist/index.d.ts CHANGED
@@ -431,6 +431,30 @@ declare class CrashReporter {
431
431
  _persistForTest(error: unknown): void;
432
432
  }
433
433
 
434
+ /**
435
+ * Messaging (#18–22): tracking de notificaciones del host (push / in-app).
436
+ * Un único evento reservado `deepdots_message` con un campo `stage` discriminador;
437
+ * el funnel se correlaciona por `message_id` y se agrupa por `message_title`.
438
+ */
439
+ type MessageStage = 'delivered' | 'clicked' | 'converted';
440
+ interface TrackMessageOptions {
441
+ /** Identificador del mensaje/notificación — correlaciona el funnel delivered→clicked→converted. */
442
+ id: string;
443
+ /** Título del mensaje — dimensión de agrupación de #18–22. */
444
+ title: string;
445
+ /** Canal de entrega. */
446
+ channel: 'push' | 'in_app';
447
+ /** Nombre de la campaña (opcional). */
448
+ campaign?: string;
449
+ /** Valor de conversión (opcional, típico en `stage: 'converted'`). */
450
+ value?: number;
451
+ currency?: string;
452
+ /** Parámetros libres adicionales. */
453
+ params?: Record<string, unknown>;
454
+ }
455
+ /** Construye los params del evento `deepdots_message` (omite opcionales ausentes). */
456
+ declare function buildMessageParams(stage: MessageStage, o: TrackMessageOptions): Record<string, unknown>;
457
+
434
458
  /**
435
459
  * Main class for managing survey popups
436
460
  */
@@ -502,6 +526,8 @@ declare class DeepdotsPopups {
502
526
  trackFindabilityFriction(frictionTopic: string, params?: Record<string, unknown>): void;
503
527
  /** Funnel: un paso del embudo, correlacionado por `taskId`. El backend reconstruye conversión/drop-off/tiempo. */
504
528
  trackFunnelStep(funnel: string, step: string, taskId: string, params?: Record<string, unknown>): void;
529
+ /** Messaging (#18–22): registra una etapa del funnel de una notificación (push/in-app). No-op si tracking off. */
530
+ trackMessage(stage: MessageStage, options: TrackMessageOptions): void;
505
531
  /**
506
532
  * Navegación MANUAL (entornos sin History API, p. ej. React Native con React Navigation).
507
533
  * El host la llama en cada cambio de pantalla; emite `page_view` al salir de la anterior.
@@ -709,4 +735,4 @@ declare function collectRnDevice(d: DeviceInfoLike): DeviceInfo;
709
735
  */
710
736
  declare function setupReactNative(sdk: DeepdotsPopups, config: DeepdotsInitParams, deps?: ReactNativeSetupDeps): () => void;
711
737
 
712
- export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, BrowserPopupRenderer, type ContactAttributeValue, type ContactAttributes, type ContactBody, ContactManager, type CrashRecord, CrashReporter, type CrashSeverity, type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, DeepdotsPopups, type DeviceInfo, type DeviceInfoLike, type DeviceSnapshot, type EventListener, type FeedbackKV, InMemoryStorage, type KeyValueStorage, type MmkvLike, NoopPopupRenderer, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupRenderer, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type ReportErrorOptions, type TriggerConfig, buildAnalyticsFeedbackBody, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, mmkvStorage, setupReactNative };
738
+ export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, BrowserPopupRenderer, type ContactAttributeValue, type ContactAttributes, type ContactBody, ContactManager, type CrashRecord, CrashReporter, type CrashSeverity, type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, DeepdotsPopups, type DeviceInfo, type DeviceInfoLike, type DeviceSnapshot, type EventListener, type FeedbackKV, InMemoryStorage, type KeyValueStorage, type MessageStage, type MmkvLike, NoopPopupRenderer, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupRenderer, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type ReportErrorOptions, type TrackMessageOptions, type TriggerConfig, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, mmkvStorage, setupReactNative };
package/dist/index.js CHANGED
@@ -3465,6 +3465,7 @@ __export(index_exports, {
3465
3465
  POPUP_TRIGGER_CONDITION_STATUSES: () => POPUP_TRIGGER_CONDITION_STATUSES,
3466
3466
  ReactNativePopupRenderer: () => ReactNativePopupRenderer,
3467
3467
  buildAnalyticsFeedbackBody: () => buildAnalyticsFeedbackBody,
3468
+ buildMessageParams: () => buildMessageParams,
3468
3469
  buildSurveyHtml: () => buildSurveyHtml,
3469
3470
  collectRnDevice: () => collectRnDevice,
3470
3471
  crashRecordToParams: () => crashRecordToParams,
@@ -4397,11 +4398,27 @@ var CrashReporter = class {
4397
4398
  }
4398
4399
  };
4399
4400
 
4401
+ // src/analytics/messaging.ts
4402
+ function buildMessageParams(stage, o) {
4403
+ const p = {
4404
+ stage,
4405
+ message_id: o.id,
4406
+ message_title: o.title,
4407
+ channel: o.channel
4408
+ };
4409
+ if (o.campaign) p.campaign = o.campaign;
4410
+ if (o.value !== void 0) p.value = o.value;
4411
+ if (o.currency) p.currency = o.currency;
4412
+ return { ...p, ...o.params ?? {} };
4413
+ }
4414
+
4400
4415
  // src/core/deepdots-popups.ts
4401
4416
  var EXIT_QUEUE_STORAGE_KEY = "__deepdots_exit_popup_queue__";
4402
4417
  var DAY_IN_MS = 24 * 60 * 60 * 1e3;
4403
4418
  var ANALYTICS_MAX_BATCH_SIZE = 20;
4404
4419
  var ANALYTICS_FLUSH_INTERVAL_MS = 3e4;
4420
+ var RESERVED_EVENT_PREFIX = "deepdots_";
4421
+ var CUSTOM_EVENT_PREFIX = "deepdots_event_";
4405
4422
  var DeepdotsPopups = class {
4406
4423
  constructor() {
4407
4424
  this.config = null;
@@ -4554,8 +4571,9 @@ var DeepdotsPopups = class {
4554
4571
  /** Registra un evento de analítica (modelo GA: nombre + params). No-op si tracking off. */
4555
4572
  track(name, params) {
4556
4573
  if (!this.tracking?.isTrackingEnabled()) return;
4557
- this.analytics?.track(name, params);
4558
- this.log("analytics \xB7 track:", name, params ?? {});
4574
+ const eventName = name.startsWith(RESERVED_EVENT_PREFIX) ? name : `${CUSTOM_EVENT_PREFIX}${name}`;
4575
+ this.analytics?.track(eventName, params);
4576
+ this.log("analytics \xB7 track:", eventName, params ?? {});
4559
4577
  }
4560
4578
  /** User attributes para breakdowns (registration_status, pass_type, sector, pass_status…). */
4561
4579
  setUserAttributes(attributes) {
@@ -4607,6 +4625,10 @@ var DeepdotsPopups = class {
4607
4625
  trackFunnelStep(funnel, step, taskId, params) {
4608
4626
  this.track("deepdots_funnel_step", { funnel, step, task_id: taskId, ...params ?? {} });
4609
4627
  }
4628
+ /** Messaging (#18–22): registra una etapa del funnel de una notificación (push/in-app). No-op si tracking off. */
4629
+ trackMessage(stage, options) {
4630
+ this.track("deepdots_message", buildMessageParams(stage, options));
4631
+ }
4610
4632
  /**
4611
4633
  * Navegación MANUAL (entornos sin History API, p. ej. React Native con React Navigation).
4612
4634
  * El host la llama en cada cambio de pantalla; emite `page_view` al salir de la anterior.