import { ContentsquareModule } from '../core/nativeModules'; /** * Re-enables the Contentsquare UX tracking SDK. */ export const resumeTracking = (): void => { ContentsquareModule.resumeTracking(); }; /** * Pauses the Contentsquare UX tracking SDK. * Once this is called the SDK will pause. */ export const pauseTracking = (): void => { ContentsquareModule.pauseTracking(); }; /** * Stops the Contentsquare UX tracking SDK. * Once this is called the SDK will completely stop. */ export const stop = (): void => { ContentsquareModule.stop(); }; /** * Sends a (key, value) pair, called DynamicVar, to Contentsquare tracking services. * * @param {string} key * @param {string | number} value * @param {(error: Error) => void} onError */ export const addDynamicVar = ( key: string, value: string | number, onError?: (error: Error) => void ): void => { if (typeof value === 'string') { ContentsquareModule.addDynamicStringVar(key, value); } else if (Number.isInteger(value) && value >= 0) { ContentsquareModule.addDynamicNumberVar(key, value); } else { const callbackError = new TypeError( 'The value of the DynamicVar should be either a string or an unsigned integer' ); if (typeof onError === 'function') { onError(callbackError); } else { console.log(callbackError.message); } } };