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 @@ -1805,6 +1805,7 @@ const CONST = {
SPAN_SUBMIT_EXPENSE: 'ManualCreateExpenseSubmit',
SPAN_NAVIGATE_AFTER_EXPENSE_CREATE: 'ManualCreateExpenseNavigation',
SPAN_EXPENSE_SERVER_RESPONSE: 'ManualCreateExpenseServerResponse',
SPAN_GEOLOCATION_WAIT: 'ManualGeolocationWait',
SPAN_SEND_MESSAGE: 'ManualSendMessage',
SPAN_NOT_FOUND_PAGE: 'ManualNotFoundPage',
SPAN_SKELETON: 'ManualSkeleton',
Expand Down
58 changes: 28 additions & 30 deletions src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,32 @@
type IOURequestStepConfirmationProps = WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_CONFIRMATION> &
WithFullTransactionOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_CONFIRMATION>;

// Ends the submit expense span, starts a geolocation child span, then calls getCurrentPosition.
// The expense callback receives GPS coordinates on success or undefined on error.
// Extracted to avoid duplicating this identical telemetry block across trackExpense and requestMoney paths.
function getCurrentPositionWithGeolocationSpan(onPosition: (gpsCoords?: {lat: number; long: number}) => void) {
const parentSpan = getSpan(CONST.TELEMETRY.SPAN_SUBMIT_EXPENSE);
markSubmitExpenseEnd();

startSpan(CONST.TELEMETRY.SPAN_GEOLOCATION_WAIT, {
name: CONST.TELEMETRY.SPAN_GEOLOCATION_WAIT,
op: CONST.TELEMETRY.SPAN_GEOLOCATION_WAIT,
parentSpan,
});

getCurrentPosition(
(successData) => {
onPosition({lat: successData.coords.latitude, long: successData.coords.longitude});
endSpan(CONST.TELEMETRY.SPAN_GEOLOCATION_WAIT);
},
(errorData) => {
Log.info('[IOURequestStepConfirmation] getCurrentPosition failed', false, errorData);
onPosition();
endSpan(CONST.TELEMETRY.SPAN_GEOLOCATION_WAIT);
},
);
}

function IOURequestStepConfirmation({
report: reportReal,
reportDraft,
Expand Down Expand Up @@ -700,7 +726,7 @@
transactions,
receiptFiles,
privateIsArchivedMap,
report,

Check warning on line 729 in src/pages/iou/request/step/IOURequestStepConfirmation.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useCallback has an unnecessary dependency: 'transactionIDs'. Either exclude it or remove the dependency array
currentUserPersonalDetails.login,
currentUserPersonalDetails.accountID,
currentUserPersonalDetails.email,
Expand Down Expand Up @@ -1214,21 +1240,7 @@
return;
}

getCurrentPosition(
(successData) => {
trackExpense(selectedParticipants, {
lat: successData.coords.latitude,
long: successData.coords.longitude,
});
markSubmitExpenseEnd();
},
(errorData) => {
Log.info('[IOURequestStepConfirmation] getCurrentPosition failed', false, errorData);
// When there is an error, the money can still be requested, it just won't include the GPS coordinates
trackExpense(selectedParticipants);
markSubmitExpenseEnd();
},
);
getCurrentPositionWithGeolocationSpan((gpsCoords) => trackExpense(selectedParticipants, gpsCoords));
return;
}

Expand Down Expand Up @@ -1266,21 +1278,7 @@
return;
}

getCurrentPosition(
(successData) => {
requestMoney(selectedParticipants, {
lat: successData.coords.latitude,
long: successData.coords.longitude,
});
markSubmitExpenseEnd();
},
(errorData) => {
Log.info('[IOURequestStepConfirmation] getCurrentPosition failed', false, errorData);
// When there is an error, the money can still be requested, it just won't include the GPS coordinates
requestMoney(selectedParticipants);
markSubmitExpenseEnd();
},
);
getCurrentPositionWithGeolocationSpan((gpsCoords) => requestMoney(selectedParticipants, gpsCoords));
return;
}

Expand Down
Loading