@splitbee/core
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -23,3 +23,3 @@ export interface RequestContext { | ||
export interface EventRequest extends GenericRequest { | ||
path: '/track'; | ||
path: '/t'; | ||
body: { | ||
@@ -26,0 +26,0 @@ event: string; |
@@ -29,16 +29,2 @@ 'use strict'; | ||
try { | ||
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, { | ||
@@ -57,4 +43,2 @@ method: 'POST', | ||
})).then(function (res) { | ||
console.log(res.status); | ||
var _temp = function () { | ||
@@ -85,3 +69,3 @@ if (typeof process.env !== undefined && res.status !== 200) { | ||
return Promise.resolve(splitbeeRequest({ | ||
path: '/track', | ||
path: '/t', | ||
context: context, | ||
@@ -88,0 +72,0 @@ body: { |
@@ -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",{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)}}}; | ||
"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:"/t",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,16 +25,2 @@ function _extends() { | ||
try { | ||
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, { | ||
@@ -53,4 +39,2 @@ method: 'POST', | ||
})).then(function (res) { | ||
console.log(res.status); | ||
var _temp = function () { | ||
@@ -81,3 +65,3 @@ if (typeof process.env !== undefined && res.status !== 200) { | ||
return Promise.resolve(splitbeeRequest({ | ||
path: '/track', | ||
path: '/t', | ||
context: context, | ||
@@ -84,0 +68,0 @@ body: { |
{ | ||
"name": "@splitbee/core", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -24,3 +24,3 @@ export interface RequestContext { | ||
export interface EventRequest extends GenericRequest { | ||
path: '/track'; | ||
path: '/t'; | ||
body: { | ||
@@ -40,13 +40,2 @@ event: string; | ||
export const splitbeeRequest = async ({ path, context, body }: Requests) => { | ||
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, { | ||
@@ -63,3 +52,2 @@ method: 'POST', | ||
}); | ||
console.log(res.status); | ||
if (typeof process.env !== undefined && res.status !== 200) { | ||
@@ -66,0 +54,0 @@ const body = await res.json(); |
@@ -14,3 +14,3 @@ import { splitbeeRequest, RequestContext, JSONType } from './api'; | ||
await splitbeeRequest({ | ||
path: '/track', | ||
path: '/t', | ||
context, | ||
@@ -17,0 +17,0 @@ body: { event, data }, |
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
28438
373