PageSense React Native — SDK Customisation

PageSense React Native — SDK Customisation

Overview  

The PageSense SDK provides configuration options that can be set during initialisation to control logging behaviour and how frequently the SDK fetches updated project settings. These options are configured in the native modules and apply to both Android and iOS.

Polling Interval  

The polling interval controls how frequently the SDK fetches updated project settings from the PageSense server. This determines how quickly experiment and goal configuration changes are reflected in the application without requiring a restart.

Default Behaviour

If no polling interval is set, the SDK uses its built-in default. Setting a custom interval overrides this default.

Configuration

The polling interval is set in minutes on the PageSenseSDKOptions object before the SDK is initialised.

Android (Kotlin)

kotlin
val pageSenseSDKOptions = PageSenseSDKOptions()
pageSenseSDKOptions.pollingInterval = 5 // Fetch updated settings every 5 minutes
iOS (Swift)
swift
let pageSenseSDKOptions = PageSenseSDKOptions()
pageSenseSDKOptions.pollingInterval = 5 // Fetch updated settings every 5 minutes

Notes

  • The polling interval value is in minutes.
  • Setting a lower interval means the SDK fetches updates more frequently, which keeps experiment configuration more current but increases network activity.
  • Setting a higher interval reduces network activity but means configuration changes take longer to reflect in the application.

Log Level  

The log level controls the verbosity of the PageSense SDK logs. Setting an appropriate log level helps with debugging during development and reduces noise in production.

Available Log Levels

Log Level
Description
TRACE
Most verbose. Logs all SDK activity including internal state transitions. Use only for deep debugging.
DEBUG
Logs detailed diagnostic information useful during development and integration. Recommended for development builds.
INFO
Logs general operational messages confirming the SDK is working as expected.
WARN
Logs potentially problematic situations that do not prevent the SDK from functioning.
ERROR
Logs error events that may cause the SDK to fail specific operations.
SEVERE
Logs only critical failures. Least verbose. Recommended for production builds.

Configuration

The log level is set on the PageSenseSDKOptions object before the SDK is initialised.

Android (Kotlin)

kotlin
val pageSenseSDKOptions = PageSenseSDKOptions()
pageSenseSDKOptions.logLevel = LogLevel.DEBUG

iOS (Swift)

swift
let pageSenseSDKOptions = PageSenseSDKOptions()
pageSenseSDKOptions.logLevel = .DEBUG

Notes

  • Use DEBUG during development to get detailed logs that help verify experiment activation, variation assignment, and goal tracking.
  • Use SEVERE or ERROR in production to minimise log output.
  • Log level does not affect SDK functionality — only what is written to the log output.

Applying SDK Options During Initialisation  

Both pollingInterval and logLevel are set on the PageSenseSDKOptions object, which is passed to the SDK initialisation call. The configuration applies for the lifetime of the PageSenseClient instance.

Android (Kotlin) 

  1. kotlin
  2. val pageSenseSDKOptions = PageSenseSDKOptions()
  3. pageSenseSDKOptions.logLevel = LogLevel.DEBUG
  4. pageSenseSDKOptions.pollingInterval = 5
  5. PageSenseClientBuilder.createNewPageSenseClient(
  6.     accountId,
  7.     sdkKey,
  8.     projectName,
  9.     pageSenseSDKOptions,
  10.     object : ProjectSettingsCallBack {
  11.         override fun onFailure(message: String?, code: Int?) {
  12.             println("SDK initialization failed: $message")
  13.             promise.resolve(false)
  14.         }
  15.         override fun onSuccess(data: PageSenseClient?) {
  16.             if (data != null) {
  17.                 client = data
  18.                 isInitialized = true
  19.                 println("SDK initialized successfully")
  20.                 promise.resolve(true)
  21.             } else {
  22.                 promise.resolve(false)
  23.             }
  24.         }
  25.     }
  26. )
iOS (Swift) 
  1. swift
  2. let pageSenseSDKOptions = PageSenseSDKOptions()
  3. pageSenseSDKOptions.logLevel = .DEBUG
  4. pageSenseSDKOptions.pollingInterval = 5
  5. PageSense.shared.createNewPageSenseClient(
  6.     sdkAccountIDForDC: accountId,
  7.     sdkKey: sdkKey,
  8.     projectname: projectName,
  9.     sdkOptions: pageSenseSDKOptions
  10. ) { pagesenseclient in
  11.     guard let client = pagesenseclient else {
  12.         print("PageSenseClient initialization failed")
  13.         resolve(false)
  14.         return
  15.     }
  16.     self.client = client
  17.     self.isInitialized = true
  18.     print("PageSenseClient initialized successfully")
  19.     resolve(true)
  20. }

Best Practices  

  • Set logLevel to DEBUG during development and integration to help diagnose issues with experiment activation, variation assignment, and goal tracking.
  • Set logLevel to SEVERE or ERROR before releasing to production to avoid excessive logging.
  • Set a polling interval that balances the freshness of experiment configuration against acceptable network activity for your application.
  • PageSenseSDKOptions must be configured before calling the initialisation function. Changes to the options after initialisation will have no effect.



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!