Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: logrocket #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
cgilbe27 marked this conversation as resolved.
Show resolved Hide resolved

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 '';
},
cgilbe27 marked this conversation as resolved.
Show resolved Hide resolved
},
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);
}
cgilbe27 marked this conversation as resolved.
Show resolved Hide resolved
},
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
Loading