Skip to content
This repository has been archived by the owner on Aug 28, 2019. It is now read-only.

Commit

Permalink
Added standard client headers for reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonStoltz committed Jul 9, 2018
1 parent b67d951 commit cc8f3d5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -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"
}
}
11 changes: 7 additions & 4 deletions 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";

Expand All @@ -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
})
Expand All @@ -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()
]
Expand Down
7 changes: 5 additions & 2 deletions 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;
Expand Down Expand Up @@ -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}`, {
Expand Down
17 changes: 17 additions & 0 deletions yarn.lock
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit cc8f3d5

Please sign in to comment.