UNPKG

redux-gtm

Version:

Google Tag Manager integration for Redux and ngrx/store

1 lines 5.62 kB
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.ReduxGTM=n():e.ReduxGTM=n()}(this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n,t){e.exports=t(1)},function(e,n,t){"use strict";var r=t(2),o=t(7),i=t(8),u=t(9),c=t(10),a=t(11),s=t(12),f=t(13);e.exports={createMiddleware:r,createMetaReducer:o,Extensions:{logger:i,offlineWeb:u,offlineReactNative:c},EventHelpers:{createGAevent:a,createGApageview:s,createGAuserTiming:f}}},function(e,n,t){"use strict";var r=t(3),o=t(4),i=t(5),u=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(t){return function(u){return function(c){if(!e[c.type])return u(c);var a=i(window,n.customDataLayer);if(void 0===a)return u(c);var s=t.getState(),f=r(e[c.type],s,c);return o(f,a,s,n,c),u(c)}}}};e.exports=u},function(e,n){"use strict";function t(e,n,t){var r=function(e){return Array.isArray(e)?e:[e]};return r(e).map(function(e){var r=e.eventName,o=e.eventFields,i=e.eventSchema,u={event:r||t.type},c="function"==typeof o?o(n,t):{},a=Object.assign(u,c);if(void 0!==i){var s=function(e){return i[e](a[e])},f=Object.keys(i).every(s);return f?a:"Schema validation failure for "+a.event}return a}).filter(function(e){return"string"!=typeof e})}e.exports=t},function(e,n){"use strict";function t(e,n,t,r,o){var i=r.logger,u=r.offlineStorage,c=function(){void 0!==i&&"function"==typeof i.log&&i.log.apply(i,arguments)},a=function(e){return e.forEach(function(e){return n.push(e)}),e};if(void 0!==u){var s=u.isConnected(t);s?(a(e),c(e,o,t),u.purgeEvents().then(function(e){Array.isArray(e)&&e.length>0&&(a(e),c(e,null,null,!1,!0))})):u.saveEvents(e).then(function(e){c(e,o,t,!0,!1)})}else a(e),c(e,o,t)}e.exports=t},function(e,n,t){"use strict";function r(e,n){return void 0!==n&&"function"==typeof n.push?n:void 0!==e?e.dataLayer=e.dataLayer||[]:void console.warn(i)}var o=t(6),i=o.NO_WINDOW_WARNING;e.exports=r},function(e,n){"use strict";var t="There is no window object, please provide a custom data layer";e.exports={NO_WINDOW_WARNING:t}},function(e,n,t){"use strict";function r(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(t){return function(r,c){if(!e[c.type])return t(r,c);var a=i(window,n.customDataLayer);if(void 0===a)return t(r,c);var s=o(e[c.type],r,c);return u(s,a,r,n,c),t(r,c)}}}var o=t(3),i=t(5),u=t(4);e.exports=r},function(e,n){"use strict";function t(){function e(e){e.length>1?(console.group("%c Events:",r.label),e.forEach(function(e,n){console.log("%c ("+(n+1)+")",r.label,e)}),console.groupEnd("Events")):console.log("%c Event: ",r.label,e[0])}function n(e){console.log("%c Action: ",r.label,e)}function t(t,o,i,u,c){u?(console.group("%c ReduxGTM (saved offline)",r.title.danger),n(o),e(t),console.groupEnd()):c?(console.group("%c ReduxGTM (was offline)",r.title.warning),e(t),console.groupEnd()):(console.group("%c ReduxGTM",r.title.primary),n(o),e(t),console.groupEnd())}var r={title:{primary:"color: #1da1f2; font-weight: bold;",danger:"color: #D63230; font-weight: bold;",warning:"color: #F39237; font-weight: bold;"},label:"color: #93748A; font-weight: bold;"};return{log:t}}e.exports=t},function(e,n){"use strict";function t(e,n){return new Promise(function(t,r){var o=window.indexedDB.open(e,n);o.onsuccess=function(e){var n=e.target.result;t(n)},o.onupgradeneeded=function(e){var n=e.target.result;n.createObjectStore("EventsStore",{autoIncrement:!0})},o.onerror=r})}function r(e,n){return new Promise(function(t,r){var o=n.transaction(["EventsStore"],"readwrite"),i=o.objectStore("EventsStore"),u=i.add(e);u.onsuccess=function(){return t(e)},u.onerror=r})}function o(e){return new Promise(function(n,t){var r=e.transaction(["EventsStore"],"readwrite"),o=r.objectStore("EventsStore"),i=o.openCursor(),u=[];i.onsuccess=function(e){var t=e.target.result;t?(u=u.concat(t.value),o.delete(t.key),t.continue()):n(u)},i.onerror=t})}function i(e){return{saveEvents:function(e){return t(u,c).then(function(n){return r(e,n)})},purgeEvents:function(){return t(u,c).then(o)},isConnected:e}}var u="ReduxGTM",c=1;e.exports=i},function(e,n){"use strict";function t(e,n){var t=function(n){return e.getItem(r).then(JSON.parse).then(function(e){return e?e.concat(n):n}).then(JSON.stringify).then(e.setItem.bind(null,r)).then(function(){return n})},o=function(){return e.getItem(r,function(){return e.removeItem(r)}).then(JSON.parse)};return{isConnected:n,saveEvents:t,purgeEvents:o}}var r="EventsStore";e.exports=t},function(e,n){"use strict";function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n={event:"REDUX_GTM_GA_EVENT",hitType:"event",eventAction:"unknown action",eventCategory:"unknown category",eventLabel:"unknown label",eventValue:"unknown value"};return Object.assign(n,e)}e.exports=t},function(e,n){"use strict";function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"unknown page",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t={event:"REDUX_GTM_GA_EVENT",hitType:"pageview",page:e};return Object.assign(t,n)}e.exports=t},function(e,n){"use strict";function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n={event:"REDUX_GTM_GA_EVENT",hitType:"timing",timingCategory:"unknown category",timingLabel:"unknown label",timingVar:"unknown var",timingValue:"unknown value"};return Object.assign(n,e)}e.exports=t}])});