diff --git a/package.json b/package.json index 3a90ccd..5c8c708 100644 --- a/package.json +++ b/package.json @@ -60,9 +60,10 @@ { "path": "@semantic-release/git", "assets": [ + ".gitignore", "package.json", "package-lock.json", - "dist/**/*.{js|css|map}", + "dist", "types" ], "message": "chore: ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" diff --git a/types/alwaysPromise.d.ts b/types/alwaysPromise.d.ts deleted file mode 100644 index 5f51bff..0000000 --- a/types/alwaysPromise.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function alwaysPromise(thing: T | Promise): Promise; diff --git a/types/behavioral-subject.d.ts b/types/behavioral-subject.d.ts deleted file mode 100644 index 9de3c65..0000000 --- a/types/behavioral-subject.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export declare class BehavioralSubject { - private subscribers; - private _value; - constructor(value: A); - next(value: A): void; - subscribe(observer: (value: A) => void): void; -} diff --git a/types/config.d.ts b/types/config.d.ts deleted file mode 100644 index ed7e2cc..0000000 --- a/types/config.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -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; -} -export interface SplitTestConfig { - cookieName: string; - globalCondition: ConditionFunction; - sessionPersister: UserSessionPersister; - tracking: TrackingEventHandler; - uiCondition: ConditionFunction; - userSessionDaysToLive: number; -} -declare const config: SplitTestConfig; -export default config; diff --git a/types/index.d.ts b/types/index.d.ts deleted file mode 100644 index 5d244cb..0000000 --- a/types/index.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -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; diff --git a/types/main.d.ts b/types/main.d.ts deleted file mode 100644 index 260440e..0000000 --- a/types/main.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -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; -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; diff --git a/types/splittest.d.ts b/types/splittest.d.ts deleted file mode 100644 index 98fabb8..0000000 --- a/types/splittest.d.ts +++ /dev/null @@ -1,69 +0,0 @@ -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; - 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; - setCondition(condition: ConditionFunction): SplitTest; - addVariation(variation: Variation): SplitTest; - setup(): Promise; - isInitialized(): Promise; - 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 trackActionPerformed 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; -} diff --git a/types/tracking.d.ts b/types/tracking.d.ts deleted file mode 100644 index 6887c81..0000000 --- a/types/tracking.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -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; diff --git a/types/ui.d.ts b/types/ui.d.ts deleted file mode 100644 index 3c9081a..0000000 --- a/types/ui.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { BehavioralSubject } from './behavioral-subject'; -import { SplitTest } from './splittest'; -import { UserAgentInfo } from './useragentinfo'; -export declare const uiFactory: (tests: BehavioralSubject, reset: () => void, getCurrentTestVariation: (testName: string) => string, getUserAgentInfo: () => UserAgentInfo) => { - show: () => void; - hide: () => void; -}; diff --git a/types/useragentinfo.d.ts b/types/useragentinfo.d.ts deleted file mode 100644 index fb0f9d0..0000000 --- a/types/useragentinfo.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface UserAgentInfo { - name: string; - version: string; - isMobile: boolean; -} -export default function getUserAgentInfo(): UserAgentInfo; diff --git a/types/usersession.d.ts b/types/usersession.d.ts deleted file mode 100644 index f37119d..0000000 --- a/types/usersession.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -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; diff --git a/types/usersessioncookiepersister.d.ts b/types/usersessioncookiepersister.d.ts deleted file mode 100644 index 4ec6ebe..0000000 --- a/types/usersessioncookiepersister.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { UserSessionPersister } from './config'; -declare const persister: UserSessionPersister; -export default persister;