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

Duck player support on RMF #914

Merged
merged 2 commits into from
Jul 29, 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
24 changes: 16 additions & 8 deletions Sources/RemoteMessaging/Matchers/UserAttributeMatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public struct MobileUserAttributeMatcher: AttributeMatching {
isPrivacyProSubscriptionActive: Bool,
isPrivacyProSubscriptionExpiring: Bool,
isPrivacyProSubscriptionExpired: Bool,
isDuckPlayerOnboarded: Bool,
isDuckPlayerEnabled: Bool,
dismissedMessageIds: [String]
) {
self.isWidgetInstalled = isWidgetInstalled
Expand All @@ -74,6 +76,8 @@ public struct MobileUserAttributeMatcher: AttributeMatching {
isPrivacyProSubscriptionActive: isPrivacyProSubscriptionActive,
isPrivacyProSubscriptionExpiring: isPrivacyProSubscriptionExpiring,
isPrivacyProSubscriptionExpired: isPrivacyProSubscriptionExpired,
isDuckPlayerOnboarded: isDuckPlayerOnboarded,
isDuckPlayerEnabled: isDuckPlayerEnabled,
dismissedMessageIds: dismissedMessageIds
)
}
Expand All @@ -92,8 +96,6 @@ public struct MobileUserAttributeMatcher: AttributeMatching {
public struct DesktopUserAttributeMatcher: AttributeMatching {
private let pinnedTabsCount: Int
private let hasCustomHomePage: Bool
private let isDuckPlayerOnboarded: Bool
private let isDuckPlayerEnabled: Bool
private let dismissedDeprecatedMacRemoteMessageIds: [String]

private let commonUserAttributeMatcher: CommonUserAttributeMatcher
Expand Down Expand Up @@ -122,8 +124,6 @@ public struct DesktopUserAttributeMatcher: AttributeMatching {
) {
self.pinnedTabsCount = pinnedTabsCount
self.hasCustomHomePage = hasCustomHomePage
self.isDuckPlayerOnboarded = isDuckPlayerOnboarded
self.isDuckPlayerEnabled = isDuckPlayerEnabled
self.dismissedDeprecatedMacRemoteMessageIds = dismissedDeprecatedMacRemoteMessageIds

commonUserAttributeMatcher = .init(
Expand All @@ -142,6 +142,8 @@ public struct DesktopUserAttributeMatcher: AttributeMatching {
isPrivacyProSubscriptionActive: isPrivacyProSubscriptionActive,
isPrivacyProSubscriptionExpiring: isPrivacyProSubscriptionExpiring,
isPrivacyProSubscriptionExpired: isPrivacyProSubscriptionExpired,
isDuckPlayerOnboarded: isDuckPlayerOnboarded,
isDuckPlayerEnabled: isDuckPlayerEnabled,
dismissedMessageIds: dismissedMessageIds
)
}
Expand All @@ -152,10 +154,6 @@ public struct DesktopUserAttributeMatcher: AttributeMatching {
return matchingAttribute.evaluate(for: pinnedTabsCount)
case let matchingAttribute as CustomHomePageMatchingAttribute:
return matchingAttribute.evaluate(for: hasCustomHomePage)
case let matchingAttribute as DuckPlayerOnboardedMatchingAttribute:
return matchingAttribute.evaluate(for: isDuckPlayerOnboarded)
case let matchingAttribute as DuckPlayerEnabledMatchingAttribute:
return matchingAttribute.evaluate(for: isDuckPlayerEnabled)
case let matchingAttribute as InteractedWithDeprecatedMacRemoteMessageMatchingAttribute:
if dismissedDeprecatedMacRemoteMessageIds.contains(where: { messageId in
StringArrayMatchingAttribute(matchingAttribute.value).matches(value: messageId) == .match
Expand Down Expand Up @@ -193,6 +191,8 @@ public struct CommonUserAttributeMatcher: AttributeMatching {
private let isPrivacyProSubscriptionActive: Bool
private let isPrivacyProSubscriptionExpiring: Bool
private let isPrivacyProSubscriptionExpired: Bool
private let isDuckPlayerOnboarded: Bool
private let isDuckPlayerEnabled: Bool
private let dismissedMessageIds: [String]

public init(statisticsStore: StatisticsStore,
Expand All @@ -210,6 +210,8 @@ public struct CommonUserAttributeMatcher: AttributeMatching {
isPrivacyProSubscriptionActive: Bool,
isPrivacyProSubscriptionExpiring: Bool,
isPrivacyProSubscriptionExpired: Bool,
isDuckPlayerOnboarded: Bool,
isDuckPlayerEnabled: Bool,
dismissedMessageIds: [String]
) {
self.statisticsStore = statisticsStore
Expand All @@ -227,6 +229,8 @@ public struct CommonUserAttributeMatcher: AttributeMatching {
self.isPrivacyProSubscriptionActive = isPrivacyProSubscriptionActive
self.isPrivacyProSubscriptionExpiring = isPrivacyProSubscriptionExpiring
self.isPrivacyProSubscriptionExpired = isPrivacyProSubscriptionExpired
self.isDuckPlayerOnboarded = isDuckPlayerOnboarded
self.isDuckPlayerEnabled = isDuckPlayerEnabled
self.dismissedMessageIds = dismissedMessageIds
}

Expand Down Expand Up @@ -272,6 +276,10 @@ public struct CommonUserAttributeMatcher: AttributeMatching {
}

return .fail
case let matchingAttribute as DuckPlayerOnboardedMatchingAttribute:
return matchingAttribute.evaluate(for: isDuckPlayerOnboarded)
case let matchingAttribute as DuckPlayerEnabledMatchingAttribute:
return matchingAttribute.evaluate(for: isDuckPlayerEnabled)
case let matchingAttribute as InteractedWithMessageMatchingAttribute:
if dismissedMessageIds.contains(where: { messageId in
StringArrayMatchingAttribute(matchingAttribute.value).matches(value: messageId) == .match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ class CommonUserAttributeMatcherTests: XCTestCase {
isPrivacyProSubscriptionActive: true,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: dismissedMessageIds
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class MobileUserAttributeMatcherTests: XCTestCase {
isPrivacyProSubscriptionActive: true,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: dismissedMessageIds
)
}
Expand Down
16 changes: 16 additions & 0 deletions Tests/RemoteMessagingTests/RemoteMessagingConfigMatcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class RemoteMessagingConfigMatcherTests: XCTestCase {
isPrivacyProSubscriptionActive: false,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: []
),
percentileStore: MockRemoteMessagePercentileStore(),
Expand Down Expand Up @@ -149,6 +151,8 @@ class RemoteMessagingConfigMatcherTests: XCTestCase {
isPrivacyProSubscriptionActive: false,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: []
),
percentileStore: MockRemoteMessagePercentileStore(),
Expand Down Expand Up @@ -254,6 +258,8 @@ class RemoteMessagingConfigMatcherTests: XCTestCase {
isPrivacyProSubscriptionActive: false,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: []
),
percentileStore: MockRemoteMessagePercentileStore(),
Expand Down Expand Up @@ -302,6 +308,8 @@ class RemoteMessagingConfigMatcherTests: XCTestCase {
isPrivacyProSubscriptionActive: false,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: []
),
percentileStore: MockRemoteMessagePercentileStore(),
Expand Down Expand Up @@ -346,6 +354,8 @@ class RemoteMessagingConfigMatcherTests: XCTestCase {
isPrivacyProSubscriptionActive: false,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: []
),
percentileStore: percentileStore,
Expand Down Expand Up @@ -388,6 +398,8 @@ class RemoteMessagingConfigMatcherTests: XCTestCase {
isPrivacyProSubscriptionActive: false,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: []
),
percentileStore: percentileStore,
Expand Down Expand Up @@ -430,6 +442,8 @@ class RemoteMessagingConfigMatcherTests: XCTestCase {
isPrivacyProSubscriptionActive: false,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: []
),
percentileStore: percentileStore,
Expand Down Expand Up @@ -472,6 +486,8 @@ class RemoteMessagingConfigMatcherTests: XCTestCase {
isPrivacyProSubscriptionActive: false,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: []
),
percentileStore: percentileStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class RemoteMessagingConfigProcessorTests: XCTestCase {
isPrivacyProSubscriptionActive: false,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: []
),
percentileStore: MockRemoteMessagePercentileStore(),
Expand Down Expand Up @@ -85,6 +87,8 @@ class RemoteMessagingConfigProcessorTests: XCTestCase {
isPrivacyProSubscriptionActive: false,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: []
),
percentileStore: MockRemoteMessagePercentileStore(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class RemoteMessagingProcessingTests: XCTestCase {
isPrivacyProSubscriptionActive: false,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: []
),
percentileStore: MockRemoteMessagePercentileStore(),
Expand Down
2 changes: 2 additions & 0 deletions Tests/RemoteMessagingTests/RemoteMessagingStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ class RemoteMessagingStoreTests: XCTestCase {
isPrivacyProSubscriptionActive: false,
isPrivacyProSubscriptionExpiring: false,
isPrivacyProSubscriptionExpired: false,
isDuckPlayerOnboarded: false,
isDuckPlayerEnabled: false,
dismissedMessageIds: []
),
percentileStore: RemoteMessagingPercentileUserDefaultsStore(keyValueStore: self.defaults),
Expand Down
Loading