{"_id":"@financial-times/n-spoor-client","_rev":"48-0841bd5ba8fc0f20e98cb73a096bacbe","name":"@financial-times/n-spoor-client","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.0":{"name":"@financial-times/n-spoor-client","version":"1.0.0","author":{"name":"Ifeanyi Isitor"},"license":"MIT","_id":"@financial-times/n-spoor-client@1.0.0","maintainers":[{"name":"financial-times","email":"strategic.products@ft.com"}],"homepage":"https://github.com/Financial-Times/n-spoor-client","bugs":{"url":"https://github.com/Financial-Times/n-spoor-client/issues"},"dist":{"shasum":"0fbb52809ff6f9011863561e019c816afb2e30ea","tarball":"https://registry.npmjs.org/@financial-times/n-spoor-client/-/n-spoor-client-1.0.0.tgz","integrity":"sha512-v/J5aFCTPDLNHyLi2IAnI7U27VhVfFBj9yc0xTXwpMoHSFoJwqtMQ+ZyzuWUYLqwXZbP/3yo78yl5uATt6WPww==","signatures":[{"sig":"MEQCIFCi997+jUIQJYFurYXoxMRwv2sMSvJGWIeXeX/chwnCAiB9uwfd4xF+U+HxynaOrKB+Q0YfziFzhaEMvg/PEwaKqg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/index.js","_from":".","files":["package.json","lib"],"_shasum":"0fbb52809ff6f9011863561e019c816afb2e30ea","gitHead":"386a3733681a675248397e310856807c1d38ef95","scripts":{"test":"make test"},"_npmUser":{"name":"financial-times","email":"strategic.products@ft.com"},"deprecated":"please use @financial-times/spoor-client instead","repository":{"url":"git+https://github.com/Financial-Times/n-spoor-client.git","type":"git"},"_npmVersion":"3.8.6","description":"Javascript client for the Spoor API","directories":{},"_nodeVersion":"5.10.1","dependencies":{"node-fetch":"^1.5.1","@financial-times/n-logger":"^5.3.0"},"devDependencies":{"nock":"^8.0.0","mocha":"^2.4.5","babel-cli":"^6.8.0","babel-register":"^6.8.0","babel-preset-es2015":"^6.6.0","babel-plugin-add-module-exports":"^0.1.4"},"_npmOperationalInternal":{"tmp":"tmp/n-spoor-client-1.0.0.tgz_1462376825918_0.04302681889384985","host":"packages-16-east.internal.npmjs.com"}},"1.0.1":{"name":"@financial-times/n-spoor-client","version":"1.0.1","author":{"name":"Ifeanyi Isitor"},"license":"MIT","_id":"@financial-times/n-spoor-client@1.0.1","maintainers":[{"name":"financial-times","email":"strategic.products@ft.com"}],"homepage":"https://github.com/Financial-Times/n-spoor-client","bugs":{"url":"https://github.com/Financial-Times/n-spoor-client/issues"},"dist":{"shasum":"0f2e3edd46ccb1ad76c57465b3307e1b6f483e9b","tarball":"https://registry.npmjs.org/@financial-times/n-spoor-client/-/n-spoor-client-1.0.1.tgz","integrity":"sha512-75TMBx9yrcoYisj+TYSrdOK6/7/H8ZHwTfR7ZnjaTLHvL8Zl1/J4PQtGAmfLy6ZUHk0Kd+00D7P9qIKI+jOmLw==","signatures":[{"sig":"MEQCIBioRUNY2s6Yum0gkrCGrRSBDJci2bkrhlN+fgN2WDv3AiACoUa4+c49ldTeJvUAECVF/yZzhGyXHlgpbQqZ/aUwUg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/index.js","_from":".","files":["package.json","lib"],"_shasum":"0f2e3edd46ccb1ad76c57465b3307e1b6f483e9b","gitHead":"1588904e07590d3434143cace0029f39c1762db7","scripts":{"test":"make test"},"_npmUser":{"name":"financial-times","email":"strategic.products@ft.com"},"deprecated":"please use @financial-times/spoor-client instead","repository":{"url":"git+https://github.com/Financial-Times/n-spoor-client.git","type":"git"},"_npmVersion":"3.8.6","description":"Javascript client for the Spoor API","directories":{},"_nodeVersion":"5.10.1","dependencies":{"node-fetch":"^1.5.1","@financial-times/n-logger":"^5.3.0"},"devDependencies":{"nock":"^8.0.0","mocha":"^2.4.5","babel-cli":"^6.8.0","babel-register":"^6.8.0","babel-preset-es2015":"^6.6.0","babel-plugin-add-module-exports":"^0.1.4"},"_npmOperationalInternal":{"tmp":"tmp/n-spoor-client-1.0.1.tgz_1462540419535_0.742839383194223","host":"packages-12-west.internal.npmjs.com"}},"1.1.0":{"name":"@financial-times/n-spoor-client","version":"1.1.0","author":{"name":"Ifeanyi Isitor"},"license":"MIT","_id":"@financial-times/n-spoor-client@1.1.0","maintainers":[{"name":"financial-times","email":"strategic.products@ft.com"}],"homepage":"https://github.com/Financial-Times/n-spoor-client","bugs":{"url":"https://github.com/Financial-Times/n-spoor-client/issues"},"dist":{"shasum":"8d7b0a054f3dba9482f766a9721ca2929b7119a0","tarball":"https://registry.npmjs.org/@financial-times/n-spoor-client/-/n-spoor-client-1.1.0.tgz","integrity":"sha512-MectsWdy+d7xhYL3msAcW6ek9euzjxMWTUcJZp+PQHCo9yTcTpt+zh1URX8knGvywFpnbWzFEAkuQC4voJ09ug==","signatures":[{"sig":"MEQCIGyXg9TIa8fQy7WZKRTQ6ezdOIn/g3EfHhhbUKsiQXgtAiBBkBpp9YzRU4viOvEuvmNvCklcTQJTT48vTW3RjFWrFg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/index.js","_from":".","files":["package.json","lib"],"_shasum":"8d7b0a054f3dba9482f766a9721ca2929b7119a0","gitHead":"2955c391fc72d79085f4fe353b9037d41c1616dc","scripts":{"test":"make test"},"_npmUser":{"name":"financial-times","email":"strategic.products@ft.com"},"deprecated":"please use @financial-times/spoor-client instead","repository":{"url":"git+https://github.com/Financial-Times/n-spoor-client.git","type":"git"},"_npmVersion":"3.9.0","description":"Javascript client for the Spoor API","directories":{},"_nodeVersion":"5.0.0","dependencies":{"node-fetch":"^1.5.1","@financial-times/n-logger":"^5.3.0"},"devDependencies":{"nock":"^8.0.0","mocha":"^2.4.5","babel-cli":"^6.8.0","babel-register":"^6.8.0","babel-preset-es2015":"^6.6.0","babel-plugin-add-module-exports":"^0.1.4"},"_npmOperationalInternal":{"tmp":"tmp/n-spoor-client-1.1.0.tgz_1464691178773_0.12099731434136629","host":"packages-12-west.internal.npmjs.com"}},"1.2.0":{"name":"@financial-times/n-spoor-client","version":"1.2.0","author":{"name":"Ifeanyi Isitor"},"license":"MIT","_id":"@financial-times/n-spoor-client@1.2.0","maintainers":[{"name":"financial-times","email":"strategic.products@ft.com"}],"homepage":"https://github.com/Financial-Times/n-spoor-client","bugs":{"url":"https://github.com/Financial-Times/n-spoor-client/issues"},"dist":{"shasum":"f73a8811536e263a8baa40c33a5387dbf65e68c6","tarball":"https://registry.npmjs.org/@financial-times/n-spoor-client/-/n-spoor-client-1.2.0.tgz","integrity":"sha512-94tUY67vhQyU0rPhPlg3fla9oOQQz3ASu9Djkl3Uren3NMICbJJ6Xutu8uYD5A+TQc+z8puL7fcumDX8rBx9Rw==","signatures":[{"sig":"MEQCIGefLBhlCu0/IsV7VAVXJ8IIh93q9B2EGUQkcJKjGV95AiB1gRk1TVjd+dN7z2zpERSLtEAogOHjxIK+XYXaU1JUww==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/index.js","_from":".","files":["package.json","lib"],"_shasum":"f73a8811536e263a8baa40c33a5387dbf65e68c6","gitHead":"64c7cc2e21260f21b8640e7f61454321ff2c3dd1","scripts":{"test":"make test","prepublish":"make"},"_npmUser":{"name":"financial-times","email":"strategic.products@ft.com"},"deprecated":"please use @financial-times/spoor-client instead","repository":{"url":"git+https://github.com/Financial-Times/n-spoor-client.git","type":"git"},"_npmVersion":"3.9.0","description":"Javascript client for the Spoor API","directories":{},"_nodeVersion":"5.10.1","dependencies":{"node-fetch":"^1.5.1","@financial-times/n-logger":"^5.3.0"},"devDependencies":{"nock":"^8.0.0","mocha":"^2.4.5","babel-cli":"^6.8.0","babel-register":"^6.8.0","babel-preset-es2015":"^6.6.0","babel-plugin-add-module-exports":"^0.1.4"},"_npmOperationalInternal":{"tmp":"tmp/n-spoor-client-1.2.0.tgz_1464706276260_0.4178540704306215","host":"packages-16-east.internal.npmjs.com"}}},"time":{"created":"2016-05-04T15:47:07.365Z","modified":"2026-06-23T16:03:00.190Z","1.0.0":"2016-05-04T15:47:07.365Z","1.0.1":"2016-05-06T13:13:42.023Z","1.1.0":"2016-05-31T10:39:41.217Z","1.2.0":"2016-05-31T14:51:17.203Z"},"bugs":{"url":"https://github.com/Financial-Times/n-spoor-client/issues"},"author":{"name":"Ifeanyi Isitor"},"license":"MIT","homepage":"https://github.com/Financial-Times/n-spoor-client","repository":{"url":"git+https://github.com/Financial-Times/n-spoor-client.git","type":"git"},"description":"Javascript client for the Spoor API","maintainers":[{"email":"code.management@ft.com","name":"the-ft"},{"email":"info+npm@rowanmanning.com","name":"rowanmanning"},{"email":"yay@chee.party","name":"chee"},{"email":"a@ax.gy","name":"alexwilson"},{"email":"howdy@aendra.com","name":"aendra"},{"email":"emma.lewis@ft.com","name":"emmalewis"},{"email":"lee@leemoody.co.uk","name":"notlee"},{"email":"hamza.samih@ft.com","name":"hamza.samih"},{"email":"robert.boulton@ft.com","name":"robertboulton"},{"email":"leila.micollier@ft.com","name":"leila.micollier"},{"email":"rob.godfrey@ft.com","name":"robgodfrey"}],"readme":"n-spoor-client [![Build Status](https://travis-ci.org/Financial-Times/n-spoor-client.svg?branch=master)](https://travis-ci.org/Financial-Times/n-spoor-client)\n==============\n\nNode client to send events to [Spoor](https://spoor-docs.herokuapp.com/)\n\n```shell\nnpm install -S @financial-times/n-spoor-client\n```\n\nUsage\n-----\n\n```js\nimport SpoorClient from '@financial-times/n-spoor-client';\n\nfunction expressRoute(req, res) {\n  const spoor = new SpoorClient({req});\n  spoor.submit({\n    category: 'foo-bar',\n    action: 'baz',\n    context: {\n      quux: 'frob'\n    }\n  }).then(\n    () => console.log('event successfully logged'),\n    ({payload, status, request}) => console.log(`submission failed, status ${status}`)\n  );\n}\n```\n\nAPI\n---\n\n### `new SpoorClient(options)`\n\nInitialize a Spoor client with options:\n\n| Option       | Description                                                                            |\n|--------------|----------------------------------------------------------------------------------------|\n| `source`     | String to tell Spoor where the event came from. *Required in constructor or `submit`*. |\n| `category`   | String for Spoor event categorisation. *Required in constructor or `submit`*.          |\n| `req`        | The default Express request for all events. *You must set either `req` or both `cookies` and `ua` either in constructor or `submit`*.     |\n| `cookies`    | Optional explicit `Cookie` HTTP header. Defaults to `req.get('ft-cookie-original')`.                              |\n| `ua`    | Optional explicit `User-Agent` HTTP header. Defaults to `req.get('user-agent')`.                              |\n| `product`    | String for Spoor `context.product`. Defaults to `\"next\"`.                              |\n| `apiKey`     | Defaults to `process.env.SPOOR_API_KEY`                                                |\n| `submitIf`   | Boolean. If false, the client will not submit events.                                  |\n| `inTestMode` | Boolean. Sets a context flag to tell Spoor the event is a test event.                  |\n\n### `client.submit(event)`\n\nSend an event to Spoor. Returns a promise which resolves when the event is successfully sent to Spoor, or rejects with a status object when submission fails. The event should be an object with keys:\n\n| Option       | Description                                                                                                                      |\n|--------------|----------------------------------------------------------------------------------------------------------------------------------|\n| `source`     | String to tell Spoor where the event came from. *Required in constructor or `submit`*.                                           |\n| `category`   | String for Spoor event categorisation. *Required in constructor or `submit`*.                                                    |\n| `req`        | The default Express request for all events. *You must set either `req` or both `cookies` and `ua` either in constructor or `submit`*.     |\n| `cookies`    | Optional explicit `Cookie` HTTP header. Defaults to `req.get('ft-cookie-original')`.                              |\n| `ua`    | Optional explicit `User-Agent` HTTP header. Defaults to `req.get('user-agent')`.                              |\n| `action`     | String name of the event action.                                                                                                 |\n| `context`    | Object containing metadata pertaining to the event. *Required*.                                                                  |\n| `apiKey`     | Defaults to `process.env.SPOOR_API_KEY`                                                                                          |\n| `product`    | String for Spoor `context.product`. Defaults to the SpoorClient constructor `product` value, which in turn defaults to `\"next\"`. |\n---\n\nOriginally part of [next-signup](https://github.com/Financial-Times/next-signup).\n","readmeFilename":"readme.md"}