()
| 424 | }; |
| 425 | |
| 426 | export const Pixels = (): ReactElement => { |
| 427 | const { cookieExists: acceptedMarketing } = useConsentCookie( |
| 428 | GdprConsentKey.Marketing, |
| 429 | ); |
| 430 | const { user, anonymous, isAuthReady, isGdprCovered } = useAuthContext(); |
| 431 | const userId = user?.id || anonymous?.id; |
| 432 | |
| 433 | const { query, pathname, isReady } = useRouter(); |
| 434 | const instanceId = query?.aiid?.toString(); |
| 435 | |
| 436 | const consent = !isGdprCovered || acceptedMarketing; |
| 437 | const props: PixelProps = { userId, instanceId, consent, email: user?.email }; |
| 438 | |
| 439 | // The query check needs `isReady`: on static pages `query` is empty until |
| 440 | // then, and once a pixel script mounts it stays loaded and reports the full |
| 441 | // URL, sensitive params included. |
| 442 | if ( |
| 443 | !isProduction || |
| 444 | !userId || |
| 445 | !isAuthReady || |
| 446 | !isReady || |
| 447 | isSensitivePage(pathname) || |
| 448 | hasSensitiveQueryParam(query) |
| 449 | ) { |
| 450 | return null; |
| 451 | } |
| 452 | |
| 453 | return ( |
| 454 | <> |
| 455 | <FbTracking {...props} /> |
| 456 | <GtagTracking {...props} /> |
| 457 | {consent && ( |
| 458 | <> |
| 459 | <TiktokTracking /> |
| 460 | <TwitterTracking /> |
| 461 | <RedditTracking /> |
| 462 | <QuoraTracking /> |
| 463 | </> |
| 464 | )} |
| 465 | </> |
| 466 | ); |
| 467 | }; |
nothing calls this directly
no test coverage detected