Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@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 32 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.