UNPKG

@yext/analytics

Version:

An analytics library for Yext

180 lines 7.46 kB
import { Action } from './Action'; import { Coordinates } from './Coordinates'; import { VersionLabel } from './VersionLabel'; /** * The payload accepted by the Analytics Events API. * * @public */ export interface EventPayload { /** The user action which caused the event, e.g. ADD_TO_CART, THUMBS_UP, C_CUSTOM_ACTION */ action?: Action; /** The authorization token for the request. This will be setup from the Key or Bearer in the config. */ authorization?: string; /** Whether the event is the result of bot activity. * * If not specified the system will automatically detect whether * this event originates from a bot. */ bot?: boolean; /** Information about the visitors device and browser. * * If not specified the system will automatically detect * the values from request headers or `userAgent` property. */ browserAgent?: { /** The browser associated with the event. */ browser?: string; /** The browser version associated with the event. */ browserVersion?: string; /** The device associated with the event. */ device?: string; /** The device class associated with the event. */ deviceClass?: string; /** The operating system associated with the event. */ os?: string; /** The operating system version associated with the event. */ osVersion?: string; /** The user agent associated with the event. */ userAgent?: string; }; /** Fields specific to reporting Chat Analytics Events */ chat?: { /** The ID of the bot that generated the event. */ botId: string; /** The ID of the conversation in which the event occurred. */ conversationId?: string; /** The ID of the individual response in which the event occurred. */ responseId?: string; }; /** * For the Yext client SDKs involved in the event, this is an object mapping * the names of those SDKs to the version labels of those SDKs. */ clientSdk?: Record<string, string>; /** * When the record summarizes multiple events, the number of events the record represents. * The event is treated as if it is duplicated this many times. */ count?: number; /** * Up to 10 pairs matching custom string keys to string values to associate with the event. * Keys are case-insensitive; values are case-sensitive. */ customTags?: Record<string, string>; /** * Up to 10 pairs matching custom string keys to number values to associate with the event. * Keys are case-insensitive. */ customValues?: Record<string, number>; /** The URL of the page the event is directing the visitor to. */ destinationUrl?: string; /** The Yext entity to which the event corresponds. If passed as a string, the value is * the mutable, customer-settable entity ID for the entity associated with the event. * If passed as a number, it is the immutable entity ID (UID) set by the system. This is an internal ID. */ entity?: string | number; /** Indicates whether the event is the result of internal activity. */ internalUser?: boolean; /** The IP address for the event.*/ ip?: { /** The IPv4 address associated with the event. * * If not specified the system will use the Source IP address * from the autogenerated IP header of the request. */ address: string; /** The algorithm to use to anonymize the IP address after collection. */ algorithm: string; }; /** A label assigned to the event, e.g. a CTA label. */ label?: string; /** The locale of the user who generated the event. * * If not specified the system will automatically * determine the locale from the autogenerated Accept-Language header. */ locale?: string; /** The location information of the visitor for the event. * Either a Coordinates object with both latitude and longitude or a string * with the country of the visitor for the event, as a ISO 3166-1 alpha-2 country code. * For more information see https://www.iso.org/iso-3166-country-codes.html. * * If not specified the system will automatically * determine all location information from the request's IP address, * or the value of the `ip` property if specified. */ location?: Coordinates | string; /** Fields specific to reporting Yext Pages Analytics Events */ pages?: { /** The scope of an action. Applies to Pages events. */ scope?: string; /** The Event name as it was used in previous analytics implementations. */ originalEventName?: string; siteUid?: number; template?: string; }; /** The URL of the page where the event occurred. * * If not specified the system will automatically use document.URL */ pageUrl?: string; /** The URL of the page which the visitor came from prior to the event. * * If not specified the system will automatically use document.referrer */ referrerUrl?: string; /** Fields specific to reporting Yext Search Analytics Events */ search?: { /** Unique identifier of the search */ searchId?: string; /** Unique identifier for a single query across pagination */ queryId?: string; /** The vertical key on which the event occurred, if any */ verticalKey?: string; /** Whether or not the event occurred on a direct answer card */ isDirectAnswer?: boolean; /** The label of the version number of the search config. Either "PRODUCTION" or "STAGING" */ versionLabel?: VersionLabel; /** The version number of the search config */ versionNumber?: number; /** The identifier of the search experience. */ experienceKey: string; /** Whether or not the event occurred on a generative direct answer card */ isGenerativeDirectAnswer?: boolean; }; /** The query entered by the user. */ searchTerm?: string; /** Unique identifier to tie together events in a single browsing session */ sessionId?: string | null; /** The timestamp at which the event occurred, in ISO format. * For example, September 27, 2022 at 6 p.m. is represented as * 2022-09-27 18:00:00.000. * For more information, see https://www.iso.org/iso-8601-date-and-time-format.html. * * If not specified the system will automatically * use the time when the request was received in UTC as the event timestamp. */ timestamp?: Date | string; /** The monetary value of the event. */ value?: { /** The monetary value. */ amount: number; /** The ISO 4217 currency code of the currency the value is expressed in. * For example, "USD" for US dollars. * * For more information see https://www.iso.org/iso-4217-currency-codes.html. */ currency: string; }; /** * Information used to associate analytics with a particular user. * * @remarks * Keys are visitor methods and values are visitor IDs. * Key pattern: `^[a-zA-Z0-9_-]{1,16}$`. * Value pattern: `^[\x20-\x7E]{1,64}$` * * @public */ visitor?: Record<string, string>; } //# sourceMappingURL=EventPayload.d.ts.map