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

chore: add defensive code and better analytics for broadcast errors, … #5375

Merged
merged 1 commit into from
May 20, 2024
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"@dlc-link/dlc-tools": "1.1.1",
"@fungible-systems/zone-file": "2.0.0",
"@hirosystems/token-metadata-api-client": "1.2.0",
"@leather-wallet/models": "0.4.4",
"@leather-wallet/models": "0.4.5",
"@leather-wallet/tokens": "0.0.14",
"@ledgerhq/hw-transport-webusb": "6.27.19",
"@noble/hashes": "1.3.2",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import get from 'lodash.get';

import { RouteUrls } from '@shared/route-urls';
import { delay, isError } from '@shared/utils';
import { analytics } from '@shared/utils/analytics';

import { useScrollLock } from '@app/common/hooks/use-scroll-lock';
import { appEvents } from '@app/common/publish-subscribe';
Expand Down Expand Up @@ -129,7 +130,15 @@ function LedgerSignStacksTxContainer() {
signedTx,
});
} catch (e) {
ledgerNavigate.toBroadcastErrorStep(isError(e) ? e.message : 'Unknown error');
const error = isError(e) ? e.message : 'Unknown error';
void analytics.track('ledger_transaction_publish_error', {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added analytics to errors that bring us to the broadcast error screen. I am unsure what we should use analytics for though.

  • should only use them for events and leave errors to sentry?
  • should I have access to segment?

error: {
message: error,
error: e,
},
});

ledgerNavigate.toBroadcastErrorStep(error);
return;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function SendInscriptionReview() {
});
},
onError(e) {
void analytics.track('ordinalbroadcast__error', { error: e });
navigate(`/${RouteUrls.SendOrdinalInscription}/${RouteUrls.SendOrdinalInscriptionError}`, {
state: {
error: e,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export function Brc20SendFormConfirmation() {
});
},
onError(e) {
void analytics.track('broadcast_brc20_error', {
error: e,
});

nav.toErrorPage(e);
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ export function BtcSendFormConfirmation() {
);
},
onError(e) {
void analytics.track('broadcast_btc_error', {
error: e,
});
nav.toErrorPage(e);
},
});
Expand Down
1 change: 1 addition & 0 deletions src/app/query/stacks/bns/bns.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export async function fetchNamesForAddress({
export async function fetchNameOwner(client: StacksClient, name: string, isTestnet: boolean) {
const fetchFromApi = async () => {
const res = await client.namesApi.getNameInfo({ name });
if (isUndefined(res.address)) return null;
if (!isString(res.address) || res.address.length === 0) return null;
return res.address;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export function useCurrentAccountNativeSegwitAddressIndexZero() {
*/
export function useNativeSegwitAccountIndexAddressIndexZero(accountIndex: number) {
const signer = useNativeSegwitSigner(accountIndex)?.(0);
// could it be this?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this note as the error thrown was Cannot read property of undefined reading .address" .

I see the deprecation warning above this function but I don't understand what it means.


/**
 * @deprecated Use signer.address instead
 */

Does that mean I can refactor this to use signer?.address instead of signer?.payment.address?

return signer?.payment.address as string;
}

Expand Down
Loading