react-metrics-service
Advanced tools
Comparing version 0.0.10-beta to 0.0.11-beta
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.MetricsService=t(require("react")):e.MetricsService=t(e.react)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t.tealium=t.googleTagManager=t.googleAnalyticsLegacy=t.googleAnalytics=t.debugLog=t.metricsServiceClick=t.withMetricsServiceClient=t.withMetricsServiceContext=t.MetricsServiceContext=t.Client=t.createClient=void 0;var o=n(3),i=n(10),c=n(11),a=n(9),u=n(4),l=r(u),s=n(6),p=r(s),f=n(5),d=r(f),y=n(7),v=r(y),h=n(8),g=r(h);t.createClient=o.createClient,t.Client=o.Client,t.MetricsServiceContext=i.MetricsServiceContext,t.withMetricsServiceContext=i.withMetricsServiceContext,t.withMetricsServiceClient=c.withMetricsServiceClient,t.metricsServiceClick=a.metricsServiceClick,t.debugLog=l.default,t.googleAnalytics=p.default,t.googleAnalyticsLegacy=d.default,t.googleTagManager=v.default,t.tealium=g.default},function(t,n){t.exports=e},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(12),i=r(o),c=function(e,t){return t+"("+(0,i.default)(e)+")"};t.default=c},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=27e3,c=function(){function e(){var t=this,o=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],i=o.dispatchers,c=o.dispatcher;n(this,e),this._dispatchers=[],i&&i.forEach&&i.forEach(function(e){t.addDispatcher(e)}),c&&"object"===("undefined"==typeof c?"undefined":r(c))&&this.addDispatcher(c)}return o(e,[{key:"addDispatcher",value:function(e){function t(){}return e._dispatcherId||(e._dispatcherId=++i),e.componentWillMount||(e.componentWillMount=t),e.componentDidMount||(e.componentDidMount=t),e.componentWillUnmount||(e.componentWillUnmount=t),this._dispatchers.push(e),this}},{key:"removeDispatcher",value:function(e){return this._dispatchers=this.dispatchers.filter(function(t){return t._dispatcherId!==e._dispatcherId}),this}},{key:"callDispatchers",value:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=!1,i=[];return this.dispatchers.forEach(function(t){var r=t[e];r&&r.constructor&&r.call&&r.apply&&(i.push(r.apply(t,n)),o=!0)}),o||console.warn("react-metrics-service: no dispatcher respond to "+e),i}},{key:"dispatchers",get:function(){return this._dispatchers}}]),e}(),a={get:function(e,t){return e[t]?e[t]:function(){for(var n=arguments.length,r=Array(n),o=0;o<n;o++)r[o]=arguments[o];return e.callDispatchers.apply(e,[t].concat(r))}}},u=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=void 0;try{r=new Proxy(new(Function.prototype.bind.apply(c,[null].concat(t))),a)}catch(o){console.error("react-metrics-service: your javascript implementation doesn't support Proxy! instead of using 'createClient()', use 'new Client()'"),r=new(Function.prototype.bind.apply(c,[null].concat(t)))}return r};t.createClient=u,t.Client=c},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){var e=void 0;try{e=new Proxy({},{get:function(e,t){return function(){for(var e,n=arguments.length,r=Array(n),o=0;o<n;o++)r[o]=arguments[o];return(e=console).warn.apply(e,["react-metrics-service: called "+t+" with:"].concat(r)),null}}})}catch(t){console.error("react-metrics-service: your javascript implementation doesn't support Proxy! debugLog will not work!"),e={}}return e}();t.debugLog=n,t.default=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){var t=e.trackingID,n=void 0===t?"":t;return{componentDidMount:function(){if(document){var e=document.createElement("script");e.type="text/javascript",e.innerHTML="\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', '"+n+"']);\n\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n ",document.head.appendChild(e)}},gaPush:function(){var e;(e=window._gaq).push.apply(e,arguments)},gaPageView:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];window._gaq.push(["_trackPageview"].concat(t))}}};t.googleAnalyticsLegacy=n,t.default=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){var t=e.trackingID,n=void 0===t?"":t;return{componentDidMount:function(){if(document){var e=document.createElement("script");e.type="text/javascript",e.innerHTML="\n (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');\n\n ga('create', '"+n+"', 'auto');\n ",document.head.appendChild(e)}},gaSend:function(){for(var e,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=window).ga.apply(e,["send"].concat(n))},gaPageView:function(){for(var e,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=window).ga.apply(e,["send","pageview"].concat(n))}}};t.googleAnalytics=n,t.default=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},r=function(e){var t=e.containerID,r=void 0===t?"":t,o=e.dataLayer,i=void 0===o?{}:o;return{componentDidMount:function(){if(document){window.dataLayer=n({},i);var e=document.createElement("noscript");e.innerHTML='\n <iframe src="//www.googletagmanager.com/ns.html?id='+r+'"\n height="0" width="0" style="display:none;visibility:hidden">\n ',document.head.appendChild(e),e=document.createElement("script"),e.type="text/javascript",e.innerHTML="\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window,document,'script','dataLayer','"+r+"');\n ",document.head.appendChild(e)}},gtmPush:function(){var e;(e=window.dataLayer).push.apply(e,arguments)}}};t.googleTagManager=r,t.default=r},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},r=function(e){var t=e.account,r=void 0===t?"":t,o=e.profile,i=void 0===o?"":o,c=e.env,a=void 0===c?"":c,u=e.utag_data,l=void 0===u?{}:u,s=e.url;return{componentDidMount:function(){if(document){window.utag_data=n({},l);var e=s||"//tags.tiqcdn.com/utag/"+r+"/"+i+"/"+a+"/utag.js",t=document.createElement("script");t.type="text/javascript",t.innerHTML="\n (function(a,b,c,d){\n a='"+e+"';\n b=document;c='script';d=b.createElement(c);d.src=a;\n d.type='text/java'+c;d.async=true;\n a=b.getElementsByTagName(c)[0];a.parentNode.insertBefore(d,a)\n })();\n ",document.head.appendChild(t)}},utagView:function(){var e;(e=window.utag).view.apply(e,arguments)},utagLink:function(){var e;(e=window.utag).link.apply(e,arguments)}}};t.tealium=r,t.default=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.metricsServiceClick=void 0;var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(1),s=r(l),p=n(2),f=r(p),d=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return function(t){var r,p;return p=r=function(r){function l(){return o(this,l),i(this,Object.getPrototypeOf(l).apply(this,arguments))}return c(l,r),u(l,[{key:"handleClick",value:function(){var t;(t=this.context.metricsServiceClient).callDispatchers.apply(t,[e].concat(n))}},{key:"render",value:function(){return s.default.createElement("div",{onClick:this.handleClick.bind(this),__self:this},s.default.createElement(t,a({},this.props,{__self:this})))}}]),l}(l.Component),r.displayName=(0,f.default)(t,"metricsServiceClick"),r.contextTypes={metricsServiceClient:l.PropTypes.object},p}};t.metricsServiceClick=d,t.default=d},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.MetricsServiceContext=t.withMetricsServiceContext=void 0;var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(1),p=r(s),f=function(e){function t(){return i(this,t),c(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),l(t,[{key:"getChildContext",value:function(){return{metricsServiceClient:this.props.client}}},{key:"componentWillMount",value:function(){for(var e,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=this.props.client).callDispatchers.apply(e,["componentWillMount"].concat(n))}},{key:"componentDidMount",value:function(){for(var e,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=this.props.client).callDispatchers.apply(e,["componentDidMount"].concat(n))}},{key:"componentWillUnmount",value:function(){for(var e,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=this.props.client).callDispatchers.apply(e,["componentWillUnmount"].concat(n))}},{key:"render",value:function(){return p.default.createElement("div",{__self:this},this.props.children)}}]),t}(s.Component);f.propTypes={client:s.PropTypes.object.isRequired,children:s.PropTypes.node},f.childContextTypes={metricsServiceClient:s.PropTypes.object};var d=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=e.client;return function(e){return function(n){var r=o(n,[]);return p.default.createElement(f,{client:t,__self:void 0},p.default.createElement(e,u({},r,{__self:void 0})))}}};t.withMetricsServiceContext=d,t.MetricsServiceContext=f},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.withMetricsServiceClient=void 0;var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(1),s=r(l),p=n(2),f=r(p),d=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=e.transform,n=void 0===t?function(e){return{metricsServiceClient:e}}:t;return function(e){var t,r;return r=t=function(t){function r(){return o(this,r),i(this,Object.getPrototypeOf(r).apply(this,arguments))}return c(r,t),u(r,[{key:"render",value:function(){return s.default.createElement(e,a({},n(this.context.metricsServiceClient),this.props,{__self:this}))}}]),r}(l.Component),t.displayName=(0,f.default)(e,"withMetricsServiceClient"),t.contextTypes={metricsServiceClient:l.PropTypes.object},r}};t.withMetricsServiceClient=d,t.default=d},function(e,t){"use strict";t.__esModule=!0;var n=function(e){if("string"==typeof e)return e;if(e)return e.displayName||e.name||"Component"};t.default=n}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.MetricsService=t(require("react")):e.MetricsService=t(e.react)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t.tealium=t.googleTagManager=t.googleAnalyticsLegacy=t.googleAnalytics=t.debugLog=t.metricsServiceClick=t.withMetricsServiceClient=t.withMetricsServiceContext=t.MetricsServiceContext=t.Client=t.createClient=void 0;var o=n(3),i=n(10),c=n(11),a=n(9),u=n(4),l=r(u),s=n(6),f=r(s),p=n(5),d=r(p),y=n(7),v=r(y),h=n(8),g=r(h);t.createClient=o.createClient,t.Client=o.Client,t.MetricsServiceContext=i.MetricsServiceContext,t.withMetricsServiceContext=i.withMetricsServiceContext,t.withMetricsServiceClient=c.withMetricsServiceClient,t.metricsServiceClick=a.metricsServiceClick,t.debugLog=l.default,t.googleAnalytics=f.default,t.googleAnalyticsLegacy=d.default,t.googleTagManager=v.default,t.tealium=g.default},function(t,n){t.exports=e},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(12),i=r(o),c=function(e,t){return t+"("+(0,i.default)(e)+")"};t.default=c},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=27e3,c=function(){function e(){var t=this,o=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],i=o.dispatchers,c=o.dispatcher;n(this,e),this._dispatchers=[],i&&i.forEach&&i.forEach(function(e){t.addDispatcher(e)}),c&&"object"===("undefined"==typeof c?"undefined":r(c))&&this.addDispatcher(c)}return o(e,[{key:"addDispatcher",value:function(e){function t(){}return e._dispatcherId||(e._dispatcherId=++i),e.componentWillMount||(e.componentWillMount=t),e.componentDidMount||(e.componentDidMount=t),e.componentWillUnmount||(e.componentWillUnmount=t),this._dispatchers.push(e),this}},{key:"removeDispatcher",value:function(e){return this._dispatchers=this.dispatchers.filter(function(t){return t._dispatcherId!==e._dispatcherId}),this}},{key:"callDispatchers",value:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=!1,i=[];return this.dispatchers.forEach(function(t){var r=t[e];r&&r.constructor&&r.call&&r.apply&&(i.push(r.apply(t,n)),o=!0)}),o||console.warn("react-metrics-service: no dispatcher respond to "+e),i}},{key:"dispatchers",get:function(){return this._dispatchers}}]),e}(),a={get:function(e,t){return e[t]?e[t]:function(){for(var n=arguments.length,r=Array(n),o=0;o<n;o++)r[o]=arguments[o];return e.callDispatchers.apply(e,[t].concat(r))}}},u=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=void 0;try{r=new Proxy(new(Function.prototype.bind.apply(c,[null].concat(t))),a)}catch(o){console.error("react-metrics-service: your javascript implementation doesn't support Proxy! instead of using 'createClient()', use 'new Client()'"),r=new(Function.prototype.bind.apply(c,[null].concat(t)))}return r};t.createClient=u,t.Client=c},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){var e=void 0;try{e=new Proxy({},{get:function(e,t){return function(){for(var e,n=arguments.length,r=Array(n),o=0;o<n;o++)r[o]=arguments[o];return(e=console).warn.apply(e,["react-metrics-service: called "+t+" with:"].concat(r)),null}}})}catch(t){console.error("react-metrics-service: your javascript implementation doesn't support Proxy! debugLog will not work!"),e={}}return e}();t.debugLog=n,t.default=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){var t=e.trackingID,n=void 0===t?"":t;return{componentWillMount:function(){"undefined"!=typeof window&&(window._gaq=window._gaq||[],window._gaq.push(["_setAccount",n]))},componentDidMount:function(){if("undefined"!=typeof document){var e=document.createElement("script");e.type="text/javascript",e.innerHTML="\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n ",document.head.appendChild(e)}},gaPush:function(){if("undefined"!=typeof window){var e;(e=window._gaq).push.apply(e,arguments)}},gaPageView:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];"undefined"!=typeof window&&window._gaq.push(["_trackPageview"].concat(t))}}};t.googleAnalyticsLegacy=n,t.default=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){var t=e.trackingID,n=void 0===t?"":t;return{componentWillMount:function(){"undefined"!=typeof window&&(window.ga=window.ga||function(){(window.ga.q=window.ga.q||[]).push(arguments)},window.ga("create",n,"auto"))},componentDidMount:function(){if("undefined"!=typeof document){var e=document.createElement("script");e.type="text/javascript",e.innerHTML="\n (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');\n ",document.head.appendChild(e)}},gaSend:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];if("undefined"!=typeof window){var r;(r=window).ga.apply(r,["send"].concat(t))}},gaPageView:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];if("undefined"!=typeof window){var r;(r=window).ga.apply(r,["send","pageview"].concat(t))}}}};t.googleAnalytics=n,t.default=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},r=function(e){var t=e.containerID,r=void 0===t?"":t,o=e.dataLayer,i=void 0===o?{}:o;return{componentWillMount:function(){"undefined"!=typeof window&&(window.dataLayer=n({},i))},componentDidMount:function(){if("undefined"!=typeof document){var e=document.createElement("noscript");e.innerHTML='\n <iframe src="//www.googletagmanager.com/ns.html?id='+r+'"\n height="0" width="0" style="display:none;visibility:hidden">\n ',document.head.appendChild(e),e=document.createElement("script"),e.type="text/javascript",e.innerHTML="\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window,document,'script','dataLayer','"+r+"');\n ",document.head.appendChild(e)}},gtmPush:function(){if("undefined"!=typeof window){var e;(e=window.dataLayer).push.apply(e,arguments)}}}};t.googleTagManager=r,t.default=r},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},r=function(e){var t=e.account,r=void 0===t?"":t,o=e.profile,i=void 0===o?"":o,c=e.env,a=void 0===c?"":c,u=e.utag_data,l=void 0===u?{}:u,s=e.url;return{componentWillMount:function(){"undefined"!=typeof document&&(window.utag_data=n({},l))},componentDidMount:function(){if("undefined"!=typeof document){var e=s||"//tags.tiqcdn.com/utag/"+r+"/"+i+"/"+a+"/utag.js",t=document.createElement("script");t.type="text/javascript",t.innerHTML="\n (function(a,b,c,d){\n a='"+e+"';\n b=document;c='script';d=b.createElement(c);d.src=a;\n d.type='text/java'+c;d.async=true;\n a=b.getElementsByTagName(c)[0];a.parentNode.insertBefore(d,a)\n })();\n ",document.head.appendChild(t)}},utagView:function(){if("undefined"!=typeof document){var e;(e=window.utag).view.apply(e,arguments)}},utagLink:function(){if("undefined"!=typeof document){var e;(e=window.utag).link.apply(e,arguments)}}}};t.tealium=r,t.default=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.metricsServiceClick=void 0;var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(1),s=r(l),f=n(2),p=r(f),d=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return function(t){var r,f;return f=r=function(r){function l(){return o(this,l),i(this,Object.getPrototypeOf(l).apply(this,arguments))}return c(l,r),u(l,[{key:"handleClick",value:function(){var t;(t=this.context.metricsServiceClient).callDispatchers.apply(t,[e].concat(n))}},{key:"render",value:function(){return s.default.createElement("div",{onClick:this.handleClick.bind(this),__self:this},s.default.createElement(t,a({},this.props,{__self:this})))}}]),l}(l.Component),r.displayName=(0,p.default)(t,"metricsServiceClick"),r.contextTypes={metricsServiceClient:l.PropTypes.object},f}};t.metricsServiceClick=d,t.default=d},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.MetricsServiceContext=t.withMetricsServiceContext=void 0;var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(1),f=r(s),p=function(e){function t(){return i(this,t),c(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),l(t,[{key:"getChildContext",value:function(){return{metricsServiceClient:this.props.client}}},{key:"componentWillMount",value:function(){for(var e,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=this.props.client).callDispatchers.apply(e,["componentWillMount"].concat(n))}},{key:"componentDidMount",value:function(){for(var e,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=this.props.client).callDispatchers.apply(e,["componentDidMount"].concat(n))}},{key:"componentWillUnmount",value:function(){for(var e,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=this.props.client).callDispatchers.apply(e,["componentWillUnmount"].concat(n))}},{key:"render",value:function(){return f.default.createElement("div",{__self:this},this.props.children)}}]),t}(s.Component);p.propTypes={client:s.PropTypes.object.isRequired,children:s.PropTypes.node},p.childContextTypes={metricsServiceClient:s.PropTypes.object};var d=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=e.client;return function(e){return function(n){var r=o(n,[]);return f.default.createElement(p,{client:t,__self:void 0},f.default.createElement(e,u({},r,{__self:void 0})))}}};t.withMetricsServiceContext=d,t.MetricsServiceContext=p},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.withMetricsServiceClient=void 0;var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(1),s=r(l),f=n(2),p=r(f),d=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=e.transform,n=void 0===t?function(e){return{metricsServiceClient:e}}:t;return function(e){var t,r;return r=t=function(t){function r(){return o(this,r),i(this,Object.getPrototypeOf(r).apply(this,arguments))}return c(r,t),u(r,[{key:"render",value:function(){return s.default.createElement(e,a({},n(this.context.metricsServiceClient),this.props,{__self:this}))}}]),r}(l.Component),t.displayName=(0,p.default)(e,"withMetricsServiceClient"),t.contextTypes={metricsServiceClient:l.PropTypes.object},r}};t.withMetricsServiceClient=d,t.default=d},function(e,t){"use strict";t.__esModule=!0;var n=function(e){if("string"==typeof e)return e;if(e)return e.displayName||e.name||"Component"};t.default=n}])}); |
@@ -10,7 +10,13 @@ 'use strict'; | ||
return { | ||
componentWillMount: function componentWillMount() { | ||
if (typeof window !== 'undefined') { | ||
window._gaq = window._gaq || []; | ||
window._gaq.push(['_setAccount', trackingID]); | ||
} | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
if (document) { | ||
if (typeof document !== 'undefined') { | ||
var elem = document.createElement('script'); | ||
elem.type = 'text/javascript'; | ||
elem.innerHTML = '\n var _gaq = _gaq || [];\n _gaq.push([\'_setAccount\', \'' + trackingID + '\']);\n\n (function() {\n var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;\n ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';\n var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);\n })();\n '; | ||
elem.innerHTML = '\n (function() {\n var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;\n ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';\n var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);\n })();\n '; | ||
document.head.appendChild(elem); | ||
@@ -20,5 +26,7 @@ } | ||
gaPush: function gaPush() { | ||
var _window$_gaq; | ||
if (typeof window !== 'undefined') { | ||
var _window$_gaq; | ||
(_window$_gaq = window._gaq).push.apply(_window$_gaq, arguments); | ||
(_window$_gaq = window._gaq).push.apply(_window$_gaq, arguments); | ||
} | ||
}, | ||
@@ -30,3 +38,5 @@ gaPageView: function gaPageView() { | ||
window._gaq.push(['_trackPageview'].concat(args)); | ||
if (typeof window !== 'undefined') { | ||
window._gaq.push(['_trackPageview'].concat(args)); | ||
} | ||
} | ||
@@ -33,0 +43,0 @@ }; |
@@ -10,7 +10,16 @@ 'use strict'; | ||
return { | ||
componentWillMount: function componentWillMount() { | ||
if (typeof window !== 'undefined') { | ||
window['ga'] = window['ga'] || function () { | ||
//eslint-disable-line | ||
(window['ga'].q = window['ga'].q || []).push(arguments); //eslint-disable-line | ||
}; | ||
window.ga('create', trackingID, 'auto'); | ||
} | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
if (document) { | ||
if (typeof document !== 'undefined') { | ||
var elem = document.createElement('script'); | ||
elem.type = 'text/javascript'; | ||
elem.innerHTML = '\n (function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){\n (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n })(window,document,\'script\',\'https://www.google-analytics.com/analytics.js\',\'ga\');\n\n ga(\'create\', \'' + trackingID + '\', \'auto\');\n '; | ||
elem.innerHTML = '\n (function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){\n (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n })(window,document,\'script\',\'https://www.google-analytics.com/analytics.js\',\'ga\');\n '; | ||
document.head.appendChild(elem); | ||
@@ -20,4 +29,2 @@ } | ||
gaSend: function gaSend() { | ||
var _window; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
@@ -27,7 +34,9 @@ args[_key] = arguments[_key]; | ||
(_window = window).ga.apply(_window, ['send'].concat(args)); | ||
if (typeof window !== 'undefined') { | ||
var _window; | ||
(_window = window).ga.apply(_window, ['send'].concat(args)); | ||
} | ||
}, | ||
gaPageView: function gaPageView() { | ||
var _window2; | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
@@ -37,3 +46,7 @@ args[_key2] = arguments[_key2]; | ||
(_window2 = window).ga.apply(_window2, ['send', 'pageview'].concat(args)); | ||
if (typeof window !== 'undefined') { | ||
var _window2; | ||
(_window2 = window).ga.apply(_window2, ['send', 'pageview'].concat(args)); | ||
} | ||
} | ||
@@ -40,0 +53,0 @@ }; |
@@ -17,6 +17,9 @@ 'use strict'; | ||
return { | ||
componentWillMount: function componentWillMount() { | ||
if (typeof window !== 'undefined') { | ||
window.dataLayer = _extends({}, dataLayer); | ||
} | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
if (document) { | ||
window.dataLayer = _extends({}, dataLayer); | ||
if (typeof document !== 'undefined') { | ||
var elem = document.createElement('noscript'); | ||
@@ -33,5 +36,7 @@ elem.innerHTML = '\n <iframe src="//www.googletagmanager.com/ns.html?id=' + containerID + '"\n height="0" width="0" style="display:none;visibility:hidden">\n '; | ||
gtmPush: function gtmPush() { | ||
var _window$dataLayer; | ||
if (typeof window !== 'undefined') { | ||
var _window$dataLayer; | ||
(_window$dataLayer = window.dataLayer).push.apply(_window$dataLayer, arguments); | ||
(_window$dataLayer = window.dataLayer).push.apply(_window$dataLayer, arguments); | ||
} | ||
} | ||
@@ -38,0 +43,0 @@ }; |
@@ -22,6 +22,9 @@ 'use strict'; | ||
return { | ||
componentWillMount: function componentWillMount() { | ||
if (typeof document !== 'undefined') { | ||
window.utag_data = _extends({}, utag_data); | ||
} | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
if (document) { | ||
window.utag_data = _extends({}, utag_data); | ||
if (typeof document !== 'undefined') { | ||
var utagjs = url || '//tags.tiqcdn.com/utag/' + account + '/' + profile + '/' + env + '/utag.js'; | ||
@@ -35,10 +38,14 @@ var elem = document.createElement('script'); | ||
utagView: function utagView() { | ||
var _window$utag; | ||
if (typeof document !== 'undefined') { | ||
var _window$utag; | ||
(_window$utag = window.utag).view.apply(_window$utag, arguments); | ||
(_window$utag = window.utag).view.apply(_window$utag, arguments); | ||
} | ||
}, | ||
utagLink: function utagLink() { | ||
var _window$utag2; | ||
if (typeof document !== 'undefined') { | ||
var _window$utag2; | ||
(_window$utag2 = window.utag).link.apply(_window$utag2, arguments); | ||
(_window$utag2 = window.utag).link.apply(_window$utag2, arguments); | ||
} | ||
} | ||
@@ -45,0 +52,0 @@ }; |
{ | ||
"name": "react-metrics-service", | ||
"version": "0.0.10-beta", | ||
"version": "0.0.11-beta", | ||
"description": "React adapter for metrics services like Google Analytics, Tealium or Comcast.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -8,2 +8,20 @@ jest.unmock('../google-analytics-legacy') | ||
describe('componentWillMount', () => { | ||
beforeEach(() => { | ||
window._gaq = undefined | ||
subject = googleAnalyticsLegacy({ trackingID: 'test' }) | ||
}) | ||
it('defines window._gaq', () => { | ||
expect(window._gaq).toBeUndefined() | ||
subject.componentWillMount() | ||
expect(window._gaq).toEqual(jasmine.any(Array)) | ||
}) | ||
it('populates window._gaq', () => { | ||
subject.componentWillMount() | ||
expect(window._gaq).toEqual([['_setAccount', 'test']]) | ||
}) | ||
}) | ||
describe('componentDidMount', () => { | ||
@@ -10,0 +28,0 @@ beforeEach(() => { |
@@ -8,2 +8,28 @@ jest.unmock('../google-analytics') | ||
describe('componentWillMount', () => { | ||
beforeEach(() => { | ||
window.ga = undefined | ||
subject = googleAnalytics({ trackingID: 'test' }) | ||
}) | ||
it('defines window.ga', () => { | ||
expect(window.ga).toBeUndefined() | ||
subject.componentWillMount() | ||
expect(window.ga).toEqual(jasmine.any(Function)) | ||
}) | ||
it('defines window.ga.q', () => { | ||
expect(window.ga).toBeUndefined() | ||
subject.componentWillMount() | ||
expect(window.ga.q).toEqual(jasmine.any(Array)) | ||
}) | ||
it('populates window.ga.q', () => { | ||
subject.componentWillMount() | ||
expect(window.ga.q[0][0]).toEqual('create') | ||
expect(window.ga.q[0][1]).toEqual('test') | ||
expect(window.ga.q[0][2]).toEqual('auto') | ||
}) | ||
}) | ||
describe('componentDidMount', () => { | ||
@@ -13,2 +39,3 @@ beforeEach(() => { | ||
}) | ||
it('returns an object', () => { | ||
@@ -18,2 +45,3 @@ expect(subject).toBeTruthy() | ||
}) | ||
it('injects a script tag into head', () => { | ||
@@ -20,0 +48,0 @@ expect(document.head.innerHTML).toBeFalsy() |
@@ -8,2 +8,24 @@ jest.unmock('../google-tag-manager') | ||
describe('componentWillMount', () => { | ||
beforeEach(() => { | ||
window.dataLayer = undefined | ||
subject = subject = googleTagManager({ | ||
containerID: 'GTM-XXXX', | ||
dataLayer: { quoth: 'the', raven: 'nevermore' }, | ||
}) | ||
}) | ||
it('defines dataLayer', () => { | ||
expect(window.dataLayer).toBeUndefined() | ||
subject.componentWillMount() | ||
expect(window.dataLayer).toEqual(jasmine.any(Object)) | ||
}) | ||
it('populates dataLayer', () => { | ||
expect(window.dataLayer).toBeUndefined() | ||
subject.componentWillMount() | ||
expect(window.dataLayer).toEqual({ quoth: 'the', raven: 'nevermore' }) | ||
}) | ||
}) | ||
describe('componentDidMount', () => { | ||
@@ -16,2 +38,3 @@ beforeEach(() => { | ||
}) | ||
it('returns an object', () => { | ||
@@ -21,2 +44,3 @@ expect(subject).toBeTruthy() | ||
}) | ||
it('injects a script tag into head', () => { | ||
@@ -23,0 +47,0 @@ expect(document.head.innerHTML).toBeFalsy() |
@@ -8,2 +8,26 @@ jest.unmock('../tealium') | ||
describe('componentWillMount', () => { | ||
beforeEach(() => { | ||
window.utag_data = undefined | ||
subject = tealium({ | ||
account: 'test', | ||
profile: 'first', | ||
env: 'prod', | ||
utag_data: { is: 'bloody', but: 'unbound' }, | ||
}) | ||
}) | ||
it('defines utag_data', () => { | ||
expect(window.utag_data).toBeUndefined() | ||
subject.componentWillMount() | ||
expect(window.utag_data).toEqual(jasmine.any(Object)) | ||
}) | ||
it('populates utag_data', () => { | ||
expect(window.utag_data).toBeUndefined() | ||
subject.componentWillMount() | ||
expect(window.utag_data).toEqual({ is: 'bloody', but: 'unbound' }) | ||
}) | ||
}) | ||
describe('componentDidMount', () => { | ||
@@ -10,0 +34,0 @@ beforeEach(() => { |
const googleAnalyticsLegacy = ({ | ||
trackingID = '', | ||
}) => ({ | ||
componentWillMount: () => { | ||
if (typeof window !== 'undefined') { | ||
window._gaq = window._gaq || [] | ||
window._gaq.push(['_setAccount', trackingID]) | ||
} | ||
}, | ||
componentDidMount: () => { | ||
if (document) { | ||
if (typeof document !== 'undefined') { | ||
const elem = document.createElement('script') | ||
@@ -10,5 +16,2 @@ elem.type = 'text/javascript' | ||
` | ||
var _gaq = _gaq || []; | ||
_gaq.push(['_setAccount', '${trackingID}']); | ||
(function() { | ||
@@ -24,6 +27,10 @@ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | ||
gaPush: (...args) => { | ||
window._gaq.push(...args) | ||
if (typeof window !== 'undefined') { | ||
window._gaq.push(...args) | ||
} | ||
}, | ||
gaPageView: (...args) => { | ||
window._gaq.push(['_trackPageview', ...args]) | ||
if (typeof window !== 'undefined') { | ||
window._gaq.push(['_trackPageview', ...args]) | ||
} | ||
}, | ||
@@ -30,0 +37,0 @@ }) |
const googleAnalytics = ({ | ||
trackingID = '', | ||
}) => ({ | ||
componentWillMount: () => { | ||
if (typeof window !== 'undefined') { | ||
window['ga'] = window['ga'] || function () { //eslint-disable-line | ||
(window['ga'].q = window['ga'].q || []).push(arguments) //eslint-disable-line | ||
} | ||
window.ga('create', trackingID, 'auto') | ||
} | ||
}, | ||
componentDidMount: () => { | ||
if (document) { | ||
if (typeof document !== 'undefined') { | ||
const elem = document.createElement('script') | ||
@@ -14,4 +22,2 @@ elem.type = 'text/javascript' | ||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | ||
ga('create', '${trackingID}', 'auto'); | ||
` | ||
@@ -22,6 +28,10 @@ document.head.appendChild(elem) | ||
gaSend: (...args) => { | ||
window.ga('send', ...args) | ||
if (typeof window !== 'undefined') { | ||
window.ga('send', ...args) | ||
} | ||
}, | ||
gaPageView: (...args) => { | ||
window.ga('send', 'pageview', ...args) | ||
if (typeof window !== 'undefined') { | ||
window.ga('send', 'pageview', ...args) | ||
} | ||
}, | ||
@@ -28,0 +38,0 @@ }) |
@@ -7,6 +7,9 @@ /* eslint-disable quotes, camelcase */ | ||
}) => ({ | ||
componentWillMount: () => { | ||
if (typeof window !== 'undefined') { | ||
window.dataLayer = { ...dataLayer } | ||
} | ||
}, | ||
componentDidMount: () => { | ||
if (document) { | ||
window.dataLayer = { ...dataLayer } | ||
if (typeof document !== 'undefined') { | ||
let elem = document.createElement('noscript') | ||
@@ -34,3 +37,5 @@ elem.innerHTML = | ||
gtmPush: (...args) => { | ||
window.dataLayer.push(...args) | ||
if (typeof window !== 'undefined') { | ||
window.dataLayer.push(...args) | ||
} | ||
}, | ||
@@ -37,0 +42,0 @@ }) |
@@ -10,6 +10,9 @@ /* eslint-disable quotes, camelcase */ | ||
}) => ({ | ||
componentWillMount: () => { | ||
if (typeof document !== 'undefined') { | ||
window.utag_data = { ...utag_data } | ||
} | ||
}, | ||
componentDidMount: () => { | ||
if (document) { | ||
window.utag_data = { ...utag_data } | ||
if (typeof document !== 'undefined') { | ||
const utagjs = url || `//tags.tiqcdn.com/utag/${account}/${profile}/${env}/utag.js` | ||
@@ -31,6 +34,10 @@ const elem = document.createElement('script') | ||
utagView: (...args) => { | ||
window.utag.view(...args) | ||
if (typeof document !== 'undefined') { | ||
window.utag.view(...args) | ||
} | ||
}, | ||
utagLink: (...args) => { | ||
window.utag.link(...args) | ||
if (typeof document !== 'undefined') { | ||
window.utag.link(...args) | ||
} | ||
}, | ||
@@ -37,0 +44,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77032
1380