Download wp-calypso/client/lib/analytics/ad-tracking/parsely.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 891 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/analytics/ad-tracking/parsely.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/lib/analytics/ad-tracking/parsely.ts
-
curl -L -o parsely.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/analytics/ad-tracking/parsely.ts
891 Bytes
| import { loadScript } from '@automattic/load-script'; | |
| import { mayWeTrackByTracker } from '../tracker-buckets'; | |
| import { PARSLEY_SCRIPT_URL } from './constants'; | |
| /** | |
| * We'll be accessing PARSELY from the window object. | |
| */ | |
| declare global { | |
| interface Window { | |
| PARSELY: { | |
| autotrack: boolean; | |
| conversions: { | |
| trackPurchase: ( label: string ) => void; | |
| }; | |
| }; | |
| } | |
| } | |
| /** | |
| * Loads the Parsely script, if the user has consented to tracking, | |
| * and tracking is allowed by the current environment. | |
| * @returns Promise<void> | |
| */ | |
| export const loadParselyTracker = async (): Promise< void > => { | |
| // Are we allowed to track (user consent, e2e, etc.)? | |
| if ( ! mayWeTrackByTracker( 'parsely' ) ) { | |
| throw new Error( 'Tracking is not allowed' ); | |
| } | |
| window.PARSELY = { ...window.PARSELY, autotrack: false }; | |
| // Load the Parsely Tracker script | |
| await loadScript( PARSLEY_SCRIPT_URL ); | |
| }; | |