Guest User

Untitled

a guest
Jun 29th, 2021
25
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import algoliasearch from 'algoliasearch/lite';
  2. import { history as historyRouter } from 'instantsearch.js/es/lib/routers';
  3. import { singleIndex as singleIndexMapping } from 'instantsearch.js/es/lib/stateMappings';
  4.  
  5.  
  6. // Send algolia insights events
  7. // www.algolia.com/doc/guides/building-search-ui/going-further/send-insights-events/js/
  8. // www.algolia.com/doc/api-reference/widgets/insights/vue/
  9.  
  10. import aa from 'search-insights';
  11.  
  12. import { createInsightsMiddleware} from 'instantsearch.js/es/middlewares';
  13.  
  14. const insightsMiddleware = createInsightsMiddleware({
  15. insightsClient: aa,
  16. insightsInitParams: {
  17. useCookie: false,
  18. },
  19. });
  20.  
  21.  
  22. export default {
  23. props: ['tips', 'algoliaIndex', 'algoliaSearchApiKey'],
  24. data() {
  25. return {
  26. searchClient: algoliasearch(
  27. 'xxxxxxxxxxxx',
  28. this.algoliaSearchApiKey
  29. ),
  30. routing: {
  31. router: historyRouter(),
  32. stateMapping: singleIndexMapping(this.algoliaIndex),
  33. },
  34. middlewares: [insightsMiddleware]
  35. };
  36. }
  37. };
RAW Paste Data