diff --git a/apps/mobile/app/common/analytics/index.js b/apps/mobile/app/common/analytics/index.js deleted file mode 100644 index 305c2acbf1..0000000000 --- a/apps/mobile/app/common/analytics/index.js +++ /dev/null @@ -1,156 +0,0 @@ -/* -This file is part of the Notesnook project (https://notesnook.com/) - -Copyright (C) 2023 Streetwriters (Private) Limited - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -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 { MMKV } from "../database/mmkv"; -import { useSettingStore } from "../../stores/use-setting-store"; - -const WEBSITE_ID = "3c6890ce-8410-49d5-8831-15fb2eb28a21"; -const baseUrl = "https://analytics.streetwriters.co/api/collect"; - -const UA = - Platform.OS === "ios" - ? "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1" - : ` -Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36`; - -/** - * - * @param {Routes} route - * @param {Routes[]} conditions - * @returns - */ -async function canUpdateAnalytics(route, conditions = []) { - if (!useSettingStore?.getState()?.settings?.telemetry) return false; - let eventsList = MMKV.getString("notesnookUserEvents"); - - if (eventsList) { - eventsList = JSON.parse(eventsList); - } - - if (eventsList && eventsList[route]) { - console.log("analytics: event already sent", route); - return false; - } - if (route !== "/welcome") { - for (let cond of conditions) { - if (!eventsList || !eventsList[cond]) { - console.log("analytics: conditions not met for event", route, cond); - return false; - } - } - } - console.log("analytics: will send event", route); - return true; -} - -async function saveAnalytics(route, value = true) { - let eventsList = MMKV.getString("notesnookUserEvents"); - if (eventsList) { - eventsList = JSON.parse(eventsList); - } else { - eventsList = {}; - } - eventsList[route] = value; - MMKV.setString("notesnookUserEvents", JSON.stringify(eventsList)); -} - -/** - *@typedef {"/welcome" | "/home" | "/signup" | "/first-note" | "/account-created" | "/pro-sheet" | "/pro-plans" | "/iap-native" | "/pro-screen" | "/editor" | "/editor-toolbar" | "/properties" | "/sidemenu"} Routes - * @param {Routes} prevRoute - * @param {Routes} route - * @param {Routes[]} conditions - * @param {boolean} once - * @returns - */ - -async function pageView( - route, - prevRoute = "", - conditions = ["/welcome"], - once = true -) { - if (__DEV__) return; - if (!(await canUpdateAnalytics(route, conditions)) && once) return; - let body = { - payload: { - website: WEBSITE_ID, - url: `notesnook-${Platform.OS}${prevRoute}${route}`, - referrer: `https://notesnook.com/notesnook-${Platform.OS}${prevRoute}`, - hostname: `notesnook-${Platform.OS}`, - language: "en-US", - screen: "1920x1080" - }, - type: "pageview" - }; - - try { - let response = await fetch(baseUrl, { - method: "POST", - headers: { - "Content-Type": "application/json", - "User-Agent": UA - }, - body: JSON.stringify(body) - }); - console.log("analytics: event sent", route); - await saveAnalytics(route); - return await response.text(); - } catch (e) { - console.log(e); - } -} - -async function sendEvent(type, value, once = true) { - if (__DEV__) return; - if (!(await canUpdateAnalytics(type)) && once) return; - let body = { - payload: { - website: WEBSITE_ID, - url: "/", - event_type: type, - event_value: value, - hostname: "notesnook-android-app", - language: "en-US", - screen: "1920x1080" - }, - type: "event" - }; - - try { - let response = await fetch(baseUrl, { - method: "POST", - headers: { - "Content-Type": "application/json", - "User-Agent": UA - }, - body: JSON.stringify(body) - }); - console.log(response.status); - return await response.text(); - } catch (e) { - console.log(e); - } -} - -export default { - sendEvent, - pageView, - saveAnalytics -}; diff --git a/apps/mobile/app/components/intro/index.js b/apps/mobile/app/components/intro/index.js index 6972edc330..ea12573626 100644 --- a/apps/mobile/app/components/intro/index.js +++ b/apps/mobile/app/components/intro/index.js @@ -43,9 +43,6 @@ import { eSendEvent } from "../../services/event-manager"; const Intro = ({ navigation }) => { const { colors } = useThemeColors(); - const isTelemetryEnabled = useSettingStore( - (state) => state.settings.telemetry - ); const { width, height } = useWindowDimensions(); const deviceMode = useSettingStore((state) => state.deviceMode); const insets = useGlobalSafeAreaInsets(); @@ -217,44 +214,6 @@ const Intro = ({ navigation }) => { type="accent" title="Get started" /> - - { - SettingsService.set({ telemetry: !isTelemetryEnabled }); - }} - > - - - - Help improve Notesnook by sending completely anonymized{" "} - private analytics and bug reports. - - ); diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx index 33e21ebca3..056cc23cdd 100644 --- a/apps/mobile/app/screens/settings/settings-data.tsx +++ b/apps/mobile/app/screens/settings/settings-data.tsx @@ -835,15 +835,6 @@ export const settingsGroups: SettingSection[] = [ id: "privacy-security", name: "Privacy and security", sections: [ - { - id: "temeltery", - type: "switch", - name: "Telemetry", - icon: "radar", - description: - "Contribute towards a better Notesnook. All tracking information is anonymous.", - property: "telemetry" - }, { id: "marketing-emails", type: "switch", diff --git a/apps/mobile/app/stores/use-setting-store.ts b/apps/mobile/app/stores/use-setting-store.ts index f01cc8b77b..8ab2c35148 100644 --- a/apps/mobile/app/stores/use-setting-store.ts +++ b/apps/mobile/app/stores/use-setting-store.ts @@ -45,7 +45,6 @@ export type Settings = { appLockTimer: number; appLockEnabled?: boolean; appLockMode?: "none" | "background" | "launch"; - telemetry?: boolean; notebooksListMode?: "normal" | "compact"; notesListMode?: "normal" | "compact"; devMode?: boolean; @@ -146,7 +145,6 @@ export const defaultSettings: SettingStore["settings"] = { screenshotMode: true, privacyScreen: false, appLockMode: "none", - telemetry: false, notebooksListMode: "normal", notesListMode: "normal", devMode: false,