Skip to content

Commit

Permalink
Merge pull request #1217 from hydralauncher/feat/intercom-userid
Browse files Browse the repository at this point in the history
feat: add userid to intercom and post to logout
  • Loading branch information
zamitto authored Nov 9, 2024
2 parents 981dbce + 77e9de7 commit 20c0019
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 851 deletions.
8 changes: 4 additions & 4 deletions src/main/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export const LUDUSAVI_MANIFEST_URL = "https://cdn.losbroxas.org/manifest.yaml";

export const defaultDownloadsPath = app.getPath("downloads");

export const isStaging = import.meta.env.MAIN_VITE_API_URL.includes("staging");

export const databaseDirectory = path.join(app.getPath("appData"), "hydra");
export const databasePath = path.join(
databaseDirectory,
import.meta.env.MAIN_VITE_API_URL.includes("staging")
? "hydra_test.db"
: "hydra.db"
isStaging ? "hydra_test.db" : "hydra.db"
);

export const logsPath = path.join(app.getPath("appData"), "hydra", "logs");
Expand All @@ -25,4 +25,4 @@ export const achievementSoundPath = app.isPackaged

export const backupsPath = path.join(app.getPath("userData"), "Backups");

export const appVersion = app.getVersion();
export const appVersion = app.getVersion() + (isStaging ? "-staging" : "");
11 changes: 9 additions & 2 deletions src/main/events/misc/open-checkout.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { shell } from "electron";
import { registerEvent } from "../register-event";
import { userAuthRepository } from "@main/repository";
import {
userAuthRepository,
userPreferencesRepository,
} from "@main/repository";
import { HydraApi } from "@main/services";

const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => {
const userAuth = await userAuthRepository.findOne({ where: { id: 1 } });
const [userAuth, userPreferences] = await Promise.all([
userAuthRepository.findOne({ where: { id: 1 } }),
userPreferencesRepository.findOne({ where: { id: 1 } }),
]);

if (!userAuth) {
return;
Expand All @@ -16,6 +22,7 @@ const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => {

const params = new URLSearchParams({
token: paymentToken,
lng: userPreferences?.language || "en",
});

shell.openExternal(
Expand Down
2 changes: 2 additions & 0 deletions src/main/services/hydra-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export class HydraApi {
expirationTimestamp: 0,
subscription: null,
};

this.post("/auth/logout", {}, { needsAuth: false }).catch(() => {});
}

static async setupApi() {
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export interface AppProps {
children: React.ReactNode;
}

console.log(import.meta.env);

Intercom({
app_id: import.meta.env.RENDERER_VITE_INTERCOM_APP_ID,
});
Expand Down
Loading

0 comments on commit 20c0019

Please sign in to comment.