Skip to content

Commit

Permalink
fix: remove mixpanel
Browse files Browse the repository at this point in the history
  • Loading branch information
Akamig committed Jun 17, 2024
1 parent 04641ba commit 68ae340
Show file tree
Hide file tree
Showing 13 changed files with 2 additions and 191 deletions.
17 changes: 0 additions & 17 deletions __tests__/mock/MockNineChroniclesMixpanel.ts

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"graphql-request": "5.1.0",
"lockfile": "^1.0.4",
"material-ui-popup-state": "^1.6.1",
"mixpanel": "^0.13.0",
"mobx": "^6.7.0",
"mobx-react": "^7.6.0",
"mobx-react-router": "^5.0.0",
Expand Down
1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ export const CUSTOM_SERVER: boolean =
LocalServerPort().notDefault ||
RpcServerHost().notDefault ||
RpcServerPort().notDefault;
export const MIXPANEL_TOKEN = "80a1e14b57d050536185c7459d45195a";
export const TRANSIFEX_TOKEN = "1/9ac6d0a1efcda679e72e470221e71f4b0497f7ab";
export const DEFAULT_DOWNLOAD_BASE_URL = "https://release.nine-chronicles.com";
export const installerName = "NineChroniclesInstaller.exe";
Expand Down
78 changes: 2 additions & 76 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
configStore,
get as getConfig,
playerPath,
MIXPANEL_TOKEN,
netenv,
baseUrl,
CONFIG_FILE_PATH,
Expand All @@ -30,11 +29,9 @@ import "core-js";
import log from "electron-log";
import * as utils from "src/utils";
import { IGameStartOptions } from "../interfaces/ipc";
import { init as createMixpanel } from "mixpanel";
import { v4 as uuidv4 } from "uuid";
import { Client as NTPClient } from "ntp-time";
import { IConfig } from "src/interfaces/config";
import { NineChroniclesMixpanel } from "./mixpanel";
import {
createWindow as createV2Window,
setQuitting as setV2Quitting,
Expand Down Expand Up @@ -79,12 +76,6 @@ const updateOptions: IUpdateOptions = {
downloadStarted: quitAllProcesses,
};

const mixpanelUUID = loadInstallerMixpanelUUID();
const mixpanel: NineChroniclesMixpanel | undefined =
getConfig("Mixpanel") && process.env.NODE_ENV === "production"
? new NineChroniclesMixpanel(createMixpanel(MIXPANEL_TOKEN), mixpanelUUID)
: undefined;

client
.syncTime()
.then((time) => {
Expand Down Expand Up @@ -115,17 +106,6 @@ if (!app.requestSingleInstanceLock()) {

app.on("open-url", (_, url) => win && send(win, IPC_OPEN_URL, url));

let quitTracked = false;
app.on("before-quit", (event) => {
if (mixpanel != null && !quitTracked) {
event.preventDefault();
mixpanel?.track("Launcher/Quit", undefined, () => {
quitTracked = true;
app.quit();
});
}
});

cleanUp();

if (process.platform === "darwin" && process.arch == "arm64") {
Expand Down Expand Up @@ -270,10 +250,6 @@ async function initializeApp() {

if (app.commandLine.hasSwitch("protocol"))
send(win!, IPC_OPEN_URL, process.argv[process.argv.length - 1]);

mixpanel?.track("Launcher/Start", {
isV2: true,
});
});

app.on("quit", (event) => {
Expand Down Expand Up @@ -350,10 +326,6 @@ function initializeIpc() {
}
});

ipcMain.on("login", async () => {
mixpanel?.login();
});

ipcMain.on("get-aws-sink-cloudwatch-guid", async (event) => {
const localAppData = process.env.localappdata;
if (process.platform === "win32" && localAppData !== undefined) {
Expand All @@ -377,19 +349,6 @@ function initializeIpc() {
event.returnValue = "Not supported platform.";
});

ipcMain.on(
"mixpanel-track-event",
async (_, eventName: string, param: object) => {
mixpanel?.track(eventName, {
...param,
});
},
);

ipcMain.on("mixpanel-alias", async (_, alias: string) => {
mixpanel?.alias(alias);
});

ipcMain.on("online-status-changed", (event, status: "online" | "offline") => {
console.log(`online-status-changed: ${status}`);
if (status === "offline") {
Expand Down Expand Up @@ -449,32 +408,6 @@ function cleanUp() {
cleanUpLockfile();
}

function loadInstallerMixpanelUUID(): string {
const planetariumPath =
process.platform === "win32"
? path.join(process.env.LOCALAPPDATA as string, "planetarium")
: app.getPath("userData");
if (!fs.existsSync(planetariumPath)) {
fs.mkdirSync(planetariumPath, {
recursive: true,
});
}

const guidPath = path.join(planetariumPath, ".installer_mixpanel_uuid");

if (!fs.existsSync(guidPath)) {
const newUUID = uuidv4();
console.log(`The installer mixpanel UUID doesn't exist at '${guidPath}'.`);
fs.writeFileSync(guidPath, newUUID);
console.log(`Created new UUID ${newUUID} and stored.`);
return newUUID;
} else {
return fs.readFileSync(guidPath, {
encoding: "utf-8",
});
}
}

async function quitAllProcesses(reason: string = "default") {
if (gameNode === null) return;
const pid = gameNode.pid!;
Expand Down Expand Up @@ -520,15 +453,8 @@ function createTray(iconPath: string) {
}

function relaunch() {
if (mixpanel !== undefined) {
mixpanel.track("Launcher/Relaunch", undefined, () => {
app.relaunch();
app.exit();
});
} else {
app.relaunch();
app.exit();
}
app.relaunch();
app.exit();
}

function initCheckForUpdateWorker(
Expand Down
48 changes: 0 additions & 48 deletions src/main/mixpanel.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/renderer/components/core/Layout/UserInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { useT } from "@transifex/react";
import { useBalance } from "src/utils/useBalance";
import { useUserStaking } from "src/utils/staking";
import { useTx } from "src/utils/useTx";
import { trackEvent } from "src/utils/mixpanel";
import { useLoginSession } from "src/utils/useLoginSession";
import { Avatar } from "src/renderer/views/ClaimCollectionRewardsOverlay/ClaimContent";
import { ExportOverlay } from "./ExportOverlay";
Expand Down Expand Up @@ -146,10 +145,6 @@ export default function UserInfo() {
fetchResult({
variables: { txId: txId!.data.stageTransaction },
});
trackEvent("Staking/Claim", {
txId,
avatar: avatar.address,
});
});
},
});
Expand Down
4 changes: 0 additions & 4 deletions src/renderer/views/LoginView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from "src/renderer/components/ui/Select";
import { PasswordField } from "src/renderer/components/ui/TextField";
import { T } from "src/renderer/i18n";
import { trackEvent } from "src/utils/mixpanel";
import { useStore } from "src/utils/useStore";

const transifexTags = "v2/login-view";
Expand Down Expand Up @@ -71,8 +70,6 @@ function LoginView() {
localStorage.setItem("lastAddress", address);
const account = (await accountStore.getAccount(address, password))!;
await accountStore.login(account, password);
ipcRenderer.send("mixpanel-alias", address);
trackEvent("Launcher/Login");

_refiner("setProject", "43e75b10-c10d-11ec-a73a-958e7574f4fc");
_refiner("identifyUser", {
Expand All @@ -85,7 +82,6 @@ function LoginView() {
history.push("/lobby");
} catch (error) {
setInvalid(true);
trackEvent("Launcher/LoginFailed");
console.error(error);
}
};
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/views/RegisterView/CreateKeyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import RetypePasswordForm, {
} from "src/renderer/components/RetypePasswordForm";
import H1 from "src/renderer/components/ui/H1";
import { T } from "src/renderer/i18n";
import { trackEvent } from "src/utils/mixpanel";
import { useStore } from "src/utils/useStore";
import { registerStyles } from ".";
import { Web3Account } from "@planetarium/account-web3-secret-storage";
Expand All @@ -21,7 +20,6 @@ function CreateKeyView() {
const accountStore = useStore("account");

const onPasswordSubmit = async ({ password }: FormData) => {
trackEvent("Launcher/CreatePrivateKey");
const account: Web3Account = await accountStore.importRaw(
utils.bytesToHex(utils.randomPrivateKey()),
password,
Expand Down
6 changes: 0 additions & 6 deletions src/renderer/views/SettingsOverlay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,6 @@ function SettingsOverlay({ onClose, isOpen }: OverlayProps) {
<GroupTitle>
<T _str="Send Information" _tags={transifexTags} />
</GroupTitle>
<Checkbox {...register("Mixpanel")}>
<T
_str="Send anonymous usage information"
_tags={transifexTags}
/>
</Checkbox>
</FormSection>
</Form>
<Button
Expand Down
1 change: 0 additions & 1 deletion src/renderer/views/TransferAssetOverlay/swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ function SwapPage() {
setDebounce(false);
}, 15000);

ipcRenderer.send("mixpanel-track-event", "Launcher/Swap WNCG");
if (!addressVerify(recipient, true) || isOutOfRange) {
return;
}
Expand Down
1 change: 0 additions & 1 deletion src/renderer/views/TransferAssetOverlay/transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ function TransferPage() {
},
};
const handleButton = async (event: React.MouseEvent<HTMLButtonElement>) => {
ipcRenderer.send("mixpanel-track-event", "Launcher/Send NCG");
if (!addressVerify(recipient, true) || !amount.gt(0)) {
return;
}
Expand Down
9 changes: 0 additions & 9 deletions src/utils/mixpanel.ts

This file was deleted.

20 changes: 0 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7659,7 +7659,6 @@ __metadata:
lockfile: ^1.0.4
material-ui-popup-state: ^1.6.1
mini-css-extract-plugin: ^2.7.6
mixpanel: ^0.13.0
mobx: ^6.7.0
mobx-react: ^7.6.0
mobx-react-router: ^5.0.0
Expand Down Expand Up @@ -13691,16 +13690,6 @@ __metadata:
languageName: node
linkType: hard

"https-proxy-agent@npm:5.0.0":
version: 5.0.0
resolution: "https-proxy-agent@npm:5.0.0"
dependencies:
agent-base: 6
debug: 4
checksum: 165bfb090bd26d47693597661298006841ab733d0c7383a8cb2f17373387a94c903a3ac687090aa739de05e379ab6f868bae84ab4eac288ad85c328cd1ec9e53
languageName: node
linkType: hard

"https-proxy-agent@npm:^2.2.1":
version: 2.2.4
resolution: "https-proxy-agent@npm:2.2.4"
Expand Down Expand Up @@ -16113,15 +16102,6 @@ __metadata:
languageName: node
linkType: hard

"mixpanel@npm:^0.13.0":
version: 0.13.0
resolution: "mixpanel@npm:0.13.0"
dependencies:
https-proxy-agent: 5.0.0
checksum: b7486d763aa8f57670e99590db0488bc722178b8844c0508d127c8f1b160fd36053e3e90f0cc11d0669dfd7778b170b3638200b481005c6583122ae343c5f069
languageName: node
linkType: hard

"mkdirp-classic@npm:^0.5.2":
version: 0.5.3
resolution: "mkdirp-classic@npm:0.5.3"
Expand Down

0 comments on commit 68ae340

Please sign in to comment.