Repository: Automattic/pocket-casts-ios
File: podcasts/Notifications/NotificationsCoordinator+AnalyticsAdapter.swift (Swift)

Code before:
extension NotificationType {

    func checkCancelConditionsForEvent(name: String, properties: [AnyHashable: Any]?) -> Bool {
        var possibleConditions: Set<AnalyticsEvent>

        switch self {
        case .reengagementWeekly:
            possibleConditions = [.applicationOpened]
        case .onboardingSignUp:
            possibleConditions = [.userSignedIn, .userAccountCreated]
        case .onboardingImport:
            possibleConditions = [.settingsImportShown, .onboardingImportShown]
        case .onboardingThemes:
            possibleConditions = [.settingsAppearanceThemeChanged]
        case .onboardingUpNext:
            possibleConditions = [.episodeAddedToUpNext, .episodeBulkAddToUpNext]
        case .onboardingFilters:
            possibleConditions = [.filterCreated]
        case .onboardingUpsell:
            possibleConditions  = [.purchaseSuccessful]
        case .onboardingStaffPicks:
            possibleConditions = [.discoverListShowAllTapped]
        case .recommendationsTrending:
            possibleConditions = [.discoverListShowAllTapped]
        case .upsell:
            possibleConditions  = [.purchaseSuccessful]
        }
        let eventMatch = possibleConditions.contains {
            $0.rawValue.toSnakeCaseFromCamelCase() == name
        }
        guard eventMatch else {
            return false
        }

        // check for properties
        switch self {
        case .onboardingStaffPicks:
            guard let properties, let listID = properties["list_id"] as? String else {
                return false
            }
            return listID == "staff-picks"
        case .recommendationsTrending:
                guard let properties, let listID = properties["list_id"] as? String else {
                    return false
                }
                return listID == "featured"
        default:
            return true
        }
    }
}

Review comment (suggestion):
⛏️ Single extra space here.

```suggestion
            possibleConditions = [.purchaseSuccessful]
```

Code after:
extension NotificationType {

    func checkCancelConditionsForEvent(name: String, properties: [AnyHashable: Any]?) -> Bool {
        var possibleConditions: Set<AnalyticsEvent>

        switch self {
        case .reengagementWeekly:
            possibleConditions = [.applicationOpened]
        case .onboardingSignUp:
            possibleConditions = [.userSignedIn, .userAccountCreated]
        case .onboardingImport:
            possibleConditions = [.settingsImportShown, .onboardingImportShown]
        case .onboardingThemes:
            possibleConditions = [.settingsAppearanceThemeChanged]
        case .onboardingUpNext:
            possibleConditions = [.episodeAddedToUpNext, .episodeBulkAddToUpNext]
        case .onboardingFilters:
            possibleConditions = [.filterCreated]
        case .onboardingUpsell:
            possibleConditions  = [.purchaseSuccessful]
        case .onboardingStaffPicks:
            possibleConditions = [.discoverListShowAllTapped]
        case .recommendationsTrending:
            possibleConditions = [.discoverListShowAllTapped]
        case .upsell:
            possibleConditions = [.purchaseSuccessful]
        }
        let eventMatch = possibleConditions.contains {
            $0.rawValue.toSnakeCaseFromCamelCase() == name
        }
        guard eventMatch else {
            return false
        }

        // check for properties
        switch self {
        case .onboardingStaffPicks:
            guard let properties, let listID = properties["list_id"] as? String else {
                return false
            }
            return listID == "staff-picks"
        case .recommendationsTrending:
                guard let properties, let listID = properties["list_id"] as? String else {
                    return false
                }
                return listID == "featured"
        default:
            return true
        }
    }
}