Skip to content

Commit

Permalink
update dependencies without breaking utm source/medium in URL tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Dec 9, 2024
1 parent c238913 commit 2f02d80
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
},
"dependencies": {
"@hebcal/core": "^5.8.3",
"@hebcal/geo-sqlite": "^5.0.6",
"@hebcal/geo-sqlite": "^5.1.0",
"@hebcal/hdate": "^0.12.0",
"@hebcal/icalendar": "^6.0.2",
"@hebcal/icalendar": "^6.1.1",
"@hebcal/learning": "^5.1.2",
"@hebcal/leyning": "^9.0.2",
"@hebcal/locales": "^5.0.2",
"@hebcal/rest-api": "^6.0.2",
"@hebcal/rest-api": "^6.1.0",
"@hebcal/triennial": "^6.0.1",
"better-sqlite3": "^11.7.0",
"dayjs": "^1.11.13",
Expand Down
8 changes: 4 additions & 4 deletions src/hebcal-download.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export async function hebcalDownload(ctx) {
if (!icalOpt.calendarColor) {
icalOpt.calendarColor = '#800002';
}
icalOpt.utmSource = query.utm_source || 'ical';
icalOpt.utmMedium = query.utm_medium || 'icalendar';
icalOpt.utmSource = query.utm_source;
icalOpt.utmMedium = query.utm_medium;
icalOpt.utmCampaign = query.utm_campaign || 'ical-' + campaignName(events, icalOpt);
if (!query.subscribe) {
ctx.response.attachment(basename(path));
Expand Down Expand Up @@ -93,8 +93,8 @@ export async function hebcalDownload(ctx) {
ctx.response.type = 'application/pdf';
const title = getCalendarTitle(events, options);
const doc = ctx.body = createPdfDoc(title, options);
options.utmSource = query.utm_source || 'pdf';
options.utmMedium = query.utm_medium || 'document';
options.utmSource = query.utm_source; // OK if undefined
options.utmMedium = query.utm_medium; // OK if undefined
options.utmCampaign = query.utm_campaign || 'pdf-' + campaignName(events, options);
renderPdf(doc, events, options);
doc.end();
Expand Down
4 changes: 4 additions & 0 deletions src/matomoTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ export function matomoTrack(ctx, category, action, name=null) {
args.set('cid', vid);
}
}
const utmSource = ctx.request?.query?.utm_source;
if (utmSource) {
args.set('_rcn', utmSource);
}
const postData = args.toString();
const postLen = Buffer.byteLength(postData);
let path = '/ma/matomo.php';
Expand Down
8 changes: 7 additions & 1 deletion src/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,13 @@ function renderPdfEvent(doc, evt, x, y, rtl, options) {
const textOptions = {};
const url = evt.url();
if (url) {
const utmSource = options.utmSource || 'pdf';
let utmSource = options.utmSource;
if (!utmSource) {
const u = new URL(url);
if (u.host === 'www.hebcal.com') {
utmSource = 'pdf';
}
}
const utmMedium = options.utmMedium || 'document';
const utmCampaign = options.utmCampaign || 'pdf-' + evt.getDate().getFullYear();
textOptions.link = appendIsraelAndTracking(url, options.il, utmSource, utmMedium, utmCampaign);
Expand Down

0 comments on commit 2f02d80

Please sign in to comment.