Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/backend/src/app/api/latest/internal/metrics/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function loadUsersByCountry(tenancy: Tenancy, includeAnonymous: boolean =
ON "Event"."endUserIpInfoGuessId" = eip.id
WHERE '$user-activity' = ANY("systemEventTypeIds"::text[])
AND "data"->>'projectId' = ${tenancy.project.id}
AND (${includeAnonymous} OR NOT "data"->>'isAnonymous' = 'true')
AND (${includeAnonymous} OR COALESCE("data"->>'isAnonymous', 'false') != 'true')
AND COALESCE("data"->>'branchId', 'main') = ${tenancy.branchId}
AND "countryCode" IS NOT NULL
ORDER BY "userId", "eventStartedAt" DESC
Expand Down Expand Up @@ -87,7 +87,7 @@ async function loadDailyActiveUsers(tenancy: Tenancy, now: Date, includeAnonymou
daily_users AS (
SELECT
DATE_TRUNC('day', "eventStartedAt") AS "day",
COUNT(DISTINCT CASE WHEN (${includeAnonymous} OR "data"->>'isAnonymous' = 'false') THEN "data"->'userId' ELSE NULL END) AS "dau"
COUNT(DISTINCT CASE WHEN (${includeAnonymous} OR COALESCE("data"->>'isAnonymous', 'false') != 'true') THEN "data"->'userId' ELSE NULL END) AS "dau"
FROM "Event"
WHERE "eventStartedAt" >= ${now}::date - INTERVAL '30 days'
AND '$user-activity' = ANY("systemEventTypeIds"::text[])
Expand Down Expand Up @@ -146,7 +146,7 @@ async function loadRecentlyActiveUsers(tenancy: Tenancy, includeAnonymous: boole
) as rn
FROM "Event"
WHERE "data"->>'projectId' = ${tenancy.project.id}
AND (${includeAnonymous} OR NOT "data"->>'isAnonymous' = 'true')
AND (${includeAnonymous} OR COALESCE("data"->>'isAnonymous', 'false') != 'true')
AND COALESCE("data"->>'branchId', 'main') = ${tenancy.branchId}
AND '$user-activity' = ANY("systemEventTypeIds"::text[])
)
Expand Down
Loading