Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@searchkit/elastic-behavioral-analytics-plugin

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@searchkit/elastic-behavioral-analytics-plugin

**Requirements** Behavioral Analytics plugin requires Elasticsearch 8.8.0 or higher.

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Setup

Requirements Behavioral Analytics plugin requires Elasticsearch 8.8.0 or higher.

Follow the getting started guide to setup Behavioral Analytics.

Add the plugin to your project:

yarn add @searchkit/elastic-behavioral-analytics-plugin

Example with Instantsearch.js


import { AnalyticsMiddleware } from '@searchkit/elastic-behavioral-analytics-plugin'

const search = instantsearch({
  indexName: 'imdb_movies',
  searchClient: searchClient
})

search.addWidgets([
  // ... widgets ...
])

search.use(
  AnalyticsMiddleware({
    tracker: {
      endpoint: 'http://localhost:9200',
      collectionName: 'website',
      apiKey: 'apikey'
    },
    attributes: {
      searchClick: {
        titleField: 'title',
        urlField: 'poster'
      }
    }
  })
)

Example with Instantsearch React Hooks

Similar to Algolia insights is used.

import { AnalyticsMiddleware } from '@searchkit/elastic-behavioral-analytics-plugin'
import { useInstantSearch } from 'react-instantsearch-hooks-web';
import { useLayoutEffect } from 'react';
import Client from '@searchkit/instantsearch-client'; 

function InsightsMiddleware() {
  const { use } = useInstantSearch();

  useLayoutEffect(() => {
    const middleware = AnalyticsMiddleware({
      tracker: {
        endpoint: 'http://localhost:9200',
        collectionName: 'website',
        apiKey: 'apikey'
      },
      attributes: {
        searchClick: {
          titleField: 'title',
          urlField: 'poster'
        }
      }
    })

    return use(middleware);
  }, [use]);

  return null;
}

const searchClient = Client({
  url: '/api/product-search'
});

function App() {
  return (
    <InstantSearch indexName="instant_search" searchClient={searchClient}>
      {/* ... */}
      <InsightsMiddleware />
    </InstantSearch>
  );
}

FAQs

Package last updated on 25 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc