@splitbee/core
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -46,3 +46,3 @@ 'use strict'; | ||
return Promise.resolve(_catch(function () { | ||
return Promise.resolve(fetch("https://hive.splitbee.io" + path, { | ||
return Promise.resolve(fetch((process.env.SPLITBEE_CUSTOM_API || "https://hive.splitbee.io") + path, { | ||
method: 'POST', | ||
@@ -49,0 +49,0 @@ headers: _extends({}, (context === null || context === void 0 ? void 0 : context.userId) && context.userId !== '' && { |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0}),"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var t=function(t){var r=t.path,o=t.context,n=t.body;return Promise.resolve(function(e,t){try{var r=e()}catch(e){return}return r&&r.then?r.then(void 0,(function(){})):r}((function(){return Promise.resolve(fetch("https://hive.splitbee.io"+r,{method:"POST",headers:e({},(null==o?void 0:o.userId)&&""!==o.userId&&{userId:o.userId},(null==o?void 0:o.uid)&&{uid:o.uid},(null==o?void 0:o.projectId)&&{sbp:o.projectId},(null==o?void 0:o.userAgent)&&{"user-agent":o.userAgent}),body:JSON.stringify(n)})).then((function(e){function t(){return{uid:e.headers.get("uid")}}var r=function(){if(void 0!==typeof process.env&&200!==e.status)return Promise.resolve(e.json()).then((function(e){console.log("Splitbee Error: ",e)}))}();return r&&r.then?r.then(t):t()}))})))};exports.analytics={track:function(e){var r=e.event,o=e.data,n=e.context,i=e.options;try{return Promise.resolve(t({path:"/t",context:n,body:{event:r,data:o,options:i}}))}catch(e){return Promise.reject(e)}},page:function(r){var o=r.page,n=r.data,i=r.context,u=r.options;try{return Promise.resolve(t({path:"/i",context:i,body:e({page:o},(null==n?void 0:n.referrer)&&{referrer:n.referrer},(null==n?void 0:n.requestId)&&{requestId:n.requestId},{options:u})}))}catch(e){return Promise.reject(e)}},identify:function(e){var r=e.userData,o=e.context;try{return Promise.resolve(t({path:"/user",context:o,body:r}))}catch(e){return Promise.reject(e)}},end:function(e){var r=e.requestId,o=e.data,n=e.context;try{return Promise.resolve(t({path:"/end",context:n,body:{requestId:r,data:o}}))}catch(e){return Promise.reject(e)}}}; | ||
"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0}),"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var t=function(t){var r=t.path,o=t.context,n=t.body;return Promise.resolve(function(e,t){try{var r=e()}catch(e){return}return r&&r.then?r.then(void 0,(function(){})):r}((function(){return Promise.resolve(fetch((process.env.SPLITBEE_CUSTOM_API||"https://hive.splitbee.io")+r,{method:"POST",headers:e({},(null==o?void 0:o.userId)&&""!==o.userId&&{userId:o.userId},(null==o?void 0:o.uid)&&{uid:o.uid},(null==o?void 0:o.projectId)&&{sbp:o.projectId},(null==o?void 0:o.userAgent)&&{"user-agent":o.userAgent}),body:JSON.stringify(n)})).then((function(e){function t(){return{uid:e.headers.get("uid")}}var r=function(){if(void 0!==typeof process.env&&200!==e.status)return Promise.resolve(e.json()).then((function(e){console.log("Splitbee Error: ",e)}))}();return r&&r.then?r.then(t):t()}))})))};exports.analytics={track:function(e){var r=e.event,o=e.data,n=e.context,i=e.options;try{return Promise.resolve(t({path:"/t",context:n,body:{event:r,data:o,options:i}}))}catch(e){return Promise.reject(e)}},page:function(r){var o=r.page,n=r.data,i=r.context,s=r.options;try{return Promise.resolve(t({path:"/i",context:i,body:e({page:o},(null==n?void 0:n.referrer)&&{referrer:n.referrer},(null==n?void 0:n.requestId)&&{requestId:n.requestId},{options:s})}))}catch(e){return Promise.reject(e)}},identify:function(e){var r=e.userData,o=e.context;try{return Promise.resolve(t({path:"/user",context:o,body:r}))}catch(e){return Promise.reject(e)}},end:function(e){var r=e.requestId,o=e.data,n=e.context;try{return Promise.resolve(t({path:"/end",context:n,body:{requestId:r,data:o}}))}catch(e){return Promise.reject(e)}}}; | ||
//# sourceMappingURL=core.cjs.production.min.js.map |
@@ -42,3 +42,3 @@ function _extends() { | ||
return Promise.resolve(_catch(function () { | ||
return Promise.resolve(fetch("https://hive.splitbee.io" + path, { | ||
return Promise.resolve(fetch((process.env.SPLITBEE_CUSTOM_API || "https://hive.splitbee.io") + path, { | ||
method: 'POST', | ||
@@ -45,0 +45,0 @@ headers: _extends({}, (context === null || context === void 0 ? void 0 : context.userId) && context.userId !== '' && { |
{ | ||
"name": "@splitbee/core", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -98,14 +98,17 @@ export type Device = { | ||
try { | ||
const res = await fetch(`https://hive.splitbee.io` + path, { | ||
method: 'POST', | ||
headers: { | ||
...(context?.userId && | ||
context.userId !== '' && { userId: context.userId }), | ||
...(context?.uid && { uid: context.uid }), | ||
...(context?.projectId && { sbp: context.projectId }), | ||
...(context?.userAgent && { 'user-agent': context.userAgent }), | ||
// ...(event.context.page && { origin: event.context.page.url }), | ||
}, | ||
body: JSON.stringify(body), | ||
}); | ||
const res = await fetch( | ||
(process.env.SPLITBEE_CUSTOM_API || `https://hive.splitbee.io`) + path, | ||
{ | ||
method: 'POST', | ||
headers: { | ||
...(context?.userId && | ||
context.userId !== '' && { userId: context.userId }), | ||
...(context?.uid && { uid: context.uid }), | ||
...(context?.projectId && { sbp: context.projectId }), | ||
...(context?.userAgent && { 'user-agent': context.userAgent }), | ||
// ...(event.context.page && { origin: event.context.page.url }), | ||
}, | ||
body: JSON.stringify(body), | ||
} | ||
); | ||
@@ -112,0 +115,0 @@ if (typeof process.env !== undefined && res.status !== 200) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
110891
588