interface PreInitVeroTracker { init: (options: { trackingApiKey: string; }) => void; } interface ConversionIdStore { get(): string | undefined; } interface SessionStorageConversionIdStoreOptions { keyNamespace: string; } declare class SessionStorageConversionIdStore implements ConversionIdStore { private readonly key; constructor(options: SessionStorageConversionIdStoreOptions); get(): string | undefined; private extractAndStoreFromUrl; } interface LegacySessionCookieConversionIdStoreOptions { cookieDomain?: string; } declare class LegacySessionCookieConversionIdStore implements ConversionIdStore { private static readonly COOKIE_NAME; private readonly cookieDomain?; constructor(options?: LegacySessionCookieConversionIdStoreOptions); get(): string | undefined; private extractAndStoreFromUrl; } interface IdentityStore { save(userId: string, email: string): void; get(): { userId: string; email: string; } | undefined; clear(): void; } interface LocalStorageIdentityStoreOptions { keyNamespace: string; } declare class LocalStorageIdentityStore implements IdentityStore { private readonly userIdKey; private readonly emailKey; constructor(options: LocalStorageIdentityStoreOptions); save(userId: string, email: string): void; get(): { userId: string; email: string; } | undefined; clear(): void; } interface SiteVisitedStore { hasVisited(userId: string): boolean; setVisited(userId: string): void; clear(userId: string): void; } interface SessionStorageSiteVisitedStoreOptions { keyNamespace: string; } declare class SessionStorageSiteVisitedStore implements SiteVisitedStore { private readonly keyNamespace; constructor(options: SessionStorageSiteVisitedStoreOptions); hasVisited(userId: string): boolean; setVisited(userId: string): void; clear(userId: string): void; } interface LegacySessionCookieSiteVisitedStoreOptions { cookieDomain?: string; } declare class LegacySessionCookieSiteVisitedStore implements SiteVisitedStore { private static readonly COOKIE_NAME; private readonly cookieDomain?; constructor(options: LegacySessionCookieSiteVisitedStoreOptions); hasVisited(): boolean; setVisited(): void; clear(): void; } type Optional = Pick, K> & Omit; interface TrackerOptions { /** * The tracking API key of your project. You can find it or create a new one on the Settings page of your * Vero project. * * @see https://connect.getvero.com/settings/project/tracking-api-keys */ trackingApiKey: string; /** * The base URL of the Vero API. * * Some browser content blockers (e.g., uBlock Origin) may block requests to the Vero API. In this case, you can * set up a reverse proxy to the Vero API and set this option to the URL of the reverse proxy. * * @default "https://api.getvero.com" */ trackingApiBaseUrl?: string; /** * When you call {@link Tracker#user.identify}, the user's identity is stored in this {@link IdentityStore}. * * By default, in the browser environment, the {@link LocalStorageIdentityStore} is used. In any other * environment where localStorage is not available (e.g., Node.js), the user identity will not be stored. * * You can implement your own {@link IdentityStore} to store the user identity differently, such as using * `AsyncLocalStorage` in Node.js or Cookies. */ identityStore?: IdentityStore; /** * Controls whether the "visited site" event should be tracked when a user is identified. * * By default, in the browser environment, the {@link SessionStorageSiteVisitedStore} is used. When you call * {@link Tracker#user.identify}, a "visited site" event is tracked against the user if such an event has not * been previously tracked in the current page session. * * This SDK also includes a {@link LegacySessionCookieSiteVisitedStore} that uses Session Cookies to track * "visited site". This is handy if you are migrating from the legacy Vero SDK m.js and want to keep exactly * identical "visited site" event tracking behavior. Here are the differences between the two: * - `sessionStorage` is more reliable in terms of when the session data is cleared, that is, when the tab is closed. * Session Cookies' clearing behavior may vary across browsers and devices. * - `sessionStorage` is more secure as the data will not be sent over the network. Session Cookies are sent over the * network. * - If the user opens a new tab for the same site, they will be in different sessions when using * {@link SessionStorageSiteVisitedStore}, and thus "visited site" events will be tracked again. Session Cookies * are not affected by this. * - The {@link LegacySessionCookieSiteVisitedStore} is not user-id-specific. * * Where possible, we recommend using the default {@link SessionStorageSiteVisitedStore} * instead of {@link LegacySessionCookieSiteVisitedStore}. */ siteVisitedStore?: SiteVisitedStore; /** * Stores the conversion ID extracted from the `vero_conv` query parameter in the URL. * * By default, in the browser environment, the {@link SessionStorageConversionIdStore} is used. * When the SDK is initialized and a `vero_conv` query parameter is present in the URL, * the value is stored in this store and attached to each event tracking request. * * This SDK also includes a {@link LegacySessionCookieConversionIdStore} that uses Session Cookies * to store the conversion ID. This is handy if you are migrating from a legacy setup and want to * keep identical behavior. * * Where possible, we recommend using the default {@link SessionStorageConversionIdStore} * instead of {@link LegacySessionCookieConversionIdStore}. * * @see https://help.getvero.com/vero-1/articles/conversion-tracking/ */ conversionIdStore?: ConversionIdStore; } interface NoSiteVisitEventRequest { /** * Set this to true if you do not want to track a "visited site" event. By default, a "visited site" event is * tracked when a user is identified and the {@link SiteVisitedStore#hasVisited} returns false. */ noSiteVisitEvent?: boolean; } interface UserIdentifyRequest extends NoSiteVisitEventRequest { /** * The unique identifier of the customer * * @example "1000" */ id: string; /** * The email of the customer * * @example "test@example.com" */ email: string; /** * An array containing objects that represent the user's device token. * Each object should represent a single device token and include the fields type, address, and platform. */ channels?: { /** * @example "push" */ type: string; /** * @example "UNIQUE_DEVICE_TOKEN" */ address: string; /** * @example "android" */ platform: string; }[]; /** * An object containing key value pairs that represent the custom user properties you want to update. * * In the browser environment, the `language`, `timezone`, `ianaTimezone` and `userAgent` attributes are reserved * properties that will be automatically populated by the SDK. If any of these attributes are defined in the request, * they will be overwritten by the SDK. * * All other keys are freeform and can be defined by you. * * @example { first_name: "Damien", last_name: "Brzoska", age: 30 } */ data?: Record; } interface OptionalUserIdRequest { /** * The unique identifier of the customer. * * Optional in the browser environment, if `identify` was called prior. * * @example "1000" */ userId?: string; } interface UserAliasRequest extends OptionalUserIdRequest { /** * The new unique identifier of the user * * @example "1001" */ newId: string; } interface UserUnsubscribeRequest extends OptionalUserIdRequest { } interface UserResubscribeRequest extends OptionalUserIdRequest { } interface UserDeleteRequest extends OptionalUserIdRequest { } interface TagEditRequest extends OptionalUserIdRequest { /** * An array of tags to add */ add?: string[]; /** * An array of tags to remove */ remove?: string[]; } interface BaseEventTrackRequest { /** * A valid object containing the keys id and email used to identify the user for which the event is being tracked. * Both email and id must be less than 255 characters, and email must be a valid email address. * * Optional in the browser environment, if `identify` was called prior. */ identity?: { /** * The unique identifier of the customer * @example "1000" */ userId: string; /** * The email of the customer * @example "test@example.com" */ email: string; }; /** * The name of the event tracked. Must be less than 255 characters. * * Capitalized and lowercase letters and spaces and underscores will be treated the same by Vero's API. * For example, `Purchased Item`, `purchased item`, and `purchased_item` will all be matched as one event * in Vero's backend. * * @example "Viewed product" */ eventName: string; /** * An object containing key value pairs that represent the custom user properties you want to track with the event. * All keys are freeform and can be defined by you. * * @example { product_name: "Red T-shirt", product_url: "http://www.yourdomain.com/products/red-t-shirt" } */ data?: Record; /** * An object containing key value pairs that represent the reserved, * Vero-specific `created_at` and `source` properties. * * @see {@link Tracker#event.track} */ extras?: { /** * @example "Segment.com" */ source: string; /** * @example "2023-05-30T04:46:31+0000" */ createdAt: string; /** * Used for conversion tracking. This should be the `vero_conv` query parameter value received on the frontend. * @see https://help.getvero.com/vero-1/articles/conversion-tracking/ */ veroConv?: string; }; } interface EventTrackRequest extends NoSiteVisitEventRequest, Optional { } declare class Tracker { private readonly network; private readonly identityStore; private readonly siteVisitedStore; private readonly conversionIdStore; constructor(options: TrackerOptions); readonly user: { /** * Creates a new user profile if the user doesn't exist yet. * Otherwise, the user profile is updated based on the properties provided. * * This method must be called before calling any other tracking methods, * unless the `userId` parameter is provided in the subsequent calls to other methods. * The identity will be stored in the specified {@link TrackerOptions.identityStore} * (default to using Local Storage in the browser). This means you don't need to call this method every time * the user refreshes the page or navigates to a new page. * * This method will also track a "visited site" event after the user is identified * (only in the browser environment). You can disable this behavior by setting `noSiteVisitEvent` to `true` * in the request. * * @param request {@link UserIdentifyRequest} */ readonly identify: (request: UserIdentifyRequest) => Promise; /** * Removes a user from the {@link TrackerOptions.identityStore}. This is generally used when a user logs out. * * This method does not delete the user from Vero. To delete a user, use {@link Tracker#user.delete}. * * This method does nothing if no {@link Tracker#user.identify} was called. */ readonly unidentify: () => void; /** * Changes a user's identifier (`id`). * * This method is used to merge two user identities, merging two sets of user data into one. * This is an advanced method and may have unintended consequences. * Please get in touch if you have questions regarding its usage. * * @param request {@link UserAliasRequest} */ readonly alias: (request: UserAliasRequest) => Promise; /** * Unsubscribes a user globally. * * @param request {@link UserUnsubscribeRequest} */ readonly unsubscribe: (request?: UserUnsubscribeRequest) => Promise; /** * Resubscribes a user globally. * * @param request {@link UserResubscribeRequest} */ readonly resubscribe: (request?: UserResubscribeRequest) => Promise; /** * Deletes a user. * * @param request {@link UserDeleteRequest} */ readonly delete: (request?: UserDeleteRequest) => Promise; }; readonly tag: { /** * Adds tags to a user's profile or removes tags from a user's profile. * * @param request {@link TagEditRequest} */ readonly edit: (request: TagEditRequest) => Promise; }; readonly event: { /** * Tracks an event for a specific user. * * If `identity` is specified and the user profile doesn't exist, Vero will create it. * * Vero will automatically deduplicate events that are sent to our API with the same `eventName`, * the same properties, and that are tracked against the same user id within a three-minute window. * This is designed to solve issues related to JavaScript event handling and retries. * You can force Vero to ignore deduplication and track every event by including a property within * data with a unique timestamp. This will ensure the event is not seen by the Vero system as * a duplicate due to the unique data. * * If the user has not been identified, a "Visited Site" event will be sent prior to the event being tracked. * You can disable this behavior by setting `noSiteVisitEvent` to `true` in the request. * * @param request {@link EventTrackRequest} */ readonly track: (request: EventTrackRequest) => Promise; }; private sendEventTrackRequest; private getUserId; private getShouldTrackVisitedSiteEvent; } declare const tracker: PreInitVeroTracker & Tracker & { initialized: boolean; }; export { type ConversionIdStore, type EventTrackRequest, type IdentityStore, LegacySessionCookieConversionIdStore, LegacySessionCookieSiteVisitedStore, LocalStorageIdentityStore, type OptionalUserIdRequest, SessionStorageConversionIdStore, SessionStorageSiteVisitedStore, type SiteVisitedStore, type TagEditRequest, Tracker, type TrackerOptions, type UserAliasRequest, type UserDeleteRequest, type UserIdentifyRequest, type UserResubscribeRequest, type UserUnsubscribeRequest, tracker as default };