Skip to content

Commit f302565

Browse files
authored
Merge pull request Expensify#79100 from callstack-internal/eliran/sentry-OpenTransactionThread-RHP-tracking
Add transaction thread span
2 parents ee12179 + 0535edc commit f302565

6 files changed

Lines changed: 32 additions & 8 deletions

File tree

src/CONST/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,10 @@ const CONST = {
17141714
},
17151715
// Attribute names
17161716
ATTRIBUTE_IOU_TYPE: 'iou_type',
1717+
ATTRIBUTE_IS_ONE_TRANSACTION_REPORT: 'is_one_transaction_report',
1718+
ATTRIBUTE_IS_TRANSACTION_THREAD: 'is_transaction_thread',
1719+
ATTRIBUTE_REPORT_TYPE: 'report_type',
1720+
ATTRIBUTE_CHAT_TYPE: 'chat_type',
17171721
ATTRIBUTE_IOU_REQUEST_TYPE: 'iou_request_type',
17181722
ATTRIBUTE_REPORT_ID: 'report_id',
17191723
ATTRIBUTE_MESSAGE_LENGTH: 'message_length',

src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,8 @@ function MoneyRequestReportActionsList({
646646

647647
didLayout.current = true;
648648

649-
markOpenReportEnd(reportID);
650-
}, [reportID]);
649+
markOpenReportEnd(report);
650+
}, [report]);
651651

652652
const isSelectAllChecked = selectedTransactionIDs.length > 0 && selectedTransactionIDs.length === transactionsWithoutPendingDelete.length;
653653
// Wrapped into useCallback to stabilize children re-renders

src/components/MoneyRequestReportView/MoneyRequestReportView.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe
166166

167167
// We need to cancel telemetry span when user leaves the screen before full report data is loaded
168168
useEffect(() => {
169-
return () => cancelSpan(`${CONST.TELEMETRY.SPAN_OPEN_REPORT}_${reportID}`);
169+
return () => {
170+
cancelSpan(`${CONST.TELEMETRY.SPAN_OPEN_REPORT}_${reportID}`);
171+
};
170172
}, [reportID]);
171173

172174
if (!!(isLoadingInitialReportActions && reportActions.length === 0 && !isOffline) || shouldWaitForTransactions) {

src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ function MoneyRequestReportPreviewContent({
516516
name: 'MoneyRequestReportPreviewContent',
517517
op: CONST.TELEMETRY.SPAN_OPEN_REPORT,
518518
});
519+
519520
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReportID, undefined, undefined, Navigation.getActiveRoute()));
520521
}, [iouReportID]);
521522

src/libs/telemetry/markOpenReportEnd.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
import Timing from '@libs/actions/Timing';
22
import Performance from '@libs/Performance';
3+
import {isOneTransactionReport, isReportTransactionThread} from '@libs/ReportUtils';
34
import CONST from '@src/CONST';
4-
import {endSpan} from './activeSpans';
5+
import type * as OnyxTypes from '@src/types/onyx';
6+
import {endSpan, getSpan} from './activeSpans';
57

68
/**
79
* Mark all 'open_report*' performance events as finished using both Performance (local) and Timing (remote) tracking.
810
*/
9-
function markOpenReportEnd(reportId: string) {
10-
endSpan(`${CONST.TELEMETRY.SPAN_OPEN_REPORT}_${reportId}`);
11+
function markOpenReportEnd(report: OnyxTypes.Report) {
12+
const {reportID, type, chatType} = report;
13+
14+
const isTransactionThread = isReportTransactionThread(report);
15+
const isOneTransactionThread = isOneTransactionReport(report);
16+
17+
const spanId = `${CONST.TELEMETRY.SPAN_OPEN_REPORT}_${reportID}`;
18+
const span = getSpan(spanId);
19+
span?.setAttributes({
20+
[CONST.TELEMETRY.ATTRIBUTE_IS_TRANSACTION_THREAD]: isTransactionThread,
21+
[CONST.TELEMETRY.ATTRIBUTE_IS_ONE_TRANSACTION_REPORT]: isOneTransactionThread,
22+
[CONST.TELEMETRY.ATTRIBUTE_REPORT_TYPE]: type,
23+
[CONST.TELEMETRY.ATTRIBUTE_CHAT_TYPE]: chatType,
24+
});
25+
26+
endSpan(spanId);
27+
1128
Performance.markEnd(CONST.TIMING.OPEN_REPORT);
1229
Timing.end(CONST.TIMING.OPEN_REPORT);
1330

src/pages/home/report/ReportActionsView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ function ReportActionsView({
269269

270270
didLayout.current = true;
271271

272-
markOpenReportEnd(reportID);
273-
}, [reportID]);
272+
markOpenReportEnd(report);
273+
}, [report]);
274274

275275
// Check if the first report action in the list is the one we're currently linked to
276276
const isTheFirstReportActionIsLinked = newestReportAction?.reportActionID === reportActionID;

0 commit comments

Comments
 (0)