SDK Customization

SDK Customization

Overview:

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.
  1. Polling Interval: Set to 10 seconds (10,000 milliseconds). This means the SDK checks the PageSense server every 10 seconds for any updates to any project configuration.
  2. Log Level: Set to INFO. This captures all log messages at the levels SEVERE, ERROR, WARNING, and INFO.
  3. Logger: The SDK uses a built-in logger that outputs all logs to your application’s console. No additional setup is needed to start capturing logs.
These defaults are ideal for quick integration and are suitable for most standard use cases.

Customizable configuration:

To offer greater flexibility and customization, the PageSense SDK provides several optional configuration functions. These functions allow you to control various aspects of how the SDK operates. You can specify these options during SDK initialization to better align the SDK's behaviour with your application’s specific requirements and environment.

Function

Description

Polling Interval

Specifies how often the SDK should poll the PageSense server for project setting updates. This ensures that your SDK instance stays in sync with the latest project configurations defined in the PageSense application.

Logger

Allows integration of a custom logger to control where and how SDK logs are captured and stored. This is especially useful for aligning SDK logs with enterprise-wide logging frameworks.

User Storage Service

Enables the use of a custom user storage mechanism to persist variation assignments across different A/B Test experiments.

Log Level

Defines the minimum level of log messages to capture. Supported levels include: TRACE, DEBUG, INFO, WARN, ERROR, and SEVERE

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:

  1. 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:

  1. PageSenseClient pageSenseClient = PageSenseClientBuilder.getBuilder(projectSettings).addlogLevel(“DEBUG”).buildClient();

Parameter details:

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:

  1. 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.

Example code to implement the PageSenseLogger interface:

  1. import com.zoho.pagesense.logging.PageSenseLogger;
  2. import org.slf4j.Logger;
  3. import org.slf4j.LoggerFactory;

  4. /**
  5.  * SLF4J-based logger implementation that integrates with the PageSenseLogger system. Automatically
  6.  * detects the highest enabled log level from SLF4J and configures the PageSenseLogger.
  7.  */
  8. public class Slf4jLogger extends PageSenseLogger {

  9.  /**
  10.  * SLF4J logger instance used to delegate actual logging calls.It logs messages based on the enabled
  11.  * levels in the underlying SLF4J binding.
  12.  */
  13.  private final Logger logger;

  14.  /**
  15.  * Constructs a Slf4jLogger for the given class name.
  16.  * @param className the class for which logging is performed
  17.  */
  18.  public Slf4jLogger(String className) {
  19.  // Create SLF4J logger instance
  20.  Logger slf4jLogger = LoggerFactory.getLogger(className);
  21.  // Call superclass constructor with class name and max log level (as String)
  22.  super(className, determineMaxLogLevel(slf4jLogger));

  23. // Initialize the logger instance
  24.  this.logger = slf4jLogger;
  25.  }

  26.  /**
  27.  * Determines the highest SLF4J log level that is currently enabled
  28.  * and returns it as a String that matches the expected format in PageSenseLogger.
  29.  * @param logger SLF4J logger instance
  30.  * @return the name of the highest enabled log level
  31.  */
  32.  private static String determineMaxLogLevel(Logger logger) {
  33.         if (logger.isTraceEnabled()) return "TRACE";
  34.         if (logger.isDebugEnabled()) return "DEBUG";
  35.         if (logger.isInfoEnabled())  return "INFO";
  36.         if (logger.isWarnEnabled())  return "WARNING"; // SLF4J uses WARN, mapped to WARNING
  37.         if (logger.isErrorEnabled()) return "ERROR";
  38.         // No SLF4J method available for FATAL, so SEVERE is usually mapped from ERROR in SLF4J or from FATAL in other systems
  39.         
  40.         // Return INFO as the default if none are enabled
  41.         return "INFO";
  42.  }

  43.  /**
  44.  * Logs a TRACE level message.
  45.  * Typically used for detailed debugging information.
  46.  */
  47.  @Override
  48.  public void trace(String logMessage) {
  49.  if (logger.isTraceEnabled()) {
  50.  logger.trace(logMessage);
  51.  }
  52.  }

  53.  /**
  54.  * Logs a DEBUG level message.
  55.  * Used for general debugging information to help diagnose application flow.
  56.  */
  57.  @Override
  58.  public void debug(String logMessage) {
  59.  if (logger.isDebugEnabled()) {
  60.  logger.debug(logMessage);
  61.  }
  62.  }

  63.  /**
  64.  * Logs an INFO level message.
  65.  * Typically used for general runtime events.
  66.  */
  67.  @Override
  68.  public void info(String logMessage) {
  69.  if (logger.isInfoEnabled()) {
  70.  logger.info(logMessage);
  71.  }
  72.  }

  73.  /**
  74.  * Logs a WARNING level message.
  75.  * Indicates a potential problem or unexpected situation that is not an error.
  76.  */
  77.  @Override
  78.  public void warn(String logMessage) {
  79.  if (logger.isWarnEnabled()) {
  80.  logger.warn(logMessage);
  81.  }
  82.  }

  83.  /**
  84.  * Logs an ERROR level message.
  85.  * Used for error events that might still allow the application to continue running.
  86.  */
  87.  @Override
  88.  public void error(String logMessage) {
  89.  if (logger.isErrorEnabled()) {
  90.  logger.error(logMessage);
  91.  }
  92.  }

  93.  /**
  94.  * Logs a SEVERE level message.
  95.  * Treated as a critical error; mapped to SLF4J's ERROR level with a [SEVERE] prefix for clarity.
  96.  */
  97.  @Override
  98.  public void severe(String logMessage) {
  99.  if (logger.isErrorEnabled()) {
  100.  logger.error("[SEVERE] " + logMessage);
  101.  }
  102.  }
  103. }
If you have already defined a log level for SDK and if you also initialize SDK with a customLogger, the log level of the custom logger will take precedence over the log level of the PageSense SDK.

User Storage Service:

User Storage Service (USS) is an external storage mechanism that allows you to store variation assignments for users across different A/B test experiments persistently within a project. This feature is particularly useful when you want to ensure consistent variation allocation—that is, ensuring users continue to see the same variation even if the project configuration changes.

Such configuration changes might include:
  1. Adding new variations
  2. Adjusting experiment traffic allocation
  3. Adjusting traffic split between the variations

By using the User Storage Service, you can preserve the user experience and maintain the integrity of your A/B Test Experiment results over time. USS is optional - to enable it, implement the UserStorageService interface and pass an instance of your implementation to the PageSense SDK using the addUserStorageService function.

Example code:

  1. PageSenseClient pageSenseClient = PageSenseClientBuilder.getBuilder(projectSettings).addUserStorageService(userStorageService).buildClient();
In the above example, userStorageService is a user-defined instance of a class that implements the UserStorageService interface.

Parameter details:

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

Example code to implement the UserStorageService interface for the PageSense Java SDK.

  1. import java.util.Map;
  2. import java.util.concurrent.ConcurrentHashMap;
  3. public class IntegratedUserStorageService implements UserStorageService {
  4.  // Declare the Storage variable
  5.  private final Map<String, String> userProfileStorage = new ConcurrentHashMap<>();
  6.  @Override
  7.  public String lookUp(String userId) {
  8.  // Validate the userId
  9.  if (userId == null || userId.trim().isEmpty()) {
  10.  throw new IllegalArgumentException("User ID cannot be null or empty");
  11.  }
  12.  return userProfileStorage.get(userId);
  13.  }
  14.  @Override
  15.  public void save(IUserProfile userProfile) {

  16.  if (userProfile == null || userProfile.getUserId() == null || 
  17. userProfile.getUserId().trim().isEmpty()) {


  18.  throw new IllegalArgumentException("UserProfile or User ID cannot be null or empty");
  19.  }
  20.  try {
  21.  // Get the User Profile JSON String
  22.  String userProfileJSON = userProfile.getUserProfileJSONString();
  23.  // Save the User Profile JSON String
  24.  userProfileStorage.put(userProfileJSON.getUserId(), userProfileJSON);
  25.  } catch (Exception ex) {
  26.  throw new RuntimeException("Failed to store the User Profile: " + ex.getMessage(), ex);
  27.  }
  28.  }
  29. }

We hope this documentation helps make the process easy for you. Please feel free to reach out to us anytime by dropping an email to support@zohopagesense.com if you need more explanation or have any questions.

      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        Access your files securely from anywhere

          Zoho CRM Training Programs

          Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

          Zoho CRM Training
            Redefine the way you work
            with Zoho Workplace

              Zoho DataPrep Personalized Demo

              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.

              Zoho CRM Training

                Create, share, and deliver

                beautiful slides from anywhere.

                Get Started Now


                  Zoho Sign now offers specialized one-on-one training for both administrators and developers.

                  BOOK A SESSION







                              Quick LinksWorkflow AutomationData Collection
                              Web FormsRetailOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceForms for Solopreneurs
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit
                              Forms for Government
                              Intake FormsLegal
                              Mobile App
                              Form DesignerHR
                              Mobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic FormsInsurance
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsWufoo alternativeEncrypted Forms
                              Accessible FormsTypeform alternativeSecure Forms

                              WCAG

                                          Create. Review. Publish.

                                          Write, edit, collaborate on, and publish documents to different content management platforms.

                                          Get Started Now






                                                            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.




                                                                Manage your brands on social media

                                                                  Use cases

                                                                  Make the most of Zoho Desk with the use cases.

                                                                   
                                                                    

                                                                  eBooks

                                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                                   
                                                                    

                                                                  Videos

                                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                                   
                                                                    

                                                                  Webinar

                                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                                   
                                                                    
                                                                  • Desk Community Learning Series


                                                                  • Meetups


                                                                  • Ask the Experts


                                                                  • Kbase


                                                                  • Resources


                                                                  • Glossary


                                                                  • Desk Marketplace


                                                                  • MVP Corner



                                                                    Zoho Sheet Resources

                                                                     

                                                                        Zoho Forms Resources


                                                                          Secure your business
                                                                          communication with Zoho Mail


                                                                          Mail on the move with
                                                                          Zoho Mail mobile application

                                                                            Stay on top of your schedule
                                                                            at all times


                                                                            Carry your calendar with you
                                                                            Anytime, anywhere




                                                                                  Zoho Sign Resources

                                                                                    Sign, Paperless!

                                                                                    Sign and send business documents on the go!

                                                                                    Get Started Now




                                                                                            Zoho TeamInbox Resources





                                                                                                      Zoho DataPrep Demo

                                                                                                      Get a personalized demo or POC

                                                                                                      REGISTER NOW


                                                                                                        Design. Discuss. Deliver.

                                                                                                        Create visually engaging stories with Zoho Show.

                                                                                                        Get Started Now









                                                                                                                            • Related Articles

                                                                                                                            • SDK Customization

                                                                                                                              Overview 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 ...
                                                                                                                            • Installation of Java SDK

                                                                                                                              The PageSense JAVA SDK empowers developers to integrate, conduct A/B testing, and personalise user experiences within JAVA applications. PageSense JAVA SDK offers a simple and reliable way to integrate FullStack A/B Testing into your JAVA-based ...
                                                                                                                            • Initialization of C# SDK

                                                                                                                              PageSenseClient is the interface provided by the PageSense C# SDK library to run the FullStack A/B Test experiments for the users. To run the FullStack experiment for the user, the PageSenseClient should be first initialised with the Project Setting ...
                                                                                                                            • Initialization of Java SDK

                                                                                                                              PageSenseClient is the interface provided by the PageSense Java SDK library to run the FullStack A/B Test experiments for the users. To run the FullStack experiment for the user, the PageSenseClient should be first initialised with the Project ...
                                                                                                                            • Installation of C#.NET SDK

                                                                                                                              Overview: The PageSense C# SDK empowers developers to integrate, conduct A/B testing, and personalize user experiences within C#.NET applications. PageSense C# SDK offers a simple and reliable way to integrate FullStack A/B Testing into your ...
                                                                                                                              Wherever you are is as good as
                                                                                                                              your workplace

                                                                                                                                Resources

                                                                                                                                Videos

                                                                                                                                Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                                eBooks

                                                                                                                                Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                                Webinars

                                                                                                                                Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                                CRM Tips

                                                                                                                                Make the most of Zoho CRM with these useful tips.



                                                                                                                                  Zoho Show Resources