From 2ab756a847a820242575d87185a47fc9f95a58e8 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Mon, 13 Feb 2023 16:49:25 +0500 Subject: [PATCH] mobile: make telemetry opt-in --- apps/mobile/app/components/auth/signup.js | 2 -- apps/mobile/app/components/intro/index.js | 14 +------------- apps/mobile/app/components/intro/welcome.js | 11 ++++++----- apps/mobile/app/components/premium/component.js | 6 +----- .../mobile/app/components/premium/pricing-plans.js | 8 +------- apps/mobile/app/components/side-menu/index.js | 2 -- .../app/screens/editor/tiptap/use-editor-events.ts | 10 ++++------ apps/mobile/app/screens/settings/app-lock.js | 2 -- apps/mobile/app/services/message.js | 6 ++---- apps/mobile/app/stores/use-setting-store.ts | 8 ++++---- 10 files changed, 19 insertions(+), 50 deletions(-) diff --git a/apps/mobile/app/components/auth/signup.js b/apps/mobile/app/components/auth/signup.js index 27f62eb8b..161f8fcbf 100644 --- a/apps/mobile/app/components/auth/signup.js +++ b/apps/mobile/app/components/auth/signup.js @@ -20,7 +20,6 @@ along with this program. If not, see . import React, { useRef, useState } from "react"; import { Dimensions, View } from "react-native"; import Animated, { FadeInDown, FadeOutUp } from "react-native-reanimated"; -import umami from "../../common/analytics"; import { db } from "../../common/database"; import { DDS } from "../../services/device-detection"; import { ToastEvent } from "../../services/event-manager"; @@ -79,7 +78,6 @@ export const Signup = ({ changeMode, trial }) => { clearMessage(); setEmailVerifyMessage(); hideAuth(); - umami.pageView("/account-created", "/welcome/signup"); await sleep(300); if (trial) { PremiumService.sheet(null, null, true); diff --git a/apps/mobile/app/components/intro/index.js b/apps/mobile/app/components/intro/index.js index 265206b93..55e07c122 100644 --- a/apps/mobile/app/components/intro/index.js +++ b/apps/mobile/app/components/intro/index.js @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -import React, { useEffect } from "react"; +import React from "react"; import { Dimensions, Image, @@ -26,7 +26,6 @@ import { View } from "react-native"; import Icon from "react-native-vector-icons/MaterialCommunityIcons"; -import umami from "../../common/analytics"; import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets"; import { useNavigationFocus } from "../../hooks/use-navigation-focus"; import { DDS } from "../../services/device-detection"; @@ -50,9 +49,6 @@ export const SVG_Z = const Intro = ({ navigation }) => { const colors = useThemeStore((state) => state.colors); - const introCompleted = useSettingStore( - (state) => state.settings.introCompleted - ); const isTelemetryEnabled = useSettingStore( (state) => state.settings.telemetry ); @@ -64,12 +60,6 @@ const Intro = ({ navigation }) => { } }); - useEffect(() => { - if (!introCompleted) { - umami.pageView("/welcome", "", []); - } - }, [introCompleted]); - return ( { navigation.navigate("AppLock", { welcome: true }); - - umami.pageView("/home", "/welcome"); }} style={{ paddingHorizontal: 24, diff --git a/apps/mobile/app/components/intro/welcome.js b/apps/mobile/app/components/intro/welcome.js index 98adede57..4c2caa242 100644 --- a/apps/mobile/app/components/intro/welcome.js +++ b/apps/mobile/app/components/intro/welcome.js @@ -19,22 +19,24 @@ along with this program. If not, see . import React from "react"; import Animated, { FadeInDown } from "react-native-reanimated"; -import umami from "../../common/analytics"; import { DDS } from "../../services/device-detection"; import { eSendEvent } from "../../services/event-manager"; import Navigation from "../../services/navigation"; import SettingsService from "../../services/settings"; import { useThemeStore } from "../../stores/use-theme-store"; import { getElevation } from "../../utils"; -import { eCloseLoading, eOpenLoginDialog } from "../../utils/events"; +import { + eCloseLoading, + eOpenLoading, + eOpenLoginDialog +} from "../../utils/events"; import { SIZE } from "../../utils/size"; +import { sleep } from "../../utils/time"; import { AuthMode } from "../auth"; import { Button } from "../ui/button"; import { SvgView } from "../ui/svg"; import Heading from "../ui/typography/heading"; import Paragraph from "../ui/typography/paragraph"; -import { eOpenLoading } from "../../utils/events"; -import { sleep } from "../../utils/time"; const IMAGE = (color) => `two_factor_authentication`; @@ -84,7 +86,6 @@ export const WelcomeNotice = () => { } ); }, 1000); - umami.pageView("/encryptionnotice", "/welcome/privacymode"); }} style={{ paddingHorizontal: 24, diff --git a/apps/mobile/app/components/premium/component.js b/apps/mobile/app/components/premium/component.js index 5d9f58dea..bbe25fc23 100644 --- a/apps/mobile/app/components/premium/component.js +++ b/apps/mobile/app/components/premium/component.js @@ -18,9 +18,8 @@ along with this program. If not, see . */ import React, { useState } from "react"; -import { ActivityIndicator, ScrollView, View } from "react-native"; +import { ActivityIndicator, Platform, ScrollView, View } from "react-native"; import { LAUNCH_ROCKET } from "../../assets/images/assets"; -import umami from "../../common/analytics"; import { db } from "../../common/database"; import { usePricing } from "../../hooks/use-pricing"; import { DDS } from "../../services/device-detection"; @@ -48,7 +47,6 @@ import { Walkthrough } from "../walkthroughs"; import { features } from "./features"; import { Group } from "./group"; import { PricingPlans } from "./pricing-plans"; -import { Platform } from "react-native"; export const Component = ({ close, promo }) => { const colors = useThemeStore((state) => state.colors); @@ -60,7 +58,6 @@ export const Component = ({ close, promo }) => { const onPress = async () => { if (user) { - umami.pageView("/pro-plans", "/pro-screen"); presentSheet({ context: "pricing_plans", component: ( @@ -69,7 +66,6 @@ export const Component = ({ close, promo }) => { }); } else { close(); - umami.pageView("/signup", "/pro-screen"); setTimeout(() => { eSendEvent(eOpenLoginDialog, AuthMode.trialSignup); }, 400); diff --git a/apps/mobile/app/components/premium/pricing-plans.js b/apps/mobile/app/components/premium/pricing-plans.js index b075eaed5..c6b66e344 100644 --- a/apps/mobile/app/components/premium/pricing-plans.js +++ b/apps/mobile/app/components/premium/pricing-plans.js @@ -17,10 +17,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -import React, { useEffect, useState } from "react"; +import React, { useCallback, useEffect, useState } from "react"; import { ActivityIndicator, Platform, Text, View } from "react-native"; import * as RNIap from "react-native-iap"; -import umami from "../../common/analytics"; import { db } from "../../common/database"; import { usePricing } from "../../hooks/use-pricing"; import { @@ -48,7 +47,6 @@ import Heading from "../ui/typography/heading"; import Paragraph from "../ui/typography/paragraph"; import { Walkthrough } from "../walkthroughs"; import { PricingItem } from "./pricing-item"; -import { useCallback } from "react"; const promoCyclesMonthly = { 1: "first month", @@ -141,10 +139,6 @@ export const PricingPlans = ({ setBuying(false); return; } - umami.pageView( - "/iap-native", - `${compact ? "pro-sheet" : "pro-screen"}/pro-plans` - ); await RNIap.requestSubscription( product?.productId, false, diff --git a/apps/mobile/app/components/side-menu/index.js b/apps/mobile/app/components/side-menu/index.js index 8896b9869..c2a101fa2 100644 --- a/apps/mobile/app/components/side-menu/index.js +++ b/apps/mobile/app/components/side-menu/index.js @@ -20,7 +20,6 @@ along with this program. If not, see . import React, { useCallback } from "react"; import { FlatList, View } from "react-native"; import { notesnook } from "../../../e2e/test.ids"; -import umami from "../../common/analytics"; import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets"; import { DDS } from "../../services/device-detection"; import { eSendEvent } from "../../services/event-manager"; @@ -76,7 +75,6 @@ export const SideMenu = React.memo( name: "Notesnook Pro", icon: "crown", func: () => { - umami.pageView("/pro-screen", "/sidemenu"); eSendEvent(eOpenPremiumDialog); } }; diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts b/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts index cf8244606..66773168b 100644 --- a/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts +++ b/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts @@ -28,8 +28,9 @@ import { NativeEventSubscription } from "react-native"; import { WebViewMessageEvent } from "react-native-webview"; -import umami from "../../../common/analytics/index"; import { db } from "../../../common/database"; +import { RelationsList } from "../../../components/sheets/relations-list"; +import ReminderSheet from "../../../components/sheets/reminder"; import useKeyboard from "../../../hooks/use-keyboard"; import { DDS } from "../../../services/device-detection"; import { @@ -53,15 +54,13 @@ import { eOpenPublishNoteDialog, eOpenTagsDialog } from "../../../utils/events"; +import { openLinkInBrowser } from "../../../utils/functions"; import { tabBarRef } from "../../../utils/global-refs"; import { NoteType } from "../../../utils/types"; import { useDragState } from "../../settings/editor/state"; +import { EventTypes } from "./editor-events"; import { EditorMessage, EditorProps, useEditorType } from "./types"; import { EditorEvents, editorState } from "./utils"; -import { openLinkInBrowser } from "../../../utils/functions"; -import { EventTypes } from "./editor-events"; -import { RelationsList } from "../../../components/sheets/relations-list"; -import ReminderSheet from "../../../components/sheets/reminder"; const publishNote = async (editor: useEditorType) => { const user = useUserStore.getState().user; @@ -363,7 +362,6 @@ export const useEditorEvents = ( if (editor.state.current?.isFocused) { editor.state.current.isFocused = true; } - umami.pageView("/pro-screen", "/editor"); eSendEvent(eOpenPremiumDialog); break; case EventTypes.monograph: diff --git a/apps/mobile/app/screens/settings/app-lock.js b/apps/mobile/app/screens/settings/app-lock.js index 11593d0d3..4e9ad7c9f 100644 --- a/apps/mobile/app/screens/settings/app-lock.js +++ b/apps/mobile/app/screens/settings/app-lock.js @@ -21,7 +21,6 @@ import React, { useState } from "react"; import { Dimensions, LayoutAnimation, Platform, View } from "react-native"; import Animated, { FadeInDown, FadeOutUp } from "react-native-reanimated"; import Icon from "react-native-vector-icons/MaterialCommunityIcons"; -import umami from "../../common/analytics"; import { SVG_Z } from "../../components/intro"; import { WelcomeNotice } from "../../components/intro/welcome"; import { Button } from "../../components/ui/button"; @@ -205,7 +204,6 @@ const AppLock = ({ route }) => { type: "linear" } }); - umami.pageView("/privacymode", "/welcome"); setStep(1); }} style={{ diff --git a/apps/mobile/app/services/message.js b/apps/mobile/app/services/message.js index dc968c514..dfc84517c 100644 --- a/apps/mobile/app/services/message.js +++ b/apps/mobile/app/services/message.js @@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +import { Platform } from "react-native"; +import { verifyUser } from "../screens/settings/functions"; import { useMessageStore } from "../stores/use-message-store"; import { eOpenLoginDialog, @@ -25,9 +27,6 @@ import { } from "../utils/events"; import { eSendEvent } from "./event-manager"; import PremiumService from "./premium"; -import { verifyUser } from "../screens/settings/functions"; -import { Platform } from "react-native"; -import umami from "../common/analytics"; import SettingsService from "./settings"; const rateAppMessage = { @@ -82,7 +81,6 @@ const loginMessage = { message: "You are not logged in", actionText: "Login to encrypt and sync notes", onPress: () => { - umami.pageView("/signup", "/welcome/home"); eSendEvent(eOpenLoginDialog); }, data: {}, diff --git a/apps/mobile/app/stores/use-setting-store.ts b/apps/mobile/app/stores/use-setting-store.ts index 9e4a0cc07..f98721fbf 100644 --- a/apps/mobile/app/stores/use-setting-store.ts +++ b/apps/mobile/app/stores/use-setting-store.ts @@ -19,12 +19,12 @@ along with this program. If not, see . import { Dimensions, PlatformOSType } from "react-native"; import Config from "react-native-config"; +import { Sound } from "react-native-notification-sounds"; +import { initialWindowMetrics } from "react-native-safe-area-context"; import { FileType } from "react-native-scoped-storage"; import create, { State } from "zustand"; -import { ACCENT } from "../utils/color-scheme"; -import { initialWindowMetrics } from "react-native-safe-area-context"; import { Reminder } from "../services/notifications"; -import { Sound } from "react-native-notification-sounds"; +import { ACCENT } from "../utils/color-scheme"; export type Settings = { showToolbarOnTop?: boolean; @@ -123,7 +123,7 @@ export const useSettingStore = create((set) => ({ screenshotMode: true, privacyScreen: false, appLockMode: "none", - telemetry: true, + telemetry: false, notebooksListMode: "normal", notesListMode: "normal", devMode: false,