feedlet-widget
Version:
Lightweight JavaScript widget for capturing user feedback and exit-intent surveys
99 lines (98 loc) • 2.64 kB
TypeScript
export interface FeedLetConfig {
projectId: string;
apiUrl?: string;
supabaseUrl?: string;
supabaseKey?: string;
color?: string;
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
enableExitIntent?: boolean;
enableFeedback?: boolean;
enableContextualFeedback?: boolean;
exitIntentSensitivity?: number;
dashboardUrl?: string;
customTexts?: {
feedbackButton?: string;
feedbackTitle?: string;
feedbackPlaceholder?: string;
exitSurveyTitle?: string;
exitSurveyQuestion?: string;
submitButton?: string;
cancelButton?: string;
contextualModeButton?: string;
contextualInstructions?: string;
};
}
export interface FeedbackReport {
type: 'bug' | 'idea' | 'other';
note: string;
screenshot_url?: string;
screenshots?: string[];
page_url: string;
user_agent: string;
project_id: string;
position_x?: number;
position_y?: number;
element_selector?: string;
element_text?: string;
viewport_width?: number;
viewport_height?: number;
scroll_x?: number;
scroll_y?: number;
is_contextual?: boolean;
contact_email?: string;
notify_on_update?: boolean;
}
export interface ExitSurvey {
question: string;
answer: string;
page_url: string;
user_agent: string;
project_id: string;
screenshots?: string[];
contact_email?: string;
notify_on_update?: boolean;
}
export interface WidgetEvents {
'feedback-submitted': FeedbackReport;
'exit-survey-submitted': ExitSurvey;
'widget-opened': {
type: 'feedback' | 'exit-survey' | 'contextual';
};
'widget-closed': {
type: 'feedback' | 'exit-survey' | 'contextual';
};
'contextual-mode-enabled': {};
'contextual-mode-disabled': {};
}
export interface ContextualMarker {
id: string;
x: number;
y: number;
element: HTMLElement | null;
elementSelector: string;
elementText: string;
timestamp: number;
}
export interface ViewportInfo {
width: number;
height: number;
scrollX: number;
scrollY: number;
}
export interface WidgetState {
isVisible: boolean;
isModalOpen: boolean;
modalType: 'feedback' | 'exit-survey' | null;
isSubmitting: boolean;
}
export interface ScreenshotOptions {
quality?: number;
format?: 'png' | 'jpeg';
backgroundColor?: string;
}
export type EventType = 'feedback-submitted' | 'exit-survey-submitted' | 'widget-opened' | 'widget-closed';
export interface FeedLetEvent {
type: EventType;
data?: any;
timestamp: number;
}