Skip to content

Commit

Permalink
chore: setup sentry vite (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuanddd authored Feb 9, 2023
1 parent 6bbd54d commit 9d6942f
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"devDependencies": {
"@iconify-json/heroicons": "^1.1.8",
"@sentry/vite-plugin": "^0.4.0",
"@types/node": "^18.11.18",
"@types/postmate": "^1.5.2",
"@types/react": "^18.0.26",
Expand Down
9 changes: 7 additions & 2 deletions src/stores/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { toast } from "react-hot-toast";
import Minimap from "scenes/Game/Minimap";
import { Menu, Minigame } from "constants/game";
import { utils } from "ethers";
import * as Sentry from "@sentry/react";

const DEFAULT_PLAYER = {
id: 0,
Expand Down Expand Up @@ -161,6 +162,7 @@ export const useGameState = create<State>((set, get) => ({
if (sessionStr) {
const session = JSON.parse(sessionStr);
set({ token: session.token, account: session.address });
Sentry.setUser({ id: session.address });
}
},
login: async (signature: `0x${string}`, message: string) => {
Expand All @@ -177,18 +179,21 @@ export const useGameState = create<State>((set, get) => ({
});
if (res.ok) {
const data = await res.json();
set({ token: data.token, account: utils.getAddress(data.user.wallet) });
const address = utils.getAddress(data.user.wallet);
set({ token: data.token, account: address });
localStorage.setItem(
"session",
JSON.stringify({
token: data.token,
address: utils.getAddress(data.user.wallet),
address,
chainId: 1,
})
);
Sentry.setUser({ id: address });
}
},
logout: async () => {
Sentry.setUser(null);
const { transitionTo } = get();
localStorage.removeItem("session");
transitionTo(SceneKey.BOOT, SceneKey.BOOT, [
Expand Down
23 changes: 20 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
import { defineConfig } from "vite";
import { defineConfig, loadEnv } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import react from "@vitejs/plugin-react";
import unocss from "@unocss/vite";
// @ts-ignore
import { config as unocssConfig } from "./unocss.config";

export default defineConfig((config) => {
import { sentryVitePlugin } from "@sentry/vite-plugin";

export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), "");

return {
plugins: [react(), unocss(unocssConfig), tsconfigPaths()],
build: {
sourcemap: true,
},
plugins: [
react(),
unocss(unocssConfig),
tsconfigPaths(),
sentryVitePlugin({
org: "consolelabs",
project: mode === "production" ? "verse-web-prod" : "verse-web-dev",
include: "./dist",
authToken: env.VITE_SENTRY_AUTH_TOKEN,
}),
],
server: { host: "0.0.0.0", port: 8000 },
clearScreen: false,
};
Expand Down
93 changes: 90 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,28 @@
"@sentry/utils" "7.36.0"
tslib "^1.9.3"

"@sentry/[email protected]":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@sentry/bundler-plugin-core/-/bundler-plugin-core-0.4.0.tgz#3e22808466ac696e2f7633497dd42ef0a80f9226"
integrity sha512-Xi+dqaSOoxbdmxegX7f66FVOxm2dVJLmrMXUpoNyuV6ASoccRWzouGaFekP059SUTTD05ytk1mHqwgVuBCA0Dw==
dependencies:
"@sentry/cli" "^2.10.0"
"@sentry/node" "^7.19.0"
"@sentry/tracing" "^7.19.0"
magic-string "0.27.0"
unplugin "1.0.1"

"@sentry/cli@^2.10.0":
version "2.12.0"
resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-2.12.0.tgz#425c044b71648786f8e0a2db38603e510d002a1f"
integrity sha512-EHDZVaje1Vkm0sygVyKuUtQgTw7OFzgysBXjwEad6BgZVPTtF46v0eizCrBK9jwA1P30logf76D1u+eULaSDDw==
dependencies:
https-proxy-agent "^5.0.0"
node-fetch "^2.6.7"
progress "^2.0.3"
proxy-from-env "^1.1.0"
which "^2.0.2"

"@sentry/[email protected]":
version "7.36.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.36.0.tgz#37c82a1ad3f74dbe2c2fcd55f45068e127012fcc"
Expand All @@ -1002,6 +1024,19 @@
"@sentry/utils" "7.36.0"
tslib "^1.9.3"

"@sentry/node@^7.19.0":
version "7.36.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.36.0.tgz#7c42a6a2f4d979563c1c595ccd5a0c6d5b5abc19"
integrity sha512-nAHAY+Rbn5OlTpNX/i6wYrmw3hT/BtwPZ/vNU52cKgw7CpeE1UrCeFjnPn18rQPB7lIh7x0vNvoaPrfemRzpSQ==
dependencies:
"@sentry/core" "7.36.0"
"@sentry/types" "7.36.0"
"@sentry/utils" "7.36.0"
cookie "^0.4.1"
https-proxy-agent "^5.0.0"
lru_map "^0.3.3"
tslib "^1.9.3"

"@sentry/react@^7.36.0":
version "7.36.0"
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.36.0.tgz#8916d7a3d4f988161dd88ecc17a884e006fd5d01"
Expand All @@ -1022,7 +1057,7 @@
"@sentry/types" "7.36.0"
"@sentry/utils" "7.36.0"

"@sentry/tracing@^7.36.0":
"@sentry/tracing@^7.19.0", "@sentry/tracing@^7.36.0":
version "7.36.0"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.36.0.tgz#aa38319ed07f3b642134cf47da81f43df7835629"
integrity sha512-5R5mfWMDncOcTMmmyYMjgus1vZJzIFw4LHaSbrX7e1IRNT/6vFyNeVxATa2ePXb9mI3XHo5f2p7YrnreAtaSXw==
Expand All @@ -1045,6 +1080,13 @@
"@sentry/types" "7.36.0"
tslib "^1.9.3"

"@sentry/vite-plugin@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@sentry/vite-plugin/-/vite-plugin-0.4.0.tgz#4c43ac18e19c2e8e9d9a32b64ac774da2c9354b7"
integrity sha512-dBxM00MCLzO/idzAqj33ZfbIBKZxP+FzpxtS2WaV0yzad9yLBAFZ/VGDIGHQJC0Qo3fsFi/CZpmN39wJkJoWFA==
dependencies:
"@sentry/bundler-plugin-core" "0.4.0"

"@solana/buffer-layout@^4.0.0":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz#b996235eaec15b1e0b5092a8ed6028df77fa6c15"
Expand Down Expand Up @@ -2217,6 +2259,11 @@ acorn@^8.4.1, acorn@^8.6.0, acorn@^8.8.0:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.1.tgz#0a3f9cbecc4ec3bea6f0a80b66ae8dd2da250b73"
integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==

acorn@^8.8.1:
version "8.8.2"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a"
integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==

[email protected]:
version "3.0.0"
resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d"
Expand Down Expand Up @@ -2937,6 +2984,11 @@ convert-source-map@^1.7.0:
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.9.0.tgz#7faae62353fb4213366d0ca98358d22e8368b05f"
integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==

cookie@^0.4.1:
version "0.4.2"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432"
integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==

copy-to-clipboard@^3.3.1:
version "3.3.3"
resolved "https://registry.yarnpkg.com/copy-to-clipboard/-/copy-to-clipboard-3.3.3.tgz#55ac43a1db8ae639a4bd99511c148cdd1b83a1b0"
Expand Down Expand Up @@ -4682,7 +4734,12 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"

magic-string@^0.27.0:
lru_map@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd"
integrity sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==

[email protected], magic-string@^0.27.0:
version "0.27.0"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.27.0.tgz#e4a3413b4bab6d98d2becffd48b4a257effdbbf3"
integrity sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==
Expand Down Expand Up @@ -5340,6 +5397,16 @@ process@^0.11.1:
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==

progress@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==

proxy-from-env@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==

pump@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"
Expand Down Expand Up @@ -6271,6 +6338,16 @@ unocss@^0.48.3:
"@unocss/transformer-variant-group" "0.48.3"
"@unocss/vite" "0.48.3"

[email protected]:
version "1.0.1"
resolved "https://registry.yarnpkg.com/unplugin/-/unplugin-1.0.1.tgz#83b528b981cdcea1cad422a12cd02e695195ef3f"
integrity sha512-aqrHaVBWW1JVKBHmGo33T5TxeL0qWzfvjWokObHA9bYmN7eNDkwOxmLjhioHl9878qDFMAaT51XNroRyuz7WxA==
dependencies:
acorn "^8.8.1"
chokidar "^3.5.3"
webpack-sources "^3.2.3"
webpack-virtual-modules "^0.5.0"

update-browserslist-db@^1.0.9:
version "1.0.10"
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz#0f54b876545726f17d00cd9a2561e6dade943ff3"
Expand Down Expand Up @@ -6410,6 +6487,16 @@ webidl-conversions@^3.0.0:
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==

webpack-sources@^3.2.3:
version "3.2.3"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde"
integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==

webpack-virtual-modules@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/webpack-virtual-modules/-/webpack-virtual-modules-0.5.0.tgz#362f14738a56dae107937ab98ea7062e8bdd3b6c"
integrity sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==

whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
Expand All @@ -6435,7 +6522,7 @@ which-typed-array@^1.1.2:
has-tostringtag "^1.0.0"
is-typed-array "^1.1.10"

which@^2.0.1:
which@^2.0.1, which@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==
Expand Down

0 comments on commit 9d6942f

Please sign in to comment.