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

@guardian/ab-react

Package Overview
Dependencies
Maintainers
35
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@guardian/ab-react - npm Package Compare versions

Comparing version 0.3.0 to 1.0.0-next.0

dist/ab.d.ts

13

dist/ab-react.d.ts
import React from 'react';
import { ABTest } from '@guardian/ab-core';
import { AbTestConfig } from '@guardian/ab-core';
/**

@@ -8,10 +8,3 @@ * ABProvider sets an instance of ABContext

*/
export declare const ABProvider: ({ tests, switches, isSensitive, mvtMax, mvtId, children, }: {
tests: ABTest[];
switches: {
[key: string]: boolean;
};
isSensitive: boolean;
mvtMax?: number | undefined;
mvtId: number;
export declare const ABProvider: ({ arrayOfTestObjects, abTestSwitches, pageIsSensitive, mvtMaxValue, mvtId, forcedTestVariant, forcedTestException, errorReporter, ophanRecord, serverSideTests, children, }: import("@guardian/ab-core/dist/types").CoreAPIConfig & import("@guardian/ab-core/dist/types").OphanAPIConfig & {
children: React.ReactNode;

@@ -24,2 +17,2 @@ }) => JSX.Element;

*/
export declare const useAB: () => import("@guardian/ab-core/dist/types").CoreAPI;
export declare const useAB: () => import("@guardian/ab-core/dist/types").ABTestAPI;

@@ -1,2 +0,2 @@

var e,t=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e,r=require("@guardian/ab-core"),i=t.createContext(void 0);exports.ABProvider=function(e){var a=e.mvtMax,s=e.children;return t.createElement(i.Provider,{value:new r.AB({mvtId:e.mvtId,mvtMaxValue:void 0===a?1e6:a,pageIsSensitive:e.isSensitive,abTestSwitches:e.switches,arrayOfTestObjects:e.tests})},s)},exports.useAB=function(){var e=t.useContext(i);if(void 0===e)throw new Error("useAB must be used within the ABProvider");return e};
var e,r=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e,t=require("@guardian/ab-core"),a=r.createContext(void 0);exports.ABProvider=function(e){var o=e.children;return r.createElement(a.Provider,{value:new t.AB({mvtId:e.mvtId,mvtMaxValue:e.mvtMaxValue,pageIsSensitive:e.pageIsSensitive,abTestSwitches:e.abTestSwitches,arrayOfTestObjects:e.arrayOfTestObjects,forcedTestVariant:e.forcedTestVariant,forcedTestException:e.forcedTestException,errorReporter:e.errorReporter,ophanRecord:e.ophanRecord,serverSideTests:e.serverSideTests})},o)},exports.useAB=function(){var e=r.useContext(a);if(void 0===e)throw new Error("useAB must be used within the ABProvider");return e};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import e from"react";import{AB as t}from"@guardian/ab-core";var r=e.createContext(void 0),i=function(i){var a=i.mvtMax,o=i.children;return e.createElement(r.Provider,{value:new t({mvtId:i.mvtId,mvtMaxValue:void 0===a?1e6:a,pageIsSensitive:i.isSensitive,abTestSwitches:i.switches,arrayOfTestObjects:i.tests})},o)},a=function(){var t=e.useContext(r);if(void 0===t)throw new Error("useAB must be used within the ABProvider");return t};export{i as ABProvider,a as useAB};
import e from"react";import{AB as r}from"@guardian/ab-core";var t=e.createContext(void 0),o=function(o){var a=o.children;return e.createElement(t.Provider,{value:new r({mvtId:o.mvtId,mvtMaxValue:o.mvtMaxValue,pageIsSensitive:o.pageIsSensitive,abTestSwitches:o.abTestSwitches,arrayOfTestObjects:o.arrayOfTestObjects,forcedTestVariant:o.forcedTestVariant,forcedTestException:o.forcedTestException,errorReporter:o.errorReporter,ophanRecord:o.ophanRecord,serverSideTests:o.serverSideTests})},a)},a=function(){var r=e.useContext(t);if(void 0===r)throw new Error("useAB must be used within the ABProvider");return r};export{o as ABProvider,a as useAB};
//# sourceMappingURL=index.modern.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@guardian/ab-core")):"function"==typeof define&&define.amd?define(["exports","react","@guardian/ab-core"],t):t((e=e||self).abReact={},e.react,e.abCore)}(this,function(e,t,r){var i=(t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t).createContext(void 0);e.ABProvider=function(e){var a=e.mvtMax,n=e.children;return t.createElement(i.Provider,{value:new r.AB({mvtId:e.mvtId,mvtMaxValue:void 0===a?1e6:a,pageIsSensitive:e.isSensitive,abTestSwitches:e.switches,arrayOfTestObjects:e.tests})},n)},e.useAB=function(){var e=t.useContext(i);if(void 0===e)throw new Error("useAB must be used within the ABProvider");return e}});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("@guardian/ab-core")):"function"==typeof define&&define.amd?define(["exports","react","@guardian/ab-core"],r):r((e=e||self).abReact={},e.react,e.abCore)}(this,function(e,r,t){var o=(r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r).createContext(void 0);e.ABProvider=function(e){var a=e.children;return r.createElement(o.Provider,{value:new t.AB({mvtId:e.mvtId,mvtMaxValue:e.mvtMaxValue,pageIsSensitive:e.pageIsSensitive,abTestSwitches:e.abTestSwitches,arrayOfTestObjects:e.arrayOfTestObjects,forcedTestVariant:e.forcedTestVariant,forcedTestException:e.forcedTestException,errorReporter:e.errorReporter,ophanRecord:e.ophanRecord,serverSideTests:e.serverSideTests})},a)},e.useAB=function(){var e=r.useContext(o);if(void 0===e)throw new Error("useAB must be used within the ABProvider");return e}});
//# sourceMappingURL=index.umd.js.map

@@ -1,76 +0,1 @@

export declare type ConfigType = {
mvtMaxValue: number;
mvtCookieId: number;
pageIsSensitive: boolean;
abTestSwitches: Record<string, boolean>;
forcedTestVariant?: {
testId: ABTest['id'];
variant: Variant;
};
forcedTestException?: ABTest['id'];
arrayOfTestObjects: ABTest[];
};
export declare type ABType = CoreAPI & OphanAPI;
export declare type CoreAPI = {
runnableTest: (test: ABTest) => Runnable<ABTest & {
variantToRun: Variant;
}> | null;
firstRunnableTest: (tests: ReadonlyArray<ABTest>) => Runnable<ABTest> | null;
isUserInVariant: (testId: ABTest['id'], variantId?: Variant['id']) => boolean;
};
export declare type OphanAPIConfig = {
serverSideTests: ServerSideTests;
errorReporter: ErrorReporterFunc;
ophanRecord: OphanRecordFunction;
};
export declare type OphanAPI = {
registerCompleteEvents: (tests: ReadonlyArray<Runnable<ABTest>>) => void;
registerImpressionEvents: (tests: ReadonlyArray<Runnable<ABTest>>) => void;
trackABTests: (tests: ReadonlyArray<Runnable<ABTest>>) => void;
};
export declare type OphanProduct = 'CONTRIBUTION' | 'RECURRING_CONTRIBUTION' | 'MEMBERSHIP_SUPPORTER' | 'MEMBERSHIP_PATRON' | 'MEMBERSHIP_PARTNER' | 'DIGITAL_SUBSCRIPTION' | 'PRINT_SUBSCRIPTION';
export interface OphanABEvent {
variantName: string;
complete: string | boolean;
campaignCodes?: ReadonlyArray<string>;
}
export declare type OphanABPayload = {
[testId: string]: OphanABEvent;
};
export declare type OphanRecordFunction = (send: {
[key: string]: OphanABPayload;
}) => void;
declare type ListenerFunction = (f: () => void) => void;
export interface Variant {
id: string;
test: (x: Record<string, unknown>) => void;
campaignCode?: string;
canRun?: () => boolean;
impression?: ListenerFunction;
success?: ListenerFunction;
}
export interface ABTest {
id: string;
start: string;
expiry: string;
author: string;
description: string;
audience: number;
audienceOffset: number;
successMeasure: string;
audienceCriteria: string;
showForSensitive?: boolean;
idealOutcome?: string;
dataLinkNames?: string;
variants: ReadonlyArray<Variant>;
canRun: () => boolean;
notInTest?: () => void;
}
export declare type Runnable<ABTest> = ABTest & {
variantToRun: Variant;
};
export declare type ServerSideTests = {
[key: string]: string;
};
export declare type ErrorReporterFunc = (...args: unknown[]) => void;
export {};
{
"version": "0.3.0",
"version": "1.0.0-next.0",
"name": "@guardian/ab-react",

@@ -25,3 +25,3 @@ "author": "The Guardian",

"validate": "yarn lint && yarn tsc && yarn test",
"prepublishOnly": "yarn build"
"prepublishOnly": "yarn validate && yarn build"
},

@@ -89,9 +89,7 @@ "devDependencies": {

"peerDependencies": {
"@guardian/ab-core": "^0.3.0",
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"dependencies": {
"@guardian/ab-core": "^0.3.0"
},
"gitHead": "533edc18b88b3531046e983f15a446c807a4b86b"
"gitHead": "af948fb107cc97c8aa17b17a0f32dee99984d1ee"
}

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