@shopgate/pwa-tracking
Version:
Tracking library for the Shopgate Connect PWA.
7 lines • 1.07 kB
JavaScript
import{getCurrentRoute}from'@shopgate/engage/core/selectors';import{categoryIsReady$}from"../streams/category";import{searchIsReady$}from"../streams/search";import{productIsReady$}from"../streams/product";import{pagesAreReady$}from"../streams/pages";import{pageIsReady$}from"../streams/page";import{makeGetTrackingData}from"../selectors";import{track}from"../helpers";/**
* Calls the pageview core tracking function.
* @param {Object} input The input of the tracked stream.
*/var callPageViewTracker=function callPageViewTracker(_ref){var getState=_ref.getState;var state=getState();var getTrackingData=makeGetTrackingData();track('pageview',getTrackingData(state,getCurrentRoute(state)),state);};/**
* Pages tracking subscriptions.
* @param {Function} subscribe The subscribe function.
*/export default function pages(subscribe){subscribe(categoryIsReady$,callPageViewTracker);subscribe(searchIsReady$,callPageViewTracker);subscribe(productIsReady$,callPageViewTracker);subscribe(pagesAreReady$,callPageViewTracker);subscribe(pageIsReady$,callPageViewTracker);}