Skip to content
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
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,7 @@ const CONST = {
SPAN_SEARCH_ROUTER_COMPUTE_OPTIONS: 'SearchRouter.ComputeOptions',
SPAN_SEARCH_ROUTER_LIST_RENDER: 'SearchRouter.ListRender',
SPAN_OPEN_CREATE_EXPENSE: 'ManualOpenCreateExpense',
SPAN_SCAN_SHORTCUT: 'ScanShortcut',
SPAN_CAMERA_INIT: 'ManualCameraInit',
SPAN_SHUTTER_TO_CONFIRMATION: 'ManualShutterToConfirmation',
SPAN_RECEIPT_CAPTURE: 'ManualReceiptCapture',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import interceptAnonymousUser from '@libs/interceptAnonymousUser';
import Navigation from '@libs/Navigation/Navigation';
import {generateReportID, getWorkspaceChats} from '@libs/ReportUtils';
import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils';
import {startSpan} from '@libs/telemetry/activeSpans';
import variables from '@styles/variables';
import Tab from '@userActions/Tab';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -61,6 +62,10 @@ function BaseFloatingCameraButton({icon}: BaseFloatingCameraButtonProps) {

const quickActionReportID = policyChatForActivePolicy?.reportID ?? reportID;
Tab.setSelectedTab(CONST.TAB.IOU_REQUEST_TYPE, CONST.IOU.REQUEST_TYPE.SCAN);
startSpan(CONST.TELEMETRY.SPAN_SCAN_SHORTCUT, {
name: CONST.TELEMETRY.SPAN_SCAN_SHORTCUT,
op: CONST.TELEMETRY.SPAN_SCAN_SHORTCUT,
});
startMoneyRequest(CONST.IOU.TYPE.CREATE, quickActionReportID, CONST.IOU.REQUEST_TYPE.SCAN, !!policyChatForActivePolicy?.reportID, undefined, allTransactionDrafts, true);
});
};
Expand Down
5 changes: 4 additions & 1 deletion src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
Onyx.connect({

Check warning on line 814 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -907,7 +907,7 @@
};

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 910 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -921,7 +921,7 @@
});

let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 924 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -930,7 +930,7 @@
});

let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {};
Onyx.connect({

Check warning on line 933 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -944,7 +944,7 @@
});

let allPolicyTags: OnyxCollection<OnyxTypes.PolicyTagLists> = {};
Onyx.connect({

Check warning on line 947 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_TAGS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -957,7 +957,7 @@
});

let allReports: OnyxCollection<OnyxTypes.Report>;
Onyx.connect({

Check warning on line 960 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -966,7 +966,7 @@
});

let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 969 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -976,7 +976,7 @@

let userAccountID = -1;
let currentUserEmail = '';
Onyx.connect({

Check warning on line 979 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -985,7 +985,7 @@
});

let deprecatedCurrentUserPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetails>;
Onyx.connect({

Check warning on line 988 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined;
Expand All @@ -993,7 +993,7 @@
});

let allReportActions: OnyxCollection<OnyxTypes.ReportActions>;
Onyx.connect({

Check warning on line 996 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -1374,7 +1374,10 @@
});
clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, skipConfirmation, draftTransactions);
if (isFromFloatingActionButton) {
Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`, {isFromFloatingActionButton});
Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`, {
isFromFloatingActionButton,
...(requestType && {iouRequestType: requestType}),
});
}
switch (requestType) {
case CONST.IOU.REQUEST_TYPE.MANUAL:
Expand Down
6 changes: 6 additions & 0 deletions src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
isPolicyExpenseChat,
} from '@libs/ReportUtils';
import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils';
import {startSpan} from '@libs/telemetry/activeSpans';
import isOnSearchMoneyRequestReportPage from '@navigation/helpers/isOnSearchMoneyRequestReportPage';
import variables from '@styles/variables';
import {closeReactNativeApp} from '@userActions/HybridApp';
Expand Down Expand Up @@ -366,6 +367,11 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref

const quickActionReportID = policyChatForActivePolicy?.reportID ?? reportID;
Tab.setSelectedTab(CONST.TAB.IOU_REQUEST_TYPE, CONST.IOU.REQUEST_TYPE.SCAN);
// Scan shortcut span: green receipt button (web sidebar) and camera FAB (narrow/mobile)
startSpan(CONST.TELEMETRY.SPAN_SCAN_SHORTCUT, {
name: CONST.TELEMETRY.SPAN_SCAN_SHORTCUT,
op: CONST.TELEMETRY.SPAN_SCAN_SHORTCUT,
});
startMoneyRequest(CONST.IOU.TYPE.CREATE, quickActionReportID, CONST.IOU.REQUEST_TYPE.SCAN, !!policyChatForActivePolicy?.reportID, undefined, allTransactionDrafts, true);
});
}, [policyChatForActivePolicy?.policyID, policyChatForActivePolicy?.reportID, reportID, allTransactionDrafts]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import NavigationAwareCamera from './NavigationAwareCamera/Camera';
import ReceiptPreviews from './ReceiptPreviews';
import type IOURequestStepScanProps from './types';
import useReceiptScan from './useReceiptScan';
import useScanShortcutSpan from './useScanShortcutSpan';

function IOURequestStepScan({
report,
Expand Down Expand Up @@ -95,6 +96,8 @@ function IOURequestStepScan({

const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${report?.policyID}`);

useScanShortcutSpan(initialTransaction);

// Track camera init telemetry
const cameraInitSpanStarted = useRef(false);
const cameraInitialized = useRef(false);
Expand Down
3 changes: 3 additions & 0 deletions src/pages/iou/request/step/IOURequestStepScan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import NavigationAwareCamera from './NavigationAwareCamera/WebCamera';
import ReceiptPreviews from './ReceiptPreviews';
import type IOURequestStepScanProps from './types';
import useReceiptScan from './useReceiptScan';
import useScanShortcutSpan from './useScanShortcutSpan';

function IOURequestStepScan({
report,
Expand Down Expand Up @@ -86,6 +87,8 @@ function IOURequestStepScan({
endSpan(CONST.TELEMETRY.SPAN_OPEN_CREATE_EXPENSE);
}, []);

useScanShortcutSpan(initialTransaction);

const navigateBack = useCallback(() => {
Navigation.goBack(backTo);
}, [backTo]);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {useLayoutEffect} from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import {cancelSpan, endSpan} from '@libs/telemetry/activeSpans';
import CONST from '@src/CONST';
import type Transaction from '@src/types/onyx/Transaction';

/**
* Ends the scan shortcut Sentry span when the Scan page finishes first render,
* only when the flow was started from the green receipt FAB (isFromFloatingActionButton + request type SCAN).
*/
function useScanShortcutSpan(initialTransaction: OnyxEntry<Transaction>) {
const isFromScanShortcut = initialTransaction?.isFromFloatingActionButton === true && initialTransaction?.iouRequestType === CONST.IOU.REQUEST_TYPE.SCAN;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Narrow shortcut-span guard to instrumented entry points

useScanShortcutSpan currently ends SPAN_SCAN_SHORTCUT for any flow where isFromFloatingActionButton && iouRequestType === SCAN, but this commit only starts that span in BaseFloatingCameraButton and startQuickScan (FloatingActionButtonAndPopover). Other scan paths still call startMoneyRequest(..., SCAN, ..., true) without startSpan (for example the long-press startScan path and the policy-chat quick action path in FloatingActionButtonAndPopover), so this hook will repeatedly hit endSpan with no active span, producing "span does not exist" telemetry noise and missing measurements for those shortcut flows.

Useful? React with 👍 / 👎.

useLayoutEffect(() => {
if (!isFromScanShortcut) {
return;
}
endSpan(CONST.TELEMETRY.SPAN_SCAN_SHORTCUT);
return () => cancelSpan(CONST.TELEMETRY.SPAN_SCAN_SHORTCUT);
}, [isFromScanShortcut]);
}

export default useScanShortcutSpan;
Loading