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 @@ -1685,6 +1685,7 @@ const CONST = {
SPAN_OPEN_SEARCH_ROUTER: 'ManualOpenSearchRouter',
SPAN_OPEN_CREATE_EXPENSE: 'ManualOpenCreateExpense',
SPAN_SEND_MESSAGE: 'ManualSendMessage',
SPAN_NOT_FOUND_PAGE: 'ManualNotFoundPage',
SPAN_SKELETON: 'ManualSkeleton',
SPAN_BOOTSPLASH: {
ROOT: 'BootsplashVisible',
Expand Down
3 changes: 3 additions & 0 deletions src/components/BlockingViews/BlockingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Text from '@components/Text';
import useBottomSafeSafeAreaPaddingStyle from '@hooks/useBottomSafeSafeAreaPaddingStyle';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import useAbsentPageSpan from '@libs/telemetry/useAbsentPageSpan';
import variables from '@styles/variables';
import type {TranslationPaths} from '@src/languages/types';
import BlockingViewSubtitle from './BlockingViewSubtitle';
Expand Down Expand Up @@ -124,6 +125,8 @@ function BlockingView({
);
const containerStyle = useBottomSafeSafeAreaPaddingStyle({addBottomSafeAreaPadding, addOfflineIndicatorBottomSafeAreaPadding, style: containerStyleProp});

useAbsentPageSpan();

return (
<View
style={[styles.flex1, styles.alignItemsCenter, styles.justifyContentCenter, styles.ph10, containerStyle]}
Expand Down
36 changes: 36 additions & 0 deletions src/libs/telemetry/useAbsentPageSpan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {useContext, useEffect} from 'react';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

move file to src/libs/telemetry

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

move file to src/libs/telemetry

done

import {Platform} from 'react-native';
import {InitialURLContext} from '@components/InitialURLContextProvider';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import {endSpan, startSpan} from './activeSpans';

export default function useAbsentPageSpan() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we rename this to useNotFoundPageSpan?

@elirangoshen elirangoshen Dec 10, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did it and than got es lint error because it not allow to use negative names..

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh...okay then 😄

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Eslint does not allow negativity in the code. I'd personally use useNotFoundPageSpan name and add eslint exception.

After some time it'll be hard to remember what is useAbsentPage as "absent" is never used in this context.

At least write a comment doc about what this is :)

const {initialURL} = useContext(InitialURLContext);

useEffect(() => {
let isDeeplink = false;
let currentUrl = '';

if (Platform.OS === 'web') {
currentUrl = window.location.href;
isDeeplink = currentUrl === initialURL;
} else {
isDeeplink = !!initialURL;
currentUrl = Navigation.getActiveRoute() || '';
}

const NAVIGATION_SOURCE = isDeeplink ? 'deeplink' : 'button';

startSpan(CONST.TELEMETRY.SPAN_NOT_FOUND_PAGE, {
name: CONST.TELEMETRY.SPAN_NOT_FOUND_PAGE,
op: CONST.TELEMETRY.SPAN_NOT_FOUND_PAGE,
attributes: {
url: currentUrl,
navigationSource: NAVIGATION_SOURCE,
},
});

endSpan(CONST.TELEMETRY.SPAN_NOT_FOUND_PAGE);
}, [initialURL]);
}
5 changes: 4 additions & 1 deletion src/pages/ErrorPage/NotFoundPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ScreenWrapper from '@components/ScreenWrapper';
import useOnyx from '@hooks/useOnyx';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import Navigation from '@libs/Navigation/Navigation';
import useAbsentPageSpan from '@libs/telemetry/useAbsentPageSpan';
import ONYXKEYS from '@src/ONYXKEYS';

type NotFoundPageProps = {
Expand All @@ -19,7 +20,9 @@ function NotFoundPage({onBackButtonPress = () => Navigation.goBack(), isReportRe
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {isSmallScreenWidth} = useResponsiveLayout();
const topmostReportId = Navigation.getTopmostReportId();
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${topmostReportId}`);
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${topmostReportId}`, {canBeMissing: true});

useAbsentPageSpan();

return (
<ScreenWrapper
Expand Down
Loading