feat(analytics): add behavior and payment funnel tracking
This commit is contained in:
+20
-1
@@ -8,6 +8,11 @@
|
||||
*/
|
||||
|
||||
import type { PayChannel } from "@/data/dto/payment";
|
||||
import {
|
||||
PAYMENT_ANALYTICS_ENTRY_PARAM,
|
||||
PAYMENT_ANALYTICS_REASON_PARAM,
|
||||
type PaymentAnalyticsContext,
|
||||
} from "@/lib/analytics/payment_analytics_context";
|
||||
|
||||
/** 静态路由字面量 */
|
||||
export const ROUTES = {
|
||||
@@ -29,11 +34,25 @@ export type StaticRoute = (typeof ROUTES)[keyof typeof ROUTES];
|
||||
export const ROUTE_BUILDERS = {
|
||||
subscription: (
|
||||
type: "vip" | "topup",
|
||||
options: { payChannel?: PayChannel; returnTo?: "chat" } = {},
|
||||
options: {
|
||||
payChannel?: PayChannel;
|
||||
returnTo?: "chat";
|
||||
analytics?: PaymentAnalyticsContext;
|
||||
} = {},
|
||||
): `/subscription?${string}` => {
|
||||
const params = new URLSearchParams({ type });
|
||||
if (options.payChannel) params.set("payChannel", options.payChannel);
|
||||
if (options.returnTo) params.set("returnTo", options.returnTo);
|
||||
if (options.analytics) {
|
||||
params.set(
|
||||
PAYMENT_ANALYTICS_ENTRY_PARAM,
|
||||
options.analytics.entryPoint,
|
||||
);
|
||||
params.set(
|
||||
PAYMENT_ANALYTICS_REASON_PARAM,
|
||||
options.analytics.triggerReason,
|
||||
);
|
||||
}
|
||||
return `${ROUTES.subscription}?${params.toString()}` as const;
|
||||
},
|
||||
authWithRedirect: (redirectTo: string): `/auth?redirect=${string}` =>
|
||||
|
||||
Reference in New Issue
Block a user