@kameleoon/javascript-sdk
Version:
Kameleoon JavaScript SDK
37 lines (36 loc) • 2.15 kB
TypeScript
import { KameleoonCore } from '@kameleoon/javascript-sdk-core/browser';
import { SDKParameters } from './types';
/**
* @class
* KameleoonClient - a class for creating kameleoon client instance
* */
export declare class KameleoonClient extends KameleoonCore {
private domain?;
private internalVisitorCodeManager;
private externalVisitorCodeManager;
private customDataManager?;
constructor({ siteCode, configuration, externals, _internals, stubMode, }: SDKParameters);
/**
* @method getVisitorCode - obtains visitor code from the browser cookie, if the visitor code doesn't yet exist generates a random visitor code (or uses a provided default) and sets a new visitor code to cookie
* @param {string | undefined} defaultVisitorCode - visitor code to be used in case there is no visitor code in cookies *Note*: if not passed visitor code will be randomly generated
* @returns {string} result visitor code
* @throws `KameleoonError` with one of the following `type` s:
*
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
* - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty
*/
getVisitorCode(defaultVisitorCode?: string): string;
/**
* @method setLegalConsent - sets or updates the legal consent status for a visitor identified by their unique visitor code, affecting values in the response cookies based on the consent status
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
* @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the
* visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not
* provided legal consent.
* @returns {void}
* @throws `KameleoonError` with one of the following `type` s:
*
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
* - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty
*/
setLegalConsent(visitorCode: string, consent: boolean): void;
}