visitory
Version:
Visitory Session Tracking SDK
92 lines (91 loc) • 2.46 kB
TypeScript
import React from 'react';
export interface TrackedAction {
type: string;
element?: string;
elementId?: string;
elementClass?: string;
path?: string;
timestamp: number;
x?: number;
y?: number;
details?: Record<string, any>;
}
export interface InsightfulConfig {
/**
* The URL of your Convex backend
* @default "https://qualified-hound-398.convex.site"
*/
convexUrl?: string;
/**
* Your API key from the Visitory dashboard
*/
apiKey: string;
}
export interface ParameterValue {
value: string | number | boolean | null;
lastUpdated: number;
}
export interface ParameterStore {
[key: string]: ParameterValue;
}
export interface InsightfulButtonProps {
/**
* Text to display on the button
* @default "Click Me"
*/
text?: string;
/**
* Optional ID for the button element
*/
id?: string;
/**
* Optional CSS class name
*/
className?: string;
/**
* Optional click handler (will be called in addition to the default "hello" logger)
*/
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
/**
* Optional button style
* @default "primary"
*/
variant?: 'primary' | 'secondary' | 'danger';
/**
* Optional size variant
* @default "medium"
*/
size?: 'small' | 'medium' | 'large';
/**
* Optional disabled state
* @default false
*/
disabled?: boolean;
/**
* Optional: Enable action tracking on the page
* @default true
*/
enableTracking?: boolean;
}
/**
* InsightfulButton - A React button component that logs "hello" when clicked
* and tracks user actions
*/
export declare function initInsightful(configuration: InsightfulConfig): Promise<void>;
/**
* Track a user action
*/
export declare function trackAction(type: string, details?: Record<string, any>): void;
/**
* Get all tracked actions
*/
export declare function getTrackedActions(): TrackedAction[];
/**
* Clear tracked actions
*/
export declare function clearTrackedActions(): void;
export declare function getParameterStore(key: string): string | number | boolean | null;
export declare function setParameterStore(key: string, value: string | number | boolean): Promise<void>;
export declare function syncParameters(): Promise<void>;
export declare const InsightfulButton: React.FC<InsightfulButtonProps>;
export default InsightfulButton;