diff --git a/package.json b/package.json index 1f1cd62..4aca9af 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "replay": "^2.3.0", "rollup": "^0.62.0", "rollup-plugin-babel": "^3.0.7", + "rollup-plugin-json": "^3.0.0", "rollup-plugin-uglify": "^4.0.0" } } diff --git a/rollup.config.js b/rollup.config.js index f17c409..fee0e2b 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,5 +1,6 @@ import babel from "rollup-plugin-babel"; import { uglify } from "rollup-plugin-uglify"; +import json from "rollup-plugin-json"; import pkg from "./package.json"; @@ -8,18 +9,19 @@ export default [ input: "src/swiftype_app_search.js", output: [ { - // browser-friendly UMD build + // browser-friendly UMD build, for Browsers or Node name: "SwiftypeAppSearch", file: "dist/swiftype_app_search.umd.js", format: "umd" }, { - // ES6 module build + // ES6 module build, for things like Rollup file: pkg.module, format: "es" } ], plugins: [ + json(), // So we can import thing like `package.json` as a module babel({ exclude: "node_modules/**" // only transpile our source code }) @@ -29,15 +31,16 @@ export default [ input: "src/swiftype_app_search.js", output: [ { - // Minified umd build + // Minified UMD build name: "SwiftypeAppSearch", file: "dist/swiftype_app_search.umd.min.js", format: "umd" } ], plugins: [ + json(), babel({ - exclude: "node_modules/**" // only transpile our source code + exclude: "node_modules/**" }), uglify() ] diff --git a/src/client.js b/src/client.js index d1b9954..2eb2757 100644 --- a/src/client.js +++ b/src/client.js @@ -1,7 +1,7 @@ "use strict"; +import { version, name } from "../package.json"; import ResultList from "./result_list"; - export default class Client { constructor(hostIdentifier, apiKey, engineName) { this.apiKey = apiKey; @@ -75,9 +75,12 @@ export default class Client { } _request(path, params) { + debugger; const headers = new Headers({ Authorization: `Bearer ${this.apiKey}`, - "Content-Type": "application/json" + "Content-Type": "application/json", + "X-Swiftype-Client": name, + "X-Swiftype-Client-Version": version }); return fetch(`${this.apiEndpoint}${path}`, { diff --git a/yarn.lock b/yarn.lock index 772310a..990642a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1344,6 +1344,10 @@ estree-walker@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.2.1.tgz#bdafe8095383d8414d5dc2ecf4c9173b6db9412e" +estree-walker@^0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.5.2.tgz#d3850be7529c9580d815600b53126515e146dd39" + esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" @@ -3412,6 +3416,12 @@ rollup-plugin-babel@^3.0.7: dependencies: rollup-pluginutils "^1.5.0" +rollup-plugin-json@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-json/-/rollup-plugin-json-3.0.0.tgz#aeed2ff36e6c4fd0c60c4a8fc3d0884479e9dfce" + dependencies: + rollup-pluginutils "^2.2.0" + rollup-plugin-uglify@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/rollup-plugin-uglify/-/rollup-plugin-uglify-4.0.0.tgz#6eb471738f1ce9ba7d9d4bc43b71cba02417c8fb" @@ -3426,6 +3436,13 @@ rollup-pluginutils@^1.5.0: estree-walker "^0.2.1" minimatch "^3.0.2" +rollup-pluginutils@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.3.0.tgz#478ace04bd7f6da2e724356ca798214884738fc4" + dependencies: + estree-walker "^0.5.2" + micromatch "^2.3.11" + rollup@^0.62.0: version "0.62.0" resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.62.0.tgz#4ca8b3c9582195dc9341ff8a1375f58319b95bfc"