jattac.react.recents
Version:
A React component and utility for tracking and displaying recent browser locations and URLs.
46 lines (45 loc) • 1.32 kB
TypeScript
import ILocation from './ILocation';
interface ITrackable {
urlOrTitle?: string;
url?: string;
}
export interface OnBrowserLocationTrackerConfig {
maxRecents: number;
namespace?: string;
dontTrack?: {
withPrefix?: ITrackable[];
withSuffix?: ITrackable[];
contains?: ITrackable[];
};
disregardQueryStrings?: {
path: string;
queryStrings: string[];
}[];
}
export declare class OnBrowserLocationTracker {
private storageKey;
private titleObserver;
private config;
private static _namespace;
constructor(config: OnBrowserLocationTrackerConfig);
static get namespace(): string;
private get fullStorageKey();
private getStoredRecents;
private isValid;
private saveRecents;
private shouldTrack;
trackVisit(location: ILocation): Promise<void>;
getRecentsAsync(): Promise<ILocation[]>;
removeRecent(url: string): Promise<void>;
clearRecents(): Promise<void>;
getCurrentLocation(): ILocation | null;
/**
* Processes the URL for tracking, taking into account the disregardQueryStrings configuration.
* @param url The URL to process.
* @returns The processed URL.
*/
private processUrlForTracking;
private observeTitleChange;
private updateLocation;
}
export {};