Download wp-calypso/client/lib/analytics/impact-affiliate.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 828 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/analytics/impact-affiliate.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/lib/analytics/impact-affiliate.js
-
curl -L -o impact-affiliate.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/analytics/impact-affiliate.js
828 Bytes
| import cookie from 'cookie'; | |
| import { recordTracksEvent } from 'calypso/lib/analytics/tracks'; | |
| import urlParseAmpCompatible from './utils/url-parse-amp-compatible'; | |
| /** | |
| * Save Impact Affiliate Click ID in a cookie if it is set as a query parameter. | |
| */ | |
| export default function saveImpactAffiliateClickId() { | |
| // Read click ID query argument, return early if there is none. | |
| const parsedUrl = urlParseAmpCompatible( window.location.href ); | |
| const clickId = parsedUrl?.searchParams.get( 'irclickid' ); | |
| if ( ! clickId ) { | |
| return; | |
| } | |
| document.cookie = cookie.serialize( 'irclickid', clickId, { | |
| path: '/', | |
| expires: new Date( Date.now() + 30 * 24 * 60 * 60 * 1000 ), // 30 days | |
| domain: '.wordpress.com', | |
| } ); | |
| recordTracksEvent( 'calypso_impact_affiliate_visit', { | |
| page: parsedUrl.host + parsedUrl.pathname, | |
| } ); | |
| } | |