diff --git a/README.md b/README.md index bc650f7b..9d5458b0 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ to construct thumbnail URLs. - `RESULTS_PER_BOX`: defaults to 3 - `SENTRY_DSN`: logs exceptions to Sentry - `SENTRY_ENV`: Sentry environment for the application. Defaults to 'unknown' if unset. +- `TACOS_URL`: The GraphQL endpoint for the [TACOS](https://github.com/mitlibraries/tacos/) application. - `TIMDEX_TIMEOUT`: value to override the 6 second default for TIMDEX timeout. ## Confirming functionality after updating dependencies @@ -94,4 +95,5 @@ bin/rails test The following additional manual testing should be performed in the PR build on Heroku. -- search for a few different terms and confirm results return and are displayed in each of the boxes as appropriate. Not all boxes should return results for all searches, but comparing to production should lead to the same results (although there is a cache in production so if results don't match you might want to first clear the production cache before being overly concerned) +- Search for a few different terms and confirm results return and are displayed in each of the boxes as appropriate. Not all boxes should return results for all searches, but comparing to production should lead to the same results (although there is a cache in production so if results don't match you might want to first clear the production cache before being overly concerned) +- If the app is integrated with TACOS, the browser console should include a response from that system confirming the search string and source system. diff --git a/app/views/search/_trigger_tacos.html.erb b/app/views/search/_trigger_tacos.html.erb new file mode 100644 index 00000000..334a4ac1 --- /dev/null +++ b/app/views/search/_trigger_tacos.html.erb @@ -0,0 +1,9 @@ +$.ajax({ + type: "POST", + url: "<%= ENV.fetch('TACOS_URL', '') %>", + contentType: 'application/json', + data: '{ "query": "{ logSearchEvent( searchTerm: \\"<%= params[:q] %>\\" sourceSystem: \\"bento\\" ) { phrase } }" }', + dataType: 'json' +}).fail(function (xhr, textStatus ) { + console.log(xhr); +}); diff --git a/app/views/search/bento.html.erb b/app/views/search/bento.html.erb index 4602ea2e..a205fa61 100644 --- a/app/views/search/bento.html.erb +++ b/app/views/search/bento.html.erb @@ -55,4 +55,9 @@ <%= render partial: "trigger_search", locals: { target: 'timdex', id: 'aspace_content'} %> <%= render partial: "trigger_hint" %> + + <% if ENV.has_key?('TACOS_URL') %> + <%= render partial: "trigger_tacos" %> + <% end %> +