Skip to content

Commit

Permalink
fix: fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitdalal committed Apr 26, 2024
1 parent 11ea541 commit e3dfa62
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,16 @@ function prepareUrlWithUtmParams(req, url) {
const referer = req.headers.referer;
const actualUrl = new URL(url);
const queryParams = actualUrl.searchParams;
const refererHostname = referer ? new URL(referer).hostname : null;
let refererHostname = null;
try {
const refererUrl = referer ? new URL(referer) : null;
if (refererUrl) {
refererHostname = refererUrl.hostname;
}
} catch (error) {
console.error(error);
Sentry.captureException(error);
}
const utmSource =
queryParams.get("utm_source") ?? refererHostname ?? "arpit.im";
const utmMedium =
Expand Down

0 comments on commit e3dfa62

Please sign in to comment.