@splitbee/core
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -34,3 +34,3 @@ export interface RequestContext { | ||
declare type Requests = PageViewRequest | EventRequest | IdentifyRequest; | ||
export declare const splitbeeRequest: ({ path, context, body }: Requests) => Promise<void>; | ||
export declare const splitbeeRequest: ({ path, context, body }: Requests) => Promise<Response>; | ||
export {}; |
@@ -41,3 +41,15 @@ 'use strict'; | ||
body: JSON.stringify(body) | ||
})).then(function () {}); | ||
})).then(function (res) { | ||
var _temp = function () { | ||
if (typeof process.env !== undefined && res.status !== 200) { | ||
return Promise.resolve(res.json()).then(function (body) { | ||
console.log('Splitbee Error: ', body); | ||
}); | ||
} | ||
}(); | ||
return _temp && _temp.then ? _temp.then(function () { | ||
return res; | ||
}) : res; | ||
}); | ||
} catch (e) { | ||
@@ -44,0 +56,0 @@ return Promise.reject(e); |
@@ -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 n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t){var r=t.path,n=t.context,o=t.body;try{return Promise.resolve(fetch("https://hive.splitbee.io"+r,{method:"POST",headers:e({},(null==n?void 0:n.userId)&&{userId:n.userId},(null==n?void 0:n.anonymousId)&&{uid:n.anonymousId},(null==n?void 0:n.projectId)&&{sbp:n.projectId},(null==n?void 0:n.userAgent)&&{"user-agent":n.userAgent}),body:JSON.stringify(o)})).then((function(){}))}catch(e){return Promise.reject(e)}};exports.analytics={track:function(e){var r=e.event,n=e.data,o=e.context;try{return Promise.resolve(t({path:"/track",context:o,body:{event:r,data:n}})).then((function(){}))}catch(e){return Promise.reject(e)}},page:function(r){var n=r.page,o=r.data,u=r.context;try{return Promise.resolve(t({path:"/i",context:u,body:e({origin:n},(null==o?void 0:o.referrer)&&{referrer:o.referrer},(null==o?void 0:o.requestId)&&{requestId:o.requestId})})).then((function(){}))}catch(e){return Promise.reject(e)}},identify:function(e){var r=e.userData,n=e.context;try{return Promise.resolve(t({path:"/user",context:n,body:r})).then((function(){}))}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 n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t){var r=t.path,n=t.context,o=t.body;try{return Promise.resolve(fetch("https://hive.splitbee.io"+r,{method:"POST",headers:e({},(null==n?void 0:n.userId)&&{userId:n.userId},(null==n?void 0:n.anonymousId)&&{uid:n.anonymousId},(null==n?void 0:n.projectId)&&{sbp:n.projectId},(null==n?void 0:n.userAgent)&&{"user-agent":n.userAgent}),body:JSON.stringify(o)})).then((function(e){var t=function(){if(void 0!==typeof process.env&&200!==e.status)return Promise.resolve(e.json()).then((function(e){console.log("Splitbee Error: ",e)}))}();return t&&t.then?t.then((function(){return e})):e}))}catch(e){return Promise.reject(e)}};exports.analytics={track:function(e){var r=e.event,n=e.data,o=e.context;try{return Promise.resolve(t({path:"/track",context:o,body:{event:r,data:n}})).then((function(){}))}catch(e){return Promise.reject(e)}},page:function(r){var n=r.page,o=r.data,u=r.context;try{return Promise.resolve(t({path:"/i",context:u,body:e({origin:n},(null==o?void 0:o.referrer)&&{referrer:o.referrer},(null==o?void 0:o.requestId)&&{requestId:o.requestId})})).then((function(){}))}catch(e){return Promise.reject(e)}},identify:function(e){var r=e.userData,n=e.context;try{return Promise.resolve(t({path:"/user",context:n,body:r})).then((function(){}))}catch(e){return Promise.reject(e)}}}; | ||
//# sourceMappingURL=core.cjs.production.min.js.map |
@@ -37,3 +37,15 @@ function _extends() { | ||
body: JSON.stringify(body) | ||
})).then(function () {}); | ||
})).then(function (res) { | ||
var _temp = function () { | ||
if (typeof process.env !== undefined && res.status !== 200) { | ||
return Promise.resolve(res.json()).then(function (body) { | ||
console.log('Splitbee Error: ', body); | ||
}); | ||
} | ||
}(); | ||
return _temp && _temp.then ? _temp.then(function () { | ||
return res; | ||
}) : res; | ||
}); | ||
} catch (e) { | ||
@@ -40,0 +52,0 @@ return Promise.reject(e); |
{ | ||
"name": "@splitbee/core", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -39,3 +39,3 @@ export interface RequestContext { | ||
export const splitbeeRequest = async ({ path, context, body }: Requests) => { | ||
await fetch(`https://hive.splitbee.io` + path, { | ||
const res = await fetch(`https://hive.splitbee.io` + path, { | ||
method: 'POST', | ||
@@ -51,2 +51,7 @@ headers: { | ||
}); | ||
if (typeof process.env !== undefined && res.status !== 200) { | ||
const body = await res.json(); | ||
console.log('Splitbee Error: ', body); | ||
} | ||
return res; | ||
}; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28486
374