@datalyr/web
Version:
Datalyr Web SDK - Modern attribution tracking for web applications
66 lines • 1.66 kB
TypeScript
/**
* Identity Management Module
* Handles anonymous_id, user_id, and identity resolution
*/
export declare class IdentityManager {
private anonymousId;
private userId;
private sessionId;
constructor();
/**
* Get or create anonymous ID (device/browser identifier)
*/
private getOrCreateAnonymousId;
/**
* Set a root domain cookie for cross-subdomain tracking
*/
private setRootDomainCookie;
/**
* Get stored user ID from previous session
*/
private getStoredUserId;
/**
* Get the anonymous ID
*/
getAnonymousId(): string;
/**
* Get the user ID (if identified)
*/
getUserId(): string | null;
/**
* Get the distinct ID (primary identifier)
* Returns user_id if identified, otherwise anonymous_id
*/
getDistinctId(): string;
/**
* Get canonical ID (alias for distinct_id)
*/
getCanonicalId(): string;
/**
* Set the session ID
*/
setSessionId(sessionId: string): void;
/**
* Get the session ID
*/
getSessionId(): string | null;
/**
* Identify a user
* Links anonymous_id to user_id
*/
identify(userId: string, traits?: Record<string, any>): Record<string, any>;
/**
* Alias one ID to another
*/
alias(userId: string, previousId?: string): Record<string, any>;
/**
* Reset the current user (on logout)
* Clears user_id but keeps anonymous_id
*/
reset(): void;
/**
* Get all identity fields for event payload
*/
getIdentityFields(): Record<string, any>;
}
//# sourceMappingURL=identity.d.ts.map