Skip to content

Commit

Permalink
feat(core): sends a custom User Agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Stanislawski committed Nov 13, 2015
1 parent 7defdbc commit 2561154
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions lib/InstantSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let union = require('lodash/array/union');
let EventEmitter = require('events').EventEmitter;

let urlSyncWidget = require('./url-sync');
let version = require('./version');

function defaultCreateURL() { return '#'; }

Expand All @@ -19,9 +20,14 @@ function defaultCreateURL() { return '#'; }
* @param {string} [options.numberLocale] The locale used to display numbers.
* @param {string} [options.searchParameters] Initial search configuration.
* @param {string} [options.urlSync] Url synchronization configuration.
* @param {string} [options.urlSync.trackedParameters] Parameters that will be synchronized in the URL. By default, it will track the query, all the refinable attribute (facets and numeric filters), the index and the page.
* @param {string} [options.urlSync.useHash] If set to true, the url will be hash based. Otherwise, it'll use the query parameters using the modern history API.
* @param {string} [options.urlSync.threshold] Time in ms after which a new state is created in the browser history. The default value is 700.
* @param {string} [options.urlSync.trackedParameters] Parameters that will
* be synchronized in the URL. By default, it will track the query, all the
* refinable attribute (facets and numeric filters), the index and the page.
* @param {string} [options.urlSync.useHash] If set to true, the url will be
* hash based. Otherwise, it'll use the query parameters using the modern
* history API.
* @param {string} [options.urlSync.threshold] Time in ms after which a new
* state is created in the browser history. The default value is 700.
* @return {Object} the instantsearch instance
*/
class InstantSearch extends EventEmitter {
Expand All @@ -45,6 +51,7 @@ Usage: instantsearch({
}

let client = algoliasearch(appId, apiKey);
client.addAlgoliaAgent('instantsearch.js ' + version);

this.client = client;
this.helper = null;
Expand All @@ -62,7 +69,8 @@ Usage: instantsearch({
* Add a widget
* @param {Object} [widget] The widget to add
* @param {function} [widget.render] Called after each search response has been received
* @param {function} [widget.getConfiguration] Let the widget update the configuration of the search with new parameters
* @param {function} [widget.getConfiguration] Let the widget update the configuration
* of the search with new parameters
* @param {function} [widget.init] Called once before the first search
* @return {Object} the added widget
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/InstantSearch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('InstantSearch lifecycle', () => {
let search;

beforeEach(() => {
client = {algolia: 'client'};
client = {algolia: 'client', addAlgoliaAgent: () => {}};
helper = new EventEmitter();

helper.search = sinon.spy();
Expand Down

0 comments on commit 2561154

Please sign in to comment.