diff --git a/src/__tests__/transmission_test.js b/src/__tests__/transmission_test.js index f6e66d7..2b16dcb 100644 --- a/src/__tests__/transmission_test.js +++ b/src/__tests__/transmission_test.js @@ -530,15 +530,18 @@ describe("base transmission", () => { dataset: "test-transmission1", addition: "", probe: userAgent => - userAgent.indexOf("libhoney") === 0 && + // user-agent order: libhoney, node, no addition present + userAgent.indexOf("libhoney-js/<@LIBHONEY_JS_VERSION@>") === 0 && + userAgent.indexOf(`node/${process.version}`) > 1 && userAgent.indexOf("addition") === -1 }, { dataset: "test-transmission2", addition: "user-agent addition", probe: userAgent => - userAgent.indexOf("libhoney") === 0 && - userAgent.indexOf("addition") !== -1 + // user-agent order: libhoney, addition, node + userAgent.indexOf("libhoney-js/<@LIBHONEY_JS_VERSION@>") === 0 && + userAgent.indexOf("addition") < userAgent.indexOf(`node/${process.version}`) } ]; diff --git a/src/transmission.js b/src/transmission.js index 673f87b..5713d19 100644 --- a/src/transmission.js +++ b/src/transmission.js @@ -10,7 +10,8 @@ import superagent from "superagent"; import urljoin from "urljoin"; -const USER_AGENT = "libhoney-js/<@LIBHONEY_JS_VERSION@>"; +const LIBHONEY_VERSION = "libhoney-js/<@LIBHONEY_JS_VERSION@>"; +const NODE_VERSION = `node/${process.version}`; const _global = typeof window !== "undefined" @@ -356,10 +357,10 @@ export class Transmission { return; } - let userAgent = USER_AGENT; + let userAgent = `${LIBHONEY_VERSION} ${NODE_VERSION}`; let trimmedAddition = this._userAgentAddition.trim(); if (trimmedAddition) { - userAgent = `${USER_AGENT} ${trimmedAddition}`; + userAgent = `${LIBHONEY_VERSION} ${trimmedAddition} ${NODE_VERSION}`; } let start = Date.now();