@datalyr/web
Version:
Datalyr Web SDK - Modern attribution tracking for web applications
175 lines • 3.89 kB
TypeScript
/**
* Datalyr Web SDK
* Modern attribution tracking for web applications
*/
import type { DatalyrConfig, EventProperties, UserTraits, PageProperties, SessionData, Attribution, TouchPoint, ConsentConfig, NetworkStatus, ErrorInfo } from './types';
export * from './types';
declare class Datalyr {
private config;
private identity;
private session;
private attribution;
private queue;
private fingerprint;
private cookies;
private container?;
private superProperties;
private userProperties;
private optedOut;
private initialized;
private errors;
private MAX_ERRORS;
private heavyFingerprintCollected;
constructor();
/**
* Initialize the SDK
*/
init(config: DatalyrConfig): void;
/**
* Track an event
*/
track(eventName: string, properties?: EventProperties): void;
/**
* Identify a user
*/
identify(userId: string, traits?: UserTraits): void;
/**
* Track a page view
*/
page(properties?: PageProperties): void;
/**
* Track a screen view (for SPAs)
*/
screen(screenName: string, properties?: Record<string, any>): void;
/**
* Associate user with a group/account
*/
group(groupId: string, traits?: Record<string, any>): void;
/**
* Alias one ID to another
*/
alias(userId: string, previousId?: string): void;
/**
* Reset the current user
*/
reset(): void;
/**
* Get the current anonymous ID
*/
getAnonymousId(): string;
/**
* Get the current user ID
*/
getUserId(): string | null;
/**
* Get the distinct ID
*/
getDistinctId(): string;
/**
* Get the current session ID
*/
getSessionId(): string;
/**
* Start a new session manually
*/
startNewSession(): string;
/**
* Get session data
*/
getSessionData(): SessionData | null;
/**
* Get current attribution data
*/
getAttribution(): Attribution;
/**
* Get customer journey
*/
getJourney(): TouchPoint[];
/**
* Set attribution manually
*/
setAttribution(attribution: Partial<Attribution>): void;
/**
* Opt out of tracking
*/
optOut(): void;
/**
* Opt in to tracking
*/
optIn(): void;
/**
* Check if user has opted out
*/
isOptedOut(): boolean;
/**
* Set consent preferences
*/
setConsent(consent: ConsentConfig): void;
/**
* Manually flush the event queue
*/
flush(): Promise<void>;
/**
* Set super properties
*/
setSuperProperties(properties: Record<string, any>): void;
/**
* Unset a super property
*/
unsetSuperProperty(propertyName: string): void;
/**
* Get super properties
*/
getSuperProperties(): Record<string, any>;
/**
* Create event payload
*/
private createEventPayload;
/**
* Check if we should track
*/
private shouldTrack;
/**
* Setup SPA tracking
*/
private setupSPATracking;
/**
* Setup page unload handler
*/
private setupUnloadHandler;
/**
* Get performance metrics
*/
private getPerformanceMetrics;
/**
* Track error
*/
private trackError;
/**
* Get errors
*/
getErrors(): ErrorInfo[];
/**
* Get network status
*/
getNetworkStatus(): NetworkStatus;
/**
* Load a container script by ID
*/
loadScript(scriptId: string): void;
/**
* Get loaded container scripts
*/
getLoadedScripts(): string[];
/**
* Debug logging
*/
private log;
/**
* Destroy the SDK instance and cleanup resources
*/
destroy(): void;
}
declare const datalyr: Datalyr;
export default datalyr;
//# sourceMappingURL=index.d.ts.map