Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@guardian/ab-react
Advanced tools
pnpm add @guardian/ab-react @guardian/ab-core preact
Note Read more on the @guardian/ab-core docs
Initialise the config options with the ABProvider
import { render } from 'react-dom';
import { ABProvider } from '@guardian/ab-react';
render(
<ABProvider
arrayOfTestObjects={tests}
abTestSwitches={{
...{ abAbTestTest: true },
...CAPI.config.switches,
}}
pageIsSensitive={CAPI.config.isSensitive}
mvtMaxValue={1_000_000}
mvtId={mvtId}
ophanRecord={ophanRecordFunc}
>
<App CAPI={CAPI} NAV={NAV} />
</ABProvider>,
);
import { useAB } from '@guardian/ab-react';
// Initialise all of the impression and completion events
const ABTestAPI = useAB();
useEffect(() => {
const allRunnableTests = ABTestAPI.allRunnableTests(tests);
ABTestAPI.registerImpressionEvents(allRunnableTests);
ABTestAPI.registerCompleteEvents(allRunnableTests);
}, [ABTestAPI]);
import { useAB } from '@guardian/ab-react';
// Example usage of AB Tests
// Used in the Cypress tests as smoke test of the AB tests framework integration
const ABTestAPI = useAB();
// We can check if a user is in a variant, returns a boolean
// ABTestTest being an ab test that was passed in via the ab test array
const abTestDataAttr =
(ABTestAPI.isUserInVariant('AbTestTest', 'control') && 'ab-test-control') ||
(ABTestAPI.isUserInVariant('AbTestTest', 'variant') && 'ab-test-variant') ||
'ab-test-not-in-test';
// We can get the variant straight from a check for
// whether the test is runnable
const runnableTest = ABTestAPI.runnableTest(abTestTest);
const variantFromRunnable =
(runnableTest && runnableTest.variantToRun.id) || 'not-runnable';
<div
data-ab-user-in-variant={abTestDataAttr}
data-ab-runnable-test={variantFromRunnable}
>
AB Test
</div>;
FAQs
A React library for A/B & multivariate testing
The npm package @guardian/ab-react receives a total of 33 weekly downloads. As such, @guardian/ab-react popularity was classified as not popular.
We found that @guardian/ab-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.