Skip to content

Commit 6ced493

Browse files
authored
Merge pull request umami-software#3414 from umami-software/dev
v2.18.1
2 parents 1552a3f + 42be91b commit 6ced493

File tree

15 files changed

+201
-281
lines changed

15 files changed

+201
-281
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ node_modules
1212
/.next/
1313
/out/
1414
/prisma/
15+
/src/generated/
1516

1617
# production
1718
/build

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ RUN set -x \
4141
&& apk add --no-cache curl
4242

4343
# Script dependencies
44-
RUN pnpm add npm-run-all dotenv prisma@6.1.0
44+
RUN pnpm add npm-run-all dotenv prisma@6.7.0
4545

4646
# Permissions for prisma
4747
RUN chown -R nextjs:nodejs node_modules/.pnpm/

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "umami",
3-
"version": "2.18.0",
3+
"version": "2.18.1",
44
"description": "A modern, privacy-focused alternative to Google Analytics.",
55
"author": "Umami Software, Inc. <[email protected]>",
66
"license": "MIT",
@@ -162,7 +162,6 @@
162162
"postcss-flexbugs-fixes": "^5.0.2",
163163
"postcss-import": "^15.1.0",
164164
"postcss-preset-env": "7.8.3",
165-
"postcss-rtlcss": "^4.0.1",
166165
"prettier": "^2.6.2",
167166
"prompts": "2.4.2",
168167
"rollup": "^3.28.0",

pnpm-lock.yaml

Lines changed: 0 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
-----------------------------------------------------
2-
-- postgreSQL
2+
-- PostgreSQL
33
-----------------------------------------------------
44
UPDATE "website_event" we
5-
SET fbclid = url.fbclid,
6-
gclid = url.gclid,
7-
li_fat_id = url.li_fat_id,
8-
msclkid = url.msclkid,
9-
ttclid = url.ttclid,
10-
twclid = url.twclid,
11-
utm_campaign = url.utm_campaign,
12-
utm_content = url.utm_content,
13-
utm_medium = url.utm_medium,
14-
utm_source = url.utm_source,
15-
utm_term = url.utm_term
5+
SET fbclid = LEFT(url.fbclid, 255),
6+
gclid = LEFT(url.gclid, 255),
7+
li_fat_id = LEFT(url.li_fat_id, 255),
8+
msclkid = LEFT(url.msclkid, 255),
9+
ttclid = LEFT(url.ttclid, 255),
10+
twclid = LEFT(url.twclid, 255),
11+
utm_campaign = LEFT(url.utm_campaign, 255),
12+
utm_content = LEFT(url.utm_content, 255),
13+
utm_medium = LEFT(url.utm_medium, 255),
14+
utm_source = LEFT(url.utm_source, 255),
15+
utm_term = LEFT(url.utm_term, 255)
1616
FROM (SELECT event_id, website_id, session_id,
1717
(regexp_matches(url_query, '(?:[&?]|^)fbclid=([^&]+)', 'i'))[1] AS fbclid,
1818
(regexp_matches(url_query, '(?:[&?]|^)gclid=([^&]+)', 'i'))[1] AS gclid,
@@ -31,18 +31,18 @@ WHERE we.event_id = url.event_id
3131
and we.website_id = url.website_id;
3232

3333
-----------------------------------------------------
34-
-- mySQL
34+
-- MySQL
3535
-----------------------------------------------------
3636
UPDATE `website_event`
37-
SET fbclid = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)fbclid=[^&]+'), '=', -1), '&', 1),
38-
gclid = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)gclid=[^&]+'), '=', -1), '&', 1),
39-
li_fat_id = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)li_fat_id=[^&]+'), '=', -1), '&', 1),
40-
msclkid = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)msclkid=[^&]+'), '=', -1), '&', 1),
41-
ttclid = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)ttclid=[^&]+'), '=', -1), '&', 1),
42-
twclid = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)twclid=[^&]+'), '=', -1), '&', 1),
43-
utm_campaign = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_campaign=[^&]+'), '=', -1), '&', 1),
44-
utm_content = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_content=[^&]+'), '=', -1), '&', 1),
45-
utm_medium = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_medium=[^&]+'), '=', -1), '&', 1),
46-
utm_source = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_source=[^&]+'), '=', -1), '&', 1),
47-
utm_term = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_term=[^&]+'), '=', -1), '&', 1)
48-
WHERE 1 = 1;
37+
SET fbclid = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)fbclid=[^&]+'), '=', -1), '&', 1), 255),
38+
gclid = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)gclid=[^&]+'), '=', -1), '&', 1), 255),
39+
li_fat_id = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)li_fat_id=[^&]+'), '=', -1), '&', 1), 255),
40+
msclkid = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)msclkid=[^&]+'), '=', -1), '&', 1), 255),
41+
ttclid = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)ttclid=[^&]+'), '=', -1), '&', 1), 255),
42+
twclid = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)twclid=[^&]+'), '=', -1), '&', 1), 255),
43+
utm_campaign = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_campaign=[^&]+'), '=', -1), '&', 1), 255),
44+
utm_content = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_content=[^&]+'), '=', -1), '&', 1), 255),
45+
utm_medium = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_medium=[^&]+'), '=', -1), '&', 1), 255),
46+
utm_source = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_source=[^&]+'), '=', -1), '&', 1), 255),
47+
utm_term = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_term=[^&]+'), '=', -1), '&', 1), 255)
48+
WHERE 1 = 1;

scripts/set-routes-manifest.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ const routesManifestPath = path.resolve(__dirname, '../.next/routes-manifest.jso
77
const originalPath = path.resolve(__dirname, '../.next/routes-manifest-orig.json');
88
const originalManifest = require(originalPath);
99

10-
const API_PATH = '/api/:path*';
11-
const TRACKER_SCRIPT = '/script.js';
10+
const basePath = originalManifest.basePath;
11+
12+
const API_PATH = basePath + '/api/:path*';
13+
const TRACKER_SCRIPT = basePath + '/script.js';
1214

1315
const collectApiEndpoint = process.env.COLLECT_API_ENDPOINT;
1416
const trackerScriptName = process.env.TRACKER_SCRIPT_NAME;
@@ -20,14 +22,16 @@ if (collectApiEndpoint) {
2022
const apiRoute = originalManifest.headers.find(route => route.source === API_PATH);
2123
const routeRegex = new RegExp(apiRoute.regex);
2224

25+
const normalizedSource = basePath + collectApiEndpoint;
26+
2327
rewrites.push({
24-
source: collectApiEndpoint,
25-
destination: '/api/send',
28+
source: normalizedSource,
29+
destination: basePath + '/api/send',
2630
});
2731

28-
if (!routeRegex.test(collectApiEndpoint)) {
32+
if (!routeRegex.test(normalizedSource)) {
2933
headers.push({
30-
source: collectApiEndpoint,
34+
source: normalizedSource,
3135
headers: apiRoute.headers,
3236
});
3337
}
@@ -40,7 +44,7 @@ if (trackerScriptName) {
4044

4145
if (names) {
4246
names.forEach(name => {
43-
const normalizedSource = `/${name.replace(/^\/+/, '')}`;
47+
const normalizedSource = `${basePath}/${name.replace(/^\/+/, '')}`;
4448

4549
rewrites.push({
4650
source: normalizedSource,

src/app/api/send/route.ts

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -187,26 +187,19 @@ export async function POST(request: Request) {
187187
websiteId,
188188
sessionId,
189189
visitId,
190+
createdAt,
191+
192+
// Page
193+
pageTitle: safeDecodeURIComponent(title),
194+
hostname: hostname || urlDomain,
190195
urlPath: safeDecodeURI(urlPath),
191196
urlQuery,
192-
utmSource,
193-
utmMedium,
194-
utmCampaign,
195-
utmContent,
196-
utmTerm,
197197
referrerPath: safeDecodeURI(referrerPath),
198198
referrerQuery,
199199
referrerDomain,
200-
pageTitle: safeDecodeURIComponent(title),
201-
gclid,
202-
fbclid,
203-
msclkid,
204-
ttclid,
205-
lifatid,
206-
twclid,
207-
eventName: name,
208-
eventData: data,
209-
hostname: hostname || urlDomain,
200+
201+
// Session
202+
distinctId: id,
210203
browser,
211204
os,
212205
device,
@@ -215,24 +208,39 @@ export async function POST(request: Request) {
215208
country,
216209
region,
217210
city,
211+
212+
// Events
213+
eventName: name,
214+
eventData: data,
218215
tag,
219-
distinctId: id,
220-
createdAt,
216+
217+
// UTM
218+
utmSource,
219+
utmMedium,
220+
utmCampaign,
221+
utmContent,
222+
utmTerm,
223+
224+
// Click IDs
225+
gclid,
226+
fbclid,
227+
msclkid,
228+
ttclid,
229+
lifatid,
230+
twclid,
221231
});
222232
}
223233

224234
if (type === COLLECTION_TYPE.identify) {
225-
if (!data) {
226-
return badRequest('Data required.');
235+
if (data) {
236+
await saveSessionData({
237+
websiteId,
238+
sessionId,
239+
sessionData: data,
240+
distinctId: id,
241+
createdAt,
242+
});
227243
}
228-
229-
await saveSessionData({
230-
websiteId,
231-
sessionId,
232-
sessionData: data,
233-
distinctId: id,
234-
createdAt,
235-
});
236244
}
237245

238246
const token = createToken({ websiteId, sessionId, visitId, iat }, secret());

src/lib/charts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function renderDateLabels(unit: string, locale: string) {
1111

1212
switch (unit) {
1313
case 'minute':
14-
return formatDate(d, 'p', locale).split(' ')[0];
14+
return formatDate(d, 'h:mm', locale);
1515
case 'hour':
1616
return formatDate(d, 'p', locale);
1717
case 'day':

0 commit comments

Comments
 (0)