@walkeros/web-destination-gtag 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -109,7 +109,7 @@ function _(e2) {
109
109
  }
110
110
  function W(e2 = {}) {
111
111
  var _a;
112
- const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = e2.group || "gr0up", r = e2.count || 1, o = S({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" }, nested: [], context: { element: ["child", 0] } }], consent: { functional: true }, id: `${t}-${n}-${r}`, trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, group: n, count: r, version: { source: "0.5.0", tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
112
+ const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = e2.group || "gr0up", r = e2.count || 1, o = S({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" }, nested: [], context: { element: ["child", 0] } }], consent: { functional: true }, id: `${t}-${n}-${r}`, trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, group: n, count: r, version: { source: "0.6.0", tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
113
113
  if (e2.name) {
114
114
  const [t2, n2] = (_a = e2.name.split(" ")) != null ? _a : [];
115
115
  t2 && n2 && (o.entity = t2, o.action = n2);
@@ -87,7 +87,7 @@ function _(e2) {
87
87
  }
88
88
  function W(e2 = {}) {
89
89
  var _a;
90
- const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = e2.group || "gr0up", r = e2.count || 1, o = S({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" }, nested: [], context: { element: ["child", 0] } }], consent: { functional: true }, id: `${t}-${n}-${r}`, trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, group: n, count: r, version: { source: "0.5.0", tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
90
+ const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = e2.group || "gr0up", r = e2.count || 1, o = S({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" }, nested: [], context: { element: ["child", 0] } }], consent: { functional: true }, id: `${t}-${n}-${r}`, trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, group: n, count: r, version: { source: "0.6.0", tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
91
91
  if (e2.name) {
92
92
  const [t2, n2] = (_a = e2.name.split(" ")) != null ? _a : [];
93
93
  t2 && n2 && (o.entity = t2, o.action = n2);
package/dist/index.es5.js CHANGED
@@ -1 +1 @@
1
- "use strict";function _array_like_to_array(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function asyncGeneratorStep(e,t,n,r,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function _async_to_generator(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){asyncGeneratorStep(a,r,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,r,o,i,c,"throw",e)}i(void 0)})}}function _define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterable_to_array_limit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){_define_property(e,t,n[t])})}return e}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function _sliced_to_array(e,t){return _array_with_holes(e)||_iterable_to_array_limit(e,t)||_unsupported_iterable_to_array(e,t)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,t){if(e){if("string"==typeof e)return _array_like_to_array(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_array_like_to_array(e,t):void 0}}function _ts_generator(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}var Destination=function(){var e=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"https://www.googletagmanager.com/gtag/js?id=",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:globalThis.document;if(!m.has(e)){var r=n.createElement("script");r.src=t+e,n.head.appendChild(r),m.add(e)}},t=function(e){var t=e;return t.dataLayer=t.dataLayer||[],t.gtag||(t.gtag=function(){t.dataLayer.push(arguments)}),t.gtag},n=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n=_object_spread({},I,n);var r=Object.entries(t).reduce(function(t,r){var o=_sliced_to_array(r,2),a=o[0],i=o[1],c=e[a];return n.merge&&Array.isArray(c)&&Array.isArray(i)?t[a]=i.reduce(function(e,t){return e.includes(t)?e:_to_consumable_array(e).concat([t])},_to_consumable_array(c)):(n.extend||a in e)&&(t[a]=i),t},{});return n.shallow?_object_spread({},e,r):(Object.assign(e,r),e)},r=function(e){return Array.isArray(e)},o=function(e){return void 0!==e},a=function(e){return"object"==(void 0===e?"undefined":_type_of(e))&&null!==e&&!r(e)&&"[object Object]"===Object.prototype.toString.call(e)},i=function(e){return"string"==typeof e},c=function(e){return P(e)?e:void 0},u=function(e,t,n){return function(){for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return _async_to_generator(function(){var r;return _ts_generator(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,4,6]),[4,e.apply(void 0,_to_consumable_array(o))];case 1:case 3:return[2,a.sent()];case 2:return r=a.sent(),t?[4,t(r)]:[2];case 4:return[4,null==n?void 0:n()];case 5:return a.sent(),[7];case 6:return[2]}})})()}},s=function(e){return _async_to_generator(function(e){var t,n,i,c,s,l,d,f,_,y,v,g,p,b=arguments;return _ts_generator(this,function(h){switch(h.label){case 0:if(t=b.length>1&&void 0!==b[1]?b[1]:{},n=b.length>2&&void 0!==b[2]?b[2]:{},!o(e))return[2];c=a(e)&&e.consent||n.consent||(null===(i=n.collector)||void 0===i?void 0:i.consent),s=r(t)?t:[t],l=!0,d=!1,f=void 0,h.label=1;case 1:h.trys.push([1,6,7,8]),_=s[Symbol.iterator](),h.label=2;case 2:return(l=(y=_.next()).done)?[3,5]:(v=y.value,[4,u(E)(e,v,_object_spread_props(_object_spread({},n),{consent:c}))]);case 3:if(g=h.sent(),o(g))return[2,g];h.label=4;case 4:return l=!0,[3,2];case 5:return[3,8];case 6:return p=h.sent(),d=!0,f=p,[3,8];case 7:try{l||null==_.return||_.return()}finally{if(d)throw f}return[7];case 8:return[2]}})}).apply(this,arguments)},l=function(e){return _object_spread({window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document},e)},d=function(e,t,r,o,i){return _async_to_generator(function(){var c,u,l,d,f,_,y;return _ts_generator(this,function(v){switch(v.label){case 0:return c=a(t)?t:{},r.data?[4,s(e,r.data,{collector:i})]:[3,2];case 1:return l=v.sent(),[3,3];case 2:l={},v.label=3;case 3:return u=l,(null==o?void 0:o.data)?[4,s(e,o.data,{collector:i})]:[3,5];case 4:return f=v.sent(),[3,6];case 5:f={},v.label=6;case 6:return d=f,_=a(u)?u:{},y=a(d)?d:{},[2,n(n(c,_),y)]}})})()},f=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,o=arguments.length>5?arguments[5]:void 0,i=l(arguments.length>4?arguments[4]:void 0).window;t.measurementId||o.throw("Config settings ga4.measurementId missing");var c=a(r)?r:{},u=function(e,t){var n={};return t.includes("all")&&(t=["context","data","event","globals","source","user","version"]),t.forEach(function(t){var r=e[t]||{};"event"==t&&(r={id:e.id,timing:e.timing,trigger:e.trigger,entity:e.entity,action:e.action,group:e.group,count:e.count}),Object.entries(r).forEach(function(e){var r=_sliced_to_array(e,2),o=r[0],a=r[1];"context"==t&&(a=a[0]),n["".concat(t,"_").concat(o)]=a})}),n}(e,n.include||t.include||["data"]),s=_object_spread({},u,c),d=e.name;!1!==t.snakeCase&&(d=function(e){return arguments.length>1&&void 0!==arguments[1]&&!arguments[1]?e:e.replace(/\s+/g,"_").toLowerCase()}(d)),s.send_to=t.measurementId,t.debug&&(s.debug_mode=!0),(0,i.gtag)("event",d,s)},_=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:globalThis.document,o=n!=k?"&l="+n:"",a=r.createElement("script");a.src=t+e+o,r.head.appendChild(a)},y=function(){C=!1},v=Object.defineProperty,g=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,b=Object.prototype.hasOwnProperty,h={};!function(e,t){for(var n in t)v(e,n,{get:t[n],enumerable:!0})}(h,{DestinationGtag:function(){return x},default:function(){return R},destinationGtag:function(){return G},resetConsentState:function(){return y}});var m=new Set,w=Object.defineProperty;!function(e,t){for(var n in t)w(e,n,{get:t[n],enumerable:!0})}({},{Level:function(){return O}});var j,O=((j=O||{})[j.ERROR=0]="ERROR",j[j.INFO=1]="INFO",j[j.DEBUG=2]="DEBUG",j),I={merge:!0,shallow:!0,extend:!0};function S(e){for(var t=arguments.length>2?arguments[2]:void 0,n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"").split("."),a=e,i=0;i<n.length;i++){var c=n[i];if("*"===c&&r(a)){var u=n.slice(i+1).join("."),s=[],l=!0,d=!1,f=void 0;try{for(var _,y=a[Symbol.iterator]();!(l=(_=y.next()).done);l=!0){var v=S(_.value,u,t);s.push(v)}}catch(e){d=!0,f=e}finally{try{l||null==y.return||y.return()}finally{if(d)throw f}}return s}if(!(a=_instanceof(a,Object)?a[c]:void 0))break}return o(a)?a:t}function P(e){return function(e){return"boolean"==typeof e}(e)||i(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!o(e)||r(e)&&e.every(P)||a(e)&&Object.values(e).every(P)}function E(e,t){return _async_to_generator(function(e,t){var n,a,l,d=arguments;return _ts_generator(this,function(f){return a=(n=d.length>2&&void 0!==d[2]?d[2]:{}).collector,l=n.consent,[2,(r(t)?t:[t]).reduce(function(t,d){return _async_to_generator(function(){var f,_,y,v,g,p,b,h,m,w,j,O,I,P,A,k,D,x,C,L,G;return _ts_generator(this,function(R){switch(R.label){case 0:return[4,t];case 1:return(f=R.sent())?[2,f]:(_=i(d)?{key:d}:d,Object.keys(_).length?(y=_.condition,v=_.consent,g=_.fn,p=_.key,b=_.loop,h=_.map,m=_.set,w=_.validate,j=_.value,(O=y)?[4,u(y)(e,d,a)]:[3,3]):[2]);case 2:O=!R.sent(),R.label=3;case 3:return O?[2]:v&&!function(e){var t=_object_spread({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),n={},r=void 0===e;return Object.keys(t).forEach(function(o){t[o]&&(n[o]=!0,e&&e[o]&&(r=!0))}),!!r&&n}(v,l)?[2,j]:(I=o(j)?j:e,g?[4,u(g)(e,d,n)]:[3,5]);case 4:I=R.sent(),R.label=5;case 5:return p&&(I=S(e,p,j)),b?(P=_sliced_to_array(b,2),A=P[0],k=P[1],"this"!==A?[3,6]:(x=[e],[3,8])):[3,11];case 6:return[4,s(e,A,n)];case 7:x=R.sent(),R.label=8;case 8:return r(D=x)?[4,Promise.all(D.map(function(e){return s(e,k,n)}))]:[3,10];case 9:I=R.sent().filter(o),R.label=10;case 10:return[3,17];case 11:return h?[4,Object.entries(h).reduce(function(t,r){var a=_sliced_to_array(r,2),i=a[0],c=a[1];return _async_to_generator(function(){var r,a;return _ts_generator(this,function(u){switch(u.label){case 0:return[4,t];case 1:return r=u.sent(),[4,s(e,c,n)];case 2:return a=u.sent(),[2,(o(a)&&(r[i]=a),r)]}})})()},Promise.resolve({}))]:[3,13];case 12:return I=R.sent(),[3,16];case 13:return(C=m)?[4,Promise.all(m.map(function(t){return E(e,t,n)}))]:[3,15];case 14:C=I=R.sent(),R.label=15;case 15:R.label=16;case 16:R.label=17;case 17:return(L=w)?[4,u(w)(I)]:[3,19];case 18:L=!R.sent(),R.label=19;case 19:return L&&(I=void 0),G=c(I),[2,o(G)?G:c(j)]}})})()},Promise.resolve(void 0))]})}).apply(this,arguments)}var A,k="dataLayer",D="https://www.googletagmanager.com/gtm.js?id=",x={},C=!1,L={marketing:["ad_storage","ad_user_data","ad_personalization"],functional:["analytics_storage"]},G={type:"google-gtag",config:{settings:{}},init:function(n){var r=n.config,o=n.env,a=n.logger,i=r.settings,c=void 0===i?{}:i,u=r.loadScript,s=c.ga4,d=c.ads,f=c.gtm;return(null==s?void 0:s.measurementId)||(null==d?void 0:d.conversionId)||(null==f?void 0:f.containerId)||a.throw("Config settings missing. Set ga4.measurementId, ads.conversionId, or gtm.containerId"),(null==s?void 0:s.measurementId)&&function(n,r,o,a){var i=l(o),c=i.window,u=i.document,s=n.measurementId,d=n.transport_url,f=n.server_container_url,_=n.pageview;s||a.throw("Config settings ga4.measurementId missing"),r&&e(s,void 0,u),t(c);var y={};d&&(y.transport_url=d),f&&(y.server_container_url=f),!1===_&&(y.send_page_view=!1);var v=c.gtag;v("js",new Date),v("config",s,y)}(s,u,o,a),(null==d?void 0:d.conversionId)&&function(n,r,o,a){var i=l(o),c=i.window,u=i.document,s=n.conversionId;s||a.throw("Config settings ads.conversionId missing"),n.currency||(n.currency="EUR"),r&&e(s,void 0,u),t(c);var d=c.gtag;d("js",new Date),d("config",s)}(d,u,o,a),(null==f?void 0:f.containerId)&&function(e,t,n){var r=l(n),o=r.window,a=r.document,i=e.containerId,c=e.dataLayer,u=e.domain,s=c||k;s===k?o.dataLayer=o.dataLayer||[]:o[s]=o[s]||[],o[s].push({"gtm.start":(new Date).getTime(),event:"gtm.js"}),t&&i&&_(i,u||D,s,a)}(f,u,o),r},push:function(e,t){return _async_to_generator(function(e,t){var n,r,o,i,c,u,s,_,y,v,g,p,b,h,m,w;return _ts_generator(this,function(j){switch(j.label){case 0:return n=t.config,r=t.mapping,o=void 0===r?{}:r,i=t.data,c=t.env,u=t.collector,s=t.logger,_=n.settings,v=(y=void 0===_?{}:_).ga4,g=y.ads,p=y.gtm,b=o.settings||{},[4,d(e,i,n,v,u)];case 1:return h=j.sent(),[4,d(e,i,n,g,u)];case 2:return m=j.sent(),[4,d(e,i,n,p,u)];case 3:return w=j.sent(),(null==v?void 0:v.measurementId)&&f(e,v,b.ga4,h,c,s),(null==g?void 0:g.conversionId)&&o.name&&function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,i=arguments.length>5?arguments[5]:void 0,c=arguments.length>6?arguments[6]:void 0,u=t.conversionId,s=t.currency,d=a(r)?r:{},f=n.label||o;f||c.throw("Config mapping ads.label missing");var _=_object_spread({send_to:"".concat(u,"/").concat(f),currency:s||"EUR"},d);(0,l(i).window.gtag)("event","conversion",_)}(e,g,b.ads,m,o.name,c,s),(null==p?void 0:p.containerId)&&function(e,t){var n=arguments.length>3?arguments[3]:void 0,r=l(arguments.length>4?arguments[4]:void 0).window,o={event:e.name};r.dataLayer.push(_object_spread({},o,a(n)?n:e))}(e,p,b.gtm,w,c,s),[2]}})}).apply(this,arguments)},on:function(e,n){var r;if("consent"===e&&n.data){var o=n.data,a=((null===(r=n.config)||void 0===r?void 0:r.settings)||{}).como,i=void 0===a||a;if(i){var c=l(n.env).window,u=t(c);if(u){var s=!0===i?L:i;if(!C){var d=new Set;if(Object.values(s).forEach(function(e){(Array.isArray(e)?e:[e]).forEach(function(e){return d.add(e)})}),d.size>0){var f={};d.forEach(function(e){f[e]="denied"}),u("consent","default",f)}C=!0}var _={};Object.entries(o).forEach(function(e){var t=_sliced_to_array(e,2),n=t[0],r=t[1],o=s[n];if(o){var a=Array.isArray(o)?o:[o],i=r?"granted":"denied";a.forEach(function(e){_[e]=i})}}),0!==Object.keys(_).length&&u("consent","update",_)}}}}},R=G;return A=h,function(e,t,n,r){if(t&&"object"===(void 0===t?"undefined":_type_of(t))||"function"==typeof t){var o=!0,a=!1,i=void 0;try{for(var c,u=function(){var o=c.value;b.call(e,o)||o===n||v(e,o,{get:function(){return t[o]},enumerable:!(r=g(t,o))||r.enumerable})},s=p(t)[Symbol.iterator]();!(o=(c=s.next()).done);o=!0)u()}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}}return e}(v({},"__esModule",{value:!0}),A)}();
1
+ "use strict";function _array_like_to_array(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function asyncGeneratorStep(e,t,n,r,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function _async_to_generator(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){asyncGeneratorStep(a,r,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,r,o,i,c,"throw",e)}i(void 0)})}}function _define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterable_to_array_limit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){_define_property(e,t,n[t])})}return e}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function _sliced_to_array(e,t){return _array_with_holes(e)||_iterable_to_array_limit(e,t)||_unsupported_iterable_to_array(e,t)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,t){if(e){if("string"==typeof e)return _array_like_to_array(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_array_like_to_array(e,t):void 0}}function _ts_generator(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(i,"next",{value:u(0)}),c(i,"throw",{value:u(1)}),c(i,"return",{value:u(2)}),"function"==typeof Symbol&&c(i,Symbol.iterator,{value:function(){return this}}),i;function u(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}var Destination=function(){var e=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"https://www.googletagmanager.com/gtag/js?id=",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:globalThis.document;if(!m.has(e)){var r=n.createElement("script");r.src=t+e,n.head.appendChild(r),m.add(e)}},t=function(e){var t=e;return t.dataLayer=t.dataLayer||[],t.gtag||(t.gtag=function(){t.dataLayer.push(arguments)}),t.gtag},n=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n=_object_spread({},I,n);var r=Object.entries(t).reduce(function(t,r){var o=_sliced_to_array(r,2),a=o[0],i=o[1],c=e[a];return n.merge&&Array.isArray(c)&&Array.isArray(i)?t[a]=i.reduce(function(e,t){return e.includes(t)?e:_to_consumable_array(e).concat([t])},_to_consumable_array(c)):(n.extend||a in e)&&(t[a]=i),t},{});return n.shallow?_object_spread({},e,r):(Object.assign(e,r),e)},r=function(e){return Array.isArray(e)},o=function(e){return void 0!==e},a=function(e){return"object"==(void 0===e?"undefined":_type_of(e))&&null!==e&&!r(e)&&"[object Object]"===Object.prototype.toString.call(e)},i=function(e){return"string"==typeof e},c=function(e){return P(e)?e:void 0},u=function(e,t,n){return function(){for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return _async_to_generator(function(){var r;return _ts_generator(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,4,6]),[4,e.apply(void 0,_to_consumable_array(o))];case 1:case 3:return[2,a.sent()];case 2:return r=a.sent(),t?[4,t(r)]:[2];case 4:return[4,null==n?void 0:n()];case 5:return a.sent(),[7];case 6:return[2]}})})()}},s=function(e){return _async_to_generator(function(e){var t,n,i,c,s,l,d,f,_,y,v,g,p,b=arguments;return _ts_generator(this,function(h){switch(h.label){case 0:if(t=b.length>1&&void 0!==b[1]?b[1]:{},n=b.length>2&&void 0!==b[2]?b[2]:{},!o(e))return[2];c=a(e)&&e.consent||n.consent||(null===(i=n.collector)||void 0===i?void 0:i.consent),s=r(t)?t:[t],l=!0,d=!1,f=void 0,h.label=1;case 1:h.trys.push([1,6,7,8]),_=s[Symbol.iterator](),h.label=2;case 2:return(l=(y=_.next()).done)?[3,5]:(v=y.value,[4,u(E)(e,v,_object_spread_props(_object_spread({},n),{consent:c}))]);case 3:if(g=h.sent(),o(g))return[2,g];h.label=4;case 4:return l=!0,[3,2];case 5:return[3,8];case 6:return p=h.sent(),d=!0,f=p,[3,8];case 7:try{l||null==_.return||_.return()}finally{if(d)throw f}return[7];case 8:return[2]}})}).apply(this,arguments)},l=function(e){return _object_spread({window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document},e)},d=function(e,t,r,o,i){return _async_to_generator(function(){var c,u,l,d,f,_,y;return _ts_generator(this,function(v){switch(v.label){case 0:return c=a(t)?t:{},r.data?[4,s(e,r.data,{collector:i})]:[3,2];case 1:return l=v.sent(),[3,3];case 2:l={},v.label=3;case 3:return u=l,(null==o?void 0:o.data)?[4,s(e,o.data,{collector:i})]:[3,5];case 4:return f=v.sent(),[3,6];case 5:f={},v.label=6;case 6:return d=f,_=a(u)?u:{},y=a(d)?d:{},[2,n(n(c,_),y)]}})})()},f=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,o=arguments.length>5?arguments[5]:void 0,i=l(arguments.length>4?arguments[4]:void 0).window;t.measurementId||o.throw("Config settings ga4.measurementId missing");var c=a(r)?r:{},u=function(e,t){var n={};return t.includes("all")&&(t=["context","data","event","globals","source","user","version"]),t.forEach(function(t){var r=e[t]||{};"event"==t&&(r={id:e.id,timing:e.timing,trigger:e.trigger,entity:e.entity,action:e.action,group:e.group,count:e.count}),Object.entries(r).forEach(function(e){var r=_sliced_to_array(e,2),o=r[0],a=r[1];"context"==t&&(a=a[0]),n["".concat(t,"_").concat(o)]=a})}),n}(e,n.include||t.include||["data"]),s=_object_spread({},u,c),d=e.name;!1!==t.snakeCase&&(d=function(e){return arguments.length>1&&void 0!==arguments[1]&&!arguments[1]?e:e.replace(/\s+/g,"_").toLowerCase()}(d)),s.send_to=t.measurementId,t.debug&&(s.debug_mode=!0),(0,i.gtag)("event",d,s)},_=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:globalThis.document,o=n!=k?"&l="+n:"",a=r.createElement("script");a.src=t+e+o,r.head.appendChild(a)},y=function(){C=!1},v=Object.defineProperty,g=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,b=Object.prototype.hasOwnProperty,h={};!function(e,t){for(var n in t)v(e,n,{get:t[n],enumerable:!0})}(h,{DestinationGtag:function(){return x},default:function(){return R},destinationGtag:function(){return G},resetConsentState:function(){return y}});var m=new Set,w=Object.defineProperty;!function(e,t){for(var n in t)w(e,n,{get:t[n],enumerable:!0})}({},{Level:function(){return O}});var j,O=((j=O||{})[j.ERROR=0]="ERROR",j[j.INFO=1]="INFO",j[j.DEBUG=2]="DEBUG",j),I={merge:!0,shallow:!0,extend:!0};function S(e){for(var t=arguments.length>2?arguments[2]:void 0,n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"").split("."),a=e,i=0;i<n.length;i++){var c=n[i];if("*"===c&&r(a)){var u=n.slice(i+1).join("."),s=[],l=!0,d=!1,f=void 0;try{for(var _,y=a[Symbol.iterator]();!(l=(_=y.next()).done);l=!0){var v=S(_.value,u,t);s.push(v)}}catch(e){d=!0,f=e}finally{try{l||null==y.return||y.return()}finally{if(d)throw f}}return s}if(!(a=_instanceof(a,Object)?a[c]:void 0))break}return o(a)?a:t}function P(e){return function(e){return"boolean"==typeof e}(e)||i(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!o(e)||r(e)&&e.every(P)||a(e)&&Object.values(e).every(P)}function E(e,t){return _async_to_generator(function(e,t){var n,a,l,d=arguments;return _ts_generator(this,function(f){return a=(n=d.length>2&&void 0!==d[2]?d[2]:{}).collector,l=n.consent,[2,(r(t)?t:[t]).reduce(function(t,d){return _async_to_generator(function(){var f,_,y,v,g,p,b,h,m,w,j,O,I,P,A,k,D,x,C,L,G;return _ts_generator(this,function(R){switch(R.label){case 0:return[4,t];case 1:return(f=R.sent())?[2,f]:(_=i(d)?{key:d}:d,Object.keys(_).length?(y=_.condition,v=_.consent,g=_.fn,p=_.key,b=_.loop,h=_.map,m=_.set,w=_.validate,j=_.value,(O=y)?[4,u(y)(e,d,a)]:[3,3]):[2]);case 2:O=!R.sent(),R.label=3;case 3:return O?[2]:v&&!function(e){var t=_object_spread({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),n={},r=void 0===e;return Object.keys(t).forEach(function(o){t[o]&&(n[o]=!0,e&&e[o]&&(r=!0))}),!!r&&n}(v,l)?[2,j]:(I=o(j)?j:e,g?[4,u(g)(e,d,n)]:[3,5]);case 4:I=R.sent(),R.label=5;case 5:return p&&(I=S(e,p,j)),b?(P=_sliced_to_array(b,2),A=P[0],k=P[1],"this"!==A?[3,6]:(x=[e],[3,8])):[3,11];case 6:return[4,s(e,A,n)];case 7:x=R.sent(),R.label=8;case 8:return r(D=x)?[4,Promise.all(D.map(function(e){return s(e,k,n)}))]:[3,10];case 9:I=R.sent().filter(o),R.label=10;case 10:return[3,17];case 11:return h?[4,Object.entries(h).reduce(function(t,r){var a=_sliced_to_array(r,2),i=a[0],c=a[1];return _async_to_generator(function(){var r,a;return _ts_generator(this,function(u){switch(u.label){case 0:return[4,t];case 1:return r=u.sent(),[4,s(e,c,n)];case 2:return a=u.sent(),[2,(o(a)&&(r[i]=a),r)]}})})()},Promise.resolve({}))]:[3,13];case 12:return I=R.sent(),[3,16];case 13:return(C=m)?[4,Promise.all(m.map(function(t){return E(e,t,n)}))]:[3,15];case 14:C=I=R.sent(),R.label=15;case 15:R.label=16;case 16:R.label=17;case 17:return(L=w)?[4,u(w)(I)]:[3,19];case 18:L=!R.sent(),R.label=19;case 19:return L&&(I=void 0),G=c(I),[2,o(G)?G:c(j)]}})})()},Promise.resolve(void 0))]})}).apply(this,arguments)}var A,k="dataLayer",D="https://www.googletagmanager.com/gtm.js?id=",x={},C=!1,L={marketing:["ad_storage","ad_user_data","ad_personalization"],functional:["analytics_storage"]},G={type:"google-gtag",config:{settings:{}},init:function(n){var r=n.config,o=n.env,a=n.logger,i=r.settings,c=void 0===i?{}:i,u=r.loadScript,s=c.ga4,d=c.ads,f=c.gtm;return(null==s?void 0:s.measurementId)||(null==d?void 0:d.conversionId)||(null==f?void 0:f.containerId)||a.throw("Config settings missing. Set ga4.measurementId, ads.conversionId, or gtm.containerId"),(null==s?void 0:s.measurementId)&&function(n,r,o,a){var i=l(o),c=i.window,u=i.document,s=n.measurementId,d=n.transport_url,f=n.server_container_url,_=n.pageview;s||a.throw("Config settings ga4.measurementId missing"),r&&e(s,void 0,u),t(c);var y={};d&&(y.transport_url=d),f&&(y.server_container_url=f),!1===_&&(y.send_page_view=!1);var v=c.gtag;v("js",new Date),v("config",s,y)}(s,u,o,a),(null==d?void 0:d.conversionId)&&function(n,r,o,a){var i=l(o),c=i.window,u=i.document,s=n.conversionId;s||a.throw("Config settings ads.conversionId missing"),n.currency||(n.currency="EUR"),r&&e(s,void 0,u),t(c);var d=c.gtag;d("js",new Date),d("config",s)}(d,u,o,a),(null==f?void 0:f.containerId)&&function(e,t,n){var r=l(n),o=r.window,a=r.document,i=e.containerId,c=e.dataLayer,u=e.domain,s=c||k;s===k?o.dataLayer=o.dataLayer||[]:o[s]=o[s]||[],o[s].push({"gtm.start":(new Date).getTime(),event:"gtm.js"}),t&&i&&_(i,u||D,s,a)}(f,u,o),r},push:function(e,t){return _async_to_generator(function(e,t){var n,r,o,i,c,u,s,_,y,v,g,p,b,h,m,w;return _ts_generator(this,function(j){switch(j.label){case 0:return n=t.config,r=t.mapping,o=void 0===r?{}:r,i=t.data,c=t.env,u=t.collector,s=t.logger,_=n.settings,v=(y=void 0===_?{}:_).ga4,g=y.ads,p=y.gtm,b=o.settings||{},[4,d(e,i,n,v,u)];case 1:return h=j.sent(),[4,d(e,i,n,g,u)];case 2:return m=j.sent(),[4,d(e,i,n,p,u)];case 3:return w=j.sent(),(null==v?void 0:v.measurementId)&&f(e,v,b.ga4,h,c,s),(null==g?void 0:g.conversionId)&&o.name&&function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,i=arguments.length>5?arguments[5]:void 0,c=arguments.length>6?arguments[6]:void 0,u=t.conversionId,s=t.currency,d=a(r)?r:{},f=n.label||o;f||c.throw("Config mapping ads.label missing");var _=_object_spread({send_to:"".concat(u,"/").concat(f),currency:s||"EUR"},d);(0,l(i).window.gtag)("event","conversion",_)}(e,g,b.ads,m,o.name,c,s),(null==p?void 0:p.containerId)&&function(e,t){var n=arguments.length>3?arguments[3]:void 0,r=l(arguments.length>4?arguments[4]:void 0).window,o={event:e.name};r.dataLayer.push(_object_spread({},o,a(n)?n:e))}(e,p,b.gtm,w,c,s),[2]}})}).apply(this,arguments)},on:function(e,n){var r;if("consent"===e&&n.data){var o=n.data,a=((null===(r=n.config)||void 0===r?void 0:r.settings)||{}).como,i=void 0===a||a;if(i){var c=l(n.env).window,u=t(c);if(u){var s=!0===i?L:i;if(!C){var d=new Set;if(Object.values(s).forEach(function(e){(Array.isArray(e)?e:[e]).forEach(function(e){return d.add(e)})}),d.size>0){var f={};d.forEach(function(e){f[e]="denied"}),u("consent","default",f)}C=!0}var _={};Object.entries(o).forEach(function(e){var t=_sliced_to_array(e,2),n=t[0],r=t[1],o=s[n];if(o){var a=Array.isArray(o)?o:[o],i=r?"granted":"denied";a.forEach(function(e){_[e]=i})}}),0!==Object.keys(_).length&&u("consent","update",_)}}}}},R=G;return A=h,function(e,t,n,r){if(t&&"object"===(void 0===t?"undefined":_type_of(t))||"function"==typeof t){var o=!0,a=!1,i=void 0;try{for(var c,u=function(){var o=c.value;b.call(e,o)||o===n||v(e,o,{get:function(){return t[o]},enumerable:!(r=g(t,o))||r.enumerable})},s=p(t)[Symbol.iterator]();!(o=(c=s.next()).done);o=!0)u()}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}}return e}(v({},"__esModule",{value:!0}),A)}();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@walkeros/web-destination-gtag",
3
3
  "description": "Unified Google destination for walkerOS (GA4, Ads, GTM)",
4
- "version": "0.5.0",
4
+ "version": "0.6.0",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -35,7 +35,7 @@
35
35
  "update": "npx npm-check-updates -u && npm update"
36
36
  },
37
37
  "dependencies": {
38
- "@walkeros/web-core": "0.5.0"
38
+ "@walkeros/web-core": "0.6.0"
39
39
  },
40
40
  "repository": {
41
41
  "url": "git+https://github.com/elbwalker/walkerOS.git",