MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / getReferrerWithQuery

Function getReferrerWithQuery

packages/common/server/parse-referrer.ts:28–66  ·  view source on GitHub ↗
(
  query: Record<string, string> | undefined,
)

Source from the content-addressed store, hash-verified

26}
27
28export function getReferrerWithQuery(
29 query: Record<string, string> | undefined,
30) {
31 if (!query) {
32 return null;
33 }
34
35 const source = (
36 query.utm_source ??
37 query.ref ??
38 query.utm_referrer ??
39 ''
40 ).toLowerCase();
41
42 if (source === '') {
43 return null;
44 }
45
46 const match =
47 referrers[source] ||
48 referrers[`${source}.com`] ||
49 Object.values(referrers).find(
50 (referrer) => referrer.name.toLowerCase() === source,
51 );
52
53 if (match) {
54 return {
55 name: match.name,
56 type: match.type,
57 url: '',
58 };
59 }
60
61 return {
62 name: source,
63 type: '',
64 url: '',
65 };
66}

Callers 5

transformEventMethod · 0.90
transformEventMethod · 0.90
transformEventMethod · 0.90
incomingEventFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected