@hellotext/hellotext 1.3.2 → 1.3.3
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.
- package/.babelrc +2 -1
- package/dist/hellotext.js +1 -1
- package/lib/errors/invalidEvent.js +26 -5
- package/lib/errors/notInitializedError.js +26 -5
- package/lib/event.js +26 -10
- package/lib/eventEmitter.js +34 -20
- package/lib/hellotext.js +112 -90
- package/lib/query.js +26 -12
- package/lib/response.js +26 -12
- package/package.json +1 -1
package/.babelrc
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"loose": true
|
|
15
15
|
}],
|
|
16
16
|
["@babel/plugin-proposal-private-property-in-object", { "loose": true }],
|
|
17
|
-
["@babel/plugin-proposal-class-properties", { "loose": true }]
|
|
17
|
+
["@babel/plugin-proposal-class-properties", { "loose": true }],
|
|
18
|
+
"@babel/plugin-transform-classes"
|
|
18
19
|
]
|
|
19
20
|
}
|
package/dist/hellotext.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var t={413:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidEvent=void 0;class r extends Error{constructor(t){super("".concat(t," is not valid. Please provide a valid event name")),this.name="InvalidEvent"}}e.InvalidEvent=r},215:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.NotInitializedError=void 0;class r extends Error{constructor(){super("You need to initialize before tracking events. Call Hellotext.initialize and pass your public business id"),this.name="NotInitializedError"}}e.NotInitializedError=r},372:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class r{static valid(t){return r.exists(t)}static invalid(t){return!this.valid(t)}static exists(t){return void 0!==this.events.find((e=>e===t))}}e.default=r,r.events=["session-set"]},179:(t,e)=>{function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function i(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?r(Object(i),!0).forEach((function(e){o(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function o(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=class{constructor(){this.subscribers={}}addSubscriber(t,e){this.subscribers=i(i({},this.subscribers),{},{[t]:this.subscribers[t]?[...this.subscribers[t],e]:[e]})}removeSubscriber(t,e){this.subscribers[t]&&(this.subscribers[t]=this.subscribers[t].filter((t=>t!==e)))}emit(t,e){this.subscribers[t].forEach((t=>{t(e)}))}get listeners(){return 0!==Object.keys(this.subscribers).length}}},474:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=class{constructor(t){this.urlSearchParams=new URLSearchParams(t)}get(t){return this.urlSearchParams.get(this.toHellotextParam(t))}has(t){return this.urlSearchParams.has(this.toHellotextParam(t))}toHellotextParam(t){return"hello_".concat(t)}}},310:(t,e)=>{function r(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=0;function o(t){return"__private_"+i+++"_"+t}var n=o("success"),s=o("response");e.default=class{constructor(t,e){Object.defineProperty(this,n,{writable:!0,value:void 0}),Object.defineProperty(this,s,{writable:!0,value:void 0}),r(this,n)[n]=t,r(this,s)[s]=e}get data(){return r(this,s)[s]}get failed(){return!1===r(this,n)[n]}get succeeded(){return!0===r(this,n)[n]}}}},e={};function r(i){var o=e[i];if(void 0!==o)return o.exports;var n=e[i]={exports:{}};return t[i](n,n.exports,r),n.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==t&&t,e={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(e.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&r.indexOf(Object.prototype.toString.call(t))>-1};function o(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function n(t){return"string"!=typeof t&&(t=String(t)),t}function s(t){var r={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return e.iterable&&(r[Symbol.iterator]=function(){return r}),r}function a(t){this.map={},t instanceof a?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function u(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function c(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function h(t){var e=new FileReader,r=c(e);return e.readAsArrayBuffer(t),r}function f(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function l(){return this.bodyUsed=!1,this._initBody=function(t){var r;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:e.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:e.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():e.arrayBuffer&&e.blob&&(r=t)&&DataView.prototype.isPrototypeOf(r)?(this._bodyArrayBuffer=f(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):e.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=f(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.blob&&(this.blob=function(){var t=u(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?u(this)||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer)):this.blob().then(h)}),this.text=function(){var t,e,r,i=u(this);if(i)return i;if(this._bodyBlob)return t=this._bodyBlob,r=c(e=new FileReader),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),i=0;i<e.length;i++)r[i]=String.fromCharCode(e[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},e.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}a.prototype.append=function(t,e){t=o(t),e=n(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},a.prototype.delete=function(t){delete this.map[o(t)]},a.prototype.get=function(t){return t=o(t),this.has(t)?this.map[t]:null},a.prototype.has=function(t){return this.map.hasOwnProperty(o(t))},a.prototype.set=function(t,e){this.map[o(t)]=n(e)},a.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},a.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),s(t)},a.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),s(t)},a.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),s(t)},e.iterable&&(a.prototype[Symbol.iterator]=a.prototype.entries);var d=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function p(t,e){if(!(this instanceof p))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,i,o=(e=e||{}).body;if(t instanceof p){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new a(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,o||null==t._bodyInit||(o=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new a(e.headers)),this.method=(i=(r=e.method||this.method||"GET").toUpperCase(),d.indexOf(i)>-1?i:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(o),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var n=/([?&])_=[^&]*/;n.test(this.url)?this.url=this.url.replace(n,"$1_="+(new Date).getTime()):this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}function y(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),i=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(o))}})),e}function b(t,e){if(!(this instanceof b))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new a(e.headers),this.url=e.url||"",this._initBody(t)}p.prototype.clone=function(){return new p(this,{body:this._bodyInit})},l.call(p.prototype),l.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new a(this.headers),url:this.url})},b.error=function(){var t=new b(null,{status:0,statusText:""});return t.type="error",t};var v=[301,302,303,307,308];b.redirect=function(t,e){if(-1===v.indexOf(e))throw new RangeError("Invalid status code");return new b(null,{status:e,headers:{location:t}})};var m=t.DOMException;try{new m}catch(t){(m=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack}).prototype=Object.create(Error.prototype),m.prototype.constructor=m}function w(r,i){return new Promise((function(o,s){var u=new p(r,i);if(u.signal&&u.signal.aborted)return s(new m("Aborted","AbortError"));var c=new XMLHttpRequest;function h(){c.abort()}c.onload=function(){var t,e,r={status:c.status,statusText:c.statusText,headers:(t=c.getAllResponseHeaders()||"",e=new a,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),i=r.shift().trim();if(i){var o=r.join(":").trim();e.append(i,o)}})),e)};r.url="responseURL"in c?c.responseURL:r.headers.get("X-Request-URL");var i="response"in c?c.response:c.responseText;setTimeout((function(){o(new b(i,r))}),0)},c.onerror=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},c.ontimeout=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},c.onabort=function(){setTimeout((function(){s(new m("Aborted","AbortError"))}),0)},c.open(u.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(u.url),!0),"include"===u.credentials?c.withCredentials=!0:"omit"===u.credentials&&(c.withCredentials=!1),"responseType"in c&&(e.blob?c.responseType="blob":e.arrayBuffer&&u.headers.get("Content-Type")&&-1!==u.headers.get("Content-Type").indexOf("application/octet-stream")&&(c.responseType="arraybuffer")),!i||"object"!=typeof i.headers||i.headers instanceof a?u.headers.forEach((function(t,e){c.setRequestHeader(e,t)})):Object.getOwnPropertyNames(i.headers).forEach((function(t){c.setRequestHeader(t,n(i.headers[t]))})),u.signal&&(u.signal.addEventListener("abort",h),c.onreadystatechange=function(){4===c.readyState&&u.signal.removeEventListener("abort",h)}),c.send(void 0===u._bodyInit?null:u._bodyInit)}))}w.polyfill=!0,t.fetch||(t.fetch=w,t.Headers=a,t.Request=p,t.Response=b)})(),(()=>{var t=a(r(372)),e=a(r(179)),i=a(r(310)),o=a(r(474)),n=r(215),s=r(413);function a(t){return t&&t.__esModule?t:{default:t}}function u(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function c(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?u(Object(r),!0).forEach((function(e){h(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function h(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function f(t,e,r,i,o,n,s){try{var a=t[n](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(i,o)}function l(t){return function(){var e=this,r=arguments;return new Promise((function(i,o){var n=t.apply(e,r);function s(t){f(n,i,o,s,a,"next",t)}function a(t){f(n,i,o,s,a,"throw",t)}s(void 0)}))}}function d(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var p=0;function y(t){return"__private_"+p+++"_"+t}var b="https://api.hellotext.com/v1/",v=y("session"),m=y("business"),w=y("eventEmitter"),O=y("query"),g=y("notInitialized"),P=y("mintAnonymousSession"),j=y("headers"),_=y("setSessionCookie"),E=y("cookie");class T{static initialize(t){if(d(this,m)[m]=t,d(this,O)[O]=new o.default(window.location.search),!d(this,O)[O].has("preview")){var e=d(this,O)[O].get("session")||d(this,E)[E];e&&"undefined"!==e&&"null"!==e?(d(this,v)[v]=e,d(this,_)[_]()):d(this,P)[P]().then((t=>{d(this,v)[v]=t.id,d(this,_)[_]()}))}}static track(t){var e=arguments,r=this;return l((function*(){var o=e.length>1&&void 0!==e[1]?e[1]:{};if(d(r,g)[g])throw new n.NotInitializedError;if(d(r,O)[O].has("preview"))return new i.default(!0,{received:!0});var s=yield fetch(b+"track/events",{headers:d(r,j)[j],method:"post",body:JSON.stringify(c(c({session:r.session,action:t},o),{},{url:o&&o.url||window.location.href}))});return new i.default(200===s.status,yield s.json())}))()}static on(e,r){if(t.default.invalid(e))throw new s.InvalidEvent(e);d(this,w)[w].addSubscriber(e,r)}static removeEventListener(e,r){if(t.default.invalid(e))throw new s.InvalidEvent(e);d(this,w)[w].removeSubscriber(e,r)}static get session(){if(d(this,g)[g])throw new n.NotInitializedError;return d(this,v)[v]}static get isInitialized(){return void 0!==d(this,v)[v]}}function A(){return(A=l((function*(){if(d(this,g)[g])throw new n.NotInitializedError;var t=b+"track/sessions";return this.mintingPromise=yield fetch(t,{method:"post",headers:{Authorization:"Bearer ".concat(d(this,m)[m])}}),this.mintingPromise.json()}))).apply(this,arguments)}Object.defineProperty(T,E,{get:function(){var t;return null===(t=document.cookie.match("(^|;)\\s*hello_session\\s*=\\s*([^;]+)"))||void 0===t?void 0:t.pop()},set:void 0}),Object.defineProperty(T,_,{value:function(){if(d(this,g)[g])throw new n.NotInitializedError;d(this,w)[w].listeners&&d(this,w)[w].emit("session-set",d(this,v)[v]),document.cookie="hello_session=".concat(d(this,v)[v])}}),Object.defineProperty(T,j,{get:function(){if(d(this,g)[g])throw new n.NotInitializedError;return{Authorization:"Bearer ".concat(d(this,m)[m]),Accept:"application.json","Content-Type":"application/json"}},set:void 0}),Object.defineProperty(T,P,{value:function(){return A.apply(this,arguments)}}),Object.defineProperty(T,g,{get:function(){return void 0===d(this,m)[m]},set:void 0}),Object.defineProperty(T,v,{writable:!0,value:void 0}),Object.defineProperty(T,m,{writable:!0,value:void 0}),Object.defineProperty(T,w,{writable:!0,value:new e.default}),Object.defineProperty(T,O,{writable:!0,value:void 0})})()})();
|
|
1
|
+
(()=>{"use strict";var e={413:(e,t)=>{function r(e){var t="function"==typeof Map?new Map:void 0;return r=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,o)}function o(){return n(e,arguments,a(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),i(o,e)},r(e)}function n(e,t,r){return n=o()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&i(o,r.prototype),o},n.apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidEvent=void 0;var s=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&i(e,t)}(u,e);var t,r,n,s=(r=u,n=o(),function(){var e,t=a(r);if(n){var o=a(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function u(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(t=s.call(this,"".concat(e," is not valid. Please provide a valid event name"))).name="InvalidEvent",t}return t=u,Object.defineProperty(t,"prototype",{writable:!1}),t}(r(Error));t.InvalidEvent=s},215:(e,t)=>{function r(e){var t="function"==typeof Map?new Map:void 0;return r=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,o)}function o(){return n(e,arguments,a(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),i(o,e)},r(e)}function n(e,t,r){return n=o()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&i(o,r.prototype),o},n.apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.NotInitializedError=void 0;var s=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&i(e,t)}(u,e);var t,r,n,s=(r=u,n=o(),function(){var e,t=a(r);if(n){var o=a(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function u(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(e=s.call(this,"You need to initialize before tracking events. Call Hellotext.initialize and pass your public business id")).name="NotInitializedError",e}return t=u,Object.defineProperty(t,"prototype",{writable:!1}),t}(r(Error));t.NotInitializedError=s},372:(e,t)=>{function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(void 0,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?o:String(o)),n)}var o}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n;return t=e,n=[{key:"valid",value:function(t){return e.exists(t)}},{key:"invalid",value:function(e){return!this.valid(e)}},{key:"exists",value:function(e){return void 0!==this.events.find((t=>t===e))}}],null&&r(t.prototype,null),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=n,n.events=["session-set"]},179:(e,t)=>{function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e,t,r){return(t=a(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function a(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.subscribers={}}var t,r;return t=e,(r=[{key:"addSubscriber",value:function(e,t){this.subscribers=n(n({},this.subscribers),{},{[e]:this.subscribers[e]?[...this.subscribers[e],t]:[t]})}},{key:"removeSubscriber",value:function(e,t){this.subscribers[e]&&(this.subscribers[e]=this.subscribers[e].filter((e=>e!==t)))}},{key:"emit",value:function(e,t){this.subscribers[e].forEach((e=>{e(t)}))}},{key:"listeners",get:function(){return 0!==Object.keys(this.subscribers).length}}])&&i(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=s},474:(e,t)=>{function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(void 0,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?o:String(o)),n)}var o}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.urlSearchParams=new URLSearchParams(t)}var t,n;return t=e,(n=[{key:"get",value:function(e){return this.urlSearchParams.get(this.toHellotextParam(e))}},{key:"has",value:function(e){return this.urlSearchParams.has(this.toHellotextParam(e))}},{key:"toHellotextParam",value:function(e){return"hello_".concat(e)}}])&&r(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=n},310:(e,t)=>{function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(void 0,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?o:String(o)),n)}var o}function n(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=0;function i(e){return"__private_"+o+++"_"+e}var a=i("success"),s=i("response"),u=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Object.defineProperty(this,a,{writable:!0,value:void 0}),Object.defineProperty(this,s,{writable:!0,value:void 0}),n(this,a)[a]=t,n(this,s)[s]=r}var t,o;return t=e,(o=[{key:"data",get:function(){return n(this,s)[s]}},{key:"failed",get:function(){return!1===n(this,a)[a]}},{key:"succeeded",get:function(){return!0===n(this,a)[a]}}])&&r(t.prototype,o),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=u}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==e&&e,t={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(t.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=ArrayBuffer.isView||function(e){return e&&r.indexOf(Object.prototype.toString.call(e))>-1};function o(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function i(e){return"string"!=typeof e&&(e=String(e)),e}function a(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function s(e){this.map={},e instanceof s?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function u(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function f(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function l(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function p(){return this.bodyUsed=!1,this._initBody=function(e){var r;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:t.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:t.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():t.arrayBuffer&&t.blob&&(r=e)&&DataView.prototype.isPrototypeOf(r)?(this._bodyArrayBuffer=l(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):t.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||n(e))?this._bodyArrayBuffer=l(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=u(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?u(this)||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer)):this.blob().then(f)}),this.text=function(){var e,t,r,n=u(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,r=c(t=new FileReader),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},t.formData&&(this.formData=function(){return this.text().then(d)}),this.json=function(){return this.text().then(JSON.parse)},this}s.prototype.append=function(e,t){e=o(e),t=i(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},s.prototype.delete=function(e){delete this.map[o(e)]},s.prototype.get=function(e){return e=o(e),this.has(e)?this.map[e]:null},s.prototype.has=function(e){return this.map.hasOwnProperty(o(e))},s.prototype.set=function(e,t){this.map[o(e)]=i(t)},s.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},s.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),a(e)},s.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),a(e)},s.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),a(e)},t.iterable&&(s.prototype[Symbol.iterator]=s.prototype.entries);var h=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function y(e,t){if(!(this instanceof y))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,n,o=(t=t||{}).body;if(e instanceof y){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new s(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new s(t.headers)),this.method=(n=(r=t.method||this.method||"GET").toUpperCase(),h.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(o),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var i=/([?&])_=[^&]*/;i.test(this.url)?this.url=this.url.replace(i,"$1_="+(new Date).getTime()):this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}function d(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(o))}})),t}function b(e,t){if(!(this instanceof b))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new s(t.headers),this.url=t.url||"",this._initBody(e)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},p.call(y.prototype),p.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new s(this.headers),url:this.url})},b.error=function(){var e=new b(null,{status:0,statusText:""});return e.type="error",e};var v=[301,302,303,307,308];b.redirect=function(e,t){if(-1===v.indexOf(t))throw new RangeError("Invalid status code");return new b(null,{status:t,headers:{location:e}})};var w=e.DOMException;try{new w}catch(e){(w=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack}).prototype=Object.create(Error.prototype),w.prototype.constructor=w}function m(r,n){return new Promise((function(o,a){var u=new y(r,n);if(u.signal&&u.signal.aborted)return a(new w("Aborted","AbortError"));var c=new XMLHttpRequest;function f(){c.abort()}c.onload=function(){var e,t,r={status:c.status,statusText:c.statusText,headers:(e=c.getAllResponseHeaders()||"",t=new s,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();t.append(n,o)}})),t)};r.url="responseURL"in c?c.responseURL:r.headers.get("X-Request-URL");var n="response"in c?c.response:c.responseText;setTimeout((function(){o(new b(n,r))}),0)},c.onerror=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},c.ontimeout=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},c.onabort=function(){setTimeout((function(){a(new w("Aborted","AbortError"))}),0)},c.open(u.method,function(t){try{return""===t&&e.location.href?e.location.href:t}catch(e){return t}}(u.url),!0),"include"===u.credentials?c.withCredentials=!0:"omit"===u.credentials&&(c.withCredentials=!1),"responseType"in c&&(t.blob?c.responseType="blob":t.arrayBuffer&&u.headers.get("Content-Type")&&-1!==u.headers.get("Content-Type").indexOf("application/octet-stream")&&(c.responseType="arraybuffer")),!n||"object"!=typeof n.headers||n.headers instanceof s?u.headers.forEach((function(e,t){c.setRequestHeader(t,e)})):Object.getOwnPropertyNames(n.headers).forEach((function(e){c.setRequestHeader(e,i(n.headers[e]))})),u.signal&&(u.signal.addEventListener("abort",f),c.onreadystatechange=function(){4===c.readyState&&u.signal.removeEventListener("abort",f)}),c.send(void 0===u._bodyInit?null:u._bodyInit)}))}m.polyfill=!0,e.fetch||(e.fetch=m,e.Headers=s,e.Request=y,e.Response=b)})(),(()=>{var e=s(r(372)),t=s(r(179)),n=s(r(310)),o=s(r(474)),i=r(215),a=r(413);function s(e){return e&&e.__esModule?e:{default:e}}function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){f(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function f(e,t,r){return(t=y(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function p(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){l(i,n,o,a,s,"next",e)}function s(e){l(i,n,o,a,s,"throw",e)}a(void 0)}))}}function h(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,y(n.key),n)}}function y(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}function d(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var b=0;function v(e){return"__private_"+b+++"_"+e}var w="https://api.hellotext.com/v1/",m=v("session"),O=v("business"),P=v("eventEmitter"),g=v("query"),j=v("notInitialized"),_=v("mintAnonymousSession"),E=v("headers"),T=v("setSessionCookie"),S=v("cookie"),A=function(){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t)}var r,s,u;return r=t,null,s=[{key:"initialize",value:function(e){if(d(this,O)[O]=e,d(this,g)[g]=new o.default(window.location.search),!d(this,g)[g].has("preview")){var t=d(this,g)[g].get("session")||d(this,S)[S];t&&"undefined"!==t&&"null"!==t?(d(this,m)[m]=t,d(this,T)[T]()):d(this,_)[_]().then((e=>{d(this,m)[m]=e.id,d(this,T)[T]()}))}}},{key:"track",value:(u=p((function*(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(d(this,j)[j])throw new i.NotInitializedError;if(d(this,g)[g].has("preview"))return new n.default(!0,{received:!0});var r=yield fetch(w+"track/events",{headers:d(this,E)[E],method:"post",body:JSON.stringify(c(c({session:this.session,action:e},t),{},{url:t&&t.url||window.location.href}))});return new n.default(200===r.status,yield r.json())})),function(e){return u.apply(this,arguments)})},{key:"on",value:function(t,r){if(e.default.invalid(t))throw new a.InvalidEvent(t);d(this,P)[P].addSubscriber(t,r)}},{key:"removeEventListener",value:function(t,r){if(e.default.invalid(t))throw new a.InvalidEvent(t);d(this,P)[P].removeSubscriber(t,r)}},{key:"session",get:function(){if(d(this,j)[j])throw new i.NotInitializedError;return d(this,m)[m]}},{key:"isInitialized",get:function(){return void 0!==d(this,m)[m]}}],s&&h(r,s),Object.defineProperty(r,"prototype",{writable:!1}),t}();function x(){return(x=p((function*(){if(d(this,j)[j])throw new i.NotInitializedError;var e=w+"track/sessions";return this.mintingPromise=yield fetch(e,{method:"post",headers:{Authorization:"Bearer ".concat(d(this,O)[O])}}),this.mintingPromise.json()}))).apply(this,arguments)}Object.defineProperty(A,S,{get:function(){var e;return null===(e=document.cookie.match("(^|;)\\s*hello_session\\s*=\\s*([^;]+)"))||void 0===e?void 0:e.pop()},set:void 0}),Object.defineProperty(A,T,{value:function(){if(d(this,j)[j])throw new i.NotInitializedError;d(this,P)[P].listeners&&d(this,P)[P].emit("session-set",d(this,m)[m]),document.cookie="hello_session=".concat(d(this,m)[m])}}),Object.defineProperty(A,E,{get:function(){if(d(this,j)[j])throw new i.NotInitializedError;return{Authorization:"Bearer ".concat(d(this,O)[O]),Accept:"application.json","Content-Type":"application/json"}},set:void 0}),Object.defineProperty(A,_,{value:function(){return x.apply(this,arguments)}}),Object.defineProperty(A,j,{get:function(){return void 0===d(this,O)[O]},set:void 0}),Object.defineProperty(A,m,{writable:!0,value:void 0}),Object.defineProperty(A,O,{writable:!0,value:void 0}),Object.defineProperty(A,P,{writable:!0,value:new t.default}),Object.defineProperty(A,g,{writable:!0,value:void 0})})()})();
|
|
@@ -4,10 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.InvalidEvent = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
8
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
13
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
15
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
16
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
17
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
18
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
|
+
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
20
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
21
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
+
var InvalidEvent = /*#__PURE__*/function (_Error) {
|
|
23
|
+
_inherits(InvalidEvent, _Error);
|
|
24
|
+
var _super = _createSuper(InvalidEvent);
|
|
25
|
+
function InvalidEvent(event) {
|
|
26
|
+
var _this;
|
|
27
|
+
_classCallCheck(this, InvalidEvent);
|
|
28
|
+
_this = _super.call(this, "".concat(event, " is not valid. Please provide a valid event name"));
|
|
29
|
+
_this.name = 'InvalidEvent';
|
|
30
|
+
return _this;
|
|
11
31
|
}
|
|
12
|
-
|
|
32
|
+
return _createClass(InvalidEvent);
|
|
33
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
13
34
|
exports.InvalidEvent = InvalidEvent;
|
|
@@ -4,10 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.NotInitializedError = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
8
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
13
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
15
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
16
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
17
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
18
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
|
+
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
20
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
21
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
+
var NotInitializedError = /*#__PURE__*/function (_Error) {
|
|
23
|
+
_inherits(NotInitializedError, _Error);
|
|
24
|
+
var _super = _createSuper(NotInitializedError);
|
|
25
|
+
function NotInitializedError() {
|
|
26
|
+
var _this;
|
|
27
|
+
_classCallCheck(this, NotInitializedError);
|
|
28
|
+
_this = _super.call(this, 'You need to initialize before tracking events. Call Hellotext.initialize and pass your public business id');
|
|
29
|
+
_this.name = 'NotInitializedError';
|
|
30
|
+
return _this;
|
|
11
31
|
}
|
|
12
|
-
|
|
32
|
+
return _createClass(NotInitializedError);
|
|
33
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
13
34
|
exports.NotInitializedError = NotInitializedError;
|
package/lib/event.js
CHANGED
|
@@ -4,16 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
class
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
+
var Event = /*#__PURE__*/function () {
|
|
13
|
+
function Event() {
|
|
14
|
+
_classCallCheck(this, Event);
|
|
10
15
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
16
|
+
_createClass(Event, null, [{
|
|
17
|
+
key: "valid",
|
|
18
|
+
value: function valid(name) {
|
|
19
|
+
return Event.exists(name);
|
|
20
|
+
}
|
|
21
|
+
}, {
|
|
22
|
+
key: "invalid",
|
|
23
|
+
value: function invalid(name) {
|
|
24
|
+
return !this.valid(name);
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
key: "exists",
|
|
28
|
+
value: function exists(name) {
|
|
29
|
+
return this.events.find(eventName => eventName === name) !== undefined;
|
|
30
|
+
}
|
|
31
|
+
}]);
|
|
32
|
+
return Event;
|
|
33
|
+
}();
|
|
18
34
|
exports.default = Event;
|
|
19
35
|
Event.events = ["session-set"];
|
package/lib/eventEmitter.js
CHANGED
|
@@ -7,29 +7,43 @@ exports.default = void 0;
|
|
|
7
7
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
8
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
9
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
13
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
14
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
var EventEmitter = /*#__PURE__*/function () {
|
|
16
|
+
function EventEmitter() {
|
|
17
|
+
_classCallCheck(this, EventEmitter);
|
|
14
18
|
this.subscribers = {};
|
|
15
19
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (this.subscribers[eventName]) {
|
|
23
|
-
this.subscribers[eventName] = this.subscribers[eventName].filter(cb => cb !== callback);
|
|
20
|
+
_createClass(EventEmitter, [{
|
|
21
|
+
key: "addSubscriber",
|
|
22
|
+
value: function addSubscriber(eventName, callback) {
|
|
23
|
+
this.subscribers = _objectSpread(_objectSpread({}, this.subscribers), {}, {
|
|
24
|
+
[eventName]: this.subscribers[eventName] ? [...this.subscribers[eventName], callback] : [callback]
|
|
25
|
+
});
|
|
24
26
|
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
}, {
|
|
28
|
+
key: "removeSubscriber",
|
|
29
|
+
value: function removeSubscriber(eventName, callback) {
|
|
30
|
+
if (this.subscribers[eventName]) {
|
|
31
|
+
this.subscribers[eventName] = this.subscribers[eventName].filter(cb => cb !== callback);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}, {
|
|
35
|
+
key: "emit",
|
|
36
|
+
value: function emit(eventName, data) {
|
|
37
|
+
this.subscribers[eventName].forEach(subscriber => {
|
|
38
|
+
subscriber(data);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "listeners",
|
|
43
|
+
get: function get() {
|
|
44
|
+
return Object.keys(this.subscribers).length !== 0;
|
|
45
|
+
}
|
|
46
|
+
}]);
|
|
47
|
+
return EventEmitter;
|
|
48
|
+
}();
|
|
35
49
|
exports.default = EventEmitter;
|
package/lib/hellotext.js
CHANGED
|
@@ -14,10 +14,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
16
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
17
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
20
18
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
19
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
21
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
22
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
23
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
21
24
|
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
|
|
22
25
|
var id = 0;
|
|
23
26
|
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
|
|
@@ -31,106 +34,125 @@ var _mintAnonymousSession = /*#__PURE__*/_classPrivateFieldLooseKey("mintAnonymo
|
|
|
31
34
|
var _headers = /*#__PURE__*/_classPrivateFieldLooseKey("headers");
|
|
32
35
|
var _setSessionCookie = /*#__PURE__*/_classPrivateFieldLooseKey("setSessionCookie");
|
|
33
36
|
var _cookie = /*#__PURE__*/_classPrivateFieldLooseKey("cookie");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
_classPrivateFieldLooseBase(this,
|
|
47
|
-
|
|
48
|
-
_classPrivateFieldLooseBase(this,
|
|
49
|
-
|
|
37
|
+
var Hellotext = /*#__PURE__*/function () {
|
|
38
|
+
function Hellotext() {
|
|
39
|
+
_classCallCheck(this, Hellotext);
|
|
40
|
+
}
|
|
41
|
+
_createClass(Hellotext, null, [{
|
|
42
|
+
key: "initialize",
|
|
43
|
+
value:
|
|
44
|
+
/**
|
|
45
|
+
* initialize the module.
|
|
46
|
+
* @param business public business id
|
|
47
|
+
*/
|
|
48
|
+
function initialize(business) {
|
|
49
|
+
_classPrivateFieldLooseBase(this, _business)[_business] = business;
|
|
50
|
+
_classPrivateFieldLooseBase(this, _query)[_query] = new _query2.default(window.location.search);
|
|
51
|
+
if (_classPrivateFieldLooseBase(this, _query)[_query].has("preview")) return;
|
|
52
|
+
var session = _classPrivateFieldLooseBase(this, _query)[_query].get("session") || _classPrivateFieldLooseBase(this, _cookie)[_cookie];
|
|
53
|
+
if (session && session !== "undefined" && session !== "null") {
|
|
54
|
+
_classPrivateFieldLooseBase(this, _session)[_session] = session;
|
|
50
55
|
_classPrivateFieldLooseBase(this, _setSessionCookie)[_setSessionCookie]();
|
|
51
|
-
}
|
|
56
|
+
} else {
|
|
57
|
+
_classPrivateFieldLooseBase(this, _mintAnonymousSession)[_mintAnonymousSession]().then(response => {
|
|
58
|
+
_classPrivateFieldLooseBase(this, _session)[_session] = response.id;
|
|
59
|
+
_classPrivateFieldLooseBase(this, _setSessionCookie)[_setSessionCookie]();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
52
62
|
}
|
|
53
|
-
}
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Tracks an action that has happened on the page
|
|
66
|
+
*
|
|
67
|
+
* @param { String } action a valid action name
|
|
68
|
+
* @param { Object } params
|
|
69
|
+
* @returns {Promise<Response>}
|
|
70
|
+
*/
|
|
71
|
+
}, {
|
|
72
|
+
key: "track",
|
|
73
|
+
value: function () {
|
|
74
|
+
var _track = _asyncToGenerator(function* (action) {
|
|
75
|
+
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
76
|
+
if (_classPrivateFieldLooseBase(this, _notInitialized)[_notInitialized]) {
|
|
77
|
+
throw new _notInitializedError.NotInitializedError();
|
|
78
|
+
}
|
|
79
|
+
if (_classPrivateFieldLooseBase(this, _query)[_query].has("preview")) {
|
|
80
|
+
return new _response.default(true, {
|
|
81
|
+
received: true
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
var response = yield fetch(apiUrl + 'track/events', {
|
|
85
|
+
headers: _classPrivateFieldLooseBase(this, _headers)[_headers],
|
|
86
|
+
method: 'post',
|
|
87
|
+
body: JSON.stringify(_objectSpread(_objectSpread({
|
|
88
|
+
session: this.session,
|
|
89
|
+
action
|
|
90
|
+
}, params), {}, {
|
|
91
|
+
url: params && params.url || window.location.href
|
|
92
|
+
}))
|
|
73
93
|
});
|
|
74
|
-
|
|
75
|
-
var response = yield fetch(apiUrl + 'track/events', {
|
|
76
|
-
headers: _classPrivateFieldLooseBase(_this, _headers)[_headers],
|
|
77
|
-
method: 'post',
|
|
78
|
-
body: JSON.stringify(_objectSpread(_objectSpread({
|
|
79
|
-
session: _this.session,
|
|
80
|
-
action
|
|
81
|
-
}, params), {}, {
|
|
82
|
-
url: params && params.url || window.location.href
|
|
83
|
-
}))
|
|
94
|
+
return new _response.default(response.status === 200, yield response.json());
|
|
84
95
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
function track(_x) {
|
|
97
|
+
return _track.apply(this, arguments);
|
|
98
|
+
}
|
|
99
|
+
return track;
|
|
100
|
+
}()
|
|
101
|
+
/**
|
|
102
|
+
* Registers an event listener
|
|
103
|
+
* @param event the name of the event to listen to
|
|
104
|
+
* @param callback the callback. This method will be called with the payload
|
|
105
|
+
*/
|
|
106
|
+
}, {
|
|
107
|
+
key: "on",
|
|
108
|
+
value: function on(event, callback) {
|
|
109
|
+
if (_event.default.invalid(event)) {
|
|
110
|
+
throw new _invalidEvent.InvalidEvent(event);
|
|
111
|
+
}
|
|
112
|
+
_classPrivateFieldLooseBase(this, _eventEmitter)[_eventEmitter].addSubscriber(event, callback);
|
|
97
113
|
}
|
|
98
|
-
_classPrivateFieldLooseBase(this, _eventEmitter)[_eventEmitter].addSubscriber(event, callback);
|
|
99
|
-
}
|
|
100
114
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Removes an event listener
|
|
117
|
+
* @param event the name of the event to remove
|
|
118
|
+
* @param callback the callback to remove
|
|
119
|
+
*/
|
|
120
|
+
}, {
|
|
121
|
+
key: "removeEventListener",
|
|
122
|
+
value: function removeEventListener(event, callback) {
|
|
123
|
+
if (_event.default.invalid(event)) {
|
|
124
|
+
throw new _invalidEvent.InvalidEvent(event);
|
|
125
|
+
}
|
|
126
|
+
_classPrivateFieldLooseBase(this, _eventEmitter)[_eventEmitter].removeSubscriber(event, callback);
|
|
109
127
|
}
|
|
110
|
-
_classPrivateFieldLooseBase(this, _eventEmitter)[_eventEmitter].removeSubscriber(event, callback);
|
|
111
|
-
}
|
|
112
128
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
* @returns {String}
|
|
132
|
+
*/
|
|
133
|
+
}, {
|
|
134
|
+
key: "session",
|
|
135
|
+
get: function get() {
|
|
136
|
+
if (_classPrivateFieldLooseBase(this, _notInitialized)[_notInitialized]) {
|
|
137
|
+
throw new _notInitializedError.NotInitializedError();
|
|
138
|
+
}
|
|
139
|
+
return _classPrivateFieldLooseBase(this, _session)[_session];
|
|
120
140
|
}
|
|
121
|
-
return _classPrivateFieldLooseBase(this, _session)[_session];
|
|
122
|
-
}
|
|
123
141
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Determines if the session is set or not
|
|
144
|
+
* @returns {boolean}
|
|
145
|
+
*/
|
|
146
|
+
}, {
|
|
147
|
+
key: "isInitialized",
|
|
148
|
+
get: function get() {
|
|
149
|
+
return _classPrivateFieldLooseBase(this, _session)[_session] !== undefined;
|
|
150
|
+
}
|
|
131
151
|
|
|
132
|
-
|
|
133
|
-
}
|
|
152
|
+
// private
|
|
153
|
+
}]);
|
|
154
|
+
return Hellotext;
|
|
155
|
+
}();
|
|
134
156
|
function _get_notInitialized() {
|
|
135
157
|
return _classPrivateFieldLooseBase(this, _business)[_business] === undefined;
|
|
136
158
|
}
|
package/lib/query.js
CHANGED
|
@@ -4,18 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
class
|
|
8
|
-
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
+
var Query = /*#__PURE__*/function () {
|
|
13
|
+
function Query(urlQueries) {
|
|
14
|
+
_classCallCheck(this, Query);
|
|
9
15
|
this.urlSearchParams = new URLSearchParams(urlQueries);
|
|
10
16
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
17
|
+
_createClass(Query, [{
|
|
18
|
+
key: "get",
|
|
19
|
+
value: function get(param) {
|
|
20
|
+
return this.urlSearchParams.get(this.toHellotextParam(param));
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
key: "has",
|
|
24
|
+
value: function has(param) {
|
|
25
|
+
return this.urlSearchParams.has(this.toHellotextParam(param));
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
key: "toHellotextParam",
|
|
29
|
+
value: function toHellotextParam(param) {
|
|
30
|
+
return "hello_".concat(param);
|
|
31
|
+
}
|
|
32
|
+
}]);
|
|
33
|
+
return Query;
|
|
34
|
+
}();
|
|
21
35
|
exports.default = Query;
|
package/lib/response.js
CHANGED
|
@@ -4,13 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
12
|
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
|
|
8
13
|
var id = 0;
|
|
9
14
|
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
|
|
10
15
|
var _success = /*#__PURE__*/_classPrivateFieldLooseKey("success");
|
|
11
16
|
var _response = /*#__PURE__*/_classPrivateFieldLooseKey("response");
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
var Response = /*#__PURE__*/function () {
|
|
18
|
+
function Response(success, response) {
|
|
19
|
+
_classCallCheck(this, Response);
|
|
14
20
|
Object.defineProperty(this, _success, {
|
|
15
21
|
writable: true,
|
|
16
22
|
value: void 0
|
|
@@ -22,14 +28,22 @@ class Response {
|
|
|
22
28
|
_classPrivateFieldLooseBase(this, _success)[_success] = success;
|
|
23
29
|
_classPrivateFieldLooseBase(this, _response)[_response] = response;
|
|
24
30
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
31
|
+
_createClass(Response, [{
|
|
32
|
+
key: "data",
|
|
33
|
+
get: function get() {
|
|
34
|
+
return _classPrivateFieldLooseBase(this, _response)[_response];
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "failed",
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _classPrivateFieldLooseBase(this, _success)[_success] === false;
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "succeeded",
|
|
43
|
+
get: function get() {
|
|
44
|
+
return _classPrivateFieldLooseBase(this, _success)[_success] === true;
|
|
45
|
+
}
|
|
46
|
+
}]);
|
|
47
|
+
return Response;
|
|
48
|
+
}();
|
|
35
49
|
exports.default = Response;
|