tiny-utm-keeper
Version:
Zero-dependency, TypeScript-first UTM parameter tracker for first-touch/last-touch attribution. SSR-friendly.
76 lines (75 loc) • 2.13 kB
TypeScript
import { UTMKeeperConfig, UTMParams, AttributionMode } from './types.js';
/**
* UTMKeeper class - Main API
*/
export declare class UTMKeeper {
private config;
constructor(config?: UTMKeeperConfig);
/**
* Capture UTM parameters from URL
*/
capture(url?: string): boolean;
/**
* Get stored UTM parameters
*/
getUTMs(): UTMParams | null;
/**
* Get stored UTM data with metadata
*/
getUTMData(): import("./types.js").StoredUTMData | null;
/**
* Clear stored UTM parameters
*/
clear(): boolean;
/**
* Append stored UTMs to a URL
*/
appendToURL(url: string): string;
/**
* Get UTM parameters as object for API calls
*/
getUTMObject(): Record<string, string>;
/**
* Create a fetch wrapper that automatically injects UTMs
*/
createFetch(): typeof fetch;
/**
* Update configuration
*/
updateConfig(config: Partial<UTMKeeperConfig>): void;
/**
* Get current configuration
*/
getConfig(): Readonly<Required<Omit<UTMKeeperConfig, 'captureUrl'>>>;
/**
* Check if UTMs are currently stored
*/
hasStoredUTMs(): boolean;
/**
* Get attribution mode
*/
getMode(): AttributionMode;
/**
* Set attribution mode
*/
setMode(mode: AttributionMode): void;
}
/**
* Initialize the default UTMKeeper instance
*/
export declare const init: (config?: UTMKeeperConfig) => UTMKeeper;
/**
* Get the default instance (creates one if it doesn't exist)
*/
export declare const getInstance: () => UTMKeeper;
/**
* Convenience functions using the default instance
*/
export declare const capture: (url?: string) => boolean;
export declare const getUTMs: () => UTMParams | null;
export declare const getUTMData: () => import("./types.js").StoredUTMData | null;
export declare const clear: () => boolean;
export declare const appendToURL: (url: string) => string;
export declare const getUTMObject: () => Record<string, string>;
export declare const createFetch: () => typeof fetch;
export declare const hasStoredUTMs: () => boolean;