From 097f9fd8414e16cb9447f7631c2f5d83c600ecf4 Mon Sep 17 00:00:00 2001 From: Ian Rumac Date: Mon, 14 Oct 2024 14:30:25 +0200 Subject: [PATCH 1/6] Update SDK and add backing for confirmAllAssigments --- CHANGELOG.md | 9 ++++++++ android/build.gradle | 2 +- .../SuperwallReactNativeModule.kt | 14 +++++++++++++ .../models/ConfirmedAssignments.kt | 13 ++++++++++++ .../models/SuperwallEvent.kt | 3 +++ .../models/SuperwallOptions.kt | 1 + example/ios/Podfile.lock | 4 ++-- ios/Json/ConfirmedAssignments+Json.swift | 21 +++++++++++++++++++ ios/SuperwallReactNative.mm | 5 +++++ ios/SuperwallReactNative.swift | 10 +++++++++ src/index.tsx | 11 +++++++++- src/public/ConfirmedAssigments.ts | 18 ++++++++++++++++ src/public/SuperwallOptions.ts | 2 ++ superwall-react-native.podspec | 2 +- 14 files changed, 110 insertions(+), 5 deletions(-) create mode 100644 android/src/main/java/com/superwallreactnative/models/ConfirmedAssignments.kt create mode 100644 ios/Json/ConfirmedAssignments+Json.swift create mode 100644 src/public/ConfirmedAssigments.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index e098d53..b42d297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ The changelog for `Superwall`. Also see the [releases](https://github.com/superwall/react-native-superwall/releases) on GitHub. +## 1.3.3 + +### Enhancements + +- Upgrades Android SDK to 1.3.0 [View Android SDK release notes](https://github.com/superwall-me/Superwall-Android/releases/tag/1.3.0) +- Upgrades iOS SDK to 3.10.1 [View iOS SDK release notes](https://github.com/superwall-me/Superwall-iOS/releases/tag/3.10.1) +- Adds `passIdentifiersToPlayStore` to `SuperwallOptions` which allows you to pass user identifiers to the Play Store purchases as account identifiers. This is useful for tracking user purchases in the Play Store console. +- Adds `confirmAllAssignments` method to `Superwall` which confirms assignments for all placements and returns an array of all confirmed experiment assignments. Note that the assignments may be different when a placement is registered due to changes in user, placement, or device parameters used in audience filters. + ## 1.3.2 ### Enhancements diff --git a/android/build.gradle b/android/build.gradle index 11e4ec2..46fdafd 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,6 +91,6 @@ dependencies { implementation "com.facebook.react:react-native:+" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation "com.superwall.sdk:superwall-android:1.2.9" + implementation "com.superwall.sdk:superwall-android:1.3.0" implementation 'com.android.billingclient:billing:6.1.0' } diff --git a/android/src/main/java/com/superwallreactnative/SuperwallReactNativeModule.kt b/android/src/main/java/com/superwallreactnative/SuperwallReactNativeModule.kt index 276f869..11c108d 100644 --- a/android/src/main/java/com/superwallreactnative/SuperwallReactNativeModule.kt +++ b/android/src/main/java/com/superwallreactnative/SuperwallReactNativeModule.kt @@ -237,4 +237,18 @@ class SuperwallReactNativeModule(private val reactContext: ReactApplicationConte promise.resolve(null) } } + + @ReactMethod + fun confirmAllAssignments(promise: Promise) { + CoroutineScope(Dispatchers.IO).launch { + val result = Superwall.instance.confirmAllAssignments() + val array = Arguments.createArray() + result.forEach { assignment -> + array.pushMap(assignment.toJson()) + } + launch(Dispatchers.Main) { + promise.resolve(array) + } + } + } } diff --git a/android/src/main/java/com/superwallreactnative/models/ConfirmedAssignments.kt b/android/src/main/java/com/superwallreactnative/models/ConfirmedAssignments.kt new file mode 100644 index 0000000..466600a --- /dev/null +++ b/android/src/main/java/com/superwallreactnative/models/ConfirmedAssignments.kt @@ -0,0 +1,13 @@ +package com.superwallreactnative.models +import com.facebook.react.bridge.Arguments +import com.facebook.react.bridge.ReadableMap + +import com.superwall.sdk.models.triggers.Experiment +import com.superwall.sdk.models.assignment.ConfirmedAssignment + +fun ConfirmedAssignment.toJson(): ReadableMap { + val assignmentMap = Arguments.createMap() + assignmentMap.putString("experimentId", this.experimentId) + assignmentMap.putString("variant", this.variant.type.toString()) + return assignmentMap +} diff --git a/android/src/main/java/com/superwallreactnative/models/SuperwallEvent.kt b/android/src/main/java/com/superwallreactnative/models/SuperwallEvent.kt index 745f520..3d8cdfc 100644 --- a/android/src/main/java/com/superwallreactnative/models/SuperwallEvent.kt +++ b/android/src/main/java/com/superwallreactnative/models/SuperwallEvent.kt @@ -196,6 +196,9 @@ class SuperwallEvent { is SuperwallEvent.ConfigFail -> { map.putString("event", "configFail") } + is SuperwallEvent.ConfirmAllAssignments -> { + map.putString("event", "confirmAllAssignments") + } } return map } diff --git a/android/src/main/java/com/superwallreactnative/models/SuperwallOptions.kt b/android/src/main/java/com/superwallreactnative/models/SuperwallOptions.kt index b8cb471..e9e97fc 100644 --- a/android/src/main/java/com/superwallreactnative/models/SuperwallOptions.kt +++ b/android/src/main/java/com/superwallreactnative/models/SuperwallOptions.kt @@ -14,6 +14,7 @@ class SuperwallOptions { options.localeIdentifier = json.getString("localeIdentifier") options.isExternalDataCollectionEnabled = json.getBoolean("isExternalDataCollectionEnabled") options.isGameControllerEnabled = json.getBoolean("isGameControllerEnabled") + options.passIdentifiersToPlayStore = json.getBoolean("passIdentifiersToPlayStore") val networkEnvironment = when (json.getString("networkEnvironment")) { "release" -> SuperwallOptions.NetworkEnvironment.Release() diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index d7013fe..5ea53c2 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1122,8 +1122,8 @@ PODS: - glog - RCT-Folly (= 2022.05.16.00) - React-Core - - SuperwallKit (= 3.10.0) - - SuperwallKit (3.10.0) + - SuperwallKit (= 3.10.1) + - SuperwallKit (3.10.1) - Yoga (1.14.0) DEPENDENCIES: diff --git a/ios/Json/ConfirmedAssignments+Json.swift b/ios/Json/ConfirmedAssignments+Json.swift new file mode 100644 index 0000000..d0769cd --- /dev/null +++ b/ios/Json/ConfirmedAssignments+Json.swift @@ -0,0 +1,21 @@ +import Foundation +import SuperwallKit + +extension ConfirmedAssignment { + func toJson() -> [String: Any] { + return [ + "experimentId": experimentId, + "variant": variant.type.rawValue + ] + } + + static func fromJson(_ json: [String: Any]) -> ConfirmedAssignment? { + guard let experimentId = json["experimentId"] as? Experiment.ID, + let variantTypeString = json["variant"] as? String, + let variantType = Experiment.Variant.VariantType(rawValue: variantTypeString) else { + return nil + } + let variant = Experiment.Variant(id: "", type: variantType, paywallId: nil) + return ConfirmedAssignment(experimentId: experimentId, variant: variant) + } +} \ No newline at end of file diff --git a/ios/SuperwallReactNative.mm b/ios/SuperwallReactNative.mm index 37f3581..ca40864 100644 --- a/ios/SuperwallReactNative.mm +++ b/ios/SuperwallReactNative.mm @@ -62,6 +62,11 @@ @interface RCT_EXTERN_MODULE(SuperwallReactNative, NSObject) withRejecter:(RCTPromiseRejectBlock)reject ) +RCT_EXTERN_METHOD( + confirmAllAssignments:(RCTPromiseResolveBlock)resolve + withRejecter:(RCTPromiseRejectBlock)reject +) + + (BOOL)requiresMainQueueSetup { return NO; diff --git a/ios/SuperwallReactNative.swift b/ios/SuperwallReactNative.swift index a4bdb66..e8bd7ba 100644 --- a/ios/SuperwallReactNative.swift +++ b/ios/SuperwallReactNative.swift @@ -214,4 +214,14 @@ class SuperwallReactNative: RCTEventEmitter { resolve(nil) } } + + @objc(confirmAllAssignments:withRejecter:) + func confirmAllAssignments( + resolve: @escaping RCTPromiseResolveBlock, + reject: @escaping RCTPromiseRejectBlock + ) { + Superwall.shared.confirmAllAssignments() { assignments in + resolve(assignments.map { $0.toJson() }) + } + } } diff --git a/src/index.tsx b/src/index.tsx index 7867223..cc69fbd 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -11,6 +11,7 @@ import { NativeEventEmitter } from 'react-native'; import { IdentityOptions } from './public/IdentityOptions'; import { EventEmitter } from 'events'; import { ConfigurationStatus } from './public/ConfigurationStatus'; +import { ConfirmedAssignment } from './public/ConfirmedAssigments'; const { version } = require('../package.json'); const LINKING_ERROR = @@ -319,9 +320,17 @@ export default class Superwall { ); } + async confirmAllAssignments(): Promise { + await this.awaitConfig(); + const assignments = await SuperwallReactNative.confirmAllAssignments(); + return assignments.map((assignment: any) => + ConfirmedAssignment.fromJson(assignment) + ); + } + async getConfigurationStatus(): Promise { const configurationStatusString = - await SuperwallReactNative.getConfigurationStatus(); + await SuperwallReactNative.confirmAllAssignments(); return ConfigurationStatus.fromString(configurationStatusString); } diff --git a/src/public/ConfirmedAssigments.ts b/src/public/ConfirmedAssigments.ts new file mode 100644 index 0000000..9d01e83 --- /dev/null +++ b/src/public/ConfirmedAssigments.ts @@ -0,0 +1,18 @@ +import { VariantType } from './Experiment'; + +export class ConfirmedAssignment { + experimentId: String; + variant: VariantType; + + constructor(experimentId: String, variant: VariantType) { + this.experimentId = experimentId; + this.variant = variant; + } + + static fromJson(json: any): ConfirmedAssignment { + return new ConfirmedAssignment( + json.experimentId, + VariantType[json.variant as keyof typeof VariantType] + ); + } +} diff --git a/src/public/SuperwallOptions.ts b/src/public/SuperwallOptions.ts index df9fc98..4bf637d 100644 --- a/src/public/SuperwallOptions.ts +++ b/src/public/SuperwallOptions.ts @@ -28,6 +28,7 @@ export class SuperwallOptions { isGameControllerEnabled: boolean = false; logging: LoggingOptions = new LoggingOptions(); collectAdServicesAttribution: boolean = false; + passIdentifiersToPlayStore: boolean = false; // Optionally, add a constructor for customization or methods for manipulation constructor(init?: Partial) { @@ -47,6 +48,7 @@ export class SuperwallOptions { isGameControllerEnabled: this.isGameControllerEnabled, logging: this.logging.toJson(), collectAdServicesAttribution: this.collectAdServicesAttribution, + passIdentifiersToPlayStore: this.passIdentifiersToPlayStore, }; } } diff --git a/superwall-react-native.podspec b/superwall-react-native.podspec index d0ac6fa..ad7d306 100644 --- a/superwall-react-native.podspec +++ b/superwall-react-native.podspec @@ -15,7 +15,7 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/superwall-me/Superwall-React-Native.git", :tag => "#{s.version}" } s.source_files = "ios/**/*.{h,m,mm,swift}" - s.dependency "SuperwallKit", '3.10.0' + s.dependency "SuperwallKit", '3.10.1' # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0. # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79. From 512eef97e5add9cb23b7a451d2e19da4a1b97cac Mon Sep 17 00:00:00 2001 From: Ian Rumac Date: Mon, 14 Oct 2024 14:47:49 +0200 Subject: [PATCH 2/6] Fix configuration status replacement --- src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index cc69fbd..88597dc 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -330,7 +330,7 @@ export default class Superwall { async getConfigurationStatus(): Promise { const configurationStatusString = - await SuperwallReactNative.confirmAllAssignments(); + await SuperwallReactNative.getConfigurationStatus(); return ConfigurationStatus.fromString(configurationStatusString); } From aba22499835405a1084c08260a252285b0a72c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20To=CC=88r?= <3296904+yusuftor@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:23:24 +0200 Subject: [PATCH 3/6] Fixes for confirmAllAssignments and experiment in PaywallInfo --- CHANGELOG.md | 4 ++ example/ios/Podfile.lock | 4 +- ios/Json/ConfirmedAssignments+Json.swift | 24 ++++------- ios/Json/Experiment+Json.swift | 8 +--- ios/Json/PaywallInfo+Json.swift | 2 +- ios/Json/Variant+Json.swift | 22 ++++++++++ ios/SuperwallReactNative.swift | 52 +++++++++++++----------- src/public/ConfirmedAssigments.ts | 6 +-- 8 files changed, 68 insertions(+), 54 deletions(-) create mode 100644 ios/Json/Variant+Json.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index b42d297..a0f5b25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ The changelog for `Superwall`. Also see the [releases](https://github.com/superw - Adds `passIdentifiersToPlayStore` to `SuperwallOptions` which allows you to pass user identifiers to the Play Store purchases as account identifiers. This is useful for tracking user purchases in the Play Store console. - Adds `confirmAllAssignments` method to `Superwall` which confirms assignments for all placements and returns an array of all confirmed experiment assignments. Note that the assignments may be different when a placement is registered due to changes in user, placement, or device parameters used in audience filters. +### Fixes + +- Fixes issue with the `Experiment` inside `PaywallInfo` being `null` in the `handleSuperwallEvent` delegate. + ## 1.3.2 ### Enhancements diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 5ea53c2..b00ade8 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1389,8 +1389,8 @@ SPEC CHECKSUMS: RevenueCat: 7be0d7bde9efb2fc1ebd1888522c55bb4f9feb18 RNPurchases: 06957eb2f35bd7bb336d32fccf3534d45a3fda8a SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 - superwall-react-native: 056b4dde47a30405c1c688bee51aa374a21ca552 - SuperwallKit: e2d162d30c5e0a464f111b32950d54dc827a9d1b + superwall-react-native: 9092fa4e0d385c480e835a032132b46a3c13b2bc + SuperwallKit: 89cfaba57c139f97a578efc6bbb1f3963d2aa6b2 Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 PODFILE CHECKSUM: 76fced934770e056b70a3087a2bc377b3556bae1 diff --git a/ios/Json/ConfirmedAssignments+Json.swift b/ios/Json/ConfirmedAssignments+Json.swift index d0769cd..df80dce 100644 --- a/ios/Json/ConfirmedAssignments+Json.swift +++ b/ios/Json/ConfirmedAssignments+Json.swift @@ -2,20 +2,10 @@ import Foundation import SuperwallKit extension ConfirmedAssignment { - func toJson() -> [String: Any] { - return [ - "experimentId": experimentId, - "variant": variant.type.rawValue - ] - } - - static func fromJson(_ json: [String: Any]) -> ConfirmedAssignment? { - guard let experimentId = json["experimentId"] as? Experiment.ID, - let variantTypeString = json["variant"] as? String, - let variantType = Experiment.Variant.VariantType(rawValue: variantTypeString) else { - return nil - } - let variant = Experiment.Variant(id: "", type: variantType, paywallId: nil) - return ConfirmedAssignment(experimentId: experimentId, variant: variant) - } -} \ No newline at end of file + func toJson() -> [String: Any] { + return [ + "experimentId": experimentId, + "variant": variant.toJson(), + ] + } +} diff --git a/ios/Json/Experiment+Json.swift b/ios/Json/Experiment+Json.swift index cd3a0b5..61f6dc1 100644 --- a/ios/Json/Experiment+Json.swift +++ b/ios/Json/Experiment+Json.swift @@ -2,16 +2,10 @@ import SuperwallKit extension Experiment { func toJson() -> [String: Any] { - var variant: [String: Any] = [ - "id": variant.id, - "type": variant.type.rawValue, - "paywallId": variant.paywallId - ] - return [ "id": id, "groupId": groupId, - "variant": variant + "variant": variant.toJson() ] } } diff --git a/ios/Json/PaywallInfo+Json.swift b/ios/Json/PaywallInfo+Json.swift index 5463649..5ea3f59 100644 --- a/ios/Json/PaywallInfo+Json.swift +++ b/ios/Json/PaywallInfo+Json.swift @@ -15,7 +15,7 @@ extension PaywallInfo { map["name"] = self.name map["url"] = self.url.absoluteString if let experiment = self.experiment { - map["experiment"] = Experiment.toJson(experiment) + map["experiment"] = experiment.toJson() } map["triggerSessionId"] = triggerSessionId diff --git a/ios/Json/Variant+Json.swift b/ios/Json/Variant+Json.swift new file mode 100644 index 0000000..bc7d179 --- /dev/null +++ b/ios/Json/Variant+Json.swift @@ -0,0 +1,22 @@ +import SuperwallKit + +extension Experiment.Variant { + func toJson() -> [String: Any] { + return [ + "id": self.id, + "type": self.type.toJson(), + "paywallId": self.paywallId, + ] + } +} + +extension Experiment.Variant.VariantType { + func toJson() -> String { + switch self { + case .treatment: + return "TREATMENT" + case .holdout: + return "HOLDOUT" + } + } +} diff --git a/ios/SuperwallReactNative.swift b/ios/SuperwallReactNative.swift index e8bd7ba..ca8071e 100644 --- a/ios/SuperwallReactNative.swift +++ b/ios/SuperwallReactNative.swift @@ -26,7 +26,7 @@ class SuperwallReactNative: RCTEventEmitter { "didDismissPaywall", "didPresentPaywall", "paywallWillOpenDeepLink", - "handleLog" + "handleLog", ] } @@ -87,38 +87,42 @@ class SuperwallReactNative: RCTEventEmitter { handler = PaywallPresentationHandler() handler?.onPresent { [weak self] paywallInfo in - let data = [ - "paywallInfoJson": paywallInfo.toJson(), - "method": "onPresent", - "handlerId": handlerId - ] as [String : Any] + let data = + [ + "paywallInfoJson": paywallInfo.toJson(), + "method": "onPresent", + "handlerId": handlerId, + ] as [String: Any] self?.sendEvent(withName: "paywallPresentationHandler", body: data) } handler?.onDismiss { [weak self] paywallInfo in - let data = [ - "paywallInfoJson": paywallInfo.toJson(), - "method": "onDismiss", - "handlerId": handlerId - ] as [String : Any] + let data = + [ + "paywallInfoJson": paywallInfo.toJson(), + "method": "onDismiss", + "handlerId": handlerId, + ] as [String: Any] self?.sendEvent(withName: "paywallPresentationHandler", body: data) } handler?.onError { [weak self] error in - let data = [ - "method": "onError", - "errorString": error.localizedDescription, - "handlerId": handlerId - ] as [String : Any] + let data = + [ + "method": "onError", + "errorString": error.localizedDescription, + "handlerId": handlerId, + ] as [String: Any] self?.sendEvent(withName: "paywallPresentationHandler", body: data) } handler?.onSkip { [weak self] reason in - let data = [ - "method": "onSkip", - "skippedReason": reason.toJson(), - "handlerId": handlerId - ] as [String : Any] + let data = + [ + "method": "onSkip", + "skippedReason": reason.toJson(), + "handlerId": handlerId, + ] as [String: Any] self?.sendEvent(withName: "paywallPresentationHandler", body: data) } } @@ -220,8 +224,8 @@ class SuperwallReactNative: RCTEventEmitter { resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock ) { - Superwall.shared.confirmAllAssignments() { assignments in - resolve(assignments.map { $0.toJson() }) - } + Superwall.shared.confirmAllAssignments { assignments in + resolve(assignments.map { $0.toJson() }) + } } } diff --git a/src/public/ConfirmedAssigments.ts b/src/public/ConfirmedAssigments.ts index 9d01e83..1af5430 100644 --- a/src/public/ConfirmedAssigments.ts +++ b/src/public/ConfirmedAssigments.ts @@ -1,8 +1,8 @@ -import { VariantType } from './Experiment'; +import { Variant } from './Experiment'; export class ConfirmedAssignment { experimentId: String; - variant: VariantType; + variant: Variant; constructor(experimentId: String, variant: VariantType) { this.experimentId = experimentId; @@ -12,7 +12,7 @@ export class ConfirmedAssignment { static fromJson(json: any): ConfirmedAssignment { return new ConfirmedAssignment( json.experimentId, - VariantType[json.variant as keyof typeof VariantType] + Variant.fromJson(json.variant) ); } } From af5b862c4b08c8dce67c49863043dad9767b414e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20To=CC=88r?= <3296904+yusuftor@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:27:17 +0200 Subject: [PATCH 4/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0f5b25..4f90820 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ The changelog for `Superwall`. Also see the [releases](https://github.com/superw ### Fixes -- Fixes issue with the `Experiment` inside `PaywallInfo` being `null` in the `handleSuperwallEvent` delegate. +- Fixes issue with the `Experiment` inside `PaywallInfo` being `null` in the `handleSuperwallEvent` delegate for iOS. ## 1.3.2 From 6824646da060ae3260fd65fe7a5d865470d97af9 Mon Sep 17 00:00:00 2001 From: Ian Rumac Date: Mon, 14 Oct 2024 19:41:56 +0200 Subject: [PATCH 5/6] Fix variant as undefined --- .../models/ConfirmedAssignments.kt | 3 ++- .../com/superwallreactnative/models/Experiment.kt | 5 +---- .../com/superwallreactnative/models/Variant.kt | 15 +++++++++++++++ src/public/ConfirmedAssigments.ts | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 android/src/main/java/com/superwallreactnative/models/Variant.kt diff --git a/android/src/main/java/com/superwallreactnative/models/ConfirmedAssignments.kt b/android/src/main/java/com/superwallreactnative/models/ConfirmedAssignments.kt index 466600a..986df04 100644 --- a/android/src/main/java/com/superwallreactnative/models/ConfirmedAssignments.kt +++ b/android/src/main/java/com/superwallreactnative/models/ConfirmedAssignments.kt @@ -1,4 +1,5 @@ package com.superwallreactnative.models + import com.facebook.react.bridge.Arguments import com.facebook.react.bridge.ReadableMap @@ -8,6 +9,6 @@ import com.superwall.sdk.models.assignment.ConfirmedAssignment fun ConfirmedAssignment.toJson(): ReadableMap { val assignmentMap = Arguments.createMap() assignmentMap.putString("experimentId", this.experimentId) - assignmentMap.putString("variant", this.variant.type.toString()) + assignmentMap.putMap("variant", this.variant.toJson()) return assignmentMap } diff --git a/android/src/main/java/com/superwallreactnative/models/Experiment.kt b/android/src/main/java/com/superwallreactnative/models/Experiment.kt index 7c660c5..57bce3a 100644 --- a/android/src/main/java/com/superwallreactnative/models/Experiment.kt +++ b/android/src/main/java/com/superwallreactnative/models/Experiment.kt @@ -8,10 +8,7 @@ import com.superwall.sdk.paywall.presentation.internal.state.PaywallSkippedReaso class Experiment { companion object { fun toJson(experiment: Experiment): ReadableMap { - val variantMap = Arguments.createMap() - variantMap.putString("id",experiment.variant.id) - variantMap.putString("type", experiment.variant.type.toString()) - variantMap.putString("paywallId", experiment.variant.paywallId) + val variantMap = experiment.variant.toJson() val experimentMap = Arguments.createMap() experimentMap.putString("id", experiment.id) diff --git a/android/src/main/java/com/superwallreactnative/models/Variant.kt b/android/src/main/java/com/superwallreactnative/models/Variant.kt new file mode 100644 index 0000000..ddb96f5 --- /dev/null +++ b/android/src/main/java/com/superwallreactnative/models/Variant.kt @@ -0,0 +1,15 @@ +package com.superwallreactnative.models + +import com.facebook.react.bridge.Arguments +import com.facebook.react.bridge.ReadableMap +import com.superwall.sdk.models.triggers.Experiment + + +fun Experiment.Variant.toJson(): ReadableMap { + val variantMap = Arguments.createMap() + variantMap.putString("id", this.id) + variantMap.putString("type", this.type.toString()) + variantMap.putString("paywallId", this.paywallId) + + return variantMap +} diff --git a/src/public/ConfirmedAssigments.ts b/src/public/ConfirmedAssigments.ts index 1af5430..65650e7 100644 --- a/src/public/ConfirmedAssigments.ts +++ b/src/public/ConfirmedAssigments.ts @@ -4,7 +4,7 @@ export class ConfirmedAssignment { experimentId: String; variant: Variant; - constructor(experimentId: String, variant: VariantType) { + constructor(experimentId: String, variant: Variant) { this.experimentId = experimentId; this.variant = variant; } From 6beec4d1a74d820179352bd89adc6afd6cfb240c Mon Sep 17 00:00:00 2001 From: Ian Rumac Date: Mon, 14 Oct 2024 19:42:41 +0200 Subject: [PATCH 6/6] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 087b776..6743ea9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@superwall/react-native-superwall", - "version": "1.3.2", + "version": "1.3.3", "description": "The React Native package for Superwall", "main": "lib/commonjs/index", "module": "lib/module/index",