Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Add secondary sort key for deterministic ordering

Blue Mouseceb3e56d6be9
diff --git a/backend/apps/cloud/src/analytics/analytics.service.ts b/backend/apps/cloud/src/analytics/analytics.service.ts
index dc5528d42..8a6b72743 100644
--- a/backend/apps/cloud/src/analytics/analytics.service.ts
+++ b/backend/apps/cloud/src/analytics/analytics.service.ts
@@ -1594,7 +1594,7 @@ export class AnalyticsService {
INNER JOIN session_info si ON e.psid = si.psid
GROUP BY e.step, si.source
)
- ORDER BY step, type, cnt DESC
+ ORDER BY step, type, cnt DESC, val ASC
LIMIT 3 BY step, type
`
diff --git a/backend/apps/community/src/analytics/analytics.service.ts b/backend/apps/community/src/analytics/analytics.service.ts
index 95376b1f1..069bb4af7 100644
--- a/backend/apps/community/src/analytics/analytics.service.ts
+++ b/backend/apps/community/src/analytics/analytics.service.ts
@@ -1555,7 +1555,7 @@ export class AnalyticsService {
INNER JOIN session_info si ON e.psid = si.psid
GROUP BY e.step, si.source
)
- ORDER BY step, type, cnt DESC
+ ORDER BY step, type, cnt DESC, val ASC
LIMIT 3 BY step, type
`