Skip to content

Commit 3ddde74

Browse files
authored
Adds record_analytics boolean flag when search is for disjunctive facet search calls (#40)
* add verbose mode to show skipped tests * adds record_analytics flag for disjunctive facets + update network snapshots
1 parent 8352321 commit 3ddde74

9 files changed

+59
-17
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"request": "launch",
1111
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
1212
"stopOnEntry": false,
13-
"args": ["--runInBand", "--forceExit", "--watch"],
13+
"args": ["--runInBand", "--forceExit", "--watch", "--verbose"],
1414
"cwd": "${workspaceRoot}",
1515
"preLaunchTask": null,
1616
"runtimeExecutable": null,

fixtures/host-2376rb.api.swiftype.com-443/disjunctive_deps_also_license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ x-swiftype-client: elastic-app-search-javascript
55
x-swiftype-client-version: 8.1.1
66
accept: */*
77
accept-encoding: gzip,deflate
8-
body: {\"query\":\"cat\",\"page\":{\"size\":0},\"filters\":{\"all\":[{\"license\":\"BSD\"}]},\"facets\":{\"dependencies\":[{\"type\":\"value\",\"size\":3}]},\"analytics\":{\"tags\":[\"Facet-Only\"]}}
8+
body: {\"query\":\"cat\",\"page\":{\"size\":0},\"filters\":{\"all\":[{\"license\":\"BSD\"}]},\"facets\":{\"dependencies\":[{\"type\":\"value\",\"size\":3}]},\"record_analytics\":false,\"analytics\":{\"tags\":[\"Facet-Only\"]}}
99

1010
HTTP/1.1 200 OK
1111
date: Thu, 27 Sep 2018 21:19:12 GMT

fixtures/host-2376rb.api.swiftype.com-443/disjunctive_deps_also_license_no_array_syntax

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ x-swiftype-client: elastic-app-search-javascript
55
x-swiftype-client-version: 8.1.1
66
accept: */*
77
accept-encoding: gzip,deflate
8-
body: {\"query\":\"cat\",\"page\":{\"size\":0},\"filters\":{\"all\":[{\"dependencies\":\"socket.io\"}]},\"facets\":{\"license\":{\"type\":\"value\",\"size\":3}},\"analytics\":{\"tags\":[\"Facet-Only\"]}}
8+
body: {\"query\":\"cat\",\"page\":{\"size\":0},\"filters\":{\"all\":[{\"dependencies\":\"socket.io\"}]},\"facets\":{\"license\":{\"type\":\"value\",\"size\":3}},\"record_analytics\":false,\"analytics\":{\"tags\":[\"Facet-Only\"]}}
99

1010
HTTP/1.1 200 OK
1111
date: Fri, 28 Sep 2018 20:07:24 GMT
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
POST /api/as/v1/engines/node-modules/search.json
2+
authorization: Bearer api-hean6g8dmxnm2shqqiag757a
3+
content-type: application/json
4+
x-swiftype-client: elastic-app-search-javascript
5+
x-swiftype-client-version: 8.1.1
6+
x-elastic-client-meta: ent=8.1.1-legacy,js=browser,t=8.1.1-legacy,ft=universal
7+
accept: */*
8+
accept-encoding: gzip,deflate
9+
body: {\"query\":\"cat\",\"page\":{\"size\":0},\"filters\":{},\"facets\":{\"license\":[{\"type\":\"value\",\"size\":3}]},\"analytics\":{\"tags\":[\"FromSERP\",\"Disjunctive\"]},\"record_analytics\":false}
10+
11+
HTTP/1.1 200 OK
12+
date: Fri, 06 May 2022 19:35:53 GMT
13+
content-type: application/json; charset=utf-8
14+
transfer-encoding: chunked
15+
connection: close
16+
vary: Accept-Encoding, Origin
17+
status: 200 OK
18+
x-frame-options: SAMEORIGIN
19+
x-xss-protection: 1; mode=block
20+
x-content-type-options: nosniff
21+
x-swiftype-backend-region: dal
22+
x-swiftype-backend-datacenter: dal10
23+
x-swiftype-backend-node: app-api03a.dal10
24+
x-ratelimit-limit: 12000
25+
x-ratelimit-remaining: 11999
26+
etag: W/"10be0071db0ead6986f2ddf45b896207"
27+
cache-control: max-age=0, private, must-revalidate
28+
x-request-id: 78e10ad9edfafd32ff71faddaaaa6292
29+
x-runtime: 0.244323
30+
x-swiftype-frontend-datacenter: dal10
31+
x-swiftype-frontend-node: web02b.dal10
32+
x-swiftype-edge-datacenter: dal10
33+
x-swiftype-edge-node: web02b.dal10
34+
35+
{"meta":{"alerts":[],"warnings":[],"page":{"current":1,"total_pages":1,"total_results":642,"size":0},"request_id":"78e10ad9edfafd32ff71faddaaaa6292"},"results":[],"facets":{"license":[{"type":"value","data":[{"value":"MIT","count":101},{"value":"BSD","count":33},{"value":"MIT/X11","count":3}]}]}}

fixtures/host-2376rb.api.swiftype.com-443/disjunctive_license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ x-swiftype-client: elastic-app-search-javascript
55
x-swiftype-client-version: 8.1.1
66
accept: */*
77
accept-encoding: gzip,deflate
8-
body: {\"query\":\"cat\",\"page\":{\"size\":0},\"filters\":{},\"facets\":{\"license\":[{\"type\":\"value\",\"size\":3}]},\"analytics\":{\"tags\":[\"Facet-Only\"]}}
8+
body: {\"query\":\"cat\",\"page\":{\"size\":0},\"filters\":{},\"facets\":{\"license\":[{\"type\":\"value\",\"size\":3}]},\"record_analytics\":false,\"analytics\":{\"tags\":[\"Facet-Only\"]}}
99

1010
HTTP/1.1 200 OK
1111
date: Thu, 27 Sep 2018 20:36:08 GMT

fixtures/host-2376rb.api.swiftype.com-443/disjunctive_license_also_deps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ x-swiftype-client: elastic-app-search-javascript
55
x-swiftype-client-version: 8.1.1
66
accept: */*
77
accept-encoding: gzip,deflate
8-
body: {\"query\":\"cat\",\"page\":{\"size\":0},\"filters\":{\"all\":[{\"dependencies\":\"socket.io\"}]},\"facets\":{\"license\":[{\"type\":\"value\",\"size\":3}]},\"analytics\":{\"tags\":[\"Facet-Only\"]}}
8+
body: {\"query\":\"cat\",\"page\":{\"size\":0},\"filters\":{\"all\":[{\"dependencies\":\"socket.io\"}]},\"facets\":{\"license\":[{\"type\":\"value\",\"size\":3}]},\"record_analytics\":false,\"analytics\":{\"tags\":[\"Facet-Only\"]}}
99

1010
HTTP/1.1 200 OK
1111
date: Thu, 27 Sep 2018 21:04:37 GMT

fixtures/host-2376rb.api.swiftype.com-443/disjunctive_license_with_override_tags

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ authorization: Bearer api-hean6g8dmxnm2shqqiag757a
33
content-type: application/json
44
x-swiftype-client: elastic-app-search-javascript
55
x-swiftype-client-version: 8.1.1
6+
x-elastic-client-meta: ent=8.1.1-legacy,js=browser,t=8.1.1-legacy,ft=universal
67
accept: */*
78
accept-encoding: gzip,deflate
8-
body: {\"query\":\"cat\",\"page\":{\"size\":0},\"filters\":{},\"facets\":{\"license\":[{\"type\":\"value\",\"size\":3}]},\"analytics\":{\"tags\":[\"FromSERP\",\"Disjunctive\"]}}
9+
body: {\"query\":\"cat\",\"page\":{\"size\":0},\"filters\":{},\"facets\":{\"license\":[{\"type\":\"value\",\"size\":3}]},\"analytics\":{\"tags\":[\"Facet-Only\"]},\"record_analytics\":false}
910

1011
HTTP/1.1 200 OK
11-
date: Thu, 27 Sep 2018 20:36:08 GMT
12+
date: Fri, 06 May 2022 15:25:51 GMT
1213
content-type: application/json; charset=utf-8
1314
transfer-encoding: chunked
1415
connection: close
@@ -17,13 +18,18 @@ status: 200 OK
1718
x-frame-options: SAMEORIGIN
1819
x-xss-protection: 1; mode=block
1920
x-content-type-options: nosniff
20-
etag: W/"d31aa222a68122cb8392577cf4a1a7f1"
21+
x-swiftype-backend-region: dal
22+
x-swiftype-backend-datacenter: dal10
23+
x-swiftype-backend-node: app-api03a.dal10
24+
x-ratelimit-limit: 12000
25+
x-ratelimit-remaining: 11998
26+
etag: W/"680394011bb0efcb7a53ebd964a1127f"
2127
cache-control: max-age=0, private, must-revalidate
22-
x-request-id: 91197d45d104a3e2281a60eecec630ff
23-
x-runtime: 0.270027
24-
x-swiftype-frontend-datacenter: dal05
25-
x-swiftype-frontend-node: web01.dal05
26-
x-swiftype-edge-datacenter: dal05
27-
x-swiftype-edge-node: web01.dal05
28+
x-request-id: 73ed894a358f45bc79fb829d2427d9d9
29+
x-runtime: 0.086157
30+
x-swiftype-frontend-datacenter: dal10
31+
x-swiftype-frontend-node: web02b.dal10
32+
x-swiftype-edge-datacenter: dal10
33+
x-swiftype-edge-node: web02b.dal10
2834

29-
{"meta":{"warnings":[],"page":{"current":1,"total_pages":642,"total_results":642,"size":1},"request_id":"91197d45d104a3e2281a60eecec630ff"},"results":[{"license":{"raw":["BSD"]},"name":{"raw":"source-map-cat"},"repository":{"raw":null},"created":{"raw":"2013-01-23T04:51:39.995Z"},"dependencies":{"raw":["coffee-script","argparse","source-map"]},"keywords":{"raw":null},"description":{"raw":"WIP cat for JS source maps."},"modified":{"raw":"2013-01-23T04:51:42.782Z"},"id":{"raw":"source-map-cat"},"version":{"raw":"0.0.0"},"owners":{"raw":["gregg@aweber.com"]},"_meta":{"score":19.12111}}],"facets":{"license":[{"type":"value","data":[{"value":"MIT","count":101},{"value":"BSD","count":33},{"value":"MIT/X11","count":3}]}]}}
35+
{"meta":{"alerts":[],"warnings":[],"page":{"current":1,"total_pages":1,"total_results":642,"size":0},"request_id":"73ed894a358f45bc79fb829d2427d9d9"},"results":[],"facets":{"license":[{"type":"value","data":[{"value":"MIT","count":101},{"value":"BSD","count":33},{"value":"MIT/X11","count":3}]}]}}

src/client.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export default class Client {
172172
return this._performSearch({
173173
...params,
174174
filters: filters.removeFilter(appliedDisjunctiveFilter).filtersJSON,
175+
record_analytics: false,
175176
page: {
176177
...page,
177178
// Set this to 0 for performance, since disjunctive queries

tests/client.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ describe("Client", () => {
225225
);
226226
});
227227

228-
// Fixture: disjunctive_license
228+
// Fixture: disjunctive_license_override_tags
229229
// Fixture: search_filter_and_multi_facet_with_tags
230230
it("will not pass tags through on disjunctive queries", async () => {
231231
// Note, this is tested implicitly by using the same disjunctive fixture as the previous test. This
@@ -401,7 +401,7 @@ describe("Client", () => {
401401
});
402402

403403
// Fixture: additional_headers
404-
it.only("should pass along additional headers", async () => {
404+
it("should pass along additional headers", async () => {
405405
const headerClient = new Client(hostIdentifier, searchKey, engineName, {
406406
additionalHeaders: { "Content-Type": "bogus/format" }
407407
});

0 commit comments

Comments
 (0)