'use strict' ; import { RNSnowplowTracker } from './native' ; import { logMessages } from './constants' ; import { validateContexts , validateSelfDesc , validateScreenView , validateStructured , validatePageView , validateTiming , validateConsentGranted , validateConsentWithdrawn , validateEcommerceTransaction , } from './events' ; import type { SelfDescribing , EventContext , ScreenViewProps , StructuredProps , PageViewProps , TimingProps , ConsentGrantedProps , ConsentWithdrawnProps , EcommerceTransactionProps , } from './types' ; param namespace { string } param argmap { Object } param contexts { Array } returns { Promise } function trackSelfDescribingEvent ( namespace , argmap , contexts = [ ] ) { return < Promise < void > > validateSelfDesc ( argmap ) . then ( ( ) => validateContexts ( contexts ) ) . then ( ( ) => < Promise < void > > RNSnowplowTracker . trackSelfDescribingEvent ( { tracker : namespace , eventData : argmap , contexts : contexts } ) ) . catch ( ( error ) => { throw new Error ( `${ logMessages . trackSelfDesc } ${ error . message }` ) ; } ) ; } param namespace { string } param argmap { Object } param contexts { Array } returns { Promise } function trackScreenViewEvent ( namespace , argmap , contexts = [ ] ) { return < Promise < void > > validateScreenView ( argmap ) . then ( ( ) => validateContexts ( contexts ) ) . then ( ( ) => < Promise < void > > RNSnowplowTracker . trackScreenViewEvent ( { tracker : namespace , eventData : argmap , contexts : contexts } ) ) . catch ( ( error ) => { throw new Error ( `${ logMessages . trackScreenView } ${ error . message }` ) ; } ) ; } param namespace { string } param argmap { Object } param contexts { Array } returns { Promise } function trackStructuredEvent ( namespace , argmap , contexts = [ ] ) { return < Promise < void > > validateStructured ( argmap ) . then ( ( ) => validateContexts ( contexts ) ) . then ( ( ) => < Promise < void > > RNSnowplowTracker . trackStructuredEvent ( { tracker : namespace , eventData : argmap , contexts : contexts } ) ) . catch ( ( error ) => { throw new Error ( `${ logMessages . trackStructured } ${ error . message }` ) ; } ) ; } param namespace { string } param argmap { Object } param contexts { Array } returns { Promise } function trackPageViewEvent ( namespace , argmap , contexts = [ ] ) { return < Promise < void > > validatePageView ( argmap ) . then ( ( ) => validateContexts ( contexts ) ) . then ( ( ) => < Promise < void > > RNSnowplowTracker . trackPageViewEvent ( { tracker : namespace , eventData : argmap , contexts : contexts } ) ) . catch ( ( error ) => { throw new Error ( `${ logMessages . trackPageView } ${ error . message }` ) ; } ) ; } param namespace { string } param argmap { Object } param contexts { Array } returns { Promise } function trackTimingEvent ( namespace , argmap , contexts = [ ] ) { return < Promise < void > > validateTiming ( argmap ) . then ( ( ) => validateContexts ( contexts ) ) . then ( ( ) => < Promise < void > > RNSnowplowTracker . trackTimingEvent ( { tracker : namespace , eventData : argmap , contexts : contexts } ) ) . catch ( ( error ) => { throw new Error ( `${ logMessages . trackTiming } ${ error . message }` ) ; } ) ; } param namespace { string } param argmap { Object } param contexts { Array } returns { Promise } function trackConsentGrantedEvent ( namespace , argmap , contexts = [ ] ) { return < Promise < void > > validateConsentGranted ( argmap ) . then ( ( ) => validateContexts ( contexts ) ) . then ( ( ) => < Promise < void > > RNSnowplowTracker . trackConsentGrantedEvent ( { tracker : namespace , eventData : argmap , contexts : contexts } ) ) . catch ( ( error ) => { throw new Error ( `${ logMessages . trackConsentGranted } ${ error . message }` ) ; } ) ; } param namespace { string } param argmap { Object } param contexts { Array } returns { Promise } function trackConsentWithdrawnEvent ( namespace , argmap , contexts = [ ] ) { return < Promise < void > > validateConsentWithdrawn ( argmap ) . then ( ( ) => validateContexts ( contexts ) ) . then ( ( ) => < Promise < void > > RNSnowplowTracker . trackConsentWithdrawnEvent ( { tracker : namespace , eventData : argmap , contexts : contexts } ) ) . catch ( ( error ) => { throw new Error ( `${ logMessages . trackConsentWithdrawn } ${ error . message }` ) ; } ) ; } param namespace { string } param argmap { Object } param contexts { Array } returns { Promise } function trackEcommerceTransactionEvent ( namespace , argmap , contexts = [ ] ) { return < Promise < void > > validateEcommerceTransaction ( argmap ) . then ( ( ) => validateContexts ( contexts ) ) . then ( ( ) => < Promise < void > > RNSnowplowTracker . trackEcommerceTransactionEvent ( { tracker : namespace , eventData : argmap , contexts : contexts } ) ) . catch ( ( error ) => { throw new Error ( `${ logMessages . trackEcommerceTransaction } ${ error . message }` ) ; } ) ; } export { trackSelfDescribingEvent , trackScreenViewEvent , trackStructuredEvent , trackPageViewEvent , trackTimingEvent , trackConsentGrantedEvent , trackConsentWithdrawnEvent , trackEcommerceTransactionEvent , } ;