| 1 |
import { PUBLIC_API_BASE_URL } from '../../content-helper/common/utils/constants'; |
| 2 |
|
| 3 |
// Only enqueuing the action if the site has a defined Site ID. |
| 4 |
if ( typeof window.wpParselySiteId !== 'undefined' ) { |
| 5 |
window.wpParselyHooks?.addAction( 'wpParselyOnLoad', 'wpParsely', uuidProfileCall ); |
| 6 |
} |
| 7 |
|
| 8 |
async function uuidProfileCall() { |
| 9 |
const uuid = window.PARSELY?.config?.parsely_site_uuid; |
| 10 |
|
| 11 |
if ( ! ( window.wpParselySiteId && uuid ) ) { |
| 12 |
return; |
| 13 |
} |
| 14 |
|
| 15 |
const url = `${ PUBLIC_API_BASE_URL }/profile?apikey=${ encodeURIComponent( |
| 16 |
window.wpParselySiteId |
| 17 |
) }&uuid=${ encodeURIComponent( uuid ) }&url=${ encodeURIComponent( window.location.href ) }`; |
| 18 |
|
| 19 |
return fetch( url ); |
| 20 |
} |
| 21 |
|