From 719cb61f448d68b9f1cd0626e3bd1dfed11398a2 Mon Sep 17 00:00:00 2001 From: Darnell Andries Date: Tue, 9 Jul 2024 14:24:50 -0700 Subject: [PATCH] Change development environment to point to premium staging --- src/services.ts | 5 +++++ src/subscriptions.ts | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/services.ts b/src/services.ts index 0dd08da5c..362d94839 100644 --- a/src/services.ts +++ b/src/services.ts @@ -1,7 +1,12 @@ +export const env = process.env.ENVIRONMENT ?? "local"; + export function resolveService( servicePrefix: string, baseHost: string = window.location.host, ): string { + if (env.startsWith("development") && servicePrefix === "account") { + return "https://account.bravesoftware.com"; + } return `https://${servicePrefix}.${secondLevelDomain(baseHost)}`; } diff --git a/src/subscriptions.ts b/src/subscriptions.ts index ed7ba0847..d7247b90a 100644 --- a/src/subscriptions.ts +++ b/src/subscriptions.ts @@ -13,7 +13,7 @@ const loadRewardsSdk = async (): Promise => { log(`calling initialize(${env}, false)...`); const sdk = await Rewards.initialize( - isDevelopment ? "development" : env, + isDevelopment ? "staging" : env, false, isProduction ? "error" : "info", ); @@ -68,12 +68,16 @@ export async function recoverCredsIfRequired(orderId: string): Promise { } } +function getCredentialHostname(): string | undefined { + return isDevelopment ? "talk.bravesoftware.com" : undefined; +} + export async function checkSubscribedUsingSDK(): Promise { try { const sdk = await loadRewardsSdk(); log(`calling credential_summary...`); - const result = await sdk.credential_summary(); + const result = await sdk.credential_summary(getCredentialHostname()); log("credential_summary returns", result); if (result && result.active) { return true; @@ -91,7 +95,7 @@ export async function setTemporaryCredentialCookie(): Promise { log(`calling present_credentials...`); - const result = await sdk.present_credentials(); + const result = await sdk.present_credentials(getCredentialHostname()); log("present_credentials returns", result); if (result) { return true;