node_modules/@analytics/core/lib/analytics.es.js
/**
 * Async reduce over matched plugin methods
 * Fires plugin functions
 */
Async reduce over matched plugin methods
Fires plugin functions
Async reduce over matched plugin methods Fires plugin functions
function _ref() {
  _ref = asyncToGenerator(
  regenerator.mark(function _callee(action, getPlugins, instance, store, eventsInfo) {
    var pluginObject, originalType, updatedType, state, activePlugins, allActivePluginKeys, allMatches, actionBefore, actionDuring, afterName, actionAfter;
    return regenerator.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            pluginObject = isFunction(getPlugins) ? getPlugins() : getPlugins;
            originalType = action.type;
            updatedType = originalType.replace(endsWithStartRegex, '');
            if (!(action._ && action._.called)) {
              _context.next = 5;
              break;
            }
            return _context.abrupt("return", action);
          case 5:
            state = instance.getState();
            activePlugins = fitlerDisabledPlugins(pluginObject, state.plugins, action.options);
            if (originalType === EVENTS.initializeStart && action.fromEnable) {
              activePlugins = Object.keys(state.plugins).filter(function (name) {
                var info = state.plugins[name];
                return action.plugins.includes(name) && !info.initialized;
              }).map(function (name) {
                return pluginObject[name];
              });
            } 
            allActivePluginKeys = activePlugins.map(function (p) {
              return p.name;
            }); 
            allMatches = getAllMatchingCalls(originalType, activePlugins, pluginObject); 
            _context.next = 12;
            return processEvent({
              action: action,
              data: {
                exact: allMatches.before,
                namespaced: allMatches.beforeNS
              },
              state: state,
              allPlugins: pluginObject,
              allMatches: allMatches,
              instance: instance,
              store: store,
              EVENTS: eventsInfo
            });
          case 12:
            actionBefore = _context.sent;
            if (!shouldAbortAll(actionBefore, allActivePluginKeys.length)) {
              _context.next = 15;
              break;
            }
            return _context.abrupt("return", actionBefore);
          case 15:
            if (!(originalType === updatedType)) {
              _context.next = 19;
              break;
            }
            actionDuring = actionBefore;
            _context.next = 22;
            break;
          case 19:
            _context.next = 21;
            return processEvent({
              action: objectSpread2(objectSpread2({}, actionBefore), {}, {
                type: updatedType
              }),
              data: {
                exact: allMatches.during,
                namespaced: allMatches.duringNS
              },
              state: state,
              allPlugins: pluginObject,
              allMatches: allMatches,
              instance: instance,
              store: store,
              EVENTS: eventsInfo
            });
          case 21:
            actionDuring = _context.sent;
          case 22:
            if (!originalType.match(endsWithStartRegex)) {
              _context.next = 28;
              break;
            }
            afterName = "".concat(updatedType, "End");
            _context.next = 26;
            return processEvent({
              action: objectSpread2(objectSpread2({}, actionDuring), {}, {
                type: afterName
              }),
              data: {
                exact: allMatches.after,
                namespaced: allMatches.afterNS
              },
              state: state,
              allPlugins: pluginObject,
              allMatches: allMatches,
              instance: instance,
              store: store,
              EVENTS: eventsInfo
            });
          case 26:
            actionAfter = _context.sent;
            if (actionAfter.meta && actionAfter.meta.hasCallback) {
              runCallback(actionAfter.meta.rid, {
                payload: actionAfter
              });
            }
          case 28:
            return _context.abrupt("return", actionBefore);
          case 29:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _ref.apply(this, arguments);
}
function _ref ( ) { _ref = asyncToGenerator ( regenerator . mark ( function _callee ( action , getPlugins , instance , store , eventsInfo ) { var pluginObject , originalType , updatedType , state , activePlugins , allActivePluginKeys , allMatches , actionBefore , actionDuring , afterName , actionAfter ; return regenerator . wrap ( function _callee$ ( _context ) { while ( 1 ) { switch ( _context . prev = _context . next ) { case 0 : pluginObject = isFunction ( getPlugins ) ? getPlugins ( ) : getPlugins ; originalType = action . type ; updatedType = originalType . replace ( endsWithStartRegex , '' ) ; if ( ! ( action . _ && action . _ . called ) ) { _context . next = 5 ; break ; } return _context . abrupt ( "return" , action ) ; case 5 : state = instance . getState ( ) ; activePlugins = fitlerDisabledPlugins ( pluginObject , state . plugins , action . options ) ; if ( originalType === EVENTS . initializeStart && action . fromEnable ) { activePlugins = Object . keys ( state . plugins ) . filter ( function ( name ) { var info = state . plugins [ name ] ; return action . plugins . includes ( name ) && ! info . initialized ; } ) . map ( function ( name ) { return pluginObject [ name ] ; } ) ; } allActivePluginKeys = activePlugins . map ( function ( p ) { return p . name ; } ) ; allMatches = getAllMatchingCalls ( originalType , activePlugins , pluginObject ) ; _context . next = 12 ; return processEvent ( { action : action , data : { exact : allMatches . before , namespaced : allMatches . beforeNS } , state : state , allPlugins : pluginObject , allMatches : allMatches , instance : instance , store : store , EVENTS : eventsInfo } ) ; case 12 : actionBefore = _context . sent ; if ( ! shouldAbortAll ( actionBefore , allActivePluginKeys . length ) ) { _context . next = 15 ; break ; } return _context . abrupt ( "return" , actionBefore ) ; case 15 : if ( ! ( originalType === updatedType ) ) { _context . next = 19 ; break ; } actionDuring = actionBefore ; _context . next = 22 ; break ; case 19 : _context . next = 21 ; return processEvent ( { action : objectSpread2 ( objectSpread2 ( { } , actionBefore ) , { } , { type : updatedType } ) , data : { exact : allMatches . during , namespaced : allMatches . duringNS } , state : state , allPlugins : pluginObject , allMatches : allMatches , instance : instance , store : store , EVENTS : eventsInfo } ) ; case 21 : actionDuring = _context . sent ; case 22 : if ( ! originalType . match ( endsWithStartRegex ) ) { _context . next = 28 ; break ; } afterName = "" . concat ( updatedType , "End" ) ; _context . next = 26 ; return processEvent ( { action : objectSpread2 ( objectSpread2 ( { } , actionDuring ) , { } , { type : afterName } ) , data : { exact : allMatches . after , namespaced : allMatches . afterNS } , state : state , allPlugins : pluginObject , allMatches : allMatches , instance : instance , store : store , EVENTS : eventsInfo } ) ; case 26 : actionAfter = _context . sent ; if ( actionAfter . meta && actionAfter . meta . hasCallback ) { runCallback ( actionAfter . meta . rid , { payload : actionAfter } ) ; } case 28 : return _context . abrupt ( "return" , actionBefore ) ; case 29 : case "end" : return _context . stop ( ) ; } } } , _callee ) ; } ) ) ; return _ref . apply ( this , arguments ) ; }
Async reduce over matched plugin methods
 Fires plugin functions
Async reduce over matched plugin methods Fires plugin functions
/*#__PURE__*/ /* If action already dispatched exit early. This makes it so plugin methods are not fired twice. */ /* Remove plugins that are disabled by options or by settings */ /* If analytics.plugin.enable calls do special behavior */ // Return list of all enabled plugins that have NOT been initialized yet // console.log(`engine activePlugins ${action.type}`, activePlugins) // console.log('allActivePluginKeys', allActivePluginKeys) // console.log('allMatches', allMatches) /* @TODO cache matches and purge on enable/disable/add plugin */ /**
             * Process all 'actionBefore' hooks
             * Example:
             *  This is processes 'pageStart' methods from plugins and update the event to send through the chain
             */ /* If type the same don't double process */ // console.log('____ actionAfter', actionAfter) /* Fire callback if supplied */ /*
              console.log('End of engine action has callback')
              console.log(actionAfter.meta)
              console.log('stack', stack)
              /** */ // @TODO figure out exact args calls and .on will get