feat(analytics): add behavior and payment funnel tracking

This commit is contained in:
2026-07-14 16:54:13 +08:00
parent ca55723e48
commit 81d6489978
70 changed files with 1576 additions and 81 deletions
@@ -1,9 +1,10 @@
import { describe, expect, it } from "vitest";
import { describe, expect, it, vi } from "vitest";
import {
getPaymentUrl,
getStripeClientSecret,
isEzpayPayment,
launchEzpayRedirect,
} from "../payment_launch";
describe("payment launch helpers", () => {
@@ -40,4 +41,22 @@ describe("payment launch helpers", () => {
}),
).toBeNull();
});
it("reports a launch failure before redirecting without an order id", async () => {
const onOpened = vi.fn();
const onFailed = vi.fn();
await launchEzpayRedirect({
orderId: null,
paymentUrl: "https://pay.example/checkout?token=secret",
subscriptionType: "topup",
onOpened,
onFailed,
});
expect(onOpened).not.toHaveBeenCalled();
expect(onFailed).toHaveBeenCalledWith(
"Missing order id before opening Ezpay.",
);
});
});