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