Skip to content

Commit

Permalink
fix: track wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
cgilbe27 committed May 20, 2024
1 parent 3a31280 commit 87e854e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 31 deletions.
14 changes: 0 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@
type="text/javascript"
src="https://www.googletagmanager.com/gtm.js?id= GTM-5Z96TB6L&l=dataLayer"
></script>
<script
src="https://cdn.logr-ingest.com/LogRocket.min.js"
crossorigin="anonymous"
></script>
<script>
if (
window.location.host.includes('explorer.nibiru.fi') &&
window.LogRocket
) {
window.LogRocket.init('pypxrk/nibiru', {
rootHostname: window.location.host,
});
}
</script>
</head>
<body>
<!-- Google Tag Manager (noscript) -->
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion src/stores/useBlockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
53 changes: 37 additions & 16 deletions src/stores/useWalletStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,28 @@ 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: () => {
return {
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: {
Expand All @@ -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();
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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' });
},
},
});
});
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 87e854e

Please sign in to comment.