feat: insights
* fix: migration for newly created self-hosting instances * fix: build script * wip * wip * wip * fix: tailwind css
This commit is contained in:
committed by
GitHub
parent
1e4f02fb5e
commit
5f38560373
@@ -1,2 +1,3 @@
|
||||
export * from './src/index';
|
||||
export * from './src/types.validation';
|
||||
export * from './src/types.insights';
|
||||
|
||||
@@ -553,3 +553,5 @@ export const zCreateImport = z.object({
|
||||
});
|
||||
|
||||
export type ICreateImport = z.infer<typeof zCreateImport>;
|
||||
|
||||
export * from './types.insights';
|
||||
|
||||
43
packages/validation/src/types.insights.ts
Normal file
43
packages/validation/src/types.insights.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
export type InsightMetricKey = 'sessions' | 'pageviews' | 'share';
|
||||
|
||||
export type InsightMetricUnit = 'count' | 'ratio';
|
||||
|
||||
export interface InsightMetricEntry {
|
||||
current: number;
|
||||
compare: number;
|
||||
delta: number;
|
||||
changePct: number | null;
|
||||
direction: 'up' | 'down' | 'flat';
|
||||
unit: InsightMetricUnit;
|
||||
}
|
||||
|
||||
export interface InsightDimension {
|
||||
key: string;
|
||||
value: string;
|
||||
displayName?: string;
|
||||
}
|
||||
|
||||
export interface InsightExtra {
|
||||
[key: string]: unknown;
|
||||
currentShare?: number;
|
||||
compareShare?: number;
|
||||
shareShiftPp?: number;
|
||||
isNew?: boolean;
|
||||
isGone?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared payload shape for insights cards. This is embedded in DB rows and
|
||||
* shipped to the frontend, so it must remain backwards compatible.
|
||||
*/
|
||||
export interface InsightPayload {
|
||||
kind?: 'insight_v1';
|
||||
dimensions: InsightDimension[];
|
||||
primaryMetric: InsightMetricKey;
|
||||
metrics: Partial<Record<InsightMetricKey, InsightMetricEntry>>;
|
||||
|
||||
/**
|
||||
* Module-specific extra data.
|
||||
*/
|
||||
extra?: Record<string, unknown>;
|
||||
}
|
||||
Reference in New Issue
Block a user