Files
discord-decomp/modules/premium/native/PremiumAnalyticsUtils.tsx
T
2026-11-01 12:12:55 +02:00

96 lines
3.2 KiB
TypeScript

// Metro module 6295 (f6296).
import { AnalyticEvents, PurchaseTypeToAnalyticsPaymentType, PurchaseTypes, SubscriptionTypes } from "../../../Constants";
import { v4 } from "../../../_bundle/Module514";
import { getPremiumPlanItem } from "../../../utils/PremiumUtils";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { HermesBuiltin } from "../../../_hermes/prelude";
const r20 = {
SKU_SELECT: "sku_select",
PLAN_SELECT: "plan_select",
REVIEW: "review",
CONFIRM: "confirm",
MOBILE_WEB_REDIRECT_CHECKOUT: "mobile_web_redirect_checkout",
YEARLY_UPSELL: "yearly_upsell",
PREMIUM_UPSELL: "premium_upsell",
EXTERNAL_PAYMENT: "external_payment",
REWARD_SKU_SELECT: "reward_sku_select"
};
const r30 = {
WHAT_YOU_LOSE: 1,
1: "WHAT_YOU_LOSE",
CONFIRM: 2,
2: "CONFIRM",
PREVIEW: 3,
3: "PREVIEW",
DOWNGRADE_TO_TIER_0: 4,
4: "DOWNGRADE_TO_TIER_0",
MOBILE_SUBSCRIPTION_MANAGE: 5,
5: "MOBILE_SUBSCRIPTION_MANAGE"
};
const r40 = {};
r40[r30.WHAT_YOU_LOSE] = "What You're Losing";
r40[r30.DOWNGRADE_TO_TIER_0] = "Downgrade To Tier 0";
r40[r30.CONFIRM] = "Confirm Cancellation";
r40[r30.PREVIEW] = "Preview Updated Subscription";
r40[r30.MOBILE_SUBSCRIPTION_MANAGE] = "Mobile Subscription Manage";
export { r20 as PaymentFlowStep };
export function getBasePurchaseFlowAnalyticsFields(a0) {
const { analyticsLoadId, isGift = false, analyticsLocation } = a0;
return {
load_id: analyticsLoadId,
payment_type: PurchaseTypeToAnalyticsPaymentType[PurchaseTypes.SUBSCRIPTION],
subscription_type: SubscriptionTypes.PREMIUM,
is_gift: isGift,
location: analyticsLocation,
location_stack: a0.analyticsLocations,
location_section: analyticsLocation?.section
};
}
export function getPaymentFlowCompletedAnalyticsFields(a0, a1) {
return {
...a0,
...a1
};
}
export function getPaymentFlowStepAnalyticsFields(a0, a1) {
return {
...a0,
...a1
};
}
export function getNewAnalyticsLoadId() {
return v4();
}
export { r30 as CancellationFlowSteps };
export { r40 as STEP_ANALYTICS_NAMES };
export function trackPremiumSubscriptionCancellationStarted(a0, a1) {
const CANCELLATION_FLOW_STARTED = AnalyticEvents.CANCELLATION_FLOW_STARTED;
const r17 = {
location_stack: a1
};
HermesBuiltin.copyDataProperties(r17, {
subscription_id: a0?.id,
subscription_type: a0?.type,
subscription_plan_id: a0 != null ? getPremiumPlanItem(a0)?.id : void 0,
subscription_plan_gateway_plan_id: a0?.paymentGatewayPlanId,
subscription_status: a0?.status
});
AnalyticsUtils.track(CANCELLATION_FLOW_STARTED, r17);
}
export function trackPremiumSubscriptionCancellationFlowStep({ fromStep, toStep, subscription, analyticsLocations }) {
const CANCELLATION_FLOW_STEP = AnalyticEvents.CANCELLATION_FLOW_STEP;
const r18 = {
from_step: fromStep,
to_step: toStep,
location_stack: analyticsLocations
};
HermesBuiltin.copyDataProperties(r18, {
subscription_id: subscription?.id,
subscription_type: subscription?.type,
subscription_plan_id: subscription != null ? getPremiumPlanItem(subscription)?.id : void 0,
subscription_plan_gateway_plan_id: subscription?.paymentGatewayPlanId,
subscription_status: subscription?.status
});
AnalyticsUtils.track(CANCELLATION_FLOW_STEP, r18);
}