chore AnalyticsRetention config

This commit is contained in:
oiov
2025-05-04 20:42:34 +08:00
parent 4469e408e9
commit fab90a0bd8
10 changed files with 50 additions and 19 deletions
+1
View File
@@ -31,6 +31,7 @@ export default async function DashboardPage() {
name: user.name || "",
apiKey: user.apiKey || "",
role: user.role,
team: user.team,
}}
action="/api/url/admin"
/>
+9 -1
View File
@@ -94,7 +94,13 @@ async function LiveLogSection() {
async function UserUrlsListSection({
user,
}: {
user: { id: string; name: string; apiKey: string; role: UserRole };
user: {
id: string;
name: string;
apiKey: string;
role: UserRole;
team: string;
};
}) {
return (
<UserUrlsList
@@ -103,6 +109,7 @@ async function UserUrlsListSection({
name: user.name,
apiKey: user.apiKey,
role: user.role,
team: user.team,
}}
action="/api/url"
/>
@@ -185,6 +192,7 @@ export default async function DashboardPage() {
name: user.name || "",
apiKey: user.apiKey || "",
role: user.role,
team: user.team,
}}
/>
</Suspense>
+11 -2
View File
@@ -3,12 +3,13 @@
import * as React from "react";
import { useState } from "react";
import Link from "next/link";
import { UrlMeta } from "@prisma/client";
import { UrlMeta, User } from "@prisma/client";
import { VisSingleContainer, VisTooltip, VisTopoJSONMap } from "@unovis/react";
import { TopoJSONMap } from "@unovis/ts";
import { WorldMapTopoJSON } from "@unovis/ts/maps";
import { Area, AreaChart, CartesianGrid, XAxis } from "recharts";
import { TeamPlanQuota } from "@/config/team";
import { getCountryName, getDeviceVendor } from "@/lib/contries";
import { DATE_DIMENSION_ENUMS } from "@/lib/enums";
import { isLink, removeUrlSuffix, timeAgo } from "@/lib/utils";
@@ -144,10 +145,12 @@ export function DailyPVUVChart({
data,
timeRange,
setTimeRange,
user,
}: {
data: UrlMeta[];
timeRange: string;
setTimeRange: React.Dispatch<React.SetStateAction<string>>;
user: Pick<User, "id" | "name" | "team">;
}) {
const [activeChart, setActiveChart] =
React.useState<keyof typeof chartConfig>("pv");
@@ -232,7 +235,13 @@ export function DailyPVUVChart({
</SelectTrigger>
<SelectContent>
{DATE_DIMENSION_ENUMS.map((e) => (
<SelectItem key={e.value} value={e.value}>
<SelectItem
disabled={
e.key > TeamPlanQuota[user.team!].SL_AnalyticsRetention
}
key={e.value}
value={e.value}
>
{e.label}
</SelectItem>
))}
+10 -2
View File
@@ -4,6 +4,7 @@ import { useState } from "react";
import { UrlMeta, User } from "@prisma/client";
import useSWR from "swr";
import { TeamPlanQuota } from "@/config/team";
import { DATE_DIMENSION_ENUMS } from "@/lib/enums";
import { fetcher } from "@/lib/utils";
import {
@@ -19,7 +20,7 @@ import { EmptyPlaceholder } from "@/components/shared/empty-placeholder";
import { DailyPVUVChart } from "./meta-chart";
export interface UrlMetaProps {
user: Pick<User, "id" | "name">;
user: Pick<User, "id" | "name" | "team">;
action: string;
urlId: string;
}
@@ -57,7 +58,13 @@ export default function UserUrlMetaInfo({ user, action, urlId }: UrlMetaProps) {
</SelectTrigger>
<SelectContent>
{DATE_DIMENSION_ENUMS.map((e) => (
<SelectItem key={e.value} value={e.value}>
<SelectItem
disabled={
e.key > TeamPlanQuota[user.team!].SL_AnalyticsRetention
}
key={e.value}
value={e.value}
>
{e.label}
</SelectItem>
))}
@@ -74,6 +81,7 @@ export default function UserUrlMetaInfo({ user, action, urlId }: UrlMetaProps) {
data={data}
timeRange={timeRange}
setTimeRange={setTimeRange}
user={user}
/>
</div>
);
+1
View File
@@ -32,6 +32,7 @@ export default async function DashboardPage() {
name: user.name || "",
apiKey: user.apiKey || "",
role: user.role,
team: user.team,
}}
action="/api/url"
/>
+6 -2
View File
@@ -58,7 +58,7 @@ import { PaginationWrapper } from "@/components/shared/pagination";
import UserUrlMetaInfo from "./meta";
export interface UrlListProps {
user: Pick<User, "id" | "name" | "apiKey" | "role">;
user: Pick<User, "id" | "name" | "apiKey" | "role" | "team">;
action: string;
}
@@ -533,7 +533,11 @@ export default function UserUrlsList({ user, action }: UrlListProps) {
</TableRow>
{isShowStats && selectedUrlId === short.id && (
<UserUrlMetaInfo
user={{ id: user.id, name: user.name || "" }}
user={{
id: user.id,
name: user.name || "",
team: user.team,
}}
action="/api/url/meta"
urlId={short.id!}
/>
+1 -1
View File
@@ -54,7 +54,7 @@ const getBenefits = (plan) => [
icon: <Icons.help className="size-4" />,
},
{
text: "API Access",
text: "Open API Access",
checked: plan.APP_ApiAccess,
icon: <Icons.unplug className="size-4" />,
},
+2 -2
View File
@@ -15,7 +15,7 @@ export const TeamPlanQuota = {
premium: {
SL_TrackedClicks: 1000000,
SL_NewLinks: 5000,
SL_AnalyticsRetention: 360,
SL_AnalyticsRetention: 365,
SL_Domains: 2,
SL_AdvancedAnalytics: true,
RC_NewRecords: 2,
@@ -28,7 +28,7 @@ export const TeamPlanQuota = {
business: {
SL_TrackedClicks: 10000000,
SL_NewLinks: 10000,
SL_AnalyticsRetention: 360,
SL_AnalyticsRetention: 1000,
SL_Domains: 2,
SL_AdvancedAnalytics: true,
RC_NewRecords: 10,
+8 -8
View File
@@ -302,12 +302,12 @@ export const TIME_RANGES: Record<string, number> = {
};
export const DATE_DIMENSION_ENUMS = [
{ value: "24h", label: "Last 24 Hours" },
{ value: "7d", label: "Last 7 Days" },
{ value: "30d", label: "Last 30 Days" },
{ value: "60d", label: "Last 2 Months" },
{ value: "90d", label: "Last 3 Months" },
{ value: "180d", label: "Last 6 Months" },
{ value: "365d", label: "Last 1 Year" },
{ value: "All", label: "All the time" },
{ value: "24h", label: "Last 24 Hours", key: 1 },
{ value: "7d", label: "Last 7 Days", key: 7 },
{ value: "30d", label: "Last 30 Days", key: 30 },
{ value: "60d", label: "Last 2 Months", key: 60 },
{ value: "90d", label: "Last 3 Months", key: 90 },
{ value: "180d", label: "Last 6 Months", key: 180 },
{ value: "365d", label: "Last 1 Year", key: 365 },
{ value: "All", label: "All the time", key: 1000 },
] as const;
+1 -1
View File
File diff suppressed because one or more lines are too long