UNPKG

@o3r/third-party

Version:

This module provides a bridge to communicate with third parties via an iFrame solution.

77 lines 2.38 kB
import type { Logger } from '@o3r/core'; import { Observable } from 'rxjs'; /** * Shared interface with the A/B testing provider */ export interface AbTestBridgeInterface<T> { /** * Start an AB testing experiment */ start(experiments: T | T[]): void; /** * Stop an AB testing experiment */ stop(experiments?: T | T[]): void; } /** * Configure the A/B testing script interfaces with the application */ export interface AbTestBridgeConfig { /** * Reference to communicate with the bridge from the window * @default 'abTestBridge' */ bridgeName: string; /** * Debug logger * @default console */ logger: Logger; /** * Event a third party can subscribe to before starting the communication with the bridge * @default 'ab-test-ready' */ readyEventName: string; } /** * Bridge between the application and a third party A/B testing provider. * Exposes a start and stop methods to allow the external script to set the list of experiments to run over the * application. * * Share the resulting list of experiments with the rest of the application via an observable. */ export declare class AbTestBridge<T> implements AbTestBridgeInterface<T> { private readonly isExperimentEqual; /** * Behaviour subject to control the experiments via the exposed interface */ private readonly experimentSubject$; /** * Options to configure the communication between the AB Testing bridge and third parties */ private readonly options; /** * Observable with the list of AB testing experiments currently applied */ experiments$: Observable<T[]>; /** * AbTestBridge constructor * @param isExperimentEqual check two different experiments match to identify an experiment to start or to stop * @param options configure the communication with the A/B testing third party provider */ constructor(isExperimentEqual: (value1?: T, value2?: T) => boolean, options?: Partial<AbTestBridgeConfig>); /** * Use configured logger to log AB testing related information * @param args */ private log; /** * @inheritDoc */ start(experiments: T | T[]): void; /** * @inheritDoc */ stop(experiments?: T | T[]): void; } //# sourceMappingURL=ab-testing-bridge.d.ts.map