Skip to main content

DeepdotsEventType

Event types emitted by the SDK.
export type DeepdotsEventType =
    | 'popup_shown'
    | 'popup_clicked'
    | 'survey_completed';

Event Types

popup_shown
string
Fired when a popup is displayed to the user
popup_clicked
string
Fired when a user clicks on any action within the popup
survey_completed
string
Fired when a user completes a survey

DeepdotsEvent

Event payload structure for all SDK events.
export interface DeepdotsEvent {
    type: DeepdotsEventType;
    surveyId: string;
    timestamp: number;
    data?: Record<string, unknown>;
}

Properties

type
DeepdotsEventType
required
The type of event that occurred
surveyId
string
required
The ID of the survey associated with this event
timestamp
number
required
Unix timestamp (in milliseconds) when the event occurred
data
Record<string, unknown>
Additional event-specific data

EventListener

Callback function type for handling SDK events.
export type EventListener = (event: DeepdotsEvent) => void;

Parameters

event
DeepdotsEvent
required
The event object containing event details

Example Usage

import { DeepdotsPopups, DeepdotsEvent } from '@magicfeedback/popup-sdk';

const popups = new DeepdotsPopups();

const handleEvent = (event: DeepdotsEvent) => {
  console.log(`Event: ${event.type}`);
  console.log(`Survey ID: ${event.surveyId}`);
  console.log(`Timestamp: ${new Date(event.timestamp)}`);
  
  if (event.data) {
    console.log('Additional data:', event.data);
  }
};

popups.on('popup_shown', handleEvent);

Build docs developers (and LLMs) love