Skip to content

Commit

Permalink
Add ff interaction event
Browse files Browse the repository at this point in the history
  • Loading branch information
rlepinski committed Oct 13, 2023
1 parent 5e6cde8 commit 6996b0e
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 28 deletions.
2 changes: 1 addition & 1 deletion AirshipFrameworkProxy.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.swift_version = "5.0"
s.source_files = "ios/AirshipFrameworkProxy/**/*.{h,m,swift}"
s.dependency 'Airship', "17.3.1"
s.dependency 'Airship', "17.5.0"

end
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
package com.urbanairship.android.framework.proxy.proxies

import com.urbanairship.featureflag.FeatureFlag
import com.urbanairship.featureflag.FeatureFlagManager
import com.urbanairship.json.JsonSerializable
import com.urbanairship.json.JsonValue
import com.urbanairship.json.jsonMapOf

public class FeatureFlagManagerProxy internal constructor(private val featureFlagManagerProvider: () -> FeatureFlagManager) {
public suspend fun flag(name: String): JsonValue {
public suspend fun flag(name: String): FeatureFlagProxy {
val flag = featureFlagManagerProvider().flag(name).getOrThrow()
return jsonMapOf(
"isEligible" to flag.isEligible,
"exists" to flag.exists,
"variables" to flag.variables
).toJsonValue()
return FeatureFlagProxy(flag)
}

public fun trackInteraction(flag: FeatureFlagProxy) {
featureFlagManagerProvider().trackInteraction(flag.original)
}
}

public data class FeatureFlagProxy(
internal val original: FeatureFlag,
) : JsonSerializable {

public constructor(jsonValue: JsonValue): this(
FeatureFlag.fromJson(jsonValue)
)
override fun toJsonValue(): JsonValue = jsonMapOf(
"isEligible" to original.isEligible,
"exists" to original.exists,
"variables" to original.variables,
"_internal" to original
).toJsonValue()
}
2 changes: 1 addition & 1 deletion android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Airship
airshipProxy = '4.3.0'
airship = '17.2.1'
airship = '17.3.0'

# Gradle plugins
androidGradlePlugin = '7.3.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ public class AirshipFeatureFlagManagerProxy {

public func flag(name: String) async throws -> FeatureFlagProxy {
let flag = try await self.featureFlagManager.flag(name: name)
return FeatureFlagProxy(isEligible: flag.isEligible, exists: flag.exists, variables: flag.variables)

return FeatureFlagProxy(flag: flag)
}

public func trackInteraction(flag: FeatureFlagProxy) throws {
try self.featureFlagManager.trackInteraction(flag: flag.original)
}
}

Expand All @@ -27,6 +30,21 @@ public struct FeatureFlagProxy: Codable {
let isEligible: Bool
let exists: Bool
let variables: AirshipJSON?
let original: FeatureFlag

init(flag: FeatureFlag) {
self.isEligible = flag.isEligible
self.exists = flag.exists
self.variables = flag.variables
self.original = flag
}

enum CodingKeys: String, CodingKey {
case isEligible
case exists
case variables
case original = "_internal"
}
}


2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
target 'AirshipFrameworkProxy' do
pod 'Airship', '17.3.1'
pod 'Airship', '17.5.0'
end

target 'AirshipFrameworkProxyTests' do
Expand Down
34 changes: 17 additions & 17 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
PODS:
- Airship (17.3.1):
- Airship/Automation (= 17.3.1)
- Airship/Basement (= 17.3.1)
- Airship/Core (= 17.3.1)
- Airship/FeatureFlags (= 17.3.1)
- Airship/MessageCenter (= 17.3.1)
- Airship/PreferenceCenter (= 17.3.1)
- Airship/Automation (17.3.1):
- Airship (17.5.0):
- Airship/Automation (= 17.5.0)
- Airship/Basement (= 17.5.0)
- Airship/Core (= 17.5.0)
- Airship/FeatureFlags (= 17.5.0)
- Airship/MessageCenter (= 17.5.0)
- Airship/PreferenceCenter (= 17.5.0)
- Airship/Automation (17.5.0):
- Airship/Core
- Airship/Basement (17.3.1)
- Airship/Core (17.3.1):
- Airship/Basement (17.5.0)
- Airship/Core (17.5.0):
- Airship/Basement
- Airship/FeatureFlags (17.3.1):
- Airship/FeatureFlags (17.5.0):
- Airship/Core
- Airship/MessageCenter (17.3.1):
- Airship/MessageCenter (17.5.0):
- Airship/Core
- Airship/PreferenceCenter (17.3.1):
- Airship/PreferenceCenter (17.5.0):
- Airship/Core

DEPENDENCIES:
- Airship (= 17.3.1)
- Airship (= 17.5.0)

SPEC REPOS:
trunk:
- Airship

SPEC CHECKSUMS:
Airship: a8ec7140cca677696f10f605749c18248d818117
Airship: 9a0748772a8b31c7cf8d57062797dbe36f460fa4

PODFILE CHECKSUM: e424bf7ba9de09d671cb81ca366bcbd9c2aae18a
PODFILE CHECKSUM: dfd8441890bc60fc647a2df304c66aa69a1d33ed

COCOAPODS: 1.12.1
COCOAPODS: 1.11.3

0 comments on commit 6996b0e

Please sign in to comment.