Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@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 17 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.