Merge branch 'dev' into hosts-support

This commit is contained in:
Mike Cao 2024-06-18 23:02:14 -07:00 committed by GitHub
commit d1559c3a98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
281 changed files with 7555 additions and 1973 deletions

View file

@ -20,6 +20,7 @@ export const DEFAULT_DATE_RANGE = '24hour';
export const DEFAULT_WEBSITE_LIMIT = 10;
export const DEFAULT_RESET_DATE = '2000-01-01';
export const DEFAULT_PAGE_SIZE = 10;
export const DEFAULT_DATE_COMPARE = 'prev';
export const REALTIME_RANGE = 30;
export const REALTIME_INTERVAL = 5000;
@ -32,7 +33,7 @@ export const FILTER_REFERRERS = 'filter-referrers';
export const FILTER_PAGES = 'filter-pages';
export const UNIT_TYPES = ['year', 'month', 'hour', 'day', 'minute'];
export const EVENT_COLUMNS = ['url', 'referrer', 'title', 'query', 'event', 'host'];
export const EVENT_COLUMNS = ['url', 'entry', 'exit', 'referrer', 'title', 'query', 'event', 'host'];
export const SESSION_COLUMNS = [
'browser',
@ -48,6 +49,8 @@ export const SESSION_COLUMNS = [
export const FILTER_COLUMNS = {
url: 'url_path',
entry: 'url_path',
exit: 'url_path',
referrer: 'referrer_domain',
host: 'hostname',
title: 'page_title',
@ -114,9 +117,11 @@ export const DATA_TYPES = {
export const REPORT_TYPES = {
funnel: 'funnel',
goals: 'goals',
insights: 'insights',
retention: 'retention',
utm: 'utm',
journey: 'journey',
} as const;
export const REPORT_PARAMETERS = {

View file

@ -88,3 +88,7 @@ function getKeyName(key: string, parentKey: string) {
return `${parentKey}.${key}`;
}
export function objectToArray(obj: object) {
return Object.keys(obj).map(key => obj[key]);
}

View file

@ -326,3 +326,13 @@ export function getDateLength(startDate: Date, endDate: Date, unit: string | num
const { diff } = DATE_FUNCTIONS[unit];
return diff(endDate, startDate) + 1;
}
export function getCompareDate(compare: string, startDate: Date, endDate: Date) {
if (compare === 'yoy') {
return { startDate: subYears(startDate, 1), endDate: subYears(endDate, 1) };
}
const diff = differenceInMinutes(endDate, startDate);
return { startDate: subMinutes(startDate, diff), endDate: subMinutes(endDate, diff) };
}

View file

@ -2,6 +2,7 @@ import {
arSA,
be,
bn,
bg,
bs,
cs,
sk,
@ -48,6 +49,7 @@ import {
export const languages = {
'ar-SA': { label: 'العربية', dateLocale: arSA, dir: 'rtl' },
'be-BY': { label: 'Беларуская', dateLocale: be },
'bg-BG': { label: 'български език', dateLocale: bg },
'bn-BD': { label: 'বাংলা', dateLocale: bn },
'bs-BA': { label: 'Bosanski', dateLocale: bs },
'ca-ES': { label: 'Català', dateLocale: ca },

View file

@ -3,7 +3,7 @@ import { Website, Session } from '@prisma/client';
import redis from '@umami/redis-client';
export async function fetchWebsite(websiteId: string): Promise<Website> {
let website;
let website = null;
if (redis.enabled) {
website = await redis.client.fetch(`website:${websiteId}`, () => getWebsite(websiteId), 86400);
@ -19,7 +19,7 @@ export async function fetchWebsite(websiteId: string): Promise<Website> {
}
export async function fetchSession(sessionId: string): Promise<Session> {
let session;
let session = null;
if (redis.enabled) {
session = await redis.client.fetch(`session:${sessionId}`, () => getSession(sessionId), 86400);