UNPKG

@kameleoon/javascript-sdk

Version:
48 lines (47 loc) 2.95 kB
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 initialize - an asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached * @returns {Promise<boolean>} Promise resolved into boolean field indicating success or fail * @throws `KameleoonError` with one of the following `type` s: * * - `KameleoonException.StorageWrite` Couldn't update storage data * - `KameleoonException.StorageRead` - Couldn't read storage data * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed */ initialize(): Promise<boolean>; /** * @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; }