diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index d0c0964..5765a76 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -20,6 +20,12 @@ jobs: - name: Clone SQLite.swift from GitHub run: | git clone --branch 0.15.3 --single-branch https://github.com/stephencelis/SQLite.swift.git ../SQLite.swift + - name: Clone Amplitude-iOS from GitHub + run: | + git clone --branch v8.21.0 --single-branch https://github.com/amplitude/Amplitude-iOS.git ../Amplitude-iOS + - name: Clone analytics-connector-ios from GitHub + run: | + git clone --branch v1.0.3 --single-branch https://github.com/amplitude/analytics-connector-ios.git ../analytics-connector-ios - name: Reset SDK Cache run: | echo "Resetting SDK cache..." diff --git a/MMEX.xcodeproj/project.pbxproj b/MMEX.xcodeproj/project.pbxproj index 0404f8f..069f880 100644 --- a/MMEX.xcodeproj/project.pbxproj +++ b/MMEX.xcodeproj/project.pbxproj @@ -146,6 +146,10 @@ A37E7D922C9AC60000B4ECFC /* ContactSupportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A37E7D912C9AC60000B4ECFC /* ContactSupportView.swift */; }; A37E7D942C9B217500B4ECFC /* InfotableData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A37E7D932C9B217500B4ECFC /* InfotableData.swift */; }; A37E7D962C9B219400B4ECFC /* InfotableRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = A37E7D952C9B219400B4ECFC /* InfotableRepository.swift */; }; + A386B2B62CDB41AA004AD9E3 /* AnalyticsConnector in Frameworks */ = {isa = PBXBuildFile; productRef = A386B2B52CDB41AA004AD9E3 /* AnalyticsConnector */; }; + A386B2BA2CDB41DC004AD9E3 /* Amplitude in Frameworks */ = {isa = PBXBuildFile; productRef = A386B2B92CDB41DC004AD9E3 /* Amplitude */; }; + A386B2BC2CDB437E004AD9E3 /* AnalyticsConnector in Frameworks */ = {isa = PBXBuildFile; productRef = A386B2BB2CDB437E004AD9E3 /* AnalyticsConnector */; }; + A386B2BF2CDB43B4004AD9E3 /* AnalyticsConnector in Frameworks */ = {isa = PBXBuildFile; productRef = A386B2BE2CDB43B4004AD9E3 /* AnalyticsConnector */; }; A39B1B362C99A0C2003E5562 /* CurrencyEditView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A39B1B352C99A0C2003E5562 /* CurrencyEditView.swift */; }; A39B1B382C99A0D8003E5562 /* CurrencyListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A39B1B372C99A0D8003E5562 /* CurrencyListView.swift */; }; A3B374C52C96A23E00943FDB /* SQLite in Frameworks */ = {isa = PBXBuildFile; productRef = A3B374C42C96A23E00943FDB /* SQLite */; }; @@ -358,7 +362,11 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + A386B2BA2CDB41DC004AD9E3 /* Amplitude in Frameworks */, A3B374C72C96A27800943FDB /* SQLite in Frameworks */, + A386B2BC2CDB437E004AD9E3 /* AnalyticsConnector in Frameworks */, + A386B2B62CDB41AA004AD9E3 /* AnalyticsConnector in Frameworks */, + A386B2BF2CDB43B4004AD9E3 /* AnalyticsConnector in Frameworks */, A3B374C52C96A23E00943FDB /* SQLite in Frameworks */, A3C1423A2C89754C00D3CEC0 /* SQLite in Frameworks */, ); @@ -595,6 +603,13 @@ path = ViewModel; sourceTree = ""; }; + A386B2A92CDB22DA004AD9E3 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; A39B1B392C9A668F003E5562 /* Account */ = { isa = PBXGroup; children = ( @@ -706,6 +721,7 @@ isa = PBXGroup; children = ( A3C142292C89751500D3CEC0 /* MMEX */, + A386B2A92CDB22DA004AD9E3 /* Frameworks */, A3C142282C89751500D3CEC0 /* Products */, ); sourceTree = ""; @@ -819,6 +835,10 @@ A3C142392C89754C00D3CEC0 /* SQLite */, A3B374C42C96A23E00943FDB /* SQLite */, A3B374C62C96A27800943FDB /* SQLite */, + A386B2B52CDB41AA004AD9E3 /* AnalyticsConnector */, + A386B2B92CDB41DC004AD9E3 /* Amplitude */, + A386B2BB2CDB437E004AD9E3 /* AnalyticsConnector */, + A386B2BE2CDB43B4004AD9E3 /* AnalyticsConnector */, ); productName = MMEX; productReference = A3C142272C89751500D3CEC0 /* MMEX.app */; @@ -860,6 +880,8 @@ mainGroup = A3C1421E2C89751500D3CEC0; packageReferences = ( A3C142382C89754C00D3CEC0 /* XCLocalSwiftPackageReference "../SQLite.swift" */, + A386B2B32CDB4192004AD9E3 /* XCLocalSwiftPackageReference "../Amplitude-iOS" */, + A386B2BD2CDB43B4004AD9E3 /* XCLocalSwiftPackageReference "../analytics-connector-ios" */, ); productRefGroup = A3C142282C89751500D3CEC0 /* Products */; projectDirPath = ""; @@ -1276,6 +1298,14 @@ /* End XCConfigurationList section */ /* Begin XCLocalSwiftPackageReference section */ + A386B2B32CDB4192004AD9E3 /* XCLocalSwiftPackageReference "../Amplitude-iOS" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = "../Amplitude-iOS"; + }; + A386B2BD2CDB43B4004AD9E3 /* XCLocalSwiftPackageReference "../analytics-connector-ios" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = "../analytics-connector-ios"; + }; A3C142382C89754C00D3CEC0 /* XCLocalSwiftPackageReference "../SQLite.swift" */ = { isa = XCLocalSwiftPackageReference; relativePath = ../SQLite.swift; @@ -1283,6 +1313,23 @@ /* End XCLocalSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + A386B2B52CDB41AA004AD9E3 /* AnalyticsConnector */ = { + isa = XCSwiftPackageProductDependency; + productName = AnalyticsConnector; + }; + A386B2B92CDB41DC004AD9E3 /* Amplitude */ = { + isa = XCSwiftPackageProductDependency; + package = A386B2B32CDB4192004AD9E3 /* XCLocalSwiftPackageReference "../Amplitude-iOS" */; + productName = Amplitude; + }; + A386B2BB2CDB437E004AD9E3 /* AnalyticsConnector */ = { + isa = XCSwiftPackageProductDependency; + productName = AnalyticsConnector; + }; + A386B2BE2CDB43B4004AD9E3 /* AnalyticsConnector */ = { + isa = XCSwiftPackageProductDependency; + productName = AnalyticsConnector; + }; A3B374C42C96A23E00943FDB /* SQLite */ = { isa = XCSwiftPackageProductDependency; productName = SQLite; diff --git a/MMEX/App/MMEXApp.swift b/MMEX/App/MMEXApp.swift index 23be76e..addb703 100644 --- a/MMEX/App/MMEXApp.swift +++ b/MMEX/App/MMEXApp.swift @@ -7,6 +7,7 @@ import SwiftUI import OSLog +import Amplitude let log = Logger( subsystem: Bundle.main.bundleIdentifier!, @@ -17,6 +18,17 @@ let log = Logger( struct MMEXApp: App { @StateObject private var env = EnvironmentManager(withStoredDatabase: ()) + @AppStorage("isTrackingEnabled") private var isTrackingEnabled: Bool = false // Default is tracking disabled + @AppStorage("userID") private var userID: String = String(format: "ios_%@", TimestampString(Date()).string) // Store user ID in AppStorage + + init() { + if isTrackingEnabled { + Amplitude.instance().defaultTracking = AMPDefaultTrackingOptions.initWithSessions(true, appLifecycles: true, deepLinks: false, screenViews: false); + Amplitude.instance().initializeApiKey("1e1fbc10354400d9c3392a89558d693d") + Amplitude.instance().setUserId(userID) // copy from/to Infotable.UID + } + } + var body: some Scene { WindowGroup { ContentView(env: env) diff --git a/MMEX/Resources/Localizable.xcstrings b/MMEX/Resources/Localizable.xcstrings index 6344b26..ad5ae59 100644 --- a/MMEX/Resources/Localizable.xcstrings +++ b/MMEX/Resources/Localizable.xcstrings @@ -276,17 +276,6 @@ } } }, - "Currencies" : { - "extractionState" : "stale", - "localizations" : { - "it" : { - "stringUnit" : { - "state" : "translated", - "value" : "Valute" - } - } - } - }, "Dark" : { "localizations" : { "it" : { @@ -412,17 +401,6 @@ }, "Delete %@" : { - }, - "Delete Account" : { - "extractionState" : "stale", - "localizations" : { - "it" : { - "stringUnit" : { - "state" : "translated", - "value" : "Elimina Conto" - } - } - } }, "Delete Category" : { "localizations" : { @@ -434,39 +412,6 @@ } } }, - "Delete Currency" : { - "extractionState" : "stale", - "localizations" : { - "it" : { - "stringUnit" : { - "state" : "translated", - "value" : "Elimina Valuta" - } - } - } - }, - "Delete Payee" : { - "extractionState" : "stale", - "localizations" : { - "it" : { - "stringUnit" : { - "state" : "translated", - "value" : "Elimina Beneficiario" - } - } - } - }, - "Delete Stock" : { - "extractionState" : "stale", - "localizations" : { - "it" : { - "stringUnit" : { - "state" : "translated", - "value" : "Elimina Azioni" - } - } - } - }, "Delete Transaction" : { "localizations" : { "it" : { @@ -765,39 +710,6 @@ } } }, - "New Database" : { - "extractionState" : "stale", - "localizations" : { - "it" : { - "stringUnit" : { - "state" : "translated", - "value" : "Nuovo Database" - } - } - } - }, - "New Payee" : { - "extractionState" : "stale", - "localizations" : { - "it" : { - "stringUnit" : { - "state" : "translated", - "value" : "Nuovo Beneficiario" - } - } - } - }, - "New Stock" : { - "extractionState" : "stale", - "localizations" : { - "it" : { - "stringUnit" : { - "state" : "translated", - "value" : "Nuova Azione" - } - } - } - }, "New Transaction" : { "localizations" : { "it" : { @@ -839,6 +751,9 @@ } } } + }, + "Off" : { + }, "OK" : { "localizations" : { @@ -849,6 +764,9 @@ } } } + }, + "On" : { + }, "Open Database" : { "localizations" : { @@ -873,17 +791,6 @@ } } }, - "Payees" : { - "extractionState" : "stale", - "localizations" : { - "it" : { - "stringUnit" : { - "state" : "translated", - "value" : "Beneficiari" - } - } - } - }, "Please open or create a database to get started." : { }, @@ -1011,6 +918,9 @@ }, "Select To Account" : { + }, + "Send Anonymous Usage Data" : { + }, "Settings" : { "localizations" : { diff --git a/MMEX/View/Settings/SettingsView.swift b/MMEX/View/Settings/SettingsView.swift index 4c9b1f7..802aaaf 100644 --- a/MMEX/View/Settings/SettingsView.swift +++ b/MMEX/View/Settings/SettingsView.swift @@ -15,6 +15,7 @@ struct SettingsView: View { @AppStorage("appearance") private var appearance: Int = UIUserInterfaceStyle.unspecified.rawValue @AppStorage("defaultPayeeSetting") private var defaultPayeeSetting: DefaultPayeeSetting = .none @AppStorage("defaultStatus") private var defaultStatus = TransactionStatus.defaultValue + @AppStorage("isTrackingEnabled") private var isTrackingEnabled: Bool = false // Default is tracking disabled @State private var dateFormat: String = "%Y-%m-%d" @@ -35,6 +36,15 @@ struct SettingsView: View { Text("Theme") } + Picker("Send Anonymous Usage Data", selection: $isTrackingEnabled) { + Text("On").tag(true) + Text("Off").tag(false) + } + .pickerStyle(NavigationLinkPickerStyle()) + .onChange(of: isTrackingEnabled) { + // TODO + } + Picker("Default Payee", selection: $defaultPayeeSetting) { Text("None").tag(DefaultPayeeSetting.none) Text("Last Used").tag(DefaultPayeeSetting.lastUsed)