@magicfeedback/popup-sdk 1.8.4 → 1.9.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.mts CHANGED
@@ -192,6 +192,12 @@ interface FeedbackSinkOptions {
192
192
  onSessionId?: (id: string) => void;
193
193
  /** Callback invocado al cerrar la sesión (`completed:true`): el sessionId cacheado se olvida. */
194
194
  onSessionReset?: () => void;
195
+ /**
196
+ * Callback invocado cuando el backend acepta el lote de cierre, con el sessionId del
197
+ * registro cerrado: el que llevaba el lote o, en una sesión de un solo lote, el que
198
+ * devuelve la respuesta. Ese registro se convierte en Feedback en segundos.
199
+ */
200
+ onSessionClosed?: (id: string) => void;
195
201
  }
196
202
  /**
197
203
  * Sink real: transforma el envelope y hace `POST {baseUrl}/sdk/feedback`.
@@ -226,6 +232,19 @@ interface DeepdotsLogger {
226
232
  error?: (...args: unknown[]) => void;
227
233
  info?: (...args: unknown[]) => void;
228
234
  }
235
+ /**
236
+ * A session of the analytics channel as the Deepdots API sees it. Every session becomes ONE
237
+ * feedback, and `sessionId` is what the API stores as `sdkSessionId` on it: the value to look
238
+ * that feedback up with (`GET /feedbacks?filter={"where":{"sdkSessionId":"<sessionId>"}}`).
239
+ * A session that closes again keeps that one feedback: the API updates it.
240
+ * - `open`: the API acknowledged the session's first batch; its events keep accumulating.
241
+ * - `closed`: the API acknowledged the session's closing batch (`completed: true`); the
242
+ * feedback is created from it within seconds.
243
+ */
244
+ interface FeedbackSession {
245
+ sessionId: string;
246
+ status: 'open' | 'closed';
247
+ }
229
248
  interface DeepdotsInitParams {
230
249
  /** API key for authentication */
231
250
  apiKey?: string;
@@ -261,6 +280,17 @@ interface DeepdotsInitParams {
261
280
  * logged when `debug` is true.
262
281
  */
263
282
  analytics?: AnalyticsKeys;
283
+ /**
284
+ * Called when the analytics channel opens or closes a session (needs `analytics`), with the
285
+ * id the Deepdots API stores as `sdkSessionId` on the feedback the session becomes: send it
286
+ * to your backend to attach data to that feedback later. A session whose only batch is the
287
+ * closing one reports just `closed`. `closed` does not come when the page unloads before the
288
+ * closing request returns, for a session dropped after 30 min hidden, nor when the closing
289
+ * request fails (the API closes those itself, later): their id already came with `open`. Key
290
+ * by `sessionId`, not by order: the next session's `open` can arrive before the previous
291
+ * one's `closed`. Same value as `getFeedbackSessionId()` while the session is open.
292
+ */
293
+ onFeedbackSession?: (session: FeedbackSession) => void;
264
294
  /**
265
295
  * IP geolocation (country/city) added to analytics. Default `true`. The lookup calls
266
296
  * third-party services (ipapi.co, then ipwho.is, then ipinfo.io as fallbacks, 3 s timeout
@@ -698,6 +728,8 @@ declare class DeepdotsPopups {
698
728
  private analytics;
699
729
  /** feedbackSessionId cacheado del canal de analytics (devuelto por POST /sdk/feedback). */
700
730
  private analyticsFeedbackSessionId;
731
+ /** `init({ onFeedbackSession })`: avisa al host al abrir y cerrar cada registro. */
732
+ private onFeedbackSession;
701
733
  /** Timer del flush periódico de analytics (cada ANALYTICS_FLUSH_INTERVAL_MS). */
702
734
  private analyticsFlushTimer;
703
735
  /** Crash & error reporting (#14–17). Null hasta init(). */
@@ -741,6 +773,15 @@ declare class DeepdotsPopups {
741
773
  getUserId(): string | null;
742
774
  /** Session id de navegación actual. Null si tracking off. */
743
775
  getSessionId(): string | null;
776
+ /**
777
+ * Id del registro de analytics abierto: el `sessionId` que devolvió `POST /sdk/feedback`,
778
+ * que la API guarda como `sdkSessionId` en el Feedback en que se convierte la sesión. No es
779
+ * `getSessionId()`. Null hasta que el backend acepta el primer lote y de nuevo al cerrar la
780
+ * sesión: para saber también qué registro se cerró, usa `init({ onFeedbackSession })`.
781
+ */
782
+ getFeedbackSessionId(): string | null;
783
+ /** Avisa al host del registro abierto o cerrado; un fallo del host no corta el envío. */
784
+ private notifyFeedbackSession;
744
785
  /** Activa/desactiva el tracking (identidad + sesión + analytics). Kill-switch del contrato §7bis. */
745
786
  setTrackingEnabled(enabled: boolean): void;
746
787
  /** Registra un evento de analítica (modelo GA: nombre + params). No-op si tracking off. */
@@ -1265,4 +1306,4 @@ declare function collectRnDevice(d: DeviceInfoLike): DeviceInfo;
1265
1306
  */
1266
1307
  declare function setupReactNative(sdk: DeepdotsPopups, config: DeepdotsInitParams, deps?: ReactNativeSetupDeps): () => void;
1267
1308
 
1268
- export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, BrowserPopupRenderer, type BuildBodyOptions, type ContactAttributeValue, type ContactAttributes, type ContactBody, ContactManager, type CrashRecord, CrashReporter, type CrashSeverity, type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, type DeepdotsInitParams, type DeepdotsLogger, DeepdotsPopups, type DeviceInfo, type DeviceInfoLike, type DeviceSnapshot, type EventListener, type FeedbackKV, InMemoryStorage, type KeyValueStorage, LABELS, MAX_TRACKED_MESSAGES, MESSAGE_CHANNELS, type MessageChannel, MessageGuard, type MessageGuardVerdict, type MessageRejectionReason, type MessageStage, type MmkvLike, NATIVE_READY_GRACE_MS, NoopPopupRenderer, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupLabels, type PopupLocale, type PopupRenderer, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, REVEAL_TIMEOUT_MS, RTL_LOCALES, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type ReportErrorOptions, type ResolvedActionLabels, SUPPORTED_LANGUAGES, type SessionEndReason, type TrackMessageOptions, type TriggerConfig, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, directionFor, getLabels, isRtlLanguage, mmkvStorage, resolveActionLabels, resolveLocale, setupReactNative };
1309
+ export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, BrowserPopupRenderer, type BuildBodyOptions, type ContactAttributeValue, type ContactAttributes, type ContactBody, ContactManager, type CrashRecord, CrashReporter, type CrashSeverity, type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, type DeepdotsInitParams, type DeepdotsLogger, DeepdotsPopups, type DeviceInfo, type DeviceInfoLike, type DeviceSnapshot, type EventListener, type FeedbackKV, type FeedbackSession, InMemoryStorage, type KeyValueStorage, LABELS, MAX_TRACKED_MESSAGES, MESSAGE_CHANNELS, type MessageChannel, MessageGuard, type MessageGuardVerdict, type MessageRejectionReason, type MessageStage, type MmkvLike, NATIVE_READY_GRACE_MS, NoopPopupRenderer, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupLabels, type PopupLocale, type PopupRenderer, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, REVEAL_TIMEOUT_MS, RTL_LOCALES, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type ReportErrorOptions, type ResolvedActionLabels, SUPPORTED_LANGUAGES, type SessionEndReason, type TrackMessageOptions, type TriggerConfig, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, directionFor, getLabels, isRtlLanguage, mmkvStorage, resolveActionLabels, resolveLocale, setupReactNative };
package/dist/index.d.ts CHANGED
@@ -192,6 +192,12 @@ interface FeedbackSinkOptions {
192
192
  onSessionId?: (id: string) => void;
193
193
  /** Callback invocado al cerrar la sesión (`completed:true`): el sessionId cacheado se olvida. */
194
194
  onSessionReset?: () => void;
195
+ /**
196
+ * Callback invocado cuando el backend acepta el lote de cierre, con el sessionId del
197
+ * registro cerrado: el que llevaba el lote o, en una sesión de un solo lote, el que
198
+ * devuelve la respuesta. Ese registro se convierte en Feedback en segundos.
199
+ */
200
+ onSessionClosed?: (id: string) => void;
195
201
  }
196
202
  /**
197
203
  * Sink real: transforma el envelope y hace `POST {baseUrl}/sdk/feedback`.
@@ -226,6 +232,19 @@ interface DeepdotsLogger {
226
232
  error?: (...args: unknown[]) => void;
227
233
  info?: (...args: unknown[]) => void;
228
234
  }
235
+ /**
236
+ * A session of the analytics channel as the Deepdots API sees it. Every session becomes ONE
237
+ * feedback, and `sessionId` is what the API stores as `sdkSessionId` on it: the value to look
238
+ * that feedback up with (`GET /feedbacks?filter={"where":{"sdkSessionId":"<sessionId>"}}`).
239
+ * A session that closes again keeps that one feedback: the API updates it.
240
+ * - `open`: the API acknowledged the session's first batch; its events keep accumulating.
241
+ * - `closed`: the API acknowledged the session's closing batch (`completed: true`); the
242
+ * feedback is created from it within seconds.
243
+ */
244
+ interface FeedbackSession {
245
+ sessionId: string;
246
+ status: 'open' | 'closed';
247
+ }
229
248
  interface DeepdotsInitParams {
230
249
  /** API key for authentication */
231
250
  apiKey?: string;
@@ -261,6 +280,17 @@ interface DeepdotsInitParams {
261
280
  * logged when `debug` is true.
262
281
  */
263
282
  analytics?: AnalyticsKeys;
283
+ /**
284
+ * Called when the analytics channel opens or closes a session (needs `analytics`), with the
285
+ * id the Deepdots API stores as `sdkSessionId` on the feedback the session becomes: send it
286
+ * to your backend to attach data to that feedback later. A session whose only batch is the
287
+ * closing one reports just `closed`. `closed` does not come when the page unloads before the
288
+ * closing request returns, for a session dropped after 30 min hidden, nor when the closing
289
+ * request fails (the API closes those itself, later): their id already came with `open`. Key
290
+ * by `sessionId`, not by order: the next session's `open` can arrive before the previous
291
+ * one's `closed`. Same value as `getFeedbackSessionId()` while the session is open.
292
+ */
293
+ onFeedbackSession?: (session: FeedbackSession) => void;
264
294
  /**
265
295
  * IP geolocation (country/city) added to analytics. Default `true`. The lookup calls
266
296
  * third-party services (ipapi.co, then ipwho.is, then ipinfo.io as fallbacks, 3 s timeout
@@ -698,6 +728,8 @@ declare class DeepdotsPopups {
698
728
  private analytics;
699
729
  /** feedbackSessionId cacheado del canal de analytics (devuelto por POST /sdk/feedback). */
700
730
  private analyticsFeedbackSessionId;
731
+ /** `init({ onFeedbackSession })`: avisa al host al abrir y cerrar cada registro. */
732
+ private onFeedbackSession;
701
733
  /** Timer del flush periódico de analytics (cada ANALYTICS_FLUSH_INTERVAL_MS). */
702
734
  private analyticsFlushTimer;
703
735
  /** Crash & error reporting (#14–17). Null hasta init(). */
@@ -741,6 +773,15 @@ declare class DeepdotsPopups {
741
773
  getUserId(): string | null;
742
774
  /** Session id de navegación actual. Null si tracking off. */
743
775
  getSessionId(): string | null;
776
+ /**
777
+ * Id del registro de analytics abierto: el `sessionId` que devolvió `POST /sdk/feedback`,
778
+ * que la API guarda como `sdkSessionId` en el Feedback en que se convierte la sesión. No es
779
+ * `getSessionId()`. Null hasta que el backend acepta el primer lote y de nuevo al cerrar la
780
+ * sesión: para saber también qué registro se cerró, usa `init({ onFeedbackSession })`.
781
+ */
782
+ getFeedbackSessionId(): string | null;
783
+ /** Avisa al host del registro abierto o cerrado; un fallo del host no corta el envío. */
784
+ private notifyFeedbackSession;
744
785
  /** Activa/desactiva el tracking (identidad + sesión + analytics). Kill-switch del contrato §7bis. */
745
786
  setTrackingEnabled(enabled: boolean): void;
746
787
  /** Registra un evento de analítica (modelo GA: nombre + params). No-op si tracking off. */
@@ -1265,4 +1306,4 @@ declare function collectRnDevice(d: DeviceInfoLike): DeviceInfo;
1265
1306
  */
1266
1307
  declare function setupReactNative(sdk: DeepdotsPopups, config: DeepdotsInitParams, deps?: ReactNativeSetupDeps): () => void;
1267
1308
 
1268
- export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, BrowserPopupRenderer, type BuildBodyOptions, type ContactAttributeValue, type ContactAttributes, type ContactBody, ContactManager, type CrashRecord, CrashReporter, type CrashSeverity, type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, type DeepdotsInitParams, type DeepdotsLogger, DeepdotsPopups, type DeviceInfo, type DeviceInfoLike, type DeviceSnapshot, type EventListener, type FeedbackKV, InMemoryStorage, type KeyValueStorage, LABELS, MAX_TRACKED_MESSAGES, MESSAGE_CHANNELS, type MessageChannel, MessageGuard, type MessageGuardVerdict, type MessageRejectionReason, type MessageStage, type MmkvLike, NATIVE_READY_GRACE_MS, NoopPopupRenderer, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupLabels, type PopupLocale, type PopupRenderer, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, REVEAL_TIMEOUT_MS, RTL_LOCALES, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type ReportErrorOptions, type ResolvedActionLabels, SUPPORTED_LANGUAGES, type SessionEndReason, type TrackMessageOptions, type TriggerConfig, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, directionFor, getLabels, isRtlLanguage, mmkvStorage, resolveActionLabels, resolveLocale, setupReactNative };
1309
+ export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, BrowserPopupRenderer, type BuildBodyOptions, type ContactAttributeValue, type ContactAttributes, type ContactBody, ContactManager, type CrashRecord, CrashReporter, type CrashSeverity, type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, type DeepdotsInitParams, type DeepdotsLogger, DeepdotsPopups, type DeviceInfo, type DeviceInfoLike, type DeviceSnapshot, type EventListener, type FeedbackKV, type FeedbackSession, InMemoryStorage, type KeyValueStorage, LABELS, MAX_TRACKED_MESSAGES, MESSAGE_CHANNELS, type MessageChannel, MessageGuard, type MessageGuardVerdict, type MessageRejectionReason, type MessageStage, type MmkvLike, NATIVE_READY_GRACE_MS, NoopPopupRenderer, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupLabels, type PopupLocale, type PopupRenderer, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, REVEAL_TIMEOUT_MS, RTL_LOCALES, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type ReportErrorOptions, type ResolvedActionLabels, SUPPORTED_LANGUAGES, type SessionEndReason, type TrackMessageOptions, type TriggerConfig, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, directionFor, getLabels, isRtlLanguage, mmkvStorage, resolveActionLabels, resolveLocale, setupReactNative };