@magicfeedback/popup-sdk 1.8.5 → 1.10.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.
@@ -122,6 +122,19 @@ interface DeepdotsLogger {
122
122
  error?: (...args: unknown[]) => void;
123
123
  info?: (...args: unknown[]) => void;
124
124
  }
125
+ /**
126
+ * A session of the analytics channel as the Deepdots API sees it. Every session becomes ONE
127
+ * feedback, and `sessionId` is what the API stores as `sdkSessionId` on it: the value to look
128
+ * that feedback up with (`GET /feedbacks?filter={"where":{"sdkSessionId":"<sessionId>"}}`).
129
+ * A session that closes again keeps that one feedback: the API updates it.
130
+ * - `open`: the API acknowledged the session's first batch; its events keep accumulating.
131
+ * - `closed`: the API acknowledged the session's closing batch (`completed: true`); the
132
+ * feedback is created from it within seconds.
133
+ */
134
+ interface FeedbackSession {
135
+ sessionId: string;
136
+ status: 'open' | 'closed';
137
+ }
125
138
  interface DeepdotsInitParams {
126
139
  /** API key for authentication */
127
140
  apiKey?: string;
@@ -157,6 +170,17 @@ interface DeepdotsInitParams {
157
170
  * logged when `debug` is true.
158
171
  */
159
172
  analytics?: AnalyticsKeys;
173
+ /**
174
+ * Called when the analytics channel opens or closes a session (needs `analytics`), with the
175
+ * id the Deepdots API stores as `sdkSessionId` on the feedback the session becomes: send it
176
+ * to your backend to attach data to that feedback later. A session whose only batch is the
177
+ * closing one reports just `closed`. `closed` does not come when the page unloads before the
178
+ * closing request returns, for a session dropped after 30 min hidden, nor when the closing
179
+ * request fails (the API closes those itself, later): their id already came with `open`. Key
180
+ * by `sessionId`, not by order: the next session's `open` can arrive before the previous
181
+ * one's `closed`. Same value as `getFeedbackSessionId()` while the session is open.
182
+ */
183
+ onFeedbackSession?: (session: FeedbackSession) => void;
160
184
  /**
161
185
  * IP geolocation (country/city) added to analytics. Default `true`. The lookup calls
162
186
  * third-party services (ipapi.co, then ipwho.is, then ipinfo.io as fallbacks, 3 s timeout
@@ -392,6 +416,8 @@ declare class DeepdotsPopups {
392
416
  private analytics;
393
417
  /** feedbackSessionId cacheado del canal de analytics (devuelto por POST /sdk/feedback). */
394
418
  private analyticsFeedbackSessionId;
419
+ /** `init({ onFeedbackSession })`: avisa al host al abrir y cerrar cada registro. */
420
+ private onFeedbackSession;
395
421
  /** Timer del flush periódico de analytics (cada ANALYTICS_FLUSH_INTERVAL_MS). */
396
422
  private analyticsFlushTimer;
397
423
  /** Crash & error reporting (#14–17). Null hasta init(). */
@@ -435,6 +461,15 @@ declare class DeepdotsPopups {
435
461
  getUserId(): string | null;
436
462
  /** Session id de navegación actual. Null si tracking off. */
437
463
  getSessionId(): string | null;
464
+ /**
465
+ * Id del registro de analytics abierto: el `sessionId` que devolvió `POST /sdk/feedback`,
466
+ * que la API guarda como `sdkSessionId` en el Feedback en que se convierte la sesión. No es
467
+ * `getSessionId()`. Null hasta que el backend acepta el primer lote y de nuevo al cerrar la
468
+ * sesión: para saber también qué registro se cerró, usa `init({ onFeedbackSession })`.
469
+ */
470
+ getFeedbackSessionId(): string | null;
471
+ /** Avisa al host del registro abierto o cerrado; un fallo del host no corta el envío. */
472
+ private notifyFeedbackSession;
438
473
  /** Activa/desactiva el tracking (identidad + sesión + analytics). Kill-switch del contrato §7bis. */
439
474
  setTrackingEnabled(enabled: boolean): void;
440
475
  /** Registra un evento de analítica (modelo GA: nombre + params). No-op si tracking off. */
@@ -122,6 +122,19 @@ interface DeepdotsLogger {
122
122
  error?: (...args: unknown[]) => void;
123
123
  info?: (...args: unknown[]) => void;
124
124
  }
125
+ /**
126
+ * A session of the analytics channel as the Deepdots API sees it. Every session becomes ONE
127
+ * feedback, and `sessionId` is what the API stores as `sdkSessionId` on it: the value to look
128
+ * that feedback up with (`GET /feedbacks?filter={"where":{"sdkSessionId":"<sessionId>"}}`).
129
+ * A session that closes again keeps that one feedback: the API updates it.
130
+ * - `open`: the API acknowledged the session's first batch; its events keep accumulating.
131
+ * - `closed`: the API acknowledged the session's closing batch (`completed: true`); the
132
+ * feedback is created from it within seconds.
133
+ */
134
+ interface FeedbackSession {
135
+ sessionId: string;
136
+ status: 'open' | 'closed';
137
+ }
125
138
  interface DeepdotsInitParams {
126
139
  /** API key for authentication */
127
140
  apiKey?: string;
@@ -157,6 +170,17 @@ interface DeepdotsInitParams {
157
170
  * logged when `debug` is true.
158
171
  */
159
172
  analytics?: AnalyticsKeys;
173
+ /**
174
+ * Called when the analytics channel opens or closes a session (needs `analytics`), with the
175
+ * id the Deepdots API stores as `sdkSessionId` on the feedback the session becomes: send it
176
+ * to your backend to attach data to that feedback later. A session whose only batch is the
177
+ * closing one reports just `closed`. `closed` does not come when the page unloads before the
178
+ * closing request returns, for a session dropped after 30 min hidden, nor when the closing
179
+ * request fails (the API closes those itself, later): their id already came with `open`. Key
180
+ * by `sessionId`, not by order: the next session's `open` can arrive before the previous
181
+ * one's `closed`. Same value as `getFeedbackSessionId()` while the session is open.
182
+ */
183
+ onFeedbackSession?: (session: FeedbackSession) => void;
160
184
  /**
161
185
  * IP geolocation (country/city) added to analytics. Default `true`. The lookup calls
162
186
  * third-party services (ipapi.co, then ipwho.is, then ipinfo.io as fallbacks, 3 s timeout
@@ -392,6 +416,8 @@ declare class DeepdotsPopups {
392
416
  private analytics;
393
417
  /** feedbackSessionId cacheado del canal de analytics (devuelto por POST /sdk/feedback). */
394
418
  private analyticsFeedbackSessionId;
419
+ /** `init({ onFeedbackSession })`: avisa al host al abrir y cerrar cada registro. */
420
+ private onFeedbackSession;
395
421
  /** Timer del flush periódico de analytics (cada ANALYTICS_FLUSH_INTERVAL_MS). */
396
422
  private analyticsFlushTimer;
397
423
  /** Crash & error reporting (#14–17). Null hasta init(). */
@@ -435,6 +461,15 @@ declare class DeepdotsPopups {
435
461
  getUserId(): string | null;
436
462
  /** Session id de navegación actual. Null si tracking off. */
437
463
  getSessionId(): string | null;
464
+ /**
465
+ * Id del registro de analytics abierto: el `sessionId` que devolvió `POST /sdk/feedback`,
466
+ * que la API guarda como `sdkSessionId` en el Feedback en que se convierte la sesión. No es
467
+ * `getSessionId()`. Null hasta que el backend acepta el primer lote y de nuevo al cerrar la
468
+ * sesión: para saber también qué registro se cerró, usa `init({ onFeedbackSession })`.
469
+ */
470
+ getFeedbackSessionId(): string | null;
471
+ /** Avisa al host del registro abierto o cerrado; un fallo del host no corta el envío. */
472
+ private notifyFeedbackSession;
438
473
  /** Activa/desactiva el tracking (identidad + sesión + analytics). Kill-switch del contrato §7bis. */
439
474
  setTrackingEnabled(enabled: boolean): void;
440
475
  /** Registra un evento de analítica (modelo GA: nombre + params). No-op si tracking off. */