mirror of
https://github.com/hanzoai/calendar.git
synced 2026-09-24 22:42:24 +00:00
* add tracking to booking + pass to handleNewBooking * save tracking to booking * return undefined if no utm params * add test for handleNewBooking * fix type error in test * refactor code * code clean up * code clean up * add missing import * fix type import * add utm params to insights (#20063) * add utm params to insights * remove duplicates * remove duplicate columns --------- Co-authored-by: CarinaWolli <[email protected]> --------- Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: Omar López <[email protected]>
14 lines
506 B
TypeScript
14 lines
506 B
TypeScript
import type { ReadonlyURLSearchParams } from "next/navigation";
|
|
|
|
export function getUtmTrackingParameters(searchParams: ReadonlyURLSearchParams | null) {
|
|
if (!searchParams) return undefined;
|
|
|
|
const utmParams = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
|
|
|
|
const tracking = Object.fromEntries(
|
|
utmParams.map((param) => [param, searchParams.get(param) ?? undefined])
|
|
);
|
|
|
|
return Object.values(tracking).every((value) => value === undefined) ? undefined : tracking;
|
|
}
|