9deb320cf6
Rename the global Sidebar route, UI, assets, analytics, and payment return context to Profile. Add accessible message-avatar navigation and preserve the source character across auth and logout flows. BREAKING CHANGE: /sidebar has been removed; use /profile instead.
81 lines
2.0 KiB
TypeScript
81 lines
2.0 KiB
TypeScript
export const PAYMENT_ANALYTICS_ENTRY_PARAM = "analytics_entry";
|
|
export const PAYMENT_ANALYTICS_REASON_PARAM = "analytics_reason";
|
|
|
|
export type PaymentAnalyticsTriggerReason =
|
|
| "daily_chat_limit"
|
|
| "private_topic_limit"
|
|
| "insufficient_credits"
|
|
| "profile_recharge"
|
|
| "vip_cta"
|
|
| "ad_landing"
|
|
| "manual_recharge"
|
|
| "unknown";
|
|
|
|
export type PaymentAnalyticsEntryPoint =
|
|
| "chat_input"
|
|
| "chat_unlock"
|
|
| "private_album_unlock"
|
|
| "private_room"
|
|
| "profile"
|
|
| "chat_offer_banner"
|
|
| "subscription_direct"
|
|
| "tip_page"
|
|
| "external_entry"
|
|
| "unknown";
|
|
|
|
export interface PaymentAnalyticsContext {
|
|
entryPoint: PaymentAnalyticsEntryPoint;
|
|
triggerReason: PaymentAnalyticsTriggerReason;
|
|
}
|
|
|
|
const ENTRY_POINTS = new Set<PaymentAnalyticsEntryPoint>([
|
|
"chat_input",
|
|
"chat_unlock",
|
|
"private_album_unlock",
|
|
"private_room",
|
|
"profile",
|
|
"chat_offer_banner",
|
|
"subscription_direct",
|
|
"tip_page",
|
|
"external_entry",
|
|
"unknown",
|
|
]);
|
|
|
|
const TRIGGER_REASONS = new Set<PaymentAnalyticsTriggerReason>([
|
|
"daily_chat_limit",
|
|
"private_topic_limit",
|
|
"insufficient_credits",
|
|
"profile_recharge",
|
|
"vip_cta",
|
|
"ad_landing",
|
|
"manual_recharge",
|
|
"unknown",
|
|
]);
|
|
|
|
export function getDefaultPaymentAnalyticsContext(
|
|
type: "vip" | "topup",
|
|
): PaymentAnalyticsContext {
|
|
return {
|
|
entryPoint: "subscription_direct",
|
|
triggerReason: type === "topup" ? "manual_recharge" : "vip_cta",
|
|
};
|
|
}
|
|
|
|
export function parsePaymentAnalyticsContext(input: {
|
|
entryPoint: string | null;
|
|
triggerReason: string | null;
|
|
subscriptionType: "vip" | "topup";
|
|
}): PaymentAnalyticsContext {
|
|
const fallback = getDefaultPaymentAnalyticsContext(input.subscriptionType);
|
|
return {
|
|
entryPoint: ENTRY_POINTS.has(input.entryPoint as PaymentAnalyticsEntryPoint)
|
|
? (input.entryPoint as PaymentAnalyticsEntryPoint)
|
|
: fallback.entryPoint,
|
|
triggerReason: TRIGGER_REASONS.has(
|
|
input.triggerReason as PaymentAnalyticsTriggerReason,
|
|
)
|
|
? (input.triggerReason as PaymentAnalyticsTriggerReason)
|
|
: fallback.triggerReason,
|
|
};
|
|
}
|