@splitbee/core
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -29,3 +29,16 @@ 'use strict'; | ||
try { | ||
console.log('Sending Splitbee Data'); | ||
console.log('Sending Splitbee Data', { | ||
path: path, | ||
context: context, | ||
body: body, | ||
header: _extends({}, (context === null || context === void 0 ? void 0 : context.userId) && { | ||
userId: context.userId | ||
}, (context === null || context === void 0 ? void 0 : context.anonymousId) && { | ||
uid: context.anonymousId | ||
}, (context === null || context === void 0 ? void 0 : context.projectId) && { | ||
sbp: context.projectId | ||
}, (context === null || context === void 0 ? void 0 : context.userAgent) && { | ||
'user-agent': context.userAgent | ||
}) | ||
}); | ||
return Promise.resolve(fetch("https://hive.splitbee.io" + path, { | ||
@@ -44,2 +57,4 @@ method: 'POST', | ||
})).then(function (res) { | ||
console.log(res.status); | ||
var _temp = function () { | ||
@@ -46,0 +61,0 @@ if (typeof process.env !== undefined && res.status !== 200) { |
@@ -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 console.log("Sending Splitbee Data"),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,i=r.context;try{return Promise.resolve(t({path:"/i",context:i,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 console.log("Sending Splitbee Data",{path:r,context:n,body:o,header: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})}),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){console.log(e.status);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 |
@@ -25,3 +25,16 @@ function _extends() { | ||
try { | ||
console.log('Sending Splitbee Data'); | ||
console.log('Sending Splitbee Data', { | ||
path: path, | ||
context: context, | ||
body: body, | ||
header: _extends({}, (context === null || context === void 0 ? void 0 : context.userId) && { | ||
userId: context.userId | ||
}, (context === null || context === void 0 ? void 0 : context.anonymousId) && { | ||
uid: context.anonymousId | ||
}, (context === null || context === void 0 ? void 0 : context.projectId) && { | ||
sbp: context.projectId | ||
}, (context === null || context === void 0 ? void 0 : context.userAgent) && { | ||
'user-agent': context.userAgent | ||
}) | ||
}); | ||
return Promise.resolve(fetch("https://hive.splitbee.io" + path, { | ||
@@ -40,2 +53,4 @@ method: 'POST', | ||
})).then(function (res) { | ||
console.log(res.status); | ||
var _temp = function () { | ||
@@ -42,0 +57,0 @@ if (typeof process.env !== undefined && res.status !== 200) { |
{ | ||
"name": "@splitbee/core", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -39,3 +39,13 @@ export interface RequestContext { | ||
export const splitbeeRequest = async ({ path, context, body }: Requests) => { | ||
console.log('Sending Splitbee Data'); | ||
console.log('Sending Splitbee Data', { | ||
path, | ||
context, | ||
body, | ||
header: { | ||
...(context?.userId && { userId: context.userId }), | ||
...(context?.anonymousId && { uid: context.anonymousId }), | ||
...(context?.projectId && { sbp: context.projectId }), | ||
...(context?.userAgent && { 'user-agent': context.userAgent }), | ||
}, | ||
}); | ||
const res = await fetch(`https://hive.splitbee.io` + path, { | ||
@@ -52,2 +62,3 @@ method: 'POST', | ||
}); | ||
console.log(res.status); | ||
if (typeof process.env !== undefined && res.status !== 200) { | ||
@@ -54,0 +65,0 @@ const body = await res.json(); |
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
33229
417