@optimizely/js-sdk-event-processor
Version:
Optimizely Full Stack Event Processor
72 lines (71 loc) • 2.01 kB
TypeScript
import { EventTags, ConversionEvent, ImpressionEvent } from '../events';
import { ProcessableEvent } from '../eventProcessor';
import { EventV1Request } from '../eventDispatcher';
export declare type EventV1 = {
account_id: string;
project_id: string;
revision: string;
client_name: string;
client_version: string;
anonymize_ip: boolean;
enrich_decisions: boolean;
visitors: Visitor[];
};
declare type Visitor = {
snapshots: Visitor.Snapshot[];
visitor_id: string;
attributes: Visitor.Attribute[];
};
declare namespace Visitor {
type AttributeType = 'custom';
type Attribute = {
entity_id: string;
key: string;
type: AttributeType;
value: string | number | boolean;
};
type Snapshot = {
decisions?: Decision[];
events: SnapshotEvent[];
};
type Decision = {
campaign_id: string | null;
experiment_id: string | null;
variation_id: string | null;
metadata: Metadata;
};
type Metadata = {
flag_key: string;
rule_key: string;
rule_type: string;
variation_key: string;
enabled: boolean;
};
type SnapshotEvent = {
entity_id: string | null;
timestamp: number;
uuid: string;
key: string;
revenue?: number;
value?: number;
tags?: EventTags;
};
}
/**
* Given an array of batchable Decision or ConversionEvent events it returns
* a single EventV1 with proper batching
*
* @param {ProcessableEvent[]} events
* @returns {EventV1}
*/
export declare function makeBatchedEventV1(events: ProcessableEvent[]): EventV1;
/**
* Event for usage with v1 logtier
*
* @export
* @interface EventBuilderV1
*/
export declare function buildImpressionEventV1(data: ImpressionEvent): EventV1;
export declare function buildConversionEventV1(data: ConversionEvent): EventV1;
export declare function formatEvents(events: ProcessableEvent[]): EventV1Request;
export {};