@objectiv/transport-xhr
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -1,2 +0,2 @@ | ||
import{makeTransportSendError as a}from"@objectiv/tracker-core";var s=({endpoint:n,events:r,console:t})=>new Promise(function(u,o){t&&(t.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Sending"),t.log("Events:"),t.log(r),t.groupEnd());let e=new XMLHttpRequest,d=!0;e.open("POST",n,d),e.setRequestHeader("Content-Type","text/plain"),e.withCredentials=!0,e.onload=()=>{e.status===200?(t&&(t.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Succeeded"),t.log("Events:"),t.log(r),t.groupEnd()),u(e.response)):(t&&(t.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Failed"),t.log("Events:"),t.log(r),t.log(`Response: ${e}`),t.groupEnd()),o(a()))},e.onerror=()=>{t&&(t.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Error"),t.log("Events:"),t.log(r),t.groupEnd()),o(a())},e.send(JSON.stringify({events:r,transport_time:Date.now()}))});import{isNonEmptyArray as l}from"@objectiv/tracker-core";var T=class{constructor(r){this.transportName="XHRTransport";var t;this.console=r.console,this.endpoint=r.endpoint,this.xmlHttpRequestFunction=(t=r.xmlHttpRequestFunction)!=null?t:s}async handle(...r){let t=await Promise.all(r);if(this.endpoint&&l(t))return this.xmlHttpRequestFunction({endpoint:this.endpoint,console:this.console,events:t})}isUsable(){return typeof XMLHttpRequest<"u"}};export{T as XHRTransport,s as defaultXHRFunction}; | ||
import{makeTransportSendError as p,TrackerConsole as t}from"@objectiv/tracker-core";var l=({endpoint:r,events:n})=>new Promise(function(o,s){t.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Sending"),t.log("Events:"),t.log(n),t.groupEnd();let e=new XMLHttpRequest,u=!0;e.open("POST",r,u),e.setRequestHeader("Content-Type","text/plain"),e.withCredentials=!0,e.onload=()=>{e.status===200?(t.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Succeeded"),t.log("Events:"),t.log(n),t.groupEnd(),o(e.response)):(t.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Failed"),t.log("Events:"),t.log(n),t.log(`Response: ${e}`),t.groupEnd(),s(p()))},e.onerror=()=>{t.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Error"),t.log("Events:"),t.log(n),t.groupEnd(),s(p())},e.send(JSON.stringify({events:n,transport_time:Date.now()}))});import{isNonEmptyArray as d}from"@objectiv/tracker-core";var c=class{constructor(n){this.transportName="XHRTransport";var o;this.endpoint=n.endpoint,this.xmlHttpRequestFunction=(o=n.xmlHttpRequestFunction)!=null?o:l}async handle(...n){let o=await Promise.all(n);if(this.endpoint&&d(o))return this.xmlHttpRequestFunction({endpoint:this.endpoint,events:o})}isUsable(){return typeof XMLHttpRequest<"u"}};export{c as XHRTransport,l as defaultXHRFunction}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { TrackerEvent, TrackerConsole, TrackerTransportConfig, TrackerTransportInterface, NonEmptyArray, TransportableEvent } from '@objectiv/tracker-core'; | ||
import { TrackerEvent, TrackerTransportInterface, NonEmptyArray, TransportableEvent } from '@objectiv/tracker-core'; | ||
@@ -6,6 +6,5 @@ /** | ||
*/ | ||
declare const defaultXHRFunction: ({ endpoint, events, console, }: { | ||
declare const defaultXHRFunction: ({ endpoint, events, }: { | ||
endpoint: string; | ||
events: [TrackerEvent, ...TrackerEvent[]]; | ||
console?: TrackerConsole | undefined; | ||
}) => Promise<unknown>; | ||
@@ -16,3 +15,3 @@ | ||
*/ | ||
declare type XHRTransportConfig = TrackerTransportConfig & { | ||
declare type XHRTransportConfig = { | ||
/** | ||
@@ -32,3 +31,2 @@ * The collector endpoint URL. | ||
declare class XHRTransport implements TrackerTransportInterface { | ||
readonly console?: TrackerConsole; | ||
readonly endpoint?: string; | ||
@@ -35,0 +33,0 @@ readonly transportName = "XHRTransport"; |
@@ -1,2 +0,2 @@ | ||
var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var c=e=>p(e,"__esModule",{value:!0});var R=(e,r)=>{for(var t in r)p(e,t,{get:r[t],enumerable:!0})},y=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of m(r))!g.call(e,o)&&(t||o!=="default")&&p(e,o,{get:()=>r[o],enumerable:!(a=f(r,o))||a.enumerable});return e};var H=(e=>(r,t)=>e&&e.get(r)||(t=y(c({}),r,1),e&&e.set(r,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var E={};R(E,{XHRTransport:()=>l,defaultXHRFunction:()=>s});var i=require("@objectiv/tracker-core"),s=({endpoint:e,events:r,console:t})=>new Promise(function(a,o){t&&(t.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Sending"),t.log("Events:"),t.log(r),t.groupEnd());let n=new XMLHttpRequest,T=!0;n.open("POST",e,T),n.setRequestHeader("Content-Type","text/plain"),n.withCredentials=!0,n.onload=()=>{n.status===200?(t&&(t.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Succeeded"),t.log("Events:"),t.log(r),t.groupEnd()),a(n.response)):(t&&(t.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Failed"),t.log("Events:"),t.log(r),t.log(`Response: ${n}`),t.groupEnd()),o((0,i.makeTransportSendError)()))},n.onerror=()=>{t&&(t.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Error"),t.log("Events:"),t.log(r),t.groupEnd()),o((0,i.makeTransportSendError)())},n.send(JSON.stringify({events:r,transport_time:Date.now()}))});var d=require("@objectiv/tracker-core");var l=class{constructor(r){this.transportName="XHRTransport";var t;this.console=r.console,this.endpoint=r.endpoint,this.xmlHttpRequestFunction=(t=r.xmlHttpRequestFunction)!=null?t:s}async handle(...r){let t=await Promise.all(r);if(this.endpoint&&(0,d.isNonEmptyArray)(t))return this.xmlHttpRequestFunction({endpoint:this.endpoint,console:this.console,events:t})}isUsable(){return typeof XMLHttpRequest<"u"}};module.exports=H(E);0&&(module.exports={XHRTransport,defaultXHRFunction}); | ||
var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var f=o=>p(o,"__esModule",{value:!0});var R=(o,t)=>{for(var e in t)p(o,e,{get:t[e],enumerable:!0})},T=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of m(t))!g.call(o,r)&&(e||r!=="default")&&p(o,r,{get:()=>t[r],enumerable:!(s=c(t,r))||s.enumerable});return o};var H=(o=>(t,e)=>o&&o.get(t)||(e=T(f({}),t,1),o&&o.set(t,e),e))(typeof WeakMap!="undefined"?new WeakMap:0);var y={};R(y,{XHRTransport:()=>u,defaultXHRFunction:()=>a});var n=require("@objectiv/tracker-core"),a=({endpoint:o,events:t})=>new Promise(function(e,s){n.TrackerConsole.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Sending"),n.TrackerConsole.log("Events:"),n.TrackerConsole.log(t),n.TrackerConsole.groupEnd();let r=new XMLHttpRequest,d=!0;r.open("POST",o,d),r.setRequestHeader("Content-Type","text/plain"),r.withCredentials=!0,r.onload=()=>{r.status===200?(n.TrackerConsole.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Succeeded"),n.TrackerConsole.log("Events:"),n.TrackerConsole.log(t),n.TrackerConsole.groupEnd(),e(r.response)):(n.TrackerConsole.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Failed"),n.TrackerConsole.log("Events:"),n.TrackerConsole.log(t),n.TrackerConsole.log(`Response: ${r}`),n.TrackerConsole.groupEnd(),s((0,n.makeTransportSendError)()))},r.onerror=()=>{n.TrackerConsole.groupCollapsed("\uFF62objectiv:XHRTransport\uFF63 Error"),n.TrackerConsole.log("Events:"),n.TrackerConsole.log(t),n.TrackerConsole.groupEnd(),s((0,n.makeTransportSendError)())},r.send(JSON.stringify({events:t,transport_time:Date.now()}))});var l=require("@objectiv/tracker-core");var u=class{constructor(t){this.transportName="XHRTransport";var e;this.endpoint=t.endpoint,this.xmlHttpRequestFunction=(e=t.xmlHttpRequestFunction)!=null?e:a}async handle(...t){let e=await Promise.all(t);if(this.endpoint&&(0,l.isNonEmptyArray)(e))return this.xmlHttpRequestFunction({endpoint:this.endpoint,events:e})}isUsable(){return typeof XMLHttpRequest<"u"}};module.exports=H(y);0&&(module.exports={XHRTransport,defaultXHRFunction}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@objectiv/transport-xhr", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "A TrackerTransport based on XMLHttpRequest API", | ||
@@ -55,16 +55,16 @@ "license": "Apache-2.0", | ||
"devDependencies": { | ||
"@objectiv/testing-tools": "^0.0.15", | ||
"@types/jest": "^27.0.3", | ||
"jest": "^27.4.5", | ||
"@objectiv/testing-tools": "^0.0.16", | ||
"@types/jest": "^27.4.1", | ||
"jest": "^27.5.1", | ||
"jest-standard-reporter": "^2.0.0", | ||
"prettier": "^2.5.1", | ||
"shx": "^0.3.3", | ||
"ts-jest": "^27.1.2", | ||
"tsup": "^5.11.13", | ||
"typescript": "^4.5.5", | ||
"shx": "^0.3.4", | ||
"ts-jest": "^27.1.3", | ||
"tsup": "^5.12.0", | ||
"typescript": "^4.6.2", | ||
"xhr-mock": "^2.5.1" | ||
}, | ||
"dependencies": { | ||
"@objectiv/tracker-core": "~0.0.15" | ||
"@objectiv/tracker-core": "~0.0.16" | ||
} | ||
} |
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
16516
48