Skip to content

Commit

Permalink
chore: 3.2.0 [skip ci]
Browse files Browse the repository at this point in the history
# [3.2.0](v3.1.0...v3.2.0) (2018-07-03)

### Features

* refresh UI ([179d5ee](179d5ee))
  • Loading branch information
semantic-release-bot committed Jul 3, 2018
1 parent a3f636c commit 51c39c6
Show file tree
Hide file tree
Showing 13 changed files with 2,436 additions and 2,233 deletions.
4,464 changes: 2,232 additions & 2,232 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "skift",
"description": "Split testing tool for the Web",
"version": "3.0.0",
"version": "3.2.0",
"author": "Trustpilot A/S",
"bugs": {
"url": "https://github.com/trustpilot/skift/issues"
Expand Down
1 change: 1 addition & 0 deletions types/alwaysPromise.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare function alwaysPromise<T>(thing: T | Promise<T>): Promise<T>;
7 changes: 7 additions & 0 deletions types/behavioral-subject.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export declare class BehavioralSubject<A> {
private subscribers;
private _value;
constructor(value: A);
next(value: A): void;
subscribe(observer: (value: A) => void): void;
}
19 changes: 19 additions & 0 deletions types/config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { TrackingEventHandler } from './tracking';
import { UserAgentInfo } from './useragentinfo';
export interface UserSessionPersister {
loadUserSession(): string | null;
saveUserSession(userSession: string, daysToLive: number): void;
}
export interface ConditionFunction {
(userAgentInfo: UserAgentInfo): boolean | Promise<boolean>;
}
export interface SplitTestConfig {
cookieName: string;
globalCondition: ConditionFunction;
sessionPersister: UserSessionPersister;
tracking: TrackingEventHandler;
uiCondition: ConditionFunction;
userSessionDaysToLive: number;
}
declare const config: SplitTestConfig;
export default config;
23 changes: 23 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { tests, config, getUserAgentInfo, getTest, create, getCurrentTestVariation, setCurrentTestVariation, reset, SplitTest, initialize } from './main';
declare const ui: {
show: () => void;
hide: () => void;
};
export { tests, config, getUserAgentInfo, getTest, create, getCurrentTestVariation, setCurrentTestVariation, reset, ui, SplitTest };
declare const _default: {
tests: SplitTest[];
config: typeof config;
getUserAgentInfo: typeof getUserAgentInfo;
getTest: typeof getTest;
create: typeof create;
getCurrentTestVariation: typeof getCurrentTestVariation;
setCurrentTestVariation: typeof setCurrentTestVariation;
reset: typeof reset;
ui: {
show: () => void;
hide: () => void;
};
SplitTest: typeof SplitTest;
initialize: typeof initialize;
};
export default _default;
25 changes: 25 additions & 0 deletions types/main.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { UserAgentInfo } from './useragentinfo';
import { SplitTest } from './splittest';
import { BehavioralSubject } from './behavioral-subject';
export { SplitTest } from './splittest';
import { TrackingEventHandler } from './tracking';
import { ConditionFunction, UserSessionPersister } from './config';
export interface UserConfig {
cookieName?: string;
globalCondition?: ConditionFunction;
sessionPersister?: UserSessionPersister;
tracking?: TrackingEventHandler;
uiCondition?: ConditionFunction;
userSessionDaysToLive?: number;
}
export declare const tests: SplitTest[];
export declare const testsObservable: BehavioralSubject<SplitTest[]>;
export declare function config(userConfig?: UserConfig): void;
export declare function initialize(): void;
export declare function getUserAgentInfo(): UserAgentInfo;
export declare function getTest(name: string): SplitTest;
export declare function create(name: string): SplitTest;
export declare function getCurrentTestVariation(testName: string): string;
export declare function setCurrentTestVariation(testName: string, variation: string): void;
export declare function reset(): void;
export declare function shouldShowUI(): Promise<boolean>;
69 changes: 69 additions & 0 deletions types/splittest.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { UserAgentInfo } from './useragentinfo';
import { BehavioralSubject } from './behavioral-subject';
import { TrackingDataExtender, TrackEventActionType } from './tracking';
import { ConditionFunction } from './config';
export interface Variation {
/** A descriptive unique name of this variation */
name: string;
/** A relative weight defining how many users should see this variation. Default value is 1 */
weight?: number;
/**
* Function to be called when this variation has been chosen and should be setup.
* It's always called after DOMContentLoaded
*/
setup?: (this: SplitTest, userAgentInfo: UserAgentInfo) => void;
/** Whether a track event should automatically be published once this variation has been setup. Default is true. */
trackEventAutoPublish?: boolean;
}
export interface InternalVariation extends Variation {
normalizedWeight: number;
weight: number;
}
export declare type State = 'uninitialized' | 'initializing' | 'initialized' | 'canceled';
export declare class SplitTest {
name: string;
private userAgentInfo;
private trackingDataExtender;
state: State;
changes: BehavioralSubject<this>;
private finalStateListeners;
private readonly _variations;
readonly variations: Variation[];
constructor(name: string, userAgentInfo: UserAgentInfo, trackingDataExtender: TrackingDataExtender);
/**
* Determines whether this test is able to run or not.
*/
shouldRun(userAgentInfo: UserAgentInfo): Promise<boolean>;
setCondition(condition: ConditionFunction): SplitTest;
addVariation(variation: Variation): SplitTest;
setup(): Promise<boolean>;
isInitialized(): Promise<boolean>;
getVariation(name: string): Variation;
getVariationUrl(variationName: string | null): string;
/**
* The tracking data extenders are called just before any event is published to the event handler.
*/
extendTrackingData(trackingDataExtender: TrackingDataExtender): SplitTest;
/**
* Emits an "Experiment Viewed" tracking event
*/
trackViewed(): void;
/**
* Emits an "Experiment Action Performed" tracking event
* @param action Specifies the action type that has been performed
* @param target Specifies a target the action has affected or originated from
*/
trackActionPerformed(action: TrackEventActionType, target?: string): void;
/**
* Attaches a <code>trackActionPerformed</code> call as a handler to a link.
* @param element The DOM element to be bound with track method.
* @param name A human readable name of the link. If left out, the innerText of the element is used
*/
trackLink(element: Element, name?: string): void;
private condition;
private normalizeVariationWeights;
private transitionState;
private subscribeStateListener;
private selectRandomVariation;
private trackEvent;
}
34 changes: 34 additions & 0 deletions types/tracking.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export interface TrackingData {
[key: string]: any;
}
/**
* Describing a handler for A/B test events
*/
export interface TrackingEventHandler {
/**
* Records an action your user performs.
* @param event The name of the event you’re tracking.
* @param trackingData A dictionary of properties for the event
*/
track(event: TrackEventType, trackingData: TrackingData): void;
/**
* A helper method that attaches the track call as a handler to a link
* @param element DOM element to be bound with track method
* @param event The name of the event, passed to the track method
* @param trackingData A dictionary of properties to pass with the track method.
*/
trackLink(element: Element, event: TrackEventType, trackingData: TrackingData): void;
}
/**
* A function that extends a tracking data object with even more data
*/
export interface TrackingDataExtender {
(trackingData: TrackingData, event: string): TrackingData;
}
export declare type TrackEventType = 'ExperimentViewed' | 'ExperimentActionPerformed';
export declare type TrackEventActionType = 'Click' | 'Type';
/**
* Constructs a new TrackingDataExtender that extending the existing tracking data with the provided tracking data
* @param newTrackingData
*/
export declare function trackingDataExtenderFactory(newTrackingData: TrackingData): TrackingDataExtender;
7 changes: 7 additions & 0 deletions types/ui.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { BehavioralSubject } from './behavioral-subject';
import { SplitTest } from './splittest';
import { UserAgentInfo } from './useragentinfo';
export declare const uiFactory: (tests: BehavioralSubject<SplitTest[]>, reset: () => void, getCurrentTestVariation: (testName: string) => string, getUserAgentInfo: () => UserAgentInfo) => {
show: () => void;
hide: () => void;
};
6 changes: 6 additions & 0 deletions types/useragentinfo.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface UserAgentInfo {
name: string;
version: string;
isMobile: boolean;
}
export default function getUserAgentInfo(): UserAgentInfo;
9 changes: 9 additions & 0 deletions types/usersession.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export declare class UserSession {
setTestVariation(testName: string, variationName: string): void;
getTestVariation(testName: string): string;
reset(): void;
private saveVariations;
private loadVariations;
}
declare const userSession: UserSession;
export default userSession;
3 changes: 3 additions & 0 deletions types/usersessioncookiepersister.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { UserSessionPersister } from './config';
declare const persister: UserSessionPersister;
export default persister;

0 comments on commit 51c39c6

Please sign in to comment.