-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# [3.2.0](v3.1.0...v3.2.0) (2018-07-03) ### Features * refresh UI ([179d5ee](179d5ee))
- Loading branch information
1 parent
a3f636c
commit 51c39c6
Showing
13 changed files
with
2,436 additions
and
2,233 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export declare function alwaysPromise<T>(thing: T | Promise<T>): Promise<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |