DeepdotsEventType
Event types emitted by the SDK.
export type DeepdotsEventType =
| 'popup_shown'
| 'popup_clicked'
| 'survey_completed';
Event Types
Fired when a popup is displayed to the user
Fired when a user clicks on any action within the popup
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
The ID of the survey associated with this event
Unix timestamp (in milliseconds) when the event occurred
Additional event-specific data
EventListener
Callback function type for handling SDK events.
export type EventListener = (event: DeepdotsEvent) => void;
Parameters
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);