Skip to content

Commit

Permalink
[IOPID-2598] Tracking offline event (#6606)
Browse files Browse the repository at this point in the history
## Short description
This PR adds the tracking of the `INGRESS_NO_INTERNET_CONNECTION` event,
logged when the user opens the app with the internet connection
disabled.

## List of changes proposed in this pull request
- Added and implemented the `INGRESS_NO_INTERNET_CONNECTION` event
- Added the `event_category: KO` to the already existing
`INGRESS_SERVICES_SLOW_DOWN`, `INGRESS_TIMEOUT` and
`INGRESS_CDN_SYSTEM_ERROR` events

## Demo
|iOS|Android|
|---|--------|
|<video
src="https://github.com/user-attachments/assets/91aa2f0f-4366-4238-9643-95b44a6189ec"></video>|<video
src="https://github.com/user-attachments/assets/71a074ec-b219-4655-bf98-0f588395acee"></video>|

## How to test
Start the app ensuring that the internet connection is disabled (as
shown in the demo). Once the blocking screen appears, close the app,
re-enable the internet connection, and reopen the app.

>[!Note]
>In this demos, I'm using [Proxyman](https://proxyman.io/) to monitor
internet traffic, but any tool of your choice can be used.
  • Loading branch information
ChrisMattew authored Jan 17, 2025
1 parent 22f5a05 commit 58557e7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 11 deletions.
20 changes: 17 additions & 3 deletions ts/features/ingress/analytics/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
import { mixpanelTrack } from "../../../mixpanel";
import { buildEventProperties } from "../../../utils/analytics";

export function trackIngressServicesSlowDown() {
void mixpanelTrack("INGRESS_SERVICES_SLOW_DOWN");
void mixpanelTrack(
"INGRESS_SERVICES_SLOW_DOWN",
buildEventProperties("KO", undefined)
);
}

export function trackIngressTimeout() {
void mixpanelTrack("INGRESS_TIMEOUT");
void mixpanelTrack("INGRESS_TIMEOUT", buildEventProperties("KO", undefined));
}

export function trackIngressCdnSystemError() {
void mixpanelTrack("INGRESS_CDN_SYSTEM_ERROR");
void mixpanelTrack(
"INGRESS_CDN_SYSTEM_ERROR",
buildEventProperties("KO", undefined)
);
}

export function trackIngressNoInternetConnection() {
void mixpanelTrack(
"INGRESS_NO_INTERNET_CONNECTION",
buildEventProperties("KO", undefined)
);
}
30 changes: 22 additions & 8 deletions ts/features/ingress/screens/IngressScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import ModalSectionStatusComponent from "../../../components/SectionStatus/modal
import { isMixpanelInitializedSelector } from "../../mixpanel/store/selectors";
import {
trackIngressCdnSystemError,
trackIngressNoInternetConnection,
trackIngressServicesSlowDown,
trackIngressTimeout
} from "../analytics";
Expand Down Expand Up @@ -84,14 +85,7 @@ export const IngressScreen = () => {
}, [dispatch]);

if (netInfo && !netInfo.isConnected) {
return (
<OperationResultScreenContent
testID="device-connection-lost-id"
pictogram="lostConnection"
title={I18n.t("startup.connection_lost.title")}
subtitle={I18n.t("startup.connection_lost.description")}
/>
);
return <IngressScreenNoInternetConnection />;
}

if (showBlockingScreen) {
Expand All @@ -114,6 +108,26 @@ export const IngressScreen = () => {
);
};

const IngressScreenNoInternetConnection = memo(() => {
const isMixpanelEnabled = useIOSelector(isMixpanelEnabledSelector);
const isMixpanelInitialized = useIOSelector(isMixpanelInitializedSelector);

useEffect(() => {
if (isMixpanelInitialized && isMixpanelEnabled !== false) {
void trackIngressNoInternetConnection();
}
}, [isMixpanelEnabled, isMixpanelInitialized]);

return (
<OperationResultScreenContent
testID="device-connection-lost-id"
pictogram="lostConnection"
title={I18n.t("startup.connection_lost.title")}
subtitle={I18n.t("startup.connection_lost.description")}
/>
);
});

const IngressScreenBlockingError = memo(() => {
const operationRef = useRef<View>(null);
const isBackendStatusLoaded = useIOSelector(isBackendStatusLoadedSelector);
Expand Down

0 comments on commit 58557e7

Please sign in to comment.