Skip to content
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

πŸ“ˆ (llm) enhance reborn analytics #9379

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .changeset/large-moles-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

Enhance reborn analytics
1 change: 1 addition & 0 deletions apps/ledger-live-mobile/__tests__/test-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ const renderWithReactQuery = (
};

return {
store,
user: userEvent.setup(userEventOptions),
QueryClient,
...rntlRender(ui, { wrapper: ProvidersWrapper, ...renderOptions }),
Expand Down
4 changes: 4 additions & 0 deletions apps/ledger-live-mobile/src/actions/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import {
SettingsSetMevProtectionPayload,
SettingsUpdateNftCollectionStatus,
SettingsSetSelectedTabPortfolioAssetsPayload,
SettingsSetIsRebornPayload,
} from "./types";
import { ImageType } from "~/components/CustomImage/types";

Expand Down Expand Up @@ -220,6 +221,9 @@ export const setSensitiveAnalytics = createAction<SettingsSetSensitiveAnalyticsP
export const setOnboardingHasDevice = createAction<SettingsSetOnboardingHasDevicePayload>(
SettingsActionTypes.SET_ONBOARDING_HAS_DEVICE,
);
export const setIsReborn = createAction<SettingsSetIsRebornPayload>(
SettingsActionTypes.SET_IS_REBORN,
);
export const setOnboardingType = createAction<SettingsSetOnboardingTypePayload>(
SettingsActionTypes.SET_ONBOARDING_TYPE,
);
Expand Down
3 changes: 3 additions & 0 deletions apps/ledger-live-mobile/src/actions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export enum SettingsActionTypes {
SET_MARKET_FILTER_BY_STARRED_ACCOUNTS = "SET_MARKET_FILTER_BY_STARRED_ACCOUNTS",
SET_SENSITIVE_ANALYTICS = "SET_SENSITIVE_ANALYTICS",
SET_ONBOARDING_HAS_DEVICE = "SET_ONBOARDING_HAS_DEVICE",
SET_IS_REBORN = "SET_IS_REBORN",
SET_NOTIFICATIONS = "SET_NOTIFICATIONS",
SET_NEVER_CLICKED_ON_ALLOW_NOTIFICATIONS_BUTTON = "SET_NEVER_CLICKED_ON_ALLOW_NOTIFICATIONS_BUTTON",
WALLET_TAB_NAVIGATOR_LAST_VISITED_TAB = "WALLET_TAB_NAVIGATOR_LAST_VISITED_TAB",
Expand Down Expand Up @@ -368,6 +369,7 @@ export type SettingsSetHasOrderedNanoPayload = SettingsState["hasOrderedNano"];
export type SettingsSetMarketCounterCurrencyPayload = SettingsState["marketCounterCurrency"];
export type SettingsSetSensitiveAnalyticsPayload = SettingsState["sensitiveAnalytics"];
export type SettingsSetOnboardingHasDevicePayload = SettingsState["onboardingHasDevice"];
export type SettingsSetIsRebornPayload = SettingsState["isReborn"];

export type SettingsSetOnboardingTypePayload = SettingsState["onboardingType"];

Expand Down Expand Up @@ -448,6 +450,7 @@ export type SettingsPayload =
| SettingsSetMarketCounterCurrencyPayload
| SettingsSetSensitiveAnalyticsPayload
| SettingsSetOnboardingHasDevicePayload
| SettingsSetIsRebornPayload
| SettingsSetNotificationsPayload
| SettingsDangerouslyOverrideStatePayload
| DangerouslyOverrideStatePayload
Expand Down
5 changes: 3 additions & 2 deletions apps/ledger-live-mobile/src/analytics/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import {
personalizedRecommendationsEnabledSelector,
hasSeenAnalyticsOptInPromptSelector,
mevProtectionSelector,
readOnlyModeEnabledSelector,
seenDevicesSelector,
isRebornSelector,
} from "../reducers/settings";
import { bleDevicesSelector } from "../reducers/ble";
import { DeviceLike, State } from "../reducers/types";
Expand Down Expand Up @@ -198,7 +198,8 @@ const extraProperties = async (store: AppStore) => {
: {};

const onboardingHasDevice = onboardingHasDeviceSelector(state);
const isReborn = readOnlyModeEnabledSelector(state);
const isReborn = isRebornSelector(state);

const notifications = notificationsSelector(state);
const notificationsOptedIn = {
notificationsAllowed: notifications.areNotificationsAllowed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useTheme } from "styled-components/native";
import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
import { hasCompletedOnboardingSelector } from "~/reducers/settings";
import { completeOnboarding } from "~/actions/settings";
import { completeOnboarding, setIsReborn, setOnboardingHasDevice } from "~/actions/settings";
import PreventNativeBack from "~/components/PreventNativeBack";

type Props = BaseComposite<
Expand All @@ -34,6 +34,8 @@ export function ActivationLoading({ route }: Props) {
useEffect(() => {
if (!hasCompletedOnboarding) {
dispatch(completeOnboarding());
dispatch(setIsReborn(false));
dispatch(setOnboardingHasDevice(true));
}
}, [dispatch, hasCompletedOnboarding]);

Expand Down
8 changes: 8 additions & 0 deletions apps/ledger-live-mobile/src/reducers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import type {
SettingsSetMevProtectionPayload,
SettingsUpdateNftCollectionStatus,
SettingsSetSelectedTabPortfolioAssetsPayload,
SettingsSetIsRebornPayload,
} from "../actions/types";
import {
SettingsActionTypes,
Expand Down Expand Up @@ -158,6 +159,7 @@ export const INITIAL_STATE: SettingsState = {
marketCounterCurrency: null,
sensitiveAnalytics: false,
onboardingHasDevice: null,
isReborn: null,
notifications: {
areNotificationsAllowed: true,
announcementsCategory: true,
Expand Down Expand Up @@ -535,6 +537,11 @@ const handlers: ReducerMap<SettingsState, SettingsPayload> = {
onboardingHasDevice: (action as Action<SettingsSetOnboardingHasDevicePayload>).payload,
}),

[SettingsActionTypes.SET_IS_REBORN]: (state, action) => ({
...state,
isReborn: (action as Action<SettingsSetIsRebornPayload>).payload,
}),

[SettingsActionTypes.SET_ONBOARDING_TYPE]: (state, action) => ({
...state,
onboardingType: (action as Action<SettingsSetOnboardingTypePayload>).payload,
Expand Down Expand Up @@ -887,6 +894,7 @@ export const marketCounterCurrencySelector = (state: State) => state.settings.ma
export const customImageBackupSelector = (state: State) => state.settings.customLockScreenBackup;
export const sensitiveAnalyticsSelector = (state: State) => state.settings.sensitiveAnalytics;
export const onboardingHasDeviceSelector = (state: State) => state.settings.onboardingHasDevice;
export const isRebornSelector = (state: State) => state.settings.isReborn;
export const onboardingTypeSelector = (state: State) => state.settings.onboardingType;
export const hasClosedNetworkBannerSelector = (state: State) =>
state.settings.depositFlow.hasClosedNetworkBanner;
Expand Down
1 change: 1 addition & 0 deletions apps/ledger-live-mobile/src/reducers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export type SettingsState = {
marketCounterCurrency: string | null | undefined;
sensitiveAnalytics: boolean;
onboardingHasDevice: boolean | null;
isReborn: boolean | null;
onboardingType: OnboardingType | null;
customLockScreenType: ImageType | null;
customLockScreenBackup: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function NoLedgerYetModal({ onClose, isOpen }: Props) {
const { navigateToRebornFlow, rebornFeatureFlagEnabled } = useRebornFlow(true);

const identifyUser = useCallback(
(hasDevice: boolean) => {
(hasDevice: boolean | null) => {
dispatch(setOnboardingHasDevice(hasDevice));
updateIdentify();
},
Expand All @@ -52,7 +52,7 @@ export function NoLedgerYetModal({ onClose, isOpen }: Props) {
const exploreLedger = useCallback(() => {
dispatch(setHasOrderedNano(false));
navigation.navigate(ScreenName.OnboardingModalDiscoverLive);
identifyUser(false);
identifyUser(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

can be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep it just sets the hasDevice to null

track("button_clicked", {
button: "Explore the app",
page: "Onboarding Get Started",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import styled, { useTheme } from "styled-components/native";
import { useDispatch } from "react-redux";
import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
import { Image, ImageProps } from "react-native";
import { completeOnboarding, setOnboardingHasDevice, setReadOnlyMode } from "~/actions/settings";
import {
completeOnboarding,
setIsReborn,
setOnboardingHasDevice,
setReadOnlyMode,
} from "~/actions/settings";
import { useRebornFlow } from "LLM/features/Reborn/hooks/useRebornFlow";
import { NavigatorName, ScreenName } from "~/const";
import { screen, track } from "~/analytics";
Expand Down Expand Up @@ -78,7 +83,6 @@ const Item = ({
dispatch(completeOnboarding());
dispatch(setReadOnlyMode(true));
onClick("Explore without a device");
dispatch(setOnboardingHasDevice(false));

navigation.reset({
index: 0,
Expand All @@ -88,9 +92,10 @@ const Item = ({

const pressExplore = useCallback(() => {
exploreLedger();
dispatch(setIsReborn(true));
dispatch(setOnboardingHasDevice(false));
onClick("Explore without a device");
}, [exploreLedger, dispatch, onClick]);
}, [dispatch, exploreLedger, onClick]);

const pressBuy = useCallback(() => {
buyLedger();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, memo } from "react";
import { useNavigation, useRoute } from "@react-navigation/native";
import { Flex, IconsLegacy } from "@ledgerhq/native-ui";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { NavigatorName, ScreenName } from "~/const";
import { ConnectDevice } from "./setupDevice/scenes";
import { TrackScreen } from "~/analytics";
Expand All @@ -10,6 +10,8 @@ import {
completeOnboarding,
setHasBeenRedirectedToPostOnboarding,
setHasBeenUpsoldProtect,
setIsReborn,
setOnboardingHasDevice,
} from "~/actions/settings";
import { useNavigationInterceptor } from "../onboardingContext";
import useNotifications from "~/logic/notifications";
Expand All @@ -23,6 +25,7 @@ import { BaseOnboardingNavigatorParamList } from "~/components/RootNavigator/typ
import styled from "styled-components/native";
import { SafeAreaView } from "react-native-safe-area-context";
import Button from "~/components/PreventDoubleClickButton";
import { hasCompletedOnboardingSelector } from "~/reducers/settings";

const StyledContainerView = styled(Flex)`
padding-left: 16px;
Expand Down Expand Up @@ -73,6 +76,7 @@ export default memo(function () {
const { resetCurrentStep } = useNavigationInterceptor();

const { deviceModelId, showSeedWarning, isProtectFlow, fromAccessExistingWallet } = route.params;
const hasCompletedOnboarding = useSelector(hasCompletedOnboardingSelector);

const onFinish = useCallback(() => {
if (isProtectFlow && deviceModelId) {
Expand All @@ -82,6 +86,10 @@ export default memo(function () {
});
return;
}
dispatch(setIsReborn(false));
if (!hasCompletedOnboarding) {
dispatch(setOnboardingHasDevice(true));
}
dispatch(completeOnboarding());
resetCurrentStep();

Expand All @@ -107,6 +115,7 @@ export default memo(function () {
isProtectFlow,
deviceModelId,
dispatch,
hasCompletedOnboarding,
resetCurrentStep,
navigation,
fromAccessExistingWallet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function PostWelcomeSelection() {
const [modalOpen, setModalOpen] = useState(false);

const openModal = () => {
identifyUser(false);
identifyUser(null);
setModalOpen(true);
track("button_clicked", {
button: "I don’t have a Ledger yet",
Expand Down Expand Up @@ -57,13 +57,13 @@ function PostWelcomeSelection() {

const setupLedger = () => {
dispatch(setReadOnlyMode(false));
identifyUser(true);
identifyUser(null);
navigation.navigate(ScreenName.OnboardingDeviceSelection);
};

const accessExistingWallet = () => {
dispatch(setReadOnlyMode(false));
identifyUser(true);
identifyUser(null);
navigation.navigate(ScreenName.OnboardingWelcomeBack);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { NavigatorName, ScreenName } from "~/const";
import StyledStatusBar from "~/components/StyledStatusBar";
import { urls } from "~/utils/urls";
import { useAcceptGeneralTerms } from "~/logic/terms";
import { setAnalytics, setOnboardingHasDevice } from "~/actions/settings";
import { setAnalytics, setIsReborn, setOnboardingHasDevice } from "~/actions/settings";
import useIsAppInBackground from "~/components/useIsAppInBackground";
import ForceTheme from "~/components/theme/ForceTheme";
import Button from "~/components/wrappedUi/Button";
Expand Down Expand Up @@ -120,6 +120,7 @@ function OnboardingStepWelcome({ navigation }: NavigationProps) {

useEffect(() => {
dispatch(setOnboardingHasDevice(null));
dispatch(setIsReborn(null));
return () => {
if (timeout.current) clearTimeout(timeout.current);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
setHasBeenRedirectedToPostOnboarding,
setHasBeenUpsoldProtect,
setHasOrderedNano,
setIsReborn,
setOnboardingHasDevice,
setReadOnlyMode,
} from "~/actions/settings";
import { RebootContext } from "~/context/Reboot";
Expand All @@ -30,6 +32,8 @@ export default function ResetOnboardingStateRow() {
dispatch(removeKnownDevices(knownDevices.map(d => d.id)));
dispatch(setHasBeenUpsoldProtect(false));
dispatch(setHasBeenRedirectedToPostOnboarding(false));
dispatch(setIsReborn(null));
dispatch(setOnboardingHasDevice(null));
unacceptGeneralTerms();
requestAnimationFrame(() => {
reboot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import { BaseComposite, RootNavigation } from "~/components/RootNavigator/types/
import { DeviceModelId } from "@ledgerhq/devices";
import EuropaCompletionView from "./EuropaCompletionView";
import StaxCompletionView from "./StaxCompletionView";
import { useDispatch } from "react-redux";
import { setHasBeenRedirectedToPostOnboarding, setHasBeenUpsoldProtect } from "~/actions/settings";
import { useDispatch, useSelector } from "react-redux";
import {
setHasBeenRedirectedToPostOnboarding,
setHasBeenUpsoldProtect,
setIsReborn,
setOnboardingHasDevice,
} from "~/actions/settings";
import { hasCompletedOnboardingSelector } from "~/reducers/settings";

type Props = BaseComposite<
StackScreenProps<SyncOnboardingStackParamList, ScreenName.SyncOnboardingCompletion>
Expand All @@ -19,11 +25,16 @@ type Props = BaseComposite<
const CompletionScreen = ({ navigation, route }: Props) => {
const { device } = route.params;
const dispatch = useDispatch();
const hasCompletedOnboarding = useSelector(hasCompletedOnboardingSelector);

useEffect(() => {
if (!hasCompletedOnboarding) {
dispatch(setOnboardingHasDevice(true));
}
dispatch(setIsReborn(false));
dispatch(setHasBeenUpsoldProtect(false));
dispatch(setHasBeenRedirectedToPostOnboarding(false));
}, [dispatch]);
}, [dispatch, hasCompletedOnboarding]);

const hasRedirected = React.useRef(false);

Expand Down
Loading
Loading