Initialization of Java SDK

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 Setting details. The Project Setting details provide the information about the list of the FullStack experiments the PageSenseClient can execute and also explains how the experimentation should be carried out.

Initialization of PageSense JAVA SDK comprises of two steps:

2.1 Getting the Project Settings for PageSenseClient
2.2 Creating the PageSenseClient instance

2.1 Get the Project Settings for PageSenseClient:

ProjectSettings provides the details of list of the FullStack Experiments to be run by the PageSenseClient. and the current state of each of the experiments. Project Settings can be obtained from the PageSense server using the getProjectSettings API.

This API should be invoked by passing the following parameters:
NAME
TYPE
DESCRIPTION
accountId
String
A unique PageSense account ID for User.
sdkKey
String
Unique Key that corresponds to the SDK Environment.
You can get this key from the Environment Tab under the Project Settings in the FullStack page.
projectName
String
Name of the Project.

Get Project Setting Details

Add the following code to your application to get the Project Setting file for your PageSense account.

 

import com.zoho.pagesense.PageSenseClient;

import com.zoho.pagesense.PageSenseClientBuilder;

 

  // Get the Project Settings

  String projectSettings = PageSenseClientBuilder.getProjectSettings("accountId" “sdkKey”, “projectName”);

Info: This function will return the Project Settings if present in the Stringified JSON format. If there are no project settings available, this function will return null.

2.2  Creating the PageSenseClient instance

Once you receive the ProjectSettings, the next setup is to initialise the PageSenseClient with the Project Setting and create an instance of the PageSenseClient. You can initialise the PageSenseClient using the following code:

PageSenseClient pageSenseClient = PageSenseClientBuilder.getBuilder(projectSettings).buildClient();

If Project Settings have valid details, it will initialise the PageSenseClient with the details of the project and return the PageSenseClient instance. If the Project details are not valid or any error occurred while initialising the PageSenseClient, this API will return null.

Note: Please make sure you implement proper error handling measures when the PageSenseClient is initialized as null.

Example code:

  import com.zoho.pagesense.PageSenseClient;

  import com.zoho.pagesense.PageSenseClientBuilder;

  // Get the Project Settings

  String projectSettings = PageSenseClientBuilder.getProjectSettings("Zylker", "Nmvqoqp2Pr2gtKA", "Zylker Marketing");

  // Create the PageSense Client Instance

PageSenseClient pageSenseClient = PageSenseClientBuilder.getBuilder(projectSettings).buildClient();

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.