From 3a312804be6e8b0091c4caf2aa1c66b41d072fd1 Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Mon, 20 May 2024 16:18:24 -0400 Subject: [PATCH 1/2] feat: logrocket --- index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/index.html b/index.html index 9ad473d342..3fd9f39764 100644 --- a/index.html +++ b/index.html @@ -15,6 +15,20 @@ type="text/javascript" src="https://www.googletagmanager.com/gtm.js?id= GTM-5Z96TB6L&l=dataLayer" > + + From 87e854e25844634880d5ac4655f83d2b41e426da Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Mon, 20 May 2024 16:40:38 -0400 Subject: [PATCH 2/2] fix: track wallet --- index.html | 14 ---------- package.json | 1 + src/stores/useBlockchain.ts | 1 - src/stores/useWalletStore.ts | 53 +++++++++++++++++++++++++----------- yarn.lock | 5 ++++ 5 files changed, 43 insertions(+), 31 deletions(-) diff --git a/index.html b/index.html index 3fd9f39764..9ad473d342 100644 --- a/index.html +++ b/index.html @@ -15,20 +15,6 @@ type="text/javascript" src="https://www.googletagmanager.com/gtm.js?id= GTM-5Z96TB6L&l=dataLayer" > - - diff --git a/package.json b/package.json index a84112a70b..629f713ffc 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "daisyui": "^3.1.0", "dayjs": "^1.11.7", "lazy-load-vue3": "^1.3.0", + "logrocket": "^8.1.0", "long": "^5.2.1", "md-editor-v3": "^2.8.1", "numeral": "^2.0.6", diff --git a/src/stores/useBlockchain.ts b/src/stores/useBlockchain.ts index 21b688cba1..06fb490340 100644 --- a/src/stores/useBlockchain.ts +++ b/src/stores/useBlockchain.ts @@ -68,7 +68,6 @@ export const useBlockchain = defineStore('blockchain', { const router = useRouter(); const routes = router?.getRoutes() || []; if (this.current && routes) { - console.log(this.current); if (this.current?.themeColor) { const { color } = hexToRgb(this.current?.themeColor); const { h, s, l } = rgbToHsl(color); diff --git a/src/stores/useWalletStore.ts b/src/stores/useWalletStore.ts index 5962287cce..740278e593 100644 --- a/src/stores/useWalletStore.ts +++ b/src/stores/useWalletStore.ts @@ -9,7 +9,19 @@ import type { WalletConnected, } from '@/types'; import { useStakingStore } from './useStakingStore'; -import router from '@/router' +import router from '@/router'; +import LogRocket from 'logrocket'; + +const isProd = window.location.host.includes('explorer.nibiru.fi'); +let hasLogRocketSetup = false; + +if (isProd && !hasLogRocketSetup) { + LogRocket.init('pypxrk/nibiru', { + rootHostname: window.location.host, + }); + + hasLogRocketSetup = true; +} export const useWalletStore = defineStore('walletStore', { state: () => { @@ -17,8 +29,8 @@ export const useWalletStore = defineStore('walletStore', { balances: [] as Coin[], delegations: [] as Delegation[], unbonding: [] as UnbondingResponses[], - rewards: {total: [], rewards: []} as DelegatorRewards, - wallet: {} as WalletConnected + rewards: { total: [], rewards: [] } as DelegatorRewards, + wallet: {} as WalletConnected, }; }, getters: { @@ -27,11 +39,16 @@ export const useWalletStore = defineStore('walletStore', { }, connectedWallet() { // @ts-ignore - if(this.wallet.cosmosAddress) return this.wallet + if (this.wallet.cosmosAddress) return this.wallet; const chainStore = useBlockchain(); const key = chainStore.defaultHDPath; const connected = JSON.parse(localStorage.getItem(key) || '{}'); - return connected + + if (isProd) { + LogRocket.identify(connected.cosmosAddress); + LogRocket.track(connected.wallet); + } + return connected; }, balanceOfStakingToken(): Coin { const stakingStore = useStakingStore(); @@ -77,15 +94,14 @@ export const useWalletStore = defineStore('walletStore', { return toBech32(chainStore.current?.bech32Prefix || prefix, data); }, shortAddress() { - const address: string = this.currentAddress - if(address.length > 4) { - return `${address.substring(address.length -4)}` + const address: string = this.currentAddress; + if (address.length > 4) { + return `${address.substring(address.length - 4)}`; } - return "" - } + return ''; + }, }, actions: { - async loadMyAsset() { if (!this.currentAddress) return; this.blockchain.rpc.getBankBalances(this.currentAddress).then((x) => { @@ -122,14 +138,19 @@ export const useWalletStore = defineStore('walletStore', { const chainStore = useBlockchain(); const key = chainStore.defaultHDPath; localStorage.removeItem(key); - this.$reset() + this.$reset(); }, setConnectedWallet(value: WalletConnected) { - if(value) this.wallet = value + if (value) this.wallet = value; + + if (isProd) { + LogRocket.identify(value.cosmosAddress); + LogRocket.track(value.wallet); + } }, suggestChain() { // const router = useRouter() - router.push({path: '/wallet/keplr'}) - } + router.push({ path: '/wallet/keplr' }); + }, }, -}); \ No newline at end of file +}); diff --git a/yarn.lock b/yarn.lock index 6830532818..8ef17b9fee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5308,6 +5308,11 @@ logform@^2.3.2, logform@^2.4.0: safe-stable-stringify "^2.3.1" triple-beam "^1.3.0" +logrocket@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/logrocket/-/logrocket-8.1.0.tgz#2b804985b5370b359831ee03c92423e08ac48044" + integrity sha512-0PRv9lnS90KBrL3mfiQzcKEPvNT3N55pRN0PRe/q3DqWFQbIW1p72MmMp9a3Qi9la6o+TXri7r68ZE0AM7vsDA== + long@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28"