mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-06 18:21:12 +00:00
maybe_landing_url signup params
This commit is contained in:
1 parent
f2c386dcb9
commit
71fd694368
6 files changed
+22
-2
No files matched your search
@@ -33,6 +33,7 @@ export function GoogleLoginButton({
|
||||
const result = await api.GoogleSSO({
|
||||
credential: credentialResponse.credential,
|
||||
maybeReferralUrl: (window as any).cached_referrer,
|
||||
maybeLandingUrl: (window as any).cached_landing_url,
|
||||
});
|
||||
if (result.success) {
|
||||
window.dispatchEvent(new Event("auth-change"));
|
||||
|
||||
@@ -58,6 +58,7 @@ export const SignupForm = ({
|
||||
passwordConfirmation: password,
|
||||
signupSource,
|
||||
maybeReferralUrl: (window as any).cached_referrer,
|
||||
maybeLandingUrl: (window as any).cached_landing_url,
|
||||
});
|
||||
|
||||
setIsLoading(false);
|
||||
|
||||
@@ -193,6 +193,7 @@ const PricingTable = ({
|
||||
plan: apiPlanSlug,
|
||||
cadence: cadence,
|
||||
maybeReferralUrl: (window as any).cached_referrer,
|
||||
maybeLandingUrl: (window as any).cached_landing_url,
|
||||
});
|
||||
|
||||
if (!response.success || !response.data) {
|
||||
|
||||
@@ -26,6 +26,9 @@ if (import.meta.env.DEV) {
|
||||
if (!(window as any).cached_referrer) {
|
||||
(window as any).cached_referrer = document.referrer || undefined;
|
||||
}
|
||||
if (!(window as any).cached_landing_url) {
|
||||
(window as any).cached_landing_url = window.location.href || undefined;
|
||||
}
|
||||
|
||||
// Fire-and-forget: log the referral once per browser session
|
||||
if (!sessionStorage.getItem("referral_logged")) {
|
||||
|
||||
@@ -35,15 +35,17 @@ export class BillingApi extends ApiManager {
|
||||
plan,
|
||||
cadence,
|
||||
maybeReferralUrl,
|
||||
maybeLandingUrl,
|
||||
}: {
|
||||
plan: string;
|
||||
cadence: "yearly" | "monthly";
|
||||
maybeReferralUrl?: string;
|
||||
maybeLandingUrl?: string;
|
||||
}): Promise<ApiResponse<{ stripeCheckoutRedirectUrl: string }>> {
|
||||
const endpoint = `${this.getApiSchemeAndHost()}/v1/stripe_artcraft/user_signup_subscription_checkout`;
|
||||
|
||||
return await this.post<
|
||||
{ plan: string; cadence: string; maybe_referral_url?: string },
|
||||
{ plan: string; cadence: string; maybe_referral_url?: string; maybe_landing_url?: string },
|
||||
{
|
||||
success: boolean;
|
||||
stripe_checkout_redirect_url?: string;
|
||||
@@ -55,6 +57,7 @@ export class BillingApi extends ApiManager {
|
||||
plan,
|
||||
cadence,
|
||||
...(maybeReferralUrl && { maybe_referral_url: maybeReferralUrl }),
|
||||
...(maybeLandingUrl && { maybe_landing_url: maybeLandingUrl }),
|
||||
},
|
||||
})
|
||||
.then((response) => ({
|
||||
|
||||
@@ -9,6 +9,7 @@ interface SignupRequest {
|
||||
password_confirmation: string;
|
||||
signup_source?: string;
|
||||
maybe_referral_url?: string;
|
||||
maybe_landing_url?: string;
|
||||
}
|
||||
|
||||
export class UsersApi extends ApiManager {
|
||||
@@ -202,6 +203,7 @@ export class UsersApi extends ApiManager {
|
||||
passwordConfirmation,
|
||||
signupSource,
|
||||
maybeReferralUrl,
|
||||
maybeLandingUrl,
|
||||
}: {
|
||||
username: string;
|
||||
email: string;
|
||||
@@ -209,6 +211,7 @@ export class UsersApi extends ApiManager {
|
||||
passwordConfirmation: string;
|
||||
signupSource?: string;
|
||||
maybeReferralUrl?: string;
|
||||
maybeLandingUrl?: string;
|
||||
}): Promise<ApiResponse<{ signedSession?: string }>> {
|
||||
const endpoint = `${this.getApiSchemeAndHost()}/v1/create_account`;
|
||||
const body: SignupRequest = {
|
||||
@@ -223,6 +226,9 @@ export class UsersApi extends ApiManager {
|
||||
if (maybeReferralUrl) {
|
||||
body.maybe_referral_url = maybeReferralUrl;
|
||||
}
|
||||
if (maybeLandingUrl) {
|
||||
body.maybe_landing_url = maybeLandingUrl;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await this.authFetch<
|
||||
@@ -259,17 +265,22 @@ export class UsersApi extends ApiManager {
|
||||
public async GoogleSSO({
|
||||
credential,
|
||||
maybeReferralUrl,
|
||||
maybeLandingUrl,
|
||||
}: {
|
||||
credential: string;
|
||||
maybeReferralUrl?: string;
|
||||
maybeLandingUrl?: string;
|
||||
}): Promise<ApiResponse<{ usernameNotYetCustomized?: boolean }>> {
|
||||
const endpoint = `${this.getApiSchemeAndHost()}/v1/accounts/google_sso`;
|
||||
const body: { google_credential: string; maybe_referral_url?: string } = {
|
||||
const body: { google_credential: string; maybe_referral_url?: string; maybe_landing_url?: string } = {
|
||||
google_credential: credential,
|
||||
};
|
||||
if (maybeReferralUrl) {
|
||||
body.maybe_referral_url = maybeReferralUrl;
|
||||
}
|
||||
if (maybeLandingUrl) {
|
||||
body.maybe_landing_url = maybeLandingUrl;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await this.authFetch<
|
||||
|
||||
Reference in new issue
Block a user