Overview
This release updates the PageSense React Native Bridge for Android and iOS with support for Revenue Goal tracking. The update introduces PageSenseUserContext and Goal Properties, providing a cleaner and more extensible API for passing user information and tracking goals with associated properties.
These additions are fully backward compatible. Existing integrations using the legacy SDK functions will continue to work without modification.
What's New
PageSenseUserContext
A new object that bundles userId and userAttributes into a single structured container. Instead of passing userId and userAttributes as separate arguments, the new SDK functions accept a single PageSenseUserContext instance.
Goal Properties
A new mechanism that enables tracking goals along with associated properties such as Revenue values. Goal properties are passed as a key-value object from JavaScript. The native bridge maps each string key to its corresponding native type before invoking the SDK.
Android — Goal properties are accepted by the SDK as a HashMap<GoalProperty, String>, where GoalProperty is a constant defined in com.zoho.pagesense.android.abtesting.constants.
iOS — Goal properties are accepted by the SDK as [GoalProperty: String], where GoalProperty is an enum exposed by PageSenseFramework with lowercase raw values.
New SDK Functions
The following context-based functions have been added to the JavaScript wrapper (PageSenseSDKWrapper.js) and to both the Android and iOS native bridge modules:
Function | Description |
activateExperimentByContext(experimentName, userContext) | Activates a FullStack experiment using PageSenseUserContext and returns the variation assigned to the user. |
getVariationNameByContext(experimentName, userContext) | Retrieves the variation assigned to a user using PageSenseUserContext without activating the experiment. |
trackGoalByContext(goalName, userContext) | Tracks a goal using PageSenseUserContext without goal properties. Use this for FullStack Custom Event Goals. |
trackGoalByContext(goalName, userContext, goalProperties) | Tracks a goal using PageSenseUserContext with goal properties. Use this for Revenue Goals. |
Function Comparison
Purpose | Old SDK Function | New SDK Function |
Activate experiment | activateExperiment(experimentName, userId, userAttributes) | activateExperimentByContext(experimentName, userContext) |
Get variation name | getVariationName(experimentName, userId, userAttributes) | getVariationNameByContext(experimentName, userContext) |
Track goal (no properties) | trackGoal(experimentName, userId, goalName, userAttributes) | trackGoalByContext(goalName, userContext) |
Track goal (with properties) | Not supported | trackGoalByContext(goalName, userContext, goalProperties) |
Backward Compatibility
The new context-based functions are additions to the existing SDK functions, not replacements. Both the old SDK functions and the new SDK functions are supported. Existing integrations will continue to work without modification.
Android
Added PageSenseUserContext support in the Kotlin native module (PageSenseSDKModule.kt).
Added activateExperimentByContext, getVariationNameByContext, trackGoalByContext, and trackGoalWithPropertiesByContext to the Kotlin native module.
Added GoalProperty import from com.zoho.pagesense.android.abtesting.constants.
Added validateAndBuildUserContext and validateAndConvertGoalPropertiesNonEmpty private validation helpers.
No changes are required to PageSenseSDKPackage.kt or MainApplication.kt.
Required SDK Version Upgrade
- To use Revenue Goal tracking, the PageSense Android SDK dependency must be upgraded to version 1.1.3 or later in android/app/build.gradle.
- gradle
- dependencies {
- implementation("com.facebook.react:react-android")
- implementation("com.zoho.pagesense:pagesense:1.1.3")
- }
After updating, perform a Gradle sync in Android Studio and rebuild the application.
iOS
Added PageSenseUserContext support in the Swift native module (PageSenseSDKModule.swift).
Added activateExperimentByContext, getVariationNameByContext, trackGoalByContext, and trackGoalWithPropertiesByContext to the Swift native module.
Added corresponding RCT_EXTERN_METHOD declarations to the Objective-C bridge file (PageSenseSDKModule.m).
Added validateAndBuildUserContext and validateAndConvertGoalPropertiesNonEmpty private validation helpers.
Goal properties are mapped from JavaScript string keys to GoalProperty enum cases using GoalProperty(rawValue:).
JavaScript Wrapper
Added GoalProperty constants object exported from PageSenseSDKWrapper.js.
Added activateExperimentByContext, getVariationNameByContext, and trackGoalByContext wrapper functions.
Added _validateUserContext and _validateGoalPropertiesNonEmpty private validation helpers.
The GoalProperty.REVENUE constant holds the string value "revenue", which maps to the native GoalProperty.REVENUE constant on Android and the GoalProperty.revenue enum case on iOS.
GoalProperty Reference
JS Constant | String Value | Android Native Constant | iOS Native Enum Case | Purpose |
GoalProperty.REVENUE | "revenue" | GoalProperty.REVENUE | GoalProperty.revenue | Revenue amount in cents, used for Revenue Goals |
Notes
Revenue values must be passed as a string in cents. For example, $100.50 should be passed as "10050".
When goalProperties is provided to trackGoalByContext, it must be a non-empty object. For goals without properties, omit the argument entirely.
For all new integrations, use the context-based SDK functions (activateExperimentByContext, getVariationNameByContext, trackGoalByContext). These represent the recommended approach for all future implementations.
We’ve
designed this documentation to guide you every step of the way. If you
need further assistance or have any questions, don’t hesitate to contact
us at
support@zohopagesense.com - we’re always here to help!