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

Basic track via Amplitude #216

Merged
merged 5 commits into from
Nov 6, 2024
Merged
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
6 changes: 6 additions & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
47 changes: 47 additions & 0 deletions MMEX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 */,
);
Expand Down Expand Up @@ -595,6 +603,13 @@
path = ViewModel;
sourceTree = "<group>";
};
A386B2A92CDB22DA004AD9E3 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
A39B1B392C9A668F003E5562 /* Account */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -706,6 +721,7 @@
isa = PBXGroup;
children = (
A3C142292C89751500D3CEC0 /* MMEX */,
A386B2A92CDB22DA004AD9E3 /* Frameworks */,
A3C142282C89751500D3CEC0 /* Products */,
);
sourceTree = "<group>";
Expand Down Expand Up @@ -819,6 +835,10 @@
A3C142392C89754C00D3CEC0 /* SQLite */,
A3B374C42C96A23E00943FDB /* SQLite */,
A3B374C62C96A27800943FDB /* SQLite */,
A386B2B52CDB41AA004AD9E3 /* AnalyticsConnector */,
A386B2B92CDB41DC004AD9E3 /* Amplitude */,
A386B2BB2CDB437E004AD9E3 /* AnalyticsConnector */,
A386B2BE2CDB43B4004AD9E3 /* AnalyticsConnector */,
);
productName = MMEX;
productReference = A3C142272C89751500D3CEC0 /* MMEX.app */;
Expand Down Expand Up @@ -860,6 +880,8 @@
mainGroup = A3C1421E2C89751500D3CEC0;
packageReferences = (
A3C142382C89754C00D3CEC0 /* XCLocalSwiftPackageReference "../SQLite.swift" */,
A386B2B32CDB4192004AD9E3 /* XCLocalSwiftPackageReference "../Amplitude-iOS" */,
A386B2BD2CDB43B4004AD9E3 /* XCLocalSwiftPackageReference "../analytics-connector-ios" */,
);
productRefGroup = A3C142282C89751500D3CEC0 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -1276,13 +1298,38 @@
/* 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;
};
/* 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;
Expand Down
12 changes: 12 additions & 0 deletions MMEX/App/MMEXApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import SwiftUI
import OSLog
import Amplitude

let log = Logger(
subsystem: Bundle.main.bundleIdentifier!,
Expand All @@ -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)
Expand Down
108 changes: 9 additions & 99 deletions MMEX/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,6 @@
}
}
},
"Currencies" : {
"extractionState" : "stale",
"localizations" : {
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Valute"
}
}
}
},
"Dark" : {
"localizations" : {
"it" : {
Expand Down Expand Up @@ -412,17 +401,6 @@
},
"Delete %@" : {

},
"Delete Account" : {
"extractionState" : "stale",
"localizations" : {
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Elimina Conto"
}
}
}
},
"Delete Category" : {
"localizations" : {
Expand All @@ -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" : {
Expand Down Expand Up @@ -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" : {
Expand Down Expand Up @@ -839,6 +751,9 @@
}
}
}
},
"Off" : {

},
"OK" : {
"localizations" : {
Expand All @@ -849,6 +764,9 @@
}
}
}
},
"On" : {

},
"Open Database" : {
"localizations" : {
Expand All @@ -873,17 +791,6 @@
}
}
},
"Payees" : {
"extractionState" : "stale",
"localizations" : {
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Beneficiari"
}
}
}
},
"Please open or create a database to get started." : {

},
Expand Down Expand Up @@ -1011,6 +918,9 @@
},
"Select To Account" : {

},
"Send Anonymous Usage Data" : {

},
"Settings" : {
"localizations" : {
Expand Down
10 changes: 10 additions & 0 deletions MMEX/View/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)
Expand Down