Ahrefs fehler.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { usePathname, useSearchParams } from "next/navigation";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { trackEvent } from "@/components/PostHogProvider";
|
||||
@@ -14,12 +14,14 @@ type TrackingContext = {
|
||||
useCase?: string;
|
||||
};
|
||||
|
||||
function getUtmProperties(searchParams: ReturnType<typeof useSearchParams>) {
|
||||
function getUtmPropertiesFromWindow() {
|
||||
if (typeof window === "undefined") return {};
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
return {
|
||||
utm_source: searchParams?.get("utm_source") || undefined,
|
||||
utm_medium: searchParams?.get("utm_medium") || undefined,
|
||||
utm_campaign: searchParams?.get("utm_campaign") || undefined,
|
||||
utm_content: searchParams?.get("utm_content") || undefined,
|
||||
utm_source: params.get("utm_source") || undefined,
|
||||
utm_medium: params.get("utm_medium") || undefined,
|
||||
utm_campaign: params.get("utm_campaign") || undefined,
|
||||
utm_content: params.get("utm_content") || undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,7 +31,6 @@ export function MarketingPageTracker({
|
||||
useCase,
|
||||
}: TrackingContext) {
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
useEffect(() => {
|
||||
if (!pathname) {
|
||||
@@ -41,9 +42,9 @@ export function MarketingPageTracker({
|
||||
page_type: pageType,
|
||||
cluster,
|
||||
use_case: useCase,
|
||||
...getUtmProperties(searchParams),
|
||||
...getUtmPropertiesFromWindow(),
|
||||
});
|
||||
}, [cluster, pageType, pathname, searchParams, useCase]);
|
||||
}, [cluster, pageType, pathname, useCase]);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -69,7 +70,6 @@ export function TrackedCtaLink({
|
||||
useCase,
|
||||
}: TrackedCtaLinkProps) {
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
return (
|
||||
<Link
|
||||
@@ -84,7 +84,7 @@ export function TrackedCtaLink({
|
||||
cta_label: ctaLabel,
|
||||
cta_location: ctaLocation,
|
||||
destination: destination || href,
|
||||
...getUtmProperties(searchParams),
|
||||
...getUtmPropertiesFromWindow(),
|
||||
});
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user