Comparing version 1.0.0 to 1.1.0
@@ -42,4 +42,10 @@ 'use strict'; | ||
// transmission constructor, or a string "worker"/"base" to pick one of our builtin versions. | ||
// transmission constructor, or a string to pick one of our builtin versions. | ||
// we fall back to the base impl if worker or a custom implementation throws on init. | ||
// string options available are: | ||
// - "base": the default transmission implementation | ||
// - "worker": a web-worker based transmission (not currently available, see https://github.com/honeycombio/libhoney-js/issues/22) | ||
// - "mock": an implementation that accumulates all events sent | ||
// - "writer": an implementation that logs to the console all events sent | ||
// - "null": an implementation that does nothing | ||
transmission: "base", | ||
@@ -133,6 +139,4 @@ | ||
/** | ||
* The hostname for the Honeycomb API server to which to send events created through this libhoney | ||
* instance. default: https://api.honeycomb.io/ | ||
* | ||
* @type {string} | ||
* The transmission implementation in use for this libhoney instance. Useful when mocking libhoney (specify | ||
* "mock" for options.transmission, and use this field to get at the list of events sent through libhoney.) | ||
*/ | ||
@@ -368,2 +372,15 @@ | ||
}, { | ||
key: 'transmission', | ||
get: function get() { | ||
return this._transmission; | ||
} | ||
/** | ||
* The hostname for the Honeycomb API server to which to send events created through this libhoney | ||
* instance. default: https://api.honeycomb.io/ | ||
* | ||
* @type {string} | ||
*/ | ||
}, { | ||
key: 'apiHost', | ||
@@ -470,12 +487,24 @@ set: function set(v) { | ||
if (typeof transmission === "string") { | ||
if (transmission === "base") { | ||
transmission = _transmission.Transmission; | ||
} else if (transmission === "worker") { | ||
console.warn("worker implementation not ready yet. using base implementation"); | ||
transmission = _transmission.Transmission; | ||
} else { | ||
throw new Error('unknown transmission implementation "' + transmission + '".'); | ||
switch (transmission) { | ||
case "base": | ||
transmission = _transmission.Transmission; | ||
break; | ||
case "worker": | ||
console.warn("worker implementation not ready yet. using base implementation"); | ||
transmission = _transmission.Transmission; | ||
break; | ||
case "mock": | ||
transmission = _transmission.MockTransmission; | ||
break; | ||
case "writer": | ||
transmission = _transmission.WriterTransmission; | ||
break; | ||
case "null": | ||
transmission = _transmission.NullTransmission; | ||
break; | ||
default: | ||
throw new Error('unknown transmission implementation "' + transmission + '".'); | ||
} | ||
} else if (typeof transmission !== "function") { | ||
throw new Error(".transmission must be one of 'base'/'worker' or a constructor."); | ||
throw new Error(".transmission must be one of 'base'/'worker'/'mock'/'writer'/'null' or a constructor."); | ||
} | ||
@@ -482,0 +511,0 @@ |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.Transmission = exports.ValidatedEvent = undefined; | ||
exports.Transmission = exports.NullTransmission = exports.WriterTransmission = exports.MockTransmission = exports.ValidatedEvent = undefined; | ||
@@ -33,3 +33,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // Copyright 2016 Hound Technology, Inc. All rights reserved. | ||
var USER_AGENT = "libhoney-js/1.0.0"; | ||
var USER_AGENT = "libhoney-js/1.1.0"; | ||
@@ -167,2 +167,69 @@ var _global = typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : undefined; | ||
var MockTransmission = exports.MockTransmission = function () { | ||
function MockTransmission(options) { | ||
_classCallCheck(this, MockTransmission); | ||
this.constructorArg = options; | ||
this.events = []; | ||
} | ||
_createClass(MockTransmission, [{ | ||
key: 'sendEvent', | ||
value: function sendEvent(ev) { | ||
this.events.push(ev); | ||
} | ||
}, { | ||
key: 'sendPresampledEvent', | ||
value: function sendPresampledEvent(ev) { | ||
this.events.push(ev); | ||
} | ||
}, { | ||
key: 'reset', | ||
value: function reset() { | ||
this.constructorArg = null; | ||
this.events = []; | ||
} | ||
}]); | ||
return MockTransmission; | ||
}(); | ||
; | ||
var WriterTransmission = exports.WriterTransmission = function () { | ||
function WriterTransmission() { | ||
_classCallCheck(this, WriterTransmission); | ||
} | ||
_createClass(WriterTransmission, [{ | ||
key: 'sendEvent', | ||
value: function sendEvent(ev) { | ||
console.log(JSON.stringify(ev)); | ||
} | ||
}, { | ||
key: 'sendPresampledEvent', | ||
value: function sendPresampledEvent(ev) { | ||
console.log(JSON.stringify(ev)); | ||
} | ||
}]); | ||
return WriterTransmission; | ||
}(); | ||
var NullTransmission = exports.NullTransmission = function () { | ||
function NullTransmission() { | ||
_classCallCheck(this, NullTransmission); | ||
} | ||
_createClass(NullTransmission, [{ | ||
key: 'sendEvent', | ||
value: function sendEvent(ev) {} | ||
}, { | ||
key: 'sendPresampledEvent', | ||
value: function sendPresampledEvent(ev) {} | ||
}]); | ||
return NullTransmission; | ||
}(); | ||
/** | ||
@@ -169,0 +236,0 @@ * @private |
{ | ||
"name": "libhoney", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Javascript library for sending data to Honeycomb", | ||
@@ -5,0 +5,0 @@ "bugs": "https://github.com/honeycombio/libhoney-js/issues", |
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
66995
23
1347