@inploi/sdk 1.5.2 → 1.5.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/cdn/index.js +1 -1
- package/package.json +1 -1
package/cdn/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This is an inploi sdk script. Learn more at https://inploi.com
|
|
2
2
|
|
|
3
|
-
"use strict";(()=>{var
|
|
3
|
+
"use strict";(()=>{var x=Object.defineProperty,T=Object.defineProperties;var S=Object.getOwnPropertyDescriptors;var u=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var m=(e,o,t)=>o in e?x(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,c=(e,o)=>{for(var t in o||(o={}))I.call(o,t)&&m(e,t,o[t]);if(u)for(var t of u(o))_.call(o,t)&&m(e,t,o[t]);return e},f=(e,o)=>T(e,S(o));var l=(e,o,t)=>new Promise((n,i)=>{var a=r=>{try{s(t.next(r))}catch(y){i(y)}},p=r=>{try{s(t.throw(r))}catch(y){i(y)}},s=r=>r.done?n(r.value):Promise.resolve(r.value).then(a,p);s((t=t.apply(e,o)).next())});var P={sandbox:"https://preview.api.inploi.com",production:"https://api.inploi.com"},A=1,v="/analytics/log";var w=({apiClient:e,logger:o})=>({log:n=>l(void 0,null,function*(){try{let i={library:{name:"inploi-sdk",version:A},page:"request"in n&&n.request instanceof Request?{href:n.request.url,referrer:n.request.referrer,title:""}:{href:location.href,referrer:document.referrer,title:document.title}},a={event:n.event,sent_at:new Date().toISOString(),context:i,properties:n.properties,custom_properties:n.customProperties};return yield e.fetch(v,{method:"POST",body:JSON.stringify(a)}),{success:!0,data:a}}catch(i){return o.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:i}}})});var b="Unauthenticated",k="This action is unauthorized.",L=e=>{let o={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(i,...a)=>l(void 0,[i,...a],function*(t,n={}){let p=f(c({},n),{headers:c(c({},n.headers),o)}),s=yield fetch(`${e.baseUrl}${t}`,p),r=yield s.json();if(typeof r=="object"&&r!==null&&"message"in r){if(r.message===b)throw new Error("You are not authenticated.");if(r.message===k)throw new Error("You are not authorised to perform this action.");if("exception"in s)throw new Error(`API error: \u201C${r.message}\u201D`);if("errors"in s)throw new Error(`API error: \u201C${r.message}\u201D`)}return r})}};var g="%c[inploi SDK]",d="color: #65BC67; font-weight: bold;",E={warn:(...e)=>console.warn(g,d,...e),error:(...e)=>console.error(g,d,...e),info:(...e)=>console.info(g,d,...e),log:(...e)=>console.log(g,d,...e)};function h({publishableKey:e,env:o,logger:t=E}){let n=L({baseUrl:P[o],publishableKey:e}),i=w({apiClient:n,logger:t});return{registerPlugin:p=>p({logger:t,apiClient:n,analytics:i})}}typeof window.inploi!="object"&&(window.inploi={});window.process=window.process||{};window.process.env=window.process.env||{};window.process.env.NODE_ENV="production";window.inploi.initialiseSdk=h;})();
|