feat: global platform update
This commit is contained in:
@@ -11,6 +11,8 @@ import type {
|
||||
AnalyticsQueryParams,
|
||||
SpendingAnalyticsQueryParams,
|
||||
PaginatedResponse,
|
||||
OverviewAnalytics,
|
||||
OverviewAnalyticsQueryParams,
|
||||
} from "@/lib/types/api";
|
||||
|
||||
export const analyticsApi = {
|
||||
@@ -49,4 +51,13 @@ export const analyticsApi = {
|
||||
`/workspaces/${workspaceId}/analytics/spending`,
|
||||
{ params }
|
||||
),
|
||||
|
||||
/**
|
||||
* Overview analytics for dashboard
|
||||
*/
|
||||
overview: (workspaceId: string, params?: OverviewAnalyticsQueryParams) =>
|
||||
api.get<OverviewAnalytics>(
|
||||
`/workspaces/${workspaceId}/analytics/overview`,
|
||||
{ params }
|
||||
),
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@ import type {
|
||||
SpendingAnalytics,
|
||||
CreativeAnalyticsItem,
|
||||
ChannelAnalyticsItem,
|
||||
OverviewAnalytics,
|
||||
} from "@/lib/types/api";
|
||||
import {
|
||||
demoWorkspace,
|
||||
@@ -26,6 +27,7 @@ import {
|
||||
demoSpendingAnalytics,
|
||||
demoCreativeAnalytics,
|
||||
demoChannelAnalytics,
|
||||
demoOverviewAnalytics,
|
||||
} from "./mock-data";
|
||||
import { DEMO_USER } from "./constants";
|
||||
|
||||
@@ -191,6 +193,13 @@ export const demoApi = {
|
||||
}
|
||||
return Promise.resolve(paginate(items));
|
||||
},
|
||||
overview: (_params?: {
|
||||
project_id?: string;
|
||||
date_from?: string;
|
||||
date_to?: string;
|
||||
}): Promise<OverviewAnalytics> => {
|
||||
return Promise.resolve(demoOverviewAnalytics);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
demoProjects,
|
||||
demoWorkspace,
|
||||
demoMember,
|
||||
demoOverviewAnalytics,
|
||||
} from "./mock-data";
|
||||
import type {
|
||||
PaginatedResponse,
|
||||
@@ -29,6 +30,7 @@ import type {
|
||||
Workspace,
|
||||
WorkspaceMember,
|
||||
DateGrouping,
|
||||
OverviewAnalytics,
|
||||
} from "@/lib/types/api";
|
||||
import {
|
||||
workspacesApi,
|
||||
@@ -305,5 +307,14 @@ export const demoAwareAnalyticsApi = {
|
||||
}
|
||||
return analyticsApi.channels(workspaceId, params);
|
||||
},
|
||||
overview: async (
|
||||
workspaceId: string,
|
||||
params?: { project_id?: string; date_from?: string; date_to?: string }
|
||||
): Promise<OverviewAnalytics> => {
|
||||
if (isDemoWorkspace(workspaceId)) {
|
||||
return demoOverviewAnalytics;
|
||||
}
|
||||
return analyticsApi.overview(workspaceId, params);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import type {
|
||||
SpendingAnalytics,
|
||||
CreativeAnalyticsItem,
|
||||
ChannelAnalyticsItem,
|
||||
OverviewAnalytics,
|
||||
} from "@/lib/types/api";
|
||||
import { DEMO_WORKSPACE_ID, DEMO_USER } from "./constants";
|
||||
|
||||
@@ -581,3 +582,125 @@ export const demoChannelAnalytics: ChannelAnalyticsItem[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const demoOverviewAnalytics: OverviewAnalytics = {
|
||||
total_cost: { value: 523400.5, delta_percent: 12.4 },
|
||||
total_reach: { value: 380000, delta_percent: -8.1 },
|
||||
placements_count: { value: 74, delta_percent: 5.7 },
|
||||
subscriptions_count: { value: 14250, delta_percent: 18.2 },
|
||||
avg_cpm: { value: 1376.06, delta_percent: 2.9 },
|
||||
avg_cpf: { value: 36.74, delta_percent: -5.4 },
|
||||
daily_stats: [
|
||||
{ date: "2024-06-01", cost: 18450, subscriptions: 420, subscriptions_delta: -15, cpf: 43.93 },
|
||||
{ date: "2024-06-02", cost: 21700, subscriptions: 505, subscriptions_delta: 85, cpf: 42.97 },
|
||||
{ date: "2024-06-03", cost: 15800, subscriptions: 380, subscriptions_delta: -125, cpf: 41.58 },
|
||||
{ date: "2024-06-04", cost: 26500, subscriptions: 640, subscriptions_delta: 260, cpf: 41.41 },
|
||||
{ date: "2024-06-05", cost: 30200, subscriptions: 715, subscriptions_delta: 75, cpf: 42.24 },
|
||||
{ date: "2024-06-06", cost: 18800, subscriptions: 455, subscriptions_delta: -260, cpf: 41.32 },
|
||||
{ date: "2024-06-07", cost: 22400, subscriptions: 520, subscriptions_delta: 65, cpf: 43.08 },
|
||||
],
|
||||
top_channels_by_cpf: [
|
||||
{
|
||||
channel_id: "chan-0005-0000-0000-000000000005",
|
||||
title: "Финансовая грамотность",
|
||||
username: "finance_edu",
|
||||
cpf: 18.7,
|
||||
total_cost: 44200,
|
||||
subscriptions: 2365,
|
||||
},
|
||||
{
|
||||
channel_id: "chan-0003-0000-0000-000000000003",
|
||||
title: "Программисты",
|
||||
username: "programmers_hub",
|
||||
cpf: 21.8,
|
||||
total_cost: 38900,
|
||||
subscriptions: 1785,
|
||||
},
|
||||
{
|
||||
channel_id: "chan-0001-0000-0000-000000000001",
|
||||
title: "Технологии Будущего",
|
||||
username: "tech_future",
|
||||
cpf: 23.4,
|
||||
total_cost: 35500,
|
||||
subscriptions: 1517,
|
||||
},
|
||||
{
|
||||
channel_id: "chan-0002-0000-0000-000000000002",
|
||||
title: "Инвестиции Pro",
|
||||
username: "invest_pro",
|
||||
cpf: 24.6,
|
||||
total_cost: 33100,
|
||||
subscriptions: 1346,
|
||||
},
|
||||
{
|
||||
channel_id: "chan-0006-0000-0000-000000000006",
|
||||
title: "Startup Daily",
|
||||
username: "startup_daily",
|
||||
cpf: 25.2,
|
||||
total_cost: 28800,
|
||||
subscriptions: 1143,
|
||||
},
|
||||
],
|
||||
worst_channels_by_cpf: [
|
||||
{
|
||||
channel_id: "chan-0010-0000-0000-000000000010",
|
||||
title: "Crypto Buzz",
|
||||
username: "cryptobuzz",
|
||||
cpf: 84.5,
|
||||
total_cost: 9900,
|
||||
subscriptions: 117,
|
||||
},
|
||||
{
|
||||
channel_id: "chan-0009-0000-0000-000000000009",
|
||||
title: "Ads Unlimited",
|
||||
username: "ads_unlimited",
|
||||
cpf: 72.3,
|
||||
total_cost: 8200,
|
||||
subscriptions: 113,
|
||||
},
|
||||
{
|
||||
channel_id: "chan-0008-0000-0000-000000000008",
|
||||
title: "News Mix",
|
||||
username: "newsmix",
|
||||
cpf: 66.2,
|
||||
total_cost: 11400,
|
||||
subscriptions: 172,
|
||||
},
|
||||
{
|
||||
channel_id: "chan-0007-0000-0000-000000000007",
|
||||
title: "Random Talks",
|
||||
username: "randomtalks",
|
||||
cpf: 61.9,
|
||||
total_cost: 13400,
|
||||
subscriptions: 216,
|
||||
},
|
||||
{
|
||||
channel_id: "chan-0004-0000-0000-000000000004",
|
||||
title: "Маркетинг Pro",
|
||||
username: "marketing_pro",
|
||||
cpf: 58.4,
|
||||
total_cost: 12700,
|
||||
subscriptions: 217,
|
||||
},
|
||||
],
|
||||
project_spending: [
|
||||
{
|
||||
project_id: "proj-0001-0000-0000-000000000001",
|
||||
project_title: "Крипто Новости",
|
||||
project_username: "crypto_news_demo",
|
||||
total_cost: 244000,
|
||||
},
|
||||
{
|
||||
project_id: "proj-0002-0000-0000-000000000002",
|
||||
project_title: "IT Вакансии",
|
||||
project_username: "it_jobs_demo",
|
||||
total_cost: 182400,
|
||||
},
|
||||
{
|
||||
project_id: "proj-0003-0000-0000-000000000003",
|
||||
project_title: "Стартапы и Бизнес",
|
||||
project_username: "startups_demo",
|
||||
total_cost: 96900,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -354,6 +354,55 @@ export interface SpendingAnalyticsQueryParams {
|
||||
grouping?: DateGrouping;
|
||||
}
|
||||
|
||||
// Overview Analytics
|
||||
export interface OverviewMetric {
|
||||
value: number;
|
||||
delta_percent: number;
|
||||
}
|
||||
|
||||
export interface OverviewDailyStat {
|
||||
date: string; // YYYY-MM-DD
|
||||
cost: number;
|
||||
subscriptions: number;
|
||||
subscriptions_delta: number;
|
||||
cpf: number;
|
||||
}
|
||||
|
||||
export interface OverviewChannelCpf {
|
||||
channel_id: string;
|
||||
title: string;
|
||||
username: string | null;
|
||||
cpf: number;
|
||||
total_cost: number;
|
||||
subscriptions: number;
|
||||
}
|
||||
|
||||
export interface OverviewProjectSpending {
|
||||
project_id: string;
|
||||
project_title: string;
|
||||
project_username: string | null;
|
||||
total_cost: number;
|
||||
}
|
||||
|
||||
export interface OverviewAnalytics {
|
||||
total_cost: OverviewMetric;
|
||||
total_reach: OverviewMetric;
|
||||
placements_count: OverviewMetric;
|
||||
subscriptions_count: OverviewMetric;
|
||||
avg_cpm: OverviewMetric;
|
||||
avg_cpf: OverviewMetric;
|
||||
daily_stats: OverviewDailyStat[];
|
||||
top_channels_by_cpf: OverviewChannelCpf[];
|
||||
worst_channels_by_cpf: OverviewChannelCpf[];
|
||||
project_spending: OverviewProjectSpending[];
|
||||
}
|
||||
|
||||
export interface OverviewAnalyticsQueryParams {
|
||||
project_id?: string;
|
||||
date_from?: string;
|
||||
date_to?: string;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Common Types
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user