@optimizely/optimizely-sdk
Version:
JavaScript SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts
82 lines (81 loc) • 2.39 kB
TypeScript
/**
* Copyright 2021-2022, 2024, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { UserEvent } from './user_event';
import { LogEvent } from '../event_dispatcher/event_dispatcher';
import { EventTags } from '../../shared_types';
import { Region } from '../../project_config/project_config';
import { Platform } from '../../platform_support';
export declare const logxEndpoint: Record<Region, string>;
export type EventBatch = {
account_id: string;
project_id: string;
revision: string;
client_name: string;
client_version: string;
anonymize_ip: boolean;
enrich_decisions: boolean;
visitors: Visitor[];
};
type Visitor = {
snapshots: Snapshot[];
visitor_id: string;
attributes: Attribute[];
};
type AttributeType = 'custom';
export type Attribute = {
entity_id: string;
key: string;
type: AttributeType;
value: string | number | boolean;
};
export 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;
cmab_uuid?: string;
};
export 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 {UserEvent[]} events
* @returns {EventBatch}
*/
export declare function makeEventBatch(events: UserEvent[]): EventBatch;
export declare function buildLogEvent(events: UserEvent[]): LogEvent;
export declare const __platforms: Platform[];
export {};