@@ -122,6 +122,32 @@ import withWritableReportOrNotFound from './withWritableReportOrNotFound';
122122type IOURequestStepConfirmationProps = WithWritableReportOrNotFoundProps < typeof SCREENS . MONEY_REQUEST . STEP_CONFIRMATION > &
123123 WithFullTransactionOrNotFoundProps < typeof SCREENS . MONEY_REQUEST . STEP_CONFIRMATION > ;
124124
125+ // Ends the submit expense span, starts a geolocation child span, then calls getCurrentPosition.
126+ // The expense callback receives GPS coordinates on success or undefined on error.
127+ // Extracted to avoid duplicating this identical telemetry block across trackExpense and requestMoney paths.
128+ function getCurrentPositionWithGeolocationSpan ( onPosition : ( gpsCoords ?: { lat : number ; long : number } ) => void ) {
129+ const parentSpan = getSpan ( CONST . TELEMETRY . SPAN_SUBMIT_EXPENSE ) ;
130+ markSubmitExpenseEnd ( ) ;
131+
132+ startSpan ( CONST . TELEMETRY . SPAN_GEOLOCATION_WAIT , {
133+ name : CONST . TELEMETRY . SPAN_GEOLOCATION_WAIT ,
134+ op : CONST . TELEMETRY . SPAN_GEOLOCATION_WAIT ,
135+ parentSpan,
136+ } ) ;
137+
138+ getCurrentPosition (
139+ ( successData ) => {
140+ onPosition ( { lat : successData . coords . latitude , long : successData . coords . longitude } ) ;
141+ endSpan ( CONST . TELEMETRY . SPAN_GEOLOCATION_WAIT ) ;
142+ } ,
143+ ( errorData ) => {
144+ Log . info ( '[IOURequestStepConfirmation] getCurrentPosition failed' , false , errorData ) ;
145+ onPosition ( ) ;
146+ endSpan ( CONST . TELEMETRY . SPAN_GEOLOCATION_WAIT ) ;
147+ } ,
148+ ) ;
149+ }
150+
125151function IOURequestStepConfirmation ( {
126152 report : reportReal ,
127153 reportDraft,
@@ -1238,21 +1264,7 @@ function IOURequestStepConfirmation({
12381264 return ;
12391265 }
12401266
1241- getCurrentPosition (
1242- ( successData ) => {
1243- trackExpense ( selectedParticipants , {
1244- lat : successData . coords . latitude ,
1245- long : successData . coords . longitude ,
1246- } ) ;
1247- markSubmitExpenseEnd ( ) ;
1248- } ,
1249- ( errorData ) => {
1250- Log . info ( '[IOURequestStepConfirmation] getCurrentPosition failed' , false , errorData ) ;
1251- // When there is an error, the money can still be requested, it just won't include the GPS coordinates
1252- trackExpense ( selectedParticipants ) ;
1253- markSubmitExpenseEnd ( ) ;
1254- } ,
1255- ) ;
1267+ getCurrentPositionWithGeolocationSpan ( ( gpsCoords ) => trackExpense ( selectedParticipants , gpsCoords ) ) ;
12561268 return ;
12571269 }
12581270
@@ -1290,21 +1302,7 @@ function IOURequestStepConfirmation({
12901302 return ;
12911303 }
12921304
1293- getCurrentPosition (
1294- ( successData ) => {
1295- requestMoney ( selectedParticipants , {
1296- lat : successData . coords . latitude ,
1297- long : successData . coords . longitude ,
1298- } ) ;
1299- markSubmitExpenseEnd ( ) ;
1300- } ,
1301- ( errorData ) => {
1302- Log . info ( '[IOURequestStepConfirmation] getCurrentPosition failed' , false , errorData ) ;
1303- // When there is an error, the money can still be requested, it just won't include the GPS coordinates
1304- requestMoney ( selectedParticipants ) ;
1305- markSubmitExpenseEnd ( ) ;
1306- } ,
1307- ) ;
1305+ getCurrentPositionWithGeolocationSpan ( ( gpsCoords ) => requestMoney ( selectedParticipants , gpsCoords ) ) ;
13081306 return ;
13091307 }
13101308
0 commit comments