Skip to content

Commit 0a2162a

Browse files
committed
Add setCollectAnalytics
1 parent f3b3bca commit 0a2162a

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ client.setSuggestionsSize(20);
7575
client.setFuzzyMatch(false);
7676
```
7777

78+
#### Collect analytics
79+
```js
80+
// Control whether search queries are sent to your AddSearch Analytics Dashboard or not (default: true)
81+
client.setCollectAnalytics(false);
82+
```
83+
7884
#### Set JSON Web Token (for authentication)
7985
```js
8086
// Add JWT to the search request (if protected search index)
@@ -218,5 +224,5 @@ npm run build
218224
Built bundle is saved under the *dist/* folder
219225

220226
## Support
221-
222-
Feel free to send any questions, ideas and suggestions at [support@addsearch.com](support@addsearch.com).
227+
Feel free to send any questions, ideas, and suggestions at [support@addsearch.com](mailto:support@addsearch.com) or
228+
visit [addsearch.com](https://www.addsearch.com/) for more information.

src/apifetch.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var executeApiFetch = function(sitekey, type, settings, cb) {
1212
const RESPONSE_SERVER_ERROR = 500;
1313

1414
var settingToQueryParam = function(setting, key) {
15-
if (setting) {
15+
if (setting || setting === false) {
1616
return '&' + key + '=' + setting;
1717
}
1818
return '';
@@ -44,6 +44,7 @@ var executeApiFetch = function(sitekey, type, settings, cb) {
4444
if (type === 'search') {
4545
qs = settingToQueryParam(settings.lang, 'lang') +
4646
settingToQueryParam(settings.fuzzy, 'fuzzy') +
47+
settingToQueryParam(settings.collectAnalytics, 'collectAnalytics') +
4748
settingToQueryParam(settings.categories, 'categories') +
4849
settingToQueryParam(settings.priceFromCents, 'priceFromCents') +
4950
settingToQueryParam(settings.priceToCents, 'priceToCents') +

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ var client = function(sitekey) {
8484
this.setFilterObject = function(filter) { this.settings.setFilterObject(filter); }
8585
this.setShuffleAndLimitTo = function(shuffleAndLimitTo) { this.settings.setShuffleAndLimitTo(shuffleAndLimitTo); }
8686
this.setFuzzyMatch = function(fuzzy) { this.settings.setFuzzyMatch(fuzzy); }
87+
this.setCollectAnalytics = function(collectAnalytics) { this.settings.setCollectAnalytics(collectAnalytics); }
8788
//this.hitClicked = function(docid, position) { sendClickHit(this.sitekey, this.settings.getSettings().keyword, docid, position); }
8889

8990
// Deprecated

src/settings.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ var settings = function() {
5151
this.settings.fuzzy = fuzzy;
5252
}
5353

54+
this.setCollectAnalytics = function(collectAnalytics) {
55+
this.settings.collectAnalytics = collectAnalytics;
56+
}
57+
5458
this.setCategoryFilters = function(categories) {
5559
this.settings.categories = categories;
5660
}

0 commit comments

Comments
 (0)