@objectiv/plugin-root-location-context-from-url
Version:
Plugin for Objectiv trackers to automatically generate and attach RootLocationContext from URLs
37 lines (33 loc) • 1.52 kB
TypeScript
import { TrackerPluginInterface, ContextsConfig } from '@objectiv/tracker-core';
/**
* This function is invoked by the Plugin to retrieve the identifier of the RootLocationContext unless a custom one
* has been specified. The resulting identifier is normalized.
*/
declare const makeRootLocationId: () => string | null;
/**
* The configuration object of RootLocationContextFromURLPlugin.
*/
declare type RootLocationContextFromURLPluginConfig = {
idFactoryFunction?: typeof makeRootLocationId;
};
/**
* The RootLocationContextFromURL Plugin factors a RootLocationContext out of the first slug of the current URL.
* RootLocationContext is validated by OpenTaxonomyValidationPlugin in Core Tracker.
*/
declare class RootLocationContextFromURLPlugin implements TrackerPluginInterface {
readonly pluginName = "RootLocationContextFromURLPlugin";
readonly idFactoryFunction: typeof makeRootLocationId;
/**
* The constructor is merely responsible for processing the given TrackerPluginConfiguration.
*/
constructor(config?: RootLocationContextFromURLPluginConfig);
/**
* Generate a fresh RootLocationContext before each TrackerEvent is handed over to the TrackerTransport.
*/
enrich(contexts: Required<ContextsConfig>): void;
/**
* Make this plugin usable only on web, eg: Document and Location APIs are both available
*/
isUsable(): boolean;
}
export { RootLocationContextFromURLPlugin, RootLocationContextFromURLPluginConfig, makeRootLocationId };