PageSense SDK provides a flexible configuration model that allows developers to adapt its behavior to suit the needs of their application. While the SDK can be used with minimal setup using the default configuration, applications with stricter performance, logging, or storage requirements may benefit from customizing the components within the SDK.
When the PageSense SDK is initialized without any custom options, it automatically creates a PageSenseClient instance using a predefined set of configuration values designed for general use:
Polling interval: PageSense SDK periodically contacts the PageSense server to pull the latest project settings. By default, this interval is set to 10 seconds, ensuring that your application stays updated with the latest project configuration changes without requiring manual refresh.
Log level: SDK captures log messages that are at the INFO level and above. This includes key operational events, warnings, errors and high severity messages.
Logger: A built-in console logger is included by default, allowing the logs to appear directly in your application's output console.
These default parameters are intended to support quick onboarding and provide reliable behavior in typical development, testing and production setups.
Option | Purpose |
Polling Interval | Controls how frequently the SDK syncs with PageSense server. Adjusting this value allows the customers to optimize network usage or increase responsiveness to project setting updates. |
Custom Logging | Customers can supply a custom logger to capture the SDK logs in a preferred format or route them into centralized logging systems |
Custom User Storage | Allows the application to define how experiment variation assignments for the users are persisted. This is valuable when consistent user experience across sessions or devices is required. |
Log Level | Enables fine-grained control over which log messages are emitted. Applications can choose from standard levels such as TRACE, DEBUG, INFO, WARN, ERROR, and SEVERE to match their debugging or monitoring standards. |
PageSense SDK contains the method addPollingInterval that allows you to control how frequently the PageSense SDK checks the PageSense server for updates to the project settings. This polling mechanism ensures that the SDK stays synchronized with the latest changes made in the PageSense for the given project —such as experiment updates, traffic reallocation, variation and goal changes etc.
By default, the PageSense SDK polls the PageSense server every 10 seconds. For applications that require a different refresh rate, the interval can be customized by supplying a value in milliseconds to the addPollingInterval method.
Usage Example
In this example, the polling interval is set to 60,000 milliseconds (60 seconds), meaning the SDK will request the latest project settings from PageSense sever once every minute.Parameter | Type | Description |
pollingInterval | Integer | Defines how often the SDK polls the PageSense server, expressed in milliseconds. |
Selecting an appropriate polling interval depends on your application’s performance requirements, usage patterns, and sensitivity to project configuration delays.
Keep the following points in mind:
1. Very Short Intervals (less than 10 seconds)
Increase the number of requests made to the PageSense server.
Can lead to higher network overhead.
May cause unnecessary load if your project configuration changes infrequently.
2. Moderate Intervals (10–60 seconds)
Suitable for most real-time or near–real-time use cases.
Provide a balance between responsiveness and network efficiency.
3. Long Intervals (greater than 5 minutes)
Reduce network traffic but may delay updates from PageSense
Users might receive outdated experiment or targeting configurations until the next poll cycle which may affect the experiment results.
Choose a shorter interval when rapid propagation of project configuration changes is important.
Use longer intervals for high-traffic applications where minimizing network usage is a priority.
PageSenseSDK contains the method addLogLevel that allows you to define how much logging information the PageSense SDK should produce while your application is running. This is useful when you need greater visibility of the SDK internal processes or wish to limit log output in production environments.
By specifying a log level, you set the lowest severity of messages the SDK will output. All messages at that level and any levels with higher severity above it —will be recorded. This gives you fine-grained control over the verbosity of the SDK’s built-in logging system.
The log level must be passed as a String, and the SDK accepts the following values :TRACE, DEBUG, INFO, WARNING, ERROR, SEVERE
These levels correspond to common logging standards used across application frameworks.
Usage Example
In the above example, the log level is set to "WARNING". PageSense SDK will therefore output log messages classified as: WARNING, ERROR, and SEVERE.Param | Type | Description |
logLevel | String | Specifies the minimum log severity to be recorded |
PageSense SDK includes a built-in logger to log the diagnostic and operational messages to the console . However, many applications rely on their own centralized or framework-specific logging systems. To support these environments, PageSense SDK allows you to supply a custom logger implementation that replaces the default logging behavior.
By registering a custom logger, all the log output generated by the SDK—across all severity levels—is routed through your implementation. This allows you to apply your own logging policies, formatting rules, routing logic, and storage strategies.
A custom logger is particularly helpful when:
Your application already uses a structured or centralized logging framework.
You need to redirect logs to external monitoring tools.
You want to standardize log output across all the modules of your system.
To integrate a custom logger, you must provide an instance of a class that implements the PageSenseLogger interface. This interface defines the methods the SDK uses to display and store the log messages. Your implementation can internally use any logging library (e.g., Monolog, Log4j, Winston) or write logs to a location of your choice. Once your logger class is ready, you register it with the SDK using the addCustomLogger method available on the PageSenseClientBuilder.
Note: When both addLogLevel() and addCustomLogger() are used in the PageSense SDK initialization, the log-level configured in the custom logger’s own takes precedence over the log level supplied to the SDK. PageSense SDK will forward all log messages to the custom logger without applying its internal log-level filters.Usage Example
In the above example, customLogger is an application-defined object that implements the PageSenseLogger interface and contains your preferred logging logic.
Parameter | Type | Description |
customLogger | Instance of a class implementing PageSenseLogger
| A user-defined logger that determines how and where SDK log messages are recorded. |
User Storage Service (USS) allows the PageSense SDK to persist variation assignments for the users across multiple A/B test experiments within a project. By providing a custom storage mechanism, you can ensure that users consistently receive the same variation over time, even when project and experiment configurations change.
This capability is especially valuable for preserving consistency in the variation assignment and delivering a stable user experience when the project settings change. Common scenarios include:
Introducing new variations
Modifying traffic allocation for an experiment
Relocating traffic distribution between variations
Migrating project settings across environments
To enable USS, you provide your own implementation of the UserStorageService interface exposed by PageSense SDK. This interface defines how the PageSense SDK should:
Store a user’s assigned variation
Retrieve the stored variation during subsequent API requests
Your implementation may use any storage mechanism appropriate for your application such as :
Local files
Relational or NoSQL databases
In-memory caches such as Redis
Distributed session stores
Custom application-level persistence systems
Once implemented, the custom storage service is supplied to the PageSenseSDK through the addUserStorageService method on the PageSenseClientBuilder.
Param | Type | Description |
userStorageService | Instance of a class implementing UserStorageService | A custom implementation to manage persistent variation assignments for users for FullStack A/B Test Experiment |
For production environments, avoid setting very short polling intervals. High-frequency polling can generate unnecessary load on your infrastructure and the PageSense servers.Webhooks provide a more efficient mechanism for near real-time configuration updates and should be preferred where feasible.
Enable USS only when users have stable identifiers such as user IDs. This ensures consistent variation assignment across sessions.For anonymous or ephemeral traffic, USS generally offers limited benefit and may introduce avoidable overhead.
The sdkKey must remain strictly on the server. Do not expose it in:
Browser-side JavaScript
Public repositories
Mobile applications
Client-facing API responses
This prevents unauthorized access to project configurations.
Integrate the SDK with established PHP standards:
PSR-3 for logging
PSR-16 for caching (optional, if used with USS or other persistence layers)
Adhering to these standards ensures predictable behavior and easier integration with common PHP frameworks.
When both addLogLevel() and addCustomLogger() are supplied, the custom logger’s internal filtering logic takes precedence.The SDK forwards all log messages to your logger without applying additional filtering.
Use consistent, non-volatile identifiers (e.g., persistent user IDs) for variation evaluation. Avoid identifiers that frequently change, such as IP addresses or session IDs.
If webhooks are used:
Validate inbound requests
Restrict access to your webhook endpoint
Ensure the endpoint is reachable and resilient
This ensures reliable delivery of configuration updates.
Implementations of UserStorageService and PageSenseLogger should be efficient and non-blocking to avoid introducing latency into request handling.
Polling intervals that are too short (<10 seconds) can lead to:
Increased server load
Excessive network traffic
Unnecessary stress on PageSense endpoints
Use with caution in production.
Polling intervals longer than several minutes may result in:
Delayed propagation of experiment updates
Users receiving outdated variation logic until the next polling cycle
Adjust intervals thoughtfully based on your application’s needs.
When using USS, ensure your storage mechanism can:
Handle read/write failures
Recover from partial writes
Manage file system or database errors
This prevents inconsistent variation assignments.
Set the log level to DEBUG in non-production environments to inspect:
Variation assignment
Bucket distributions
Webhook and polling activity
SDK initialization details
Avoid enabling DEBUG logs in production except when diagnosing issues.
Recording variation assignments during rollout helps verify:
Hashing consistency
Correct traffic allocation
Environment-to-environment alignment (Dev → QA → Prod)
Simulate scenarios such as:
Experiment updates
New variations
Traffic reallocation
Experiment relaunches
Ensure stored variations continue to resolve correctly or are refreshed as intended.
Check:
Server reachability
Firewall rules
Web server logs
PageSense retry attempts (every 30 seconds, up to 15 minutes)
Webhook failures may prevent timely configuration updates.
Ensure that:
Polling thread is active
Polling interval is configured correctly
Network errors are handled gracefully
Polling should serve as a fallback when webhooks are not available.
Ensure that all configuration options (polling interval, log level, custom logger, USS) are applied to the builder before calling buildClient().
Confirm that the hosting environment supports:
File system permissions (if using file-based USS)
Sufficient memory limits
Required PHP extensions (e.g., cURL, JSON, OpenSSL)
Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.
If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.
You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.