import type { EventData, IntegrationOptions, LoadIntegrationEventData, PageviewEventData, SetUserEventData, TrackEventData, TrackTypesValues } from '@farfetch/blackout-analytics'; import type { OPTION_DATA_LAYER_NAME, OPTION_ENABLE_AUTOMATIC_PAGE_VIEWS, OPTION_GOOGLE_CONSENT_CONFIG, OPTION_LOAD_SCRIPT_FUNCTION, OPTION_MEASUREMENT_ID, OPTION_NON_INTERACTION_EVENTS, OPTION_ON_PRE_PROCESS_COMMANDS, OPTION_PRODUCT_MAPPINGS, OPTION_SCHEMAS, OPTION_SCOPE_COMMANDS, OPTION_SET_CUSTOM_USER_ID_PROPERTY } from '../constants.js'; import type { Schema } from '../../shared/types/shared.types.js'; import { type GoogleConsentModeConfig } from '../../shared/index.js'; export type Schemas = Record; export interface GA4IntegrationOptions extends IntegrationOptions { [OPTION_MEASUREMENT_ID]: string; [OPTION_ENABLE_AUTOMATIC_PAGE_VIEWS]?: boolean; [OPTION_NON_INTERACTION_EVENTS]?: NonInteractionEvents; [OPTION_PRODUCT_MAPPINGS]?: ProductMappings; [OPTION_SCOPE_COMMANDS]?: ScopeCommands; [OPTION_SCHEMAS]?: Schemas; [OPTION_SET_CUSTOM_USER_ID_PROPERTY]?: boolean; [OPTION_DATA_LAYER_NAME]?: string; [OPTION_LOAD_SCRIPT_FUNCTION]?: () => Promise; [OPTION_ON_PRE_PROCESS_COMMANDS]?: OnPreProcessCommandsHandler; [OPTION_GOOGLE_CONSENT_CONFIG]?: GoogleConsentModeConfig; } export type ProductMappings = Record; export type NonInteractionEvents = Record; export type OnPreProcessCommandsHandler = (commandList: GA4CommandList, data: EventData | SetUserEventData | LoadIntegrationEventData) => GA4CommandList; export type GA4CommandList = GA4Command[]; export type GA4Command = [command: string, ...args: unknown[]]; export type EventScopeCommandsHandlers = { extras?: (data: TrackEventData) => GA4CommandList; main?: (data: TrackEventData, productMappings?: ProductMappings) => GA4CommandList; }; type EventScopeCommands = { [eventName: string]: EventScopeCommandsHandlers; }; export type PageviewScopeExtrasCommandsHandler = { extras: (data: PageviewEventData) => GA4CommandList; }; export type UserScopeCommandsHandler = (data: SetUserEventData | LoadIntegrationEventData) => GA4CommandList; export type ScopeCommands = { user?: UserScopeCommandsHandler; pageview?: PageviewScopeExtrasCommandsHandler; event?: EventScopeCommands; }; export {};