SDK customization involves tailoring a Software Development Kit (SDK) to meet the unique needs of your application or development environment. An SDK typically includes tools, libraries, documentation, and code samples to assist developers in building applications.
When you initialize the PageSense SDK with default settings, it will create a PageSenseClient instance with the following configuration.
These defaults are ideal for quick integration and are suitable for most standard use cases.
Polling Interval:
The addPollingInterval function allows you to set the polling interval for the PageSense SDK polling service.
By default, the polling interval is assigned a value of 10 seconds. User can change the polling interval by invoking the function addPollingInterval as described below:
Example code:
- PageSenseClient pageSenseClient = PageSenseClientBuilder.getBuilder(projectSettings).addPollingInterval(60000).buildClient();
Parameter details:
Parameter | Type | Description |
addPollingInterval | Integer | Sets the polling interval for the SDK polling service |
The API accepts the time in milliseconds to set the polling interval. In the above example, the polling interval is set as 60000 milliseconds, which is equal to 60 seconds.
1. Choose a polling interval based on your application’s update frequency, expected traffic volume, and server performance capabilities.
2. Short intervals (<10 seconds) can lead to:
a. Increased server load.
b. Higher network traffic.
c. Potential race conditions if updates are frequent.
3. Long intervals (>5 minutes) may:
a. Cause delay in the propagation of latest project setting changes from PageSense.
b. Cause users to be served A/B Test experiment with outdated project configurations.
logLevel of SDK logger:
The addlogLevel function allows you to configure the log level for the built-in logger of the PageSense SDK. This setting helps control the verbosity of logs written by the PageSenseClient, enabling you to manage log storage effectively based on your file system capacity.
By specifying a log level, you define the minimum severity of log messages that will be recorded. Log levels must be provided as a String and can be set to one of the following values (case-insensitive): TRACE, DEBUG, INFO, WARNING, ERROR, or SEVERE.
Example code:
- PageSenseClient pageSenseClient = PageSenseClientBuilder.getBuilder(projectSettings).addlogLevel(“DEBUG”).buildClient();
Param | Type | Description |
logLevel | String | Specifies the minimum log severity to be recorded |
In the example above, the log level is set to DEBUG. As a result, all log messages with severity levels of DEBUG, INFO, WARNING, ERROR, and SEVERE will be captured and written to the customer's console.
Custom logger:
In addition to the built-in SDK logger, the PageSense SDK allows you to integrate your own custom logger to capture application events. This can be useful if you have an existing logging framework or need more control over how logs are handled.
The addCustomLogger function enables you to register a user-defined logger that will be used by the PageSense SDK to log all events. When a custom logger is provided, the PageSense SDK will route all log messages through your implementation instead of its own built-in logger.
Example code:
- PageSenseClient pageSenseClient = PageSenseClientBuilder.getBuilder(projectSettings).addCustomLogger(customLogger).buildClient();
Parameter details:
Param | Type | Description |
customLogger | Instance of PageSenseLogger | Specifies the minimum log severity to be recorded |
In the example above, customLogger is an instance of a class that implements the PageSenseLogger interface. Before passing it to addCustomLogger, you must implement this interface in your custom logger to handle the logging behaviour as needed.