sdk improvement and get profile with events

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-02-11 23:26:30 +01:00
parent 85e4922dc3
commit 6f2aeffdff
8 changed files with 86 additions and 24 deletions

View File

@@ -24,3 +24,27 @@ export function parseReferrer(url: string | undefined) {
url: url ?? '',
};
}
export function getReferrerWithQuery(
query: Record<string, string> | undefined
) {
if (!query) {
return null;
}
const source = query.utm_source ?? query.ref ?? query.utm_referrer ?? '';
const match = Object.values(referrers).find(
(referrer) => referrer.name.toLowerCase() === source?.toLowerCase()
);
if (!match) {
return null;
}
return {
name: match.name,
type: match.type,
url: '',
};
}