'use strict' ; import { RNSnowplowTracker } from './native' ; import { initValidate , isValidGC } from './configurations' ; import { logMessages } from './constants' ; import * as tracker from './tracker' ; import * as subject from './subject' ; import type { InitTrackerConfiguration , SubjectConfiguration , SelfDescribing , EventContext , ScreenViewProps , StructuredProps , PageViewProps , TimingProps , ConsentGrantedProps , ConsentWithdrawnProps , EcommerceTransactionProps , GlobalContext , ScreenSize , } from './types' ; param initConfig { Object } returns function createTracker ( initConfig ) { return < Promise < void > > initValidate ( initConfig ) . then ( ( ) => < Promise < void > > RNSnowplowTracker . createTracker ( initConfig ) ) . catch ( ( error ) => { throw new Error ( `${ logMessages . createTracker } ${ error . message }.` ) ; } ) ; } param trackerNamespace { string } returns function removeTracker ( trackerNamespace ) { if ( typeof trackerNamespace !== 'string' ) { return Promise . reject ( new Error ( logMessages . removeTracker ) ) ; } return < Promise < boolean > > Promise . resolve ( RNSnowplowTracker . removeTracker ( { tracker : trackerNamespace } ) ) ; } returns function removeAllTrackers ( ) { return < Promise < boolean > > Promise . resolve ( RNSnowplowTracker . removeAllTrackers ( ) ) ; } param namespace { string } returns function trackSelfDescribingEvent ( namespace ) { return function ( argmap , contexts = [ ] ) : Promise < void > { return tracker . trackSelfDescribingEvent ( namespace , argmap , contexts ) ; } ; } param namespace { string } returns function trackScreenViewEvent ( namespace ) { return function ( argmap , contexts = [ ] ) : Promise < void > { return tracker . trackScreenViewEvent ( namespace , argmap , contexts ) ; } ; } param namespace { string } returns function trackStructuredEvent ( namespace ) { return function ( argmap , contexts = [ ] ) : Promise < void > { return tracker . trackStructuredEvent ( namespace , argmap , contexts ) ; } ; } param namespace { string } returns function trackPageViewEvent ( namespace ) { return function ( argmap , contexts = [ ] ) : Promise < void > { return tracker . trackPageViewEvent ( namespace , argmap , contexts ) ; } ; } param namespace { string } returns function trackTimingEvent ( namespace ) { return function ( argmap , contexts = [ ] ) : Promise < void > { return tracker . trackTimingEvent ( namespace , argmap , contexts ) ; } ; } param namespace { string } returns function trackConsentGrantedEvent ( namespace ) { return function ( argmap , contexts = [ ] ) : Promise < void > { return tracker . trackConsentGrantedEvent ( namespace , argmap , contexts ) ; } ; } param namespace { string } returns function trackConsentWithdrawnEvent ( namespace ) { return function ( argmap , contexts = [ ] ) : Promise < void > { return tracker . trackConsentWithdrawnEvent ( namespace , argmap , contexts ) ; } ; } param namespace { string } returns function trackEcommerceTransactionEvent ( namespace ) { return function ( argmap , contexts = [ ] ) : Promise < void > { return tracker . trackEcommerceTransactionEvent ( namespace , argmap , contexts ) ; } ; } param namespace { string } returns function removeGlobalContexts ( namespace ) { return function ( tag ) : Promise < void > { if ( typeof tag !== 'string' ) { return Promise . reject ( new Error ( `${ logMessages . removeGlobalContexts } ${ logMessages . gcTagType }` ) ) ; } return < Promise < void > > Promise . resolve ( RNSnowplowTracker . removeGlobalContexts ( { tracker : namespace , removeTag : tag } ) ) ; } ; } param namespace { string } returns function addGlobalContexts ( namespace ) { return function ( gc ) : Promise < void > { if ( ! isValidGC ( gc ) ) { return Promise . reject ( new Error ( `${ logMessages . addGlobalContexts } ${ logMessages . gcType }` ) ) ; } return < Promise < void > > Promise . resolve ( RNSnowplowTracker . addGlobalContexts ( { tracker : namespace , addGlobalContext : gc } ) ) ; } ; } param namespace { string } returns function setUserId ( namespace ) { return function ( newUid ) : Promise < void > { return subject . setUserId ( namespace , newUid ) ; } ; } param namespace { string } returns function setNetworkUserId ( namespace ) { return function ( newNuid ) : Promise < void > { return subject . setNetworkUserId ( namespace , newNuid ) ; } ; } param namespace { string } returns function setDomainUserId ( namespace ) { return function ( newDuid ) : Promise < void > { return subject . setDomainUserId ( namespace , newDuid ) ; } ; } param namespace { string } returns function setIpAddress ( namespace ) { return function ( newIp ) : Promise < void > { return subject . setIpAddress ( namespace , newIp ) ; } ; } param namespace { string } returns function setUseragent ( namespace ) { return function ( newUagent ) : Promise < void > { return subject . setUseragent ( namespace , newUagent ) ; } ; } param namespace { string } returns function setTimezone ( namespace ) { return function ( newTz ) : Promise < void > { return subject . setTimezone ( namespace , newTz ) ; } ; } param namespace { string } returns function setLanguage ( namespace ) { return function ( newLang ) : Promise < void > { return subject . setLanguage ( namespace , newLang ) ; } ; } param namespace { string } returns function setScreenResolution ( namespace ) { return function ( newRes ) : Promise < void > { return subject . setScreenResolution ( namespace , newRes ) ; } ; } param namespace { string } returns function setScreenViewport ( namespace ) { return function ( newView ) : Promise < void > { return subject . setScreenViewport ( namespace , newView ) ; } ; } param namespace { string } returns function setColorDepth ( namespace ) { return function ( newColorD ) : Promise < void > { return subject . setColorDepth ( namespace , newColorD ) ; } ; } param namespace { string } returns function setSubjectData ( namespace ) { return function ( config ) : Promise < void > { return subject . setSubjectData ( namespace , config ) ; } ; } param namespace { string } returns function getSessionUserId ( namespace ) { return function ( ) : Promise < string > { return < Promise < string > > Promise . resolve ( RNSnowplowTracker . getSessionUserId ( { tracker : namespace } ) ) ; } ; } param namespace { string } returns function getSessionId ( namespace ) { return function ( ) : Promise < string > { return < Promise < string > > Promise . resolve ( RNSnowplowTracker . getSessionId ( { tracker : namespace } ) ) ; } ; } param namespace { string } returns function getSessionIndex ( namespace ) { return function ( ) : Promise < number > { return < Promise < number > > Promise . resolve ( RNSnowplowTracker . getSessionIndex ( { tracker : namespace } ) ) ; } ; } param namespace { string } returns function getIsInBackground ( namespace ) { return function ( ) : Promise < boolean > { return < Promise < boolean > > Promise . resolve ( RNSnowplowTracker . getIsInBackground ( { tracker : namespace } ) ) ; } ; } param namespace { string } returns function getBackgroundIndex ( namespace ) { return function ( ) : Promise < number > { return < Promise < number > > Promise . resolve ( RNSnowplowTracker . getBackgroundIndex ( { tracker : namespace } ) ) ; } ; } param namespace { string } returns function getForegroundIndex ( namespace ) { return function ( ) : Promise < number > { return < Promise < number > > Promise . resolve ( RNSnowplowTracker . getForegroundIndex ( { tracker : namespace } ) ) ; } ; } export { createTracker , removeTracker , removeAllTrackers , trackSelfDescribingEvent , trackScreenViewEvent , trackStructuredEvent , trackPageViewEvent , trackTimingEvent , trackConsentGrantedEvent , trackConsentWithdrawnEvent , trackEcommerceTransactionEvent , removeGlobalContexts , addGlobalContexts , setUserId , setNetworkUserId , setDomainUserId , setIpAddress , setUseragent , setTimezone , setLanguage , setScreenResolution , setScreenViewport , setColorDepth , setSubjectData , getSessionUserId , getSessionId , getSessionIndex , getIsInBackground , getBackgroundIndex , getForegroundIndex , } ;