Initialization of C# SDK

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 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 C# SDK comprises of two steps:
  1. Getting the Project Settings for PageSenseClient
  2. Creating the PageSenseClient instance

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.

  1. using PageSenseSDK; 

  2. // Get the Project Settings
  3. 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.

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:

Method

  1. PageSenseClient pageSenseClient =
  2. 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. 
Notes
Please make sure you implement proper error handling measures when the PageSenseClient is initialized as null.

Usage Example

  1. using PageSenseSDK; 

  2. // Get the Project Settings
  3. string projectSettings = PageSenseClientBuilder.GetProjectSettings(accountId, sdkKey, projectName); 

  4. // Create the PageSense Client Instance
  5. 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.