()
| 457 | }; |
| 458 | |
| 459 | export const Pixels = (): ReactElement => { |
| 460 | const { cookieExists: acceptedMarketing } = useConsentCookie( |
| 461 | GdprConsentKey.Marketing, |
| 462 | ); |
| 463 | const { user, anonymous, isAuthReady, isGdprCovered } = useAuthContext(); |
| 464 | const userId = user?.id || anonymous?.id; |
| 465 | |
| 466 | const { query, pathname, isReady } = useRouter(); |
| 467 | const instanceId = query?.aiid?.toString(); |
| 468 | |
| 469 | const consent = !isGdprCovered || acceptedMarketing; |
| 470 | const props: PixelProps = { userId, instanceId, consent, email: user?.email }; |
| 471 | |
| 472 | // The query check needs `isReady`: on static pages `query` is empty until |
| 473 | // then, and once a pixel script mounts it stays loaded and reports the full |
| 474 | // URL, sensitive params included. |
| 475 | if ( |
| 476 | !isProduction || |
| 477 | !userId || |
| 478 | !isAuthReady || |
| 479 | !isReady || |
| 480 | isSensitivePage(pathname) || |
| 481 | hasSensitiveQueryParam(query) |
| 482 | ) { |
| 483 | return null; |
| 484 | } |
| 485 | |
| 486 | return ( |
| 487 | <> |
| 488 | <FbTracking {...props} /> |
| 489 | <GtagTracking {...props} /> |
| 490 | {consent && ( |
| 491 | <> |
| 492 | <TiktokTracking /> |
| 493 | <TwitterTracking /> |
| 494 | <RedditTracking /> |
| 495 | <QuoraTracking /> |
| 496 | </> |
| 497 | )} |
| 498 | </> |
| 499 | ); |
| 500 | }; |
nothing calls this directly
no test coverage detected