2022-12-13 04:45:38 +01:00
|
|
|
import { NextApiRequest } from 'next';
|
2023-07-02 07:02:49 +02:00
|
|
|
import { COLLECTION_TYPE, DATA_TYPE, EVENT_TYPE, KAFKA_TOPIC, ROLES } from './constants';
|
2023-03-03 07:48:30 +01:00
|
|
|
|
|
|
|
type ObjectValues<T> = T[keyof T];
|
|
|
|
|
2023-06-01 06:46:49 +02:00
|
|
|
export type CollectionType = ObjectValues<typeof COLLECTION_TYPE>;
|
2022-12-13 04:45:38 +01:00
|
|
|
|
2023-06-01 06:46:49 +02:00
|
|
|
export type Role = ObjectValues<typeof ROLES>;
|
2023-03-23 22:01:15 +01:00
|
|
|
|
2023-06-01 06:46:49 +02:00
|
|
|
export type EventType = ObjectValues<typeof EVENT_TYPE>;
|
2023-03-23 22:01:15 +01:00
|
|
|
|
2023-07-02 07:02:49 +02:00
|
|
|
export type DynamicDataType = ObjectValues<typeof DATA_TYPE>;
|
2023-03-23 22:01:15 +01:00
|
|
|
|
2023-06-01 06:46:49 +02:00
|
|
|
export type KafkaTopic = ObjectValues<typeof KAFKA_TOPIC>;
|
|
|
|
|
|
|
|
export interface DynamicData {
|
|
|
|
[key: string]: number | string | DynamicData | number[] | string[] | DynamicData[];
|
2023-03-23 22:01:15 +01:00
|
|
|
}
|
2023-04-02 02:38:35 +02:00
|
|
|
|
2022-12-13 04:45:38 +01:00
|
|
|
export interface Auth {
|
|
|
|
user?: {
|
|
|
|
id: string;
|
|
|
|
username: string;
|
|
|
|
role: string;
|
|
|
|
isAdmin: boolean;
|
|
|
|
};
|
2022-12-13 20:27:55 +01:00
|
|
|
shareToken?: {
|
|
|
|
websiteId: string;
|
|
|
|
};
|
2022-12-13 04:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface NextApiRequestQueryBody<TQuery = any, TBody = any> extends NextApiRequest {
|
|
|
|
auth?: Auth;
|
|
|
|
query: TQuery & { [key: string]: string | string[] };
|
|
|
|
body: TBody;
|
|
|
|
headers: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface NextApiRequestAuth extends NextApiRequest {
|
|
|
|
auth?: Auth;
|
|
|
|
headers: any;
|
|
|
|
}
|
|
|
|
|
2023-02-28 05:03:04 +01:00
|
|
|
export interface User {
|
|
|
|
id: string;
|
|
|
|
username: string;
|
|
|
|
password?: string;
|
2023-04-13 21:08:53 +02:00
|
|
|
role: string;
|
2023-02-28 05:03:04 +01:00
|
|
|
createdAt?: Date;
|
|
|
|
}
|
|
|
|
|
2022-12-13 04:45:38 +01:00
|
|
|
export interface Website {
|
|
|
|
id: string;
|
|
|
|
userId: string;
|
2023-03-27 20:25:16 +02:00
|
|
|
resetAt: Date;
|
2022-12-13 04:45:38 +01:00
|
|
|
name: string;
|
|
|
|
domain: string;
|
|
|
|
shareId: string;
|
|
|
|
createdAt: Date;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Share {
|
|
|
|
id: string;
|
|
|
|
token: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface WebsiteActive {
|
|
|
|
x: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface WebsiteMetric {
|
|
|
|
x: string;
|
|
|
|
y: number;
|
|
|
|
}
|
|
|
|
|
2023-04-02 00:44:30 +02:00
|
|
|
export interface WebsiteMetricFilter {
|
|
|
|
domain?: string;
|
|
|
|
url?: string;
|
|
|
|
referrer?: string;
|
|
|
|
title?: string;
|
|
|
|
query?: string;
|
|
|
|
event?: string;
|
|
|
|
os?: string;
|
|
|
|
browser?: string;
|
|
|
|
device?: string;
|
|
|
|
country?: string;
|
2023-04-17 09:10:51 +02:00
|
|
|
region?: string;
|
2023-04-02 00:44:30 +02:00
|
|
|
city?: string;
|
|
|
|
}
|
|
|
|
|
2022-12-13 04:45:38 +01:00
|
|
|
export interface WebsiteEventMetric {
|
|
|
|
x: string;
|
|
|
|
t: string;
|
|
|
|
y: number;
|
|
|
|
}
|
|
|
|
|
2023-03-23 22:01:15 +01:00
|
|
|
export interface WebsiteEventDataMetric {
|
|
|
|
x: string;
|
|
|
|
t: string;
|
|
|
|
eventName?: string;
|
|
|
|
urlPath?: string;
|
|
|
|
}
|
|
|
|
|
2022-12-13 04:45:38 +01:00
|
|
|
export interface WebsitePageviews {
|
|
|
|
pageviews: {
|
|
|
|
t: string;
|
|
|
|
y: number;
|
|
|
|
};
|
|
|
|
sessions: {
|
|
|
|
t: string;
|
|
|
|
y: number;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface WebsiteStats {
|
|
|
|
pageviews: { value: number; change: number };
|
|
|
|
uniques: { value: number; change: number };
|
|
|
|
bounces: { value: number; change: number };
|
|
|
|
totalTime: { value: number; change: number };
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface RealtimeInit {
|
|
|
|
websites: Website[];
|
|
|
|
token: string;
|
|
|
|
data: RealtimeUpdate;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface RealtimeUpdate {
|
|
|
|
pageviews: any[];
|
|
|
|
sessions: any[];
|
|
|
|
events: any[];
|
|
|
|
timestamp: number;
|
|
|
|
}
|