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

fix: fe stats event #2248

Merged
merged 2 commits into from
Apr 30, 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
6 changes: 4 additions & 2 deletions src/background/controller/provider/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ class ProviderController extends BaseController {
preExecSuccess: cacheExplain
? cacheExplain.pre_exec.success && cacheExplain.calcSuccess
: true,
createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
source: options?.data?.$ctx?.ga?.source || '',
trigger: options?.data?.$ctx?.ga?.trigger || '',
networkType: chainItem?.isTestnet
Expand Down Expand Up @@ -574,7 +574,7 @@ class ProviderController extends BaseController {
preExecSuccess: cacheExplain
? cacheExplain.pre_exec.success && cacheExplain.calcSuccess
: true,
createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
source: options?.data?.$ctx?.ga?.source || '',
trigger: options?.data?.$ctx?.ga?.trigger || '',
networkType: chainItem?.isTestnet
Expand Down Expand Up @@ -675,6 +675,7 @@ class ProviderController extends BaseController {
);

onTransactionCreated({ hash, reqId, pushType });
notificationService.setStatsData(statsData);
} else {
const res = await openapiService.submitTx({
tx: {
Expand Down Expand Up @@ -725,6 +726,7 @@ class ProviderController extends BaseController {
params: [rawTx as any],
});
onTransactionCreated({ hash, reqId, pushType });
notificationService.setStatsData(statsData);
}

return hash;
Expand Down
4 changes: 2 additions & 2 deletions src/background/controller/provider/rpcFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function reportStatsData() {
category: statsData?.category,
success: statsData?.signedSuccess,
preExecSuccess: statsData?.preExecSuccess,
createBy: statsData?.createBy,
createdBy: statsData?.createdBy,
source: statsData?.source,
trigger: statsData?.trigger,
networkType: statsData?.networkType,
Expand All @@ -317,7 +317,7 @@ function reportStatsData() {
category: statsData?.category,
success: statsData?.submitSuccess,
preExecSuccess: statsData?.preExecSuccess,
createBy: statsData?.createBy,
createdBy: statsData?.createdBy,
source: statsData?.source,
trigger: statsData?.trigger,
networkType: statsData?.networkType || '',
Expand Down
4 changes: 2 additions & 2 deletions src/background/service/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export type StatsData = {
chainId: string;
category: KEYRING_CATEGORY;
preExecSuccess: boolean;
createBy: string;
createdBy: string;
source: any;
trigger: any;
reported: boolean;
Expand Down Expand Up @@ -271,7 +271,7 @@ class NotificationService extends Events {
success: explain
? explain.calcSuccess && explain.pre_exec.success
: true,
createBy: data?.params.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: data?.params.$ctx?.ga ? 'rabby' : 'dapp',
source: data?.params.$ctx?.ga?.source || '',
trigger: data?.params.$ctx?.ga.trigger || '',
networkType: chain?.isTestnet
Expand Down
2 changes: 1 addition & 1 deletion src/background/service/transactionHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ class TxHistory {
preExecSuccess: target?.explain
? target.explain?.pre_exec.success && target.explain?.calcSuccess
: true,
createBy: target?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: target?.$ctx?.ga ? 'rabby' : 'dapp',
source: target?.$ctx?.ga?.source || '',
trigger: target?.$ctx?.ga?.trigger || '',
networkType: chain?.isTestnet ? 'Custom Network' : 'Integrated Network',
Expand Down
2 changes: 1 addition & 1 deletion src/ui/views/Approval/components/CoinbaseWaiting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const CoinbaseWaiting = ({ params }: { params: ApprovalParams }) => {
preExecSuccess: explain
? explain?.calcSuccess && explain?.pre_exec.success
: true,
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
networkType: chainInfo?.isTestnet
Expand Down
4 changes: 2 additions & 2 deletions src/ui/views/Approval/components/CommonWaiting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ export const CommonWaiting = ({ params }: { params: ApprovalParams }) => {

const explain = signingTx?.explain;

stats.report('signTransaction', {
wallet.reportStats('signTransaction', {
type: account.brandName,
chainId: chain?.serverId || '',
category: KEYRING_CATEGORY_MAP[account.type],
preExecSuccess: explain
? explain?.calcSuccess && explain?.pre_exec.success
: true,
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
networkType: chain?.isTestnet
Expand Down
4 changes: 2 additions & 2 deletions src/ui/views/Approval/components/ImKeyHardwareWaiting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ export const ImKeyHardwareWaiting = ({

const explain = signingTx?.explain;

stats.report('signTransaction', {
wallet.reportStats('signTransaction', {
type: account.brandName,
chainId: chain?.serverId || '',
category: KEYRING_CATEGORY_MAP[account.type],
preExecSuccess: explain
? explain?.calcSuccess && explain?.pre_exec.success
: true,
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
networkType: chain?.isTestnet
Expand Down
4 changes: 2 additions & 2 deletions src/ui/views/Approval/components/LedgerHardwareWaiting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ const LedgerHardwareWaiting = ({ params }: { params: ApprovalParams }) => {

const explain = signingTx?.explain;

stats.report('signTransaction', {
wallet.reportStats('signTransaction', {
type: account.brandName,
chainId: chain?.serverId || '',
category: KEYRING_CATEGORY_MAP[account.type],
preExecSuccess: explain
? explain?.calcSuccess && explain?.pre_exec.success
: true,
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
networkType: chain?.isTestnet
Expand Down
5 changes: 3 additions & 2 deletions src/ui/views/Approval/components/PrivatekeyWaiting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const PrivatekeyWaiting = ({ params }: { params: ApprovalParams }) => {
const isSignText = params.isGnosis
? true
: approval?.data.approvalType !== 'SignTx';

if (!isSignText) {
const signingTxId = approval.data.params.signingTxId;
if (signingTxId) {
Expand All @@ -119,14 +120,14 @@ export const PrivatekeyWaiting = ({ params }: { params: ApprovalParams }) => {

const explain = signingTx?.explain;

stats.report('signTransaction', {
wallet.reportStats('signTransaction', {
type: account.brandName,
chainId: chain?.serverId || '',
category: KEYRING_CATEGORY_MAP[account.type],
preExecSuccess: explain
? explain?.calcSuccess && explain?.pre_exec.success
: true,
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
networkType: chain?.isTestnet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ const QRHardWareWaiting = ({ params }) => {

const explain = signingTx?.explain;

stats.report('signTransaction', {
wallet.reportStats('signTransaction', {
type: account.brandName,
chainId: chainInfo?.serverId || '',
category: KEYRING_CATEGORY_MAP[account.type],
preExecSuccess: explain
? explain?.calcSuccess && explain?.pre_exec.success
: true,
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
signMethod,
Expand Down
4 changes: 2 additions & 2 deletions src/ui/views/Approval/components/SignTestnetTx/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export const SignTestnetTx = ({ params, origin }: SignTxProps) => {
type: currentAccount.brandName,
category: KEYRING_CATEGORY_MAP[currentAccount.type],
chainId: chain?.serverId || '',
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
networkType: chain?.isTestnet ? 'Custom Network' : 'Integrated Network',
Expand Down Expand Up @@ -462,7 +462,7 @@ export const SignTestnetTx = ({ params, origin }: SignTxProps) => {
chainId: chain?.serverId || '',
category: KEYRING_CATEGORY_MAP[currentAccount.type],
preExecSuccess: true,
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
networkType: chain?.isTestnet ? 'Custom Network' : 'Integrated Network',
Expand Down
12 changes: 6 additions & 6 deletions src/ui/views/Approval/components/SignTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1143,13 +1143,13 @@ const SignTx = ({ params, origin }: SignTxProps) => {

const handleGnosisConfirm = async (account: Account) => {
if (!safeInfo) return;
stats.report('signTransaction', {
wallet.reportStats('signTransaction', {
type: KEYRING_TYPE.GnosisKeyring,
category: KEYRING_CATEGORY_MAP[KEYRING_CLASS.GNOSIS],
chainId: chain.serverId,
preExecSuccess:
checkErrors.length > 0 || !txDetail?.pre_exec.success ? false : true,
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
networkType: chain?.isTestnet ? 'Custom Network' : 'Integrated Network',
Expand Down Expand Up @@ -1186,13 +1186,13 @@ const SignTx = ({ params, origin }: SignTxProps) => {
const handleCoboArugsConfirm = async (account: Account) => {
if (!coboArgusInfo) return;

stats.report('signTransaction', {
wallet.reportStats('signTransaction', {
type: KEYRING_TYPE.CoboArgusKeyring,
category: KEYRING_CATEGORY_MAP[KEYRING_CLASS.CoboArgus],
chainId: chain.serverId,
preExecSuccess:
checkErrors.length > 0 || !txDetail?.pre_exec.success ? false : true,
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
networkType: chain?.isTestnet ? 'Custom Network' : 'Integrated Network',
Expand Down Expand Up @@ -1362,7 +1362,7 @@ const SignTx = ({ params, origin }: SignTxProps) => {
category: KEYRING_CATEGORY_MAP[currentAccount.type],
preExecSuccess:
checkErrors.length > 0 || !txDetail?.pre_exec.success ? false : true,
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
networkType: chain?.isTestnet ? 'Custom Network' : 'Integrated Network',
Expand Down Expand Up @@ -1655,7 +1655,7 @@ const SignTx = ({ params, origin }: SignTxProps) => {
type: currentAccount.brandName,
category: KEYRING_CATEGORY_MAP[currentAccount.type],
chainId: chain.serverId,
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
networkType: chain?.isTestnet ? 'Custom Network' : 'Integrated Network',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const WatchAddressWaiting = ({ params }: { params: ApprovalParams }) => {
// preExecSuccess: explain
// ? explain?.calcSuccess && explain?.pre_exec.success
// : true,
// createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
// createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
// source: params?.$ctx?.ga?.source || '',
// trigger: params?.$ctx?.ga?.trigger || '',
// });
Expand Down Expand Up @@ -187,7 +187,7 @@ const WatchAddressWaiting = ({ params }: { params: ApprovalParams }) => {
// preExecSuccess: explain
// ? explain?.calcSuccess && explain?.pre_exec.success
// : true,
// createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
// createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
// source: params?.$ctx?.ga?.source || '',
// trigger: params?.$ctx?.ga?.trigger || '',
// });
Expand Down Expand Up @@ -226,7 +226,7 @@ const WatchAddressWaiting = ({ params }: { params: ApprovalParams }) => {
preExecSuccess: explain
? explain?.calcSuccess && explain?.pre_exec.success
: true,
createBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
createdBy: params?.$ctx?.ga ? 'rabby' : 'dapp',
source: params?.$ctx?.ga?.source || '',
trigger: params?.$ctx?.ga?.trigger || '',
networkType: chainInfo?.isTestnet
Expand Down
Loading