Skip to content

Commit

Permalink
Merge branch 'soeren/sentry'
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Nov 20, 2024
2 parents 94b8835 + f119203 commit 2a65093
Show file tree
Hide file tree
Showing 17 changed files with 207 additions and 308 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@nimiq/utils": "^0.11.7",
"@nimiq/vue-components": "https://github.com/nimiq/vue-components#build/albatross",
"@opengsn/common": "^2.2.5",
"@sentry/vue": "^6.0.0",
"@sentry/vue": "^8.39.0",
"@unstoppabledomains/resolution": "^9.1.0",
"@vue/composition-api": "^0.4.0",
"ethers": "^5.7.2",
Expand Down
20 changes: 7 additions & 13 deletions src/components/modals/BuyCryptoModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ import {
SetupSwapRequest,
SetupSwapResult,
} from '@nimiq/hub-api';
import { captureException } from '@sentry/vue';
import { Bank } from '@nimiq/oasis-bank-list';
import { getNetworkClient } from '@/network';
import { SwapState, useSwapsStore } from '@/stores/Swaps';
Expand Down Expand Up @@ -379,6 +378,7 @@ import { useBankStore } from '../../stores/Bank';
import { useKycStore } from '../../stores/Kyc';
import KycPrompt from '../kyc/KycPrompt.vue';
import KycOverlay from '../kyc/KycOverlay.vue';
import { reportToSentry } from '../../lib/Sentry';
enum Pages {
WELCOME,
Expand Down Expand Up @@ -664,8 +664,7 @@ export default defineComponent({
signedTransactions = await setupSwap(hubRequest);
if (signedTransactions === undefined) return; // Using Hub redirects
} catch (error: any) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
swapError.value = error.message;
cancelSwap({ id: (await hubRequest).swapId } as PreSwap);
// currentlySigning.value = false;
Expand All @@ -685,8 +684,7 @@ export default defineComponent({
if (typeof signedTransactions.eur !== 'string' || (!signedTransactions.nim && !signedTransactions.btc)) {
const error = new Error('Internal error: Hub result did not contain EUR or (NIM|BTC) data');
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
swapError.value = error.message;
cancelSwap({ id: (await hubRequest).swapId } as PreSwap);
// currentlySigning.value = false;
Expand Down Expand Up @@ -716,8 +714,7 @@ export default defineComponent({
? request.redeem.input.value - request.redeem.output.value
: 0;
} catch (error) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
swapError.value = 'Invalid swap state, swap aborted!';
cancelSwap({ id: swapId } as PreSwap);
// currentlySigning.value = false;
Expand Down Expand Up @@ -748,8 +745,7 @@ export default defineComponent({
throw new Error(`UNEXPECTED: OASIS HTLC is not 'pending' but '${oasisHtlc.status}'`);
}
} catch (error) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
swapError.value = 'Invalid OASIS contract state, swap aborted!';
setActiveSwap(null);
cancelSwap({ id: swapId } as PreSwap);
Expand All @@ -769,8 +765,7 @@ export default defineComponent({
throw new Error('OASIS HTLC amount + fee does not match swap amount');
}
} catch (error) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
swapError.value = 'Invalid OASIS contract, swap aborted!';
setActiveSwap(null);
cancelSwap({ id: swapId } as PreSwap);
Expand Down Expand Up @@ -831,8 +826,7 @@ export default defineComponent({
});
console.debug('Swap watchtower notified'); // eslint-disable-line no-console
}).catch((error) => {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
});
}
Expand Down
20 changes: 7 additions & 13 deletions src/components/modals/SellCryptoModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ import {
SetupSwapRequest,
SetupSwapResult,
} from '@nimiq/hub-api';
import { captureException } from '@sentry/vue';
import { Bank } from '@nimiq/oasis-bank-list';
import { getNetworkClient } from '../../network';
import { SwapState, useSwapsStore } from '../../stores/Swaps';
Expand Down Expand Up @@ -344,6 +343,7 @@ import {
import { useKycStore } from '../../stores/Kyc';
import KycPrompt from '../kyc/KycPrompt.vue';
import KycOverlay from '../kyc/KycOverlay.vue';
import { reportToSentry } from '../../lib/Sentry';
type KycResult = import('../../swap-kyc-handler').SetupSwapWithKycResult['kyc'];
Expand Down Expand Up @@ -691,8 +691,7 @@ export default defineComponent({
signedTransactions = setupSwapResult; // can be null if the hub popup was cancelled
}
} catch (error: any) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
swapError.value = error.message;
cancelSwap({ id: (await hubRequest).swapId } as PreSwap);
// currentlySigning.value = false;
Expand All @@ -712,8 +711,7 @@ export default defineComponent({
if (typeof signedTransactions.eur !== 'string' || (!signedTransactions.nim && !signedTransactions.btc)) {
const error = new Error('Internal error: Hub result did not contain EUR or (NIM|BTC) data');
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
swapError.value = error.message;
cancelSwap({ id: (await hubRequest).swapId } as PreSwap);
// currentlySigning.value = false;
Expand Down Expand Up @@ -753,8 +751,7 @@ export default defineComponent({
: 0;
confirmedSwap.to.fee = (request.redeem as EuroHtlcSettlementInstructions).fee;
} catch (error) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
swapError.value = 'Invalid swap state, swap aborted!';
cancelSwap({ id: swapId } as PreSwap);
// currentlySigning.value = false;
Expand Down Expand Up @@ -794,8 +791,7 @@ export default defineComponent({
const oasisHtlc = await getHtlc(contract.htlc.address);
if (oasisHtlc.status !== HtlcStatus.PENDING && oasisHtlc.status !== HtlcStatus.CLEARED) {
const error = new Error(`UNEXPECTED: OASIS HTLC is not 'pending'/'cleared' but '${oasisHtlc.status}'`);
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
swapError.value = 'Invalid OASIS contract state, swap aborted!';
cancelSwap({ id: swapId } as PreSwap);
// currentlySigning.value = false;
Expand All @@ -819,8 +815,7 @@ export default defineComponent({
// we are taking the fee that OASIS reports, so we don't run into an HTLC validation error.
swap.value!.to.serviceEscrowFee = oasisHtlc.fee;
} catch (error) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
swapError.value = 'Invalid OASIS contract, swap aborted!';
cancelSwap({ id: swapId } as PreSwap);
// currentlySigning.value = false;
Expand Down Expand Up @@ -882,8 +877,7 @@ export default defineComponent({
});
console.debug('Swap watchtower notified'); // eslint-disable-line no-console
}).catch((error) => {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
});
}
Expand Down
7 changes: 2 additions & 5 deletions src/components/modals/SendModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ import {
InfoCircleSmallIcon,
} from '@nimiq/vue-components';
import { parseRequestLink, AddressBook, Utf8Tools, Currency, CurrencyInfo, ValidationUtils } from '@nimiq/utils';
import { captureException } from '@sentry/vue';
import Modal, { disableNextModalTransition } from './Modal.vue';
import ContactShortcuts from '../ContactShortcuts.vue';
import ContactBook from '../ContactBook.vue';
Expand All @@ -293,13 +292,13 @@ import {
GoCryptoPaymentDetails,
GoCryptoPaymentApiError,
} from '../../lib/GoCrypto';
import { useConfig } from '../../composables/useConfig';
import { useWindowSize } from '../../composables/useWindowSize';
import { i18n } from '../../i18n/i18n-setup';
import {
isValidDomain as isValidUnstoppableDomain,
resolve as resolveUnstoppableDomain,
} from '../../lib/UnstoppableDomains';
import { reportToSentry } from '../../lib/Sentry';
export enum RecipientType {
CONTACT,
Expand Down Expand Up @@ -330,7 +329,6 @@ export default defineComponent({
const { state: addresses$, activeAddressInfo, addressInfos } = useAddressStore();
const { contactsArray: contacts, setContact, getLabel } = useContactsStore();
const { consensus, height } = useNetworkStore();
const { config } = useConfig();
const recipientDetailsOpened = ref(false);
const recipientWithLabel = ref<{address: string, label: string, type: RecipientType} | null>(null);
Expand Down Expand Up @@ -817,8 +815,7 @@ export default defineComponent({
modal$.value!.forceClose();
}, SUCCESS_REDIRECT_DELAY);
} catch (error: any) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
// Show error screen
statusType.value = 'signing';
Expand Down
5 changes: 2 additions & 3 deletions src/components/modals/StablecoinSendModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ import {
FiatAmount,
CircleSpinner,
} from '@nimiq/vue-components';
import { captureException } from '@sentry/vue';
import { computed, defineComponent, onBeforeUnmount, ref, Ref, watch } from '@vue/composition-api';
import { useConfig } from '../../composables/useConfig';
import { useWindowSize } from '../../composables/useWindowSize';
Expand Down Expand Up @@ -284,6 +283,7 @@ import UsdcContactShortcuts from '../UsdcContactShortcuts.vue';
import Modal, { disableNextModalTransition } from './Modal.vue';
import { useAccountSettingsStore } from '../../stores/AccountSettings';
import { useUsdtContactsStore } from '../../stores/UsdtContacts';
import { reportToSentry } from '../../lib/Sentry';
export enum RecipientType {
CONTACT,
Expand Down Expand Up @@ -672,8 +672,7 @@ export default defineComponent({
modal$.value!.forceClose();
}, SUCCESS_REDIRECT_DELAY);
} catch (error: any) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
// Show error screen
statusState.value = State.WARNING;
Expand Down
8 changes: 2 additions & 6 deletions src/components/staking/StakingGraphPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
</template>

<script lang="ts">
import { captureException } from '@sentry/vue';
import { computed, defineComponent, ref } from '@vue/composition-api';
import { InfoCircleSmallIcon, Amount, PageHeader, PageBody, Tooltip } from '@nimiq/vue-components';
Expand All @@ -88,8 +87,6 @@ import { calculateDisplayedDecimals } from '../../lib/NumberFormatting';
import { getNetworkClient } from '../../network';
import { sendStaking } from '../../hub';
import { useConfig } from '../../composables/useConfig';
import { useAddressStore } from '../../stores/Address';
import { useStakingStore } from '../../stores/Staking';
import { useNetworkStore } from '../../stores/Network';
Expand All @@ -103,10 +100,10 @@ import AmountSlider from './AmountSlider.vue';
import { StatusChangeType } from './StakingModal.vue';
import MessageTransition from '../MessageTransition.vue';
import StakingGraph from './StakingGraph.vue';
import { reportToSentry } from '../../lib/Sentry';
export default defineComponent({
setup(props, context) {
const { config } = useConfig();
const { activeAddress } = useAddressStore();
const { activeStake, activeValidator } = useStakingStore();
Expand Down Expand Up @@ -267,8 +264,7 @@ export default defineComponent({
context.emit('next');
}, SUCCESS_REDIRECT_DELAY);
} catch (error: any) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
// Show error screen
context.emit('statusChange', {
Expand Down
10 changes: 3 additions & 7 deletions src/components/staking/StakingInfoPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ import {
Tooltip,
ArrowRightSmallIcon,
} from '@nimiq/vue-components';
import { captureException } from '@sentry/vue';
import { useStakingStore } from '../../stores/Staking';
import { useAddressStore } from '../../stores/Address';
Expand All @@ -186,17 +185,16 @@ import FiatConvertedAmount from '../FiatConvertedAmount.vue';
import { sendStaking } from '../../hub';
import { useNetworkStore } from '../../stores/Network';
import { useConfig } from '../../composables/useConfig';
import { getNetworkClient } from '../../network';
import ArrowDownIcon from '../icons/ArrowDownIcon.vue';
import ValidatorIcon from './ValidatorIcon.vue';
import { reportToSentry } from '../../lib/Sentry';
export default defineComponent({
setup(props, context) {
const { activeAddress, activeAddressInfo } = useAddressStore();
const { activeStake: stake, activeValidator: validator } = useStakingStore();
const { height, consensus } = useNetworkStore();
const { config } = useConfig();
const graphUpdate = ref(0);
const availableBalance = computed(() => activeAddressInfo.value?.balance || 0);
Expand Down Expand Up @@ -302,8 +300,7 @@ export default defineComponent({
timeout: SUCCESS_REDIRECT_DELAY,
});
} catch (error: any) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
context.emit('statusChange', {
state: State.WARNING,
Expand Down Expand Up @@ -380,8 +377,7 @@ export default defineComponent({
timeout: SUCCESS_REDIRECT_DELAY,
});
} catch (error: any) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
context.emit('statusChange', {
state: State.WARNING,
Expand Down
7 changes: 2 additions & 5 deletions src/components/staking/ValidatorDetailsOverlay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
</template>

<script lang="ts">
import { captureException } from '@sentry/vue';
import { defineComponent } from '@vue/composition-api';
import { PageHeader, PageBody, PageFooter } from '@nimiq/vue-components';
import { Validator, useStakingStore } from '../../stores/Staking';
Expand All @@ -70,9 +69,9 @@ import { useNetworkStore } from '../../stores/Network';
import { State, SUCCESS_REDIRECT_DELAY } from '../StatusScreen.vue';
import { StatusChangeType } from './StakingModal.vue';
import { getNetworkClient } from '../../network';
import { useConfig } from '../../composables/useConfig';
import ValidatorReward from './tooltips/ValidatorReward.vue';
import BlueLink from '../BlueLink.vue';
import { reportToSentry } from '../../lib/Sentry';
export default defineComponent({
props: {
Expand All @@ -86,7 +85,6 @@ export default defineComponent({
},
},
setup(props, context) {
const { config } = useConfig();
const { activeAddress } = useAddressStore();
const { activeStake, setStake } = useStakingStore();
Expand Down Expand Up @@ -156,8 +154,7 @@ export default defineComponent({
}, SUCCESS_REDIRECT_DELAY);
}
} catch (error: any) {
if (config.reportToSentry) captureException(error);
else console.error(error); // eslint-disable-line no-console
reportToSentry(error);
context.emit('statusChange', {
state: State.WARNING,
Expand Down
Loading

0 comments on commit 2a65093

Please sign in to comment.