1.1.5: fix activation analytics blind spots + purchase environment tagging
- dish_added now carries a `source` param; onboarding-created dishes fire it with source="onboarding" (previously untracked, undercounting activation) - onboarding_completed now reports dish_count - premium_purchased tagged with StoreKit environment (production/sandbox/xcode) so test purchases can be excluded from conversion metrics - add .gitignore to keep signing secrets (.p12/.cer/.mobileprovision) and build artifacts out of the repo - document branch↔MARKETING_VERSION naming convention Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtWT52pAE91D7mbDda1cAM
This commit is contained in:
@@ -58,8 +58,11 @@ enum AnalyticsService {
|
||||
|
||||
// MARK: - Convenience methods
|
||||
|
||||
static func logDishAdded(tagCount: Int) {
|
||||
logEvent(AnalyticsEvent.dishAdded, parameters: ["tag_count": tagCount])
|
||||
static func logDishAdded(tagCount: Int, source: String = "editor") {
|
||||
logEvent(AnalyticsEvent.dishAdded, parameters: [
|
||||
"tag_count": tagCount,
|
||||
"source": source
|
||||
])
|
||||
}
|
||||
|
||||
static func logDishDeleted() {
|
||||
@@ -86,16 +89,16 @@ enum AnalyticsService {
|
||||
logEvent(AnalyticsEvent.premiumUpgradeTapped, parameters: ["source": source])
|
||||
}
|
||||
|
||||
static func logPremiumPurchased() {
|
||||
logEvent(AnalyticsEvent.premiumPurchased)
|
||||
static func logPremiumPurchased(environment: String = "unknown") {
|
||||
logEvent(AnalyticsEvent.premiumPurchased, parameters: ["environment": environment])
|
||||
}
|
||||
|
||||
static func logPremiumRestored() {
|
||||
logEvent(AnalyticsEvent.premiumRestored)
|
||||
}
|
||||
|
||||
static func logOnboardingCompleted() {
|
||||
logEvent(AnalyticsEvent.onboardingCompleted)
|
||||
static func logOnboardingCompleted(dishCount: Int) {
|
||||
logEvent(AnalyticsEvent.onboardingCompleted, parameters: ["dish_count": dishCount])
|
||||
}
|
||||
|
||||
static func logOnboardingStepViewed(step: Int) {
|
||||
|
||||
@@ -81,7 +81,7 @@ final class StoreManager: ObservableObject {
|
||||
if case .verified(let transaction) = verification {
|
||||
await transaction.finish()
|
||||
isPremium = true
|
||||
AnalyticsService.logPremiumPurchased()
|
||||
AnalyticsService.logPremiumPurchased(environment: Self.environmentName(for: transaction))
|
||||
return .success
|
||||
}
|
||||
return .failed
|
||||
@@ -181,6 +181,17 @@ final class StoreManager: ObservableObject {
|
||||
return false
|
||||
}
|
||||
|
||||
/// Maps a transaction's StoreKit environment to an analytics-friendly string
|
||||
/// so sandbox/Xcode test purchases can be excluded from real conversion metrics.
|
||||
static func environmentName(for transaction: StoreKit.Transaction) -> String {
|
||||
switch transaction.environment {
|
||||
case .production: return "production"
|
||||
case .sandbox: return "sandbox"
|
||||
case .xcode: return "xcode"
|
||||
default: return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
private struct TimeoutError: Error {}
|
||||
|
||||
private func loadProductsWithRetries(maxAttempts: Int = 3) async throws -> [Product] {
|
||||
|
||||
@@ -147,6 +147,7 @@ final class OnboardingViewModel: ObservableObject {
|
||||
context.insert(dish)
|
||||
}
|
||||
let createdDishes = !addedDishes.isEmpty
|
||||
let onboardingDishCount = addedDishes.count
|
||||
|
||||
// Create first week plan
|
||||
let weekStart = Date().startOfWeek()
|
||||
@@ -154,7 +155,12 @@ final class OnboardingViewModel: ObservableObject {
|
||||
|
||||
do {
|
||||
try context.save()
|
||||
AnalyticsService.logOnboardingCompleted()
|
||||
// Dishes created inside onboarding didn't previously fire dish_added,
|
||||
// so activation looked lower than it was. Emit one per dish, tagged.
|
||||
for dishData in addedDishes {
|
||||
AnalyticsService.logDishAdded(tagCount: dishData.tagIds.count, source: "onboarding")
|
||||
}
|
||||
AnalyticsService.logOnboardingCompleted(dishCount: onboardingDishCount)
|
||||
// If the user added dishes, auto-fill their first week on launch so they
|
||||
// land on a ready plan instead of an empty one. Otherwise fall back to the
|
||||
// home auto-assign prompt.
|
||||
|
||||
Reference in New Issue
Block a user