import { RpcMethod } from './commonTypes'; export type EventsService_Get = RpcMethod; export type EventsService_List = RpcMethod; export type EventsService_Create = RpcMethod; export type EventsService_Update = RpcMethod; export type EventsService_Delete = RpcMethod; export type EventsService_GetAttributeValues = RpcMethod; export type EventsService_GetTriggeredCount = RpcMethod; export type EventsService_GetDetailedStatistics = RpcMethod; export type EventsService_GetTotalStatistics = RpcMethod; export interface EventsService { /** Returns one custom event by name for an application, including its attributes, store-days and revenue mapping. Use after list_events to inspect a single event's definition. */ Get: EventsService_Get; /** Lists an application's custom events (ordered by name or creation) with paging and an optional revenue-only filter. Use to browse events or find an event name before get_event or the statistics calls. */ List: EventsService_List; /** Creates a new custom event in an application with its attributes and optional revenue mapping. Fails if an event with the same name already exists; use update_event to change an existing one. */ Create: EventsService_Create; /** Overwrites a custom event's description, attribute set and revenue mapping (the name is immutable). Fully replaces the attribute list, so resend every attribute you want to keep. */ Update: EventsService_Update; /** Deletes a custom event and its attributes from an application. Fails if the event is still referenced by a filter/segment or in-app trigger; not undoable. */ Delete: EventsService_Delete; /** Returns distinct recorded values of one attribute of a custom event, with paging and a value search. Use to populate attribute-value pickers when building event-based filters. */ GetAttributeValues: EventsService_GetAttributeValues; /** Returns all-time total and unique triggered counts for the named custom events in an application. Use for a quick per-event volume check; for a time series use get_event_detailed_statistics. */ GetTriggeredCount: EventsService_GetTriggeredCount; /** Returns a triggered-count time series for one custom event over a date range bucketed by interval, with optional attribute conditions. Use to chart how often an event fired over time. */ GetDetailedStatistics: EventsService_GetDetailedStatistics; /** Returns total and unique triggered counts for custom events over a date range, optionally scoped to a message code or campaign. Use to attribute event volume to a specific send or campaign. */ GetTotalStatistics: EventsService_GetTotalStatistics; } export type GetEventRequest = { /** Application code (format XXXXX-XXXXX) the event belongs to. */ application?: string; /** Name of the custom event to fetch. */ name?: string; }; export type EventAttribute_Type = 'UNKNOWN' | 'INTEGER' | 'STRING' | 'LIST' | 'DATE' | 'BOOLEAN' | 'PRICE'; export type EventAttribute = { name: string; type: EventAttribute_Type; }; /** * RevenueMapping maps a source event's attributes onto the normalized * PW_Conversion revenue slots. Each field holds the name of the source * event attribute that feeds the corresponding slot (empty = not mapped). */ export type RevenueMapping = { valueAttr: string; currencyAttr: string; transactionIdAttr: string; productIdAttr: string; }; export type Event = { name: string; description: string; attributes: EventAttribute[]; canDelete: boolean; storeDays: number; trackRevenue: boolean; revenueMapping: RevenueMapping; }; export type ListEventsRequest_OrderBy = 'NAME' | 'CREATED'; export type ListEventsRequest_OrderDirection = 'ASC' | 'DESC'; export type ListEventsRequest = { /** Application code (format XXXXX-XXXXX) whose events to list. */ application?: string; /** Case-insensitive substring match on event name (matches %name%). */ searchByName?: string; orderBy?: ListEventsRequest_OrderBy; orderDirection?: ListEventsRequest_OrderDirection; page?: number; perPage?: number; /** when true, return only revenue-mapped events */ trackRevenueOnly?: boolean; }; export type ListEventsResponse = { events: Event[]; page: number; perPage: number; totalPages: number; total: number; }; export type CreateEventRequest = { /** Name of the custom event to create; must be unique within the application. */ name?: string; /** Application code (format XXXXX-XXXXX) to create the event in. */ application?: string; description?: string; /** Attributes recorded with each event trigger. */ attributes?: EventAttribute[]; revenueMapping?: RevenueMapping; }; export type CreateEventResponse = { name: string; }; export type UpdateEventRequest = { /** Name of the custom event to update (immutable, used to locate the event). */ name?: string; /** Application code (format XXXXX-XXXXX) the event belongs to. */ application?: string; /** new description */ description?: string; /** new event attributes (fully replaces the current set) */ attributes?: EventAttribute[]; /** revenue slot mapping (nil = leave unchanged, empty = clear) */ revenueMapping?: RevenueMapping; }; export type UpdateEventResponse = {}; export type DeleteEventRequest = { /** Name of the custom event to delete. */ name?: string; /** Application code (format XXXXX-XXXXX) the event belongs to. */ application?: string; }; export type DeleteEventResponse = {}; export type GetAttributeValuesRequest = { /** Application code (format XXXXX-XXXXX) the event belongs to. */ application?: string; /** Name of the custom event whose attribute values to return. */ event?: string; /** Name of the event attribute whose recorded values to return. */ attribute?: string; /** Number of values to skip (offset paging). */ skip?: number; /** Maximum number of values to return (defaults to 100). */ limit?: number; /** Free-text filter over the attribute values (not an id). */ search?: string; }; export type GetAttributeValuesResponse = { total: number; values: string[]; }; export type GetTriggeredCountRequest = { /** Application code (format XXXXX-XXXXX) the events belong to. */ application?: string; /** Names of the custom events to count. */ events?: string[]; }; export type GetTriggeredCountResponse_Count = { totalTriggered: number; uniqueTriggered: number; }; export type GetTriggeredCountResponse = { count: Record; }; export type TimeInterval = 'TIME_INTERVAL_UNSPECIFIED' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH'; export type ListOfValues = { values: string[]; }; export type Value_kind_string = { type: 'string'; data: string; }; export type Value_kind_integer = { type: 'integer'; data: number; }; export type Value_kind_float = { type: 'float'; data: number; }; export type Value_kind_bool = { type: 'bool'; data: boolean; }; export type Value_kind_list = { type: 'list'; data: ListOfValues; }; export type Value_kind_timestamp = { type: 'timestamp'; data: Date; }; export type Value_kind = Value_kind_string | Value_kind_integer | Value_kind_float | Value_kind_bool | Value_kind_list | Value_kind_timestamp; export type Value = { kind: Value_kind; }; export type AttributeCondition_Operator = 'OPERATOR_UNSPECIFIED' | 'EQ' | 'NOT_EQ' | 'GTE' | 'LTE' | 'BETWEEN' | 'IN' | 'NOT_IN'; export type AttributeCondition = { name: string; operator: AttributeCondition_Operator; values: Value[]; }; export type GetDetailedStatisticsRequest = { /** Application code (format XXXXX-XXXXX) the event belongs to. */ application?: string; /** Name of the custom event to build the time series for. */ name?: string; dateFrom?: Date; dateTo?: Date; /** Bucket size for the time series (hour, day, week or month). */ interval?: TimeInterval; /** Filter triggers to those whose attributes match these conditions. */ attributeConditions?: AttributeCondition[]; }; export type GetDetailedStatisticsResponse_TriggeredCount = { timestamp: Date; triggeredCount: number; }; export type GetDetailedStatisticsResponse = { metrics: GetDetailedStatisticsResponse_TriggeredCount[]; }; export type GetTotalStatisticsRequest = { /** Application code (format XXXXX-XXXXX) the events belong to. */ application?: string; /** Names of the custom events to count. */ events?: string[]; dateFrom?: Date; dateTo?: Date; /** Message code to attribute event triggers to a single send (transactional sends have no numeric id, so this returns empty). */ messageCode?: string; /** Campaign code to attribute event triggers to a whole campaign. */ campaign?: string; }; export type GetTotalStatisticsResponse_EventTriggeredCount = { event: string; triggeredCount: number; uniqTriggeredCount: number; }; export type GetTotalStatisticsResponse = { metrics: GetTotalStatisticsResponse_EventTriggeredCount[]; };