-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Track expense created events in Sentry per request type #90388
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import * as Sentry from '@sentry/react-native'; | ||
| import type {ValueOf} from 'type-fest'; | ||
| import type CONST from '@src/CONST'; | ||
|
|
||
| type IOURequestType = ValueOf<typeof CONST.IOU.REQUEST_TYPE>; | ||
|
|
||
| function emitExpenseCreated(iouRequestType: IOURequestType | undefined) { | ||
| if (!iouRequestType) { | ||
| return; | ||
| } | ||
| Sentry.startInactiveSpan({ | ||
| name: `ExpenseCreated.${iouRequestType}`, | ||
| op: 'expense.created', | ||
| forceTransaction: true, | ||
| })?.end(); | ||
| } | ||
|
|
||
| export default emitExpenseCreated; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import React, {useEffect, useMemo, useState} from 'react'; | ||
| import * as Sentry from '@sentry/react-native'; | ||
| import React, {useCallback, useEffect, useMemo, useState} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import FocusTrapContainerElement from '@components/FocusTrap/FocusTrapContainerElement'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
|
|
@@ -18,7 +19,7 @@ import {endSpan} from '@libs/telemetry/activeSpans'; | |
| import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type SCREENS from '@src/SCREENS'; | ||
| import SCREENS from '@src/SCREENS'; | ||
| import type {SelectedTabRequest} from '@src/types/onyx'; | ||
| import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; | ||
| import IOURequestStepDistanceGPS from './step/IOURequestStepDistanceGPS'; | ||
|
|
@@ -84,6 +85,14 @@ function DistanceRequestStartPage({ | |
| endSpan(CONST.TELEMETRY.SPAN_OPEN_CREATE_EXPENSE); | ||
| }, []); | ||
|
|
||
| const handleTabFocused = useCallback((tabName: SelectedTabRequest) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ CLEAN-REACT-PATTERNS-0 (docs)React Compiler is enabled and this file compiles successfully. The Remove const handleTabFocused = (tabName: SelectedTabRequest) => {
Sentry.startInactiveSpan({
name: `${SCREENS.MONEY_REQUEST.DISTANCE_CREATE}.tab.${tabName}`,
op: 'ui.tab.focus',
forceTransaction: true,
})?.end();
};Reviewed at: 1de2933 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also think this should be added |
||
| Sentry.startInactiveSpan({ | ||
| name: `${SCREENS.MONEY_REQUEST.DISTANCE_CREATE}.tab.${tabName}`, | ||
| op: 'ui.tab.focus', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ CONSISTENCY-2 (docs)The string Define this as a constant in // In CONST.ts under TELEMETRY
OP_TAB_FOCUS: 'ui.tab.focus',Reviewed at: 1de2933 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency. |
||
| forceTransaction: true, | ||
| })?.end(); | ||
| }, []); | ||
|
|
||
| const navigateBack = () => { | ||
| Navigation.closeRHPFlow(); | ||
| }; | ||
|
|
@@ -126,6 +135,7 @@ function DistanceRequestStartPage({ | |
| tabBar={TabSelector} | ||
| onTabBarFocusTrapContainerElementChanged={setTabBarContainerElement} | ||
| onActiveTabFocusTrapContainerElementChanged={setActiveTabContainerElement} | ||
| onTabFocused={handleTabFocused} | ||
| lazyLoadEnabled | ||
| > | ||
| <TopTab.Screen name={CONST.TAB_REQUEST.DISTANCE_MAP}> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ CONSISTENCY-2 (docs)
The strings
'expense.created'(op) and the'ExpenseCreated.'prefix (name) are magic strings. The existing telemetry codebase consistently defines span identifiers as named constants inCONST.TELEMETRY(e.g.,CONST.TELEMETRY.SPAN_SUBMIT_EXPENSE,CONST.TELEMETRY.SPAN_APP_STARTUP). Using inline strings here diverges from that established pattern and makes it harder to find all telemetry span definitions in one place.Define these as constants in
CONST.TELEMETRYand reference them here:Reviewed at: 1de2933 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Julesssss this makes sense IMO