Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@guardian/ab-core

Package Overview
Dependencies
Maintainers
6
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@guardian/ab-core - npm Package Compare versions

Comparing version 7.0.0 to 7.0.1

6

CHANGELOG.md
# @guardian/ab-core
## 7.0.1
### Patch Changes
- c8c9634: Reduce code repetition, which may improve bundle size
## 7.0.0

@@ -4,0 +10,0 @@

31

cjs/ab.d.ts

@@ -1,19 +0,16 @@

import { AbTestConfig, CoreAPI, OphanAPI } from "./index-de573d55.js";
declare class AB {
private _allRunnableTests;
private _isUserInVariant;
private _firstRunnableTest;
private _runnableTest;
private _registerCompleteEvents;
private _registerImpressionEvents;
private _trackABTests;
constructor(config: AbTestConfig);
get allRunnableTests(): CoreAPI['allRunnableTests'];
get firstRunnableTest(): CoreAPI['firstRunnableTest'];
get runnableTest(): CoreAPI['runnableTest'];
get isUserInVariant(): CoreAPI['isUserInVariant'];
get registerCompleteEvents(): OphanAPI['registerCompleteEvents'];
get registerImpressionEvents(): OphanAPI['registerImpressionEvents'];
get trackABTests(): OphanAPI['trackABTests'];
import { ABTestAPI, AbTestConfig } from "./index-de573d55.js";
declare class AB implements ABTestAPI {
private readonly _core;
private readonly _ophan;
constructor({ abTestSwitches, arrayOfTestObjects, errorReporter, forcedTestException, forcedTestVariants, mvtId, mvtMaxValue, ophanRecord, pageIsSensitive, serverSideTests, }: AbTestConfig);
get allRunnableTests(): (tests: readonly import("./index-de573d55.js").ABTest[]) => [] | readonly import("./index-de573d55.js").Runnable<import("./index-de573d55.js").ABTest>[];
get firstRunnableTest(): (tests: readonly import("./index-de573d55.js").ABTest[]) => import("./index-de573d55.js").Runnable<import("./index-de573d55.js").ABTest> | null;
get runnableTest(): (test: import("./index-de573d55.js").ABTest) => import("./index-de573d55.js").Runnable<import("./index-de573d55.js").ABTest & {
variantToRun: import("./index-de573d55.js").Variant;
}> | null;
get isUserInVariant(): (testId: string, variantId?: string | undefined) => boolean;
get registerCompleteEvents(): (tests: readonly import("./index-de573d55.js").Runnable<import("./index-de573d55.js").ABTest>[]) => void;
get registerImpressionEvents(): (tests: readonly import("./index-de573d55.js").Runnable<import("./index-de573d55.js").ABTest>[]) => void;
get trackABTests(): (tests: readonly import("./index-de573d55.js").Runnable<import("./index-de573d55.js").ABTest>[]) => void;
}
export { AB };

@@ -9,48 +9,40 @@ 'use strict';

class AB {
constructor(config) {
const { mvtMaxValue, mvtId, pageIsSensitive, abTestSwitches, serverSideTests, forcedTestVariants, forcedTestException, errorReporter, ophanRecord, arrayOfTestObjects, } = config;
const core$1 = core.initCore({
constructor({ abTestSwitches, arrayOfTestObjects, errorReporter, forcedTestException, forcedTestVariants, mvtId, mvtMaxValue, ophanRecord, pageIsSensitive, serverSideTests, }) {
this._core = core.initCore({
abTestSwitches,
arrayOfTestObjects,
forcedTestException,
forcedTestVariants,
mvtId,
mvtMaxValue,
mvtId,
pageIsSensitive,
abTestSwitches,
forcedTestVariants,
forcedTestException,
arrayOfTestObjects,
});
const ophan$1 = ophan.initOphan({
serverSideTests,
this._ophan = ophan.initOphan({
errorReporter,
ophanRecord,
serverSideTests,
});
this._allRunnableTests = core$1.allRunnableTests;
this._firstRunnableTest = core$1.firstRunnableTest;
this._runnableTest = core$1.runnableTest;
this._isUserInVariant = core$1.isUserInVariant;
this._registerCompleteEvents = ophan$1.registerCompleteEvents;
this._registerImpressionEvents = ophan$1.registerImpressionEvents;
this._trackABTests = ophan$1.trackABTests;
}
// CoreAPI
get allRunnableTests() {
return this._allRunnableTests;
return this._core.allRunnableTests;
}
get firstRunnableTest() {
return this._firstRunnableTest;
return this._core.firstRunnableTest;
}
get runnableTest() {
return this._runnableTest;
return this._core.runnableTest;
}
get isUserInVariant() {
return this._isUserInVariant;
return this._core.isUserInVariant;
}
// OphanAPI
get registerCompleteEvents() {
return this._registerCompleteEvents;
return this._ophan.registerCompleteEvents;
}
get registerImpressionEvents() {
return this._registerImpressionEvents;
return this._ophan.registerImpressionEvents;
}
get trackABTests() {
return this._trackABTests;
return this._ophan.trackABTests;
}

@@ -57,0 +49,0 @@ }

import { CoreAPI, CoreAPIConfig } from "./index-de573d55.js";
declare const initCore: (config: CoreAPIConfig) => CoreAPI;
declare const initCore: ({ mvtMaxValue, mvtId, pageIsSensitive, abTestSwitches, forcedTestVariants, forcedTestException, arrayOfTestObjects, }: CoreAPIConfig) => CoreAPI;
export { initCore };

@@ -7,4 +7,3 @@ 'use strict';

const initCore = (config) => {
const { mvtMaxValue = 1000000, mvtId, pageIsSensitive, abTestSwitches, forcedTestVariants, forcedTestException, arrayOfTestObjects = [], } = config;
const initCore = ({ mvtMaxValue = 1000000, mvtId, pageIsSensitive, abTestSwitches, forcedTestVariants, forcedTestException, arrayOfTestObjects = [], }) => {
/**

@@ -11,0 +10,0 @@ * We only take account of a variant's canRun function if it's defined.

export type { ABTest, ABTestAPI, AbTestConfig, CoreAPIConfig, Participations, Runnable, Variant } from "./index-de573d55.js";
export { AB } from "./ab.js";
//# sourceMappingURL=index.d.ts.map
import { OphanAPI, OphanAPIConfig } from "./index-de573d55.js";
declare const initOphan: (config: OphanAPIConfig) => OphanAPI;
declare const initOphan: ({ serverSideTests, errorReporter, ophanRecord, }: OphanAPIConfig) => OphanAPI;
export { initOphan };

@@ -5,5 +5,2 @@ 'use strict';

const noop = () => {
// Do nothing !
};
const submit = (payload, ophanRecord) => ophanRecord({

@@ -47,5 +44,6 @@ abTestRegister: payload,

const registerCompleteEvent = (complete, errorReporter, ophanRecord) => (test) => {
var _a;
const variant = test.variantToRun;
const listener = (_a = (complete ? variant.success : variant.impression)) !== null && _a !== void 0 ? _a : noop;
const listener = complete ? variant.success : variant.impression;
if (!listener)
return;
try {

@@ -83,17 +81,11 @@ listener(buildOphanSubmitter(test, variant, complete, ophanRecord));

};
const initOphan = (config) => {
const { serverSideTests, errorReporter, ophanRecord } = config;
const registerCompleteEvents = (tests) => {
return tests.forEach(registerCompleteEvent(true, errorReporter, ophanRecord));
};
const registerImpressionEvents = (tests) => {
tests
.filter(defersImpression)
.forEach(registerCompleteEvent(false, errorReporter, ophanRecord));
};
const trackABTests = (tests) => submit(buildOphanPayload(tests, errorReporter, serverSideTests), ophanRecord);
return { registerCompleteEvents, registerImpressionEvents, trackABTests };
};
const initOphan = ({ serverSideTests, errorReporter, ophanRecord, }) => ({
registerCompleteEvents: (tests) => tests.forEach(registerCompleteEvent(true, errorReporter, ophanRecord)),
registerImpressionEvents: (tests) => tests
.filter(defersImpression)
.forEach(registerCompleteEvent(false, errorReporter, ophanRecord)),
trackABTests: (tests) => submit(buildOphanPayload(tests, errorReporter, serverSideTests), ophanRecord),
});
exports.initOphan = initOphan;
//# sourceMappingURL=ophan.js.map

@@ -1,19 +0,16 @@

import { AbTestConfig, CoreAPI, OphanAPI } from "./index-de573d55.js";
declare class AB {
private _allRunnableTests;
private _isUserInVariant;
private _firstRunnableTest;
private _runnableTest;
private _registerCompleteEvents;
private _registerImpressionEvents;
private _trackABTests;
constructor(config: AbTestConfig);
get allRunnableTests(): CoreAPI['allRunnableTests'];
get firstRunnableTest(): CoreAPI['firstRunnableTest'];
get runnableTest(): CoreAPI['runnableTest'];
get isUserInVariant(): CoreAPI['isUserInVariant'];
get registerCompleteEvents(): OphanAPI['registerCompleteEvents'];
get registerImpressionEvents(): OphanAPI['registerImpressionEvents'];
get trackABTests(): OphanAPI['trackABTests'];
import { ABTestAPI, AbTestConfig } from "./index-de573d55.js";
declare class AB implements ABTestAPI {
private readonly _core;
private readonly _ophan;
constructor({ abTestSwitches, arrayOfTestObjects, errorReporter, forcedTestException, forcedTestVariants, mvtId, mvtMaxValue, ophanRecord, pageIsSensitive, serverSideTests, }: AbTestConfig);
get allRunnableTests(): (tests: readonly import("./index-de573d55.js").ABTest[]) => [] | readonly import("./index-de573d55.js").Runnable<import("./index-de573d55.js").ABTest>[];
get firstRunnableTest(): (tests: readonly import("./index-de573d55.js").ABTest[]) => import("./index-de573d55.js").Runnable<import("./index-de573d55.js").ABTest> | null;
get runnableTest(): (test: import("./index-de573d55.js").ABTest) => import("./index-de573d55.js").Runnable<import("./index-de573d55.js").ABTest & {
variantToRun: import("./index-de573d55.js").Variant;
}> | null;
get isUserInVariant(): (testId: string, variantId?: string | undefined) => boolean;
get registerCompleteEvents(): (tests: readonly import("./index-de573d55.js").Runnable<import("./index-de573d55.js").ABTest>[]) => void;
get registerImpressionEvents(): (tests: readonly import("./index-de573d55.js").Runnable<import("./index-de573d55.js").ABTest>[]) => void;
get trackABTests(): (tests: readonly import("./index-de573d55.js").Runnable<import("./index-de573d55.js").ABTest>[]) => void;
}
export { AB };

@@ -5,55 +5,42 @@ import { initCore } from './core.js';

class AB {
_allRunnableTests;
_isUserInVariant;
_firstRunnableTest;
_runnableTest;
_registerCompleteEvents;
_registerImpressionEvents;
_trackABTests;
constructor(config) {
const { mvtMaxValue, mvtId, pageIsSensitive, abTestSwitches, serverSideTests, forcedTestVariants, forcedTestException, errorReporter, ophanRecord, arrayOfTestObjects, } = config;
const core = initCore({
_core;
_ophan;
constructor({ abTestSwitches, arrayOfTestObjects, errorReporter, forcedTestException, forcedTestVariants, mvtId, mvtMaxValue, ophanRecord, pageIsSensitive, serverSideTests, }) {
this._core = initCore({
abTestSwitches,
arrayOfTestObjects,
forcedTestException,
forcedTestVariants,
mvtId,
mvtMaxValue,
mvtId,
pageIsSensitive,
abTestSwitches,
forcedTestVariants,
forcedTestException,
arrayOfTestObjects,
});
const ophan = initOphan({
serverSideTests,
this._ophan = initOphan({
errorReporter,
ophanRecord,
serverSideTests,
});
this._allRunnableTests = core.allRunnableTests;
this._firstRunnableTest = core.firstRunnableTest;
this._runnableTest = core.runnableTest;
this._isUserInVariant = core.isUserInVariant;
this._registerCompleteEvents = ophan.registerCompleteEvents;
this._registerImpressionEvents = ophan.registerImpressionEvents;
this._trackABTests = ophan.trackABTests;
}
// CoreAPI
get allRunnableTests() {
return this._allRunnableTests;
return this._core.allRunnableTests;
}
get firstRunnableTest() {
return this._firstRunnableTest;
return this._core.firstRunnableTest;
}
get runnableTest() {
return this._runnableTest;
return this._core.runnableTest;
}
get isUserInVariant() {
return this._isUserInVariant;
return this._core.isUserInVariant;
}
// OphanAPI
get registerCompleteEvents() {
return this._registerCompleteEvents;
return this._ophan.registerCompleteEvents;
}
get registerImpressionEvents() {
return this._registerImpressionEvents;
return this._ophan.registerImpressionEvents;
}
get trackABTests() {
return this._trackABTests;
return this._ophan.trackABTests;
}

@@ -60,0 +47,0 @@ }

import { CoreAPI, CoreAPIConfig } from "./index-de573d55.js";
declare const initCore: (config: CoreAPIConfig) => CoreAPI;
declare const initCore: ({ mvtMaxValue, mvtId, pageIsSensitive, abTestSwitches, forcedTestVariants, forcedTestException, arrayOfTestObjects, }: CoreAPIConfig) => CoreAPI;
export { initCore };
import { isExpired } from './time.js';
const initCore = (config) => {
const { mvtMaxValue = 1000000, mvtId, pageIsSensitive, abTestSwitches, forcedTestVariants, forcedTestException, arrayOfTestObjects = [], } = config;
const initCore = ({ mvtMaxValue = 1_000_000, mvtId, pageIsSensitive, abTestSwitches, forcedTestVariants, forcedTestException, arrayOfTestObjects = [], }) => {
/**

@@ -6,0 +5,0 @@ * We only take account of a variant's canRun function if it's defined.

export type { ABTest, ABTestAPI, AbTestConfig, CoreAPIConfig, Participations, Runnable, Variant } from "./index-de573d55.js";
export { AB } from "./ab.js";
//# sourceMappingURL=index.d.ts.map
import { OphanAPI, OphanAPIConfig } from "./index-de573d55.js";
declare const initOphan: (config: OphanAPIConfig) => OphanAPI;
declare const initOphan: ({ serverSideTests, errorReporter, ophanRecord, }: OphanAPIConfig) => OphanAPI;
export { initOphan };

@@ -1,4 +0,1 @@

const noop = () => {
// Do nothing !
};
const submit = (payload, ophanRecord) => ophanRecord({

@@ -43,3 +40,5 @@ abTestRegister: payload,

const variant = test.variantToRun;
const listener = (complete ? variant.success : variant.impression) ?? noop;
const listener = complete ? variant.success : variant.impression;
if (!listener)
return;
try {

@@ -77,17 +76,11 @@ listener(buildOphanSubmitter(test, variant, complete, ophanRecord));

};
const initOphan = (config) => {
const { serverSideTests, errorReporter, ophanRecord } = config;
const registerCompleteEvents = (tests) => {
return tests.forEach(registerCompleteEvent(true, errorReporter, ophanRecord));
};
const registerImpressionEvents = (tests) => {
tests
.filter(defersImpression)
.forEach(registerCompleteEvent(false, errorReporter, ophanRecord));
};
const trackABTests = (tests) => submit(buildOphanPayload(tests, errorReporter, serverSideTests), ophanRecord);
return { registerCompleteEvents, registerImpressionEvents, trackABTests };
};
const initOphan = ({ serverSideTests, errorReporter, ophanRecord, }) => ({
registerCompleteEvents: (tests) => tests.forEach(registerCompleteEvent(true, errorReporter, ophanRecord)),
registerImpressionEvents: (tests) => tests
.filter(defersImpression)
.forEach(registerCompleteEvent(false, errorReporter, ophanRecord)),
trackABTests: (tests) => submit(buildOphanPayload(tests, errorReporter, serverSideTests), ophanRecord),
});
export { initOphan };
//# sourceMappingURL=ophan.js.map
{
"name": "@guardian/ab-core",
"version": "7.0.0",
"version": "7.0.1",
"private": false,

@@ -31,3 +31,3 @@ "description": "A client-side library for A/B & multivariate testing",

"readme": "ERROR: No README data found!",
"_id": "@guardian/ab-core@7.0.0"
"_id": "@guardian/ab-core@7.0.1"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc