Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hook/callback on searches #36

Open
KieranHunt opened this issue Mar 27, 2021 · 0 comments
Open

Add hook/callback on searches #36

KieranHunt opened this issue Mar 27, 2021 · 0 comments

Comments

@KieranHunt
Copy link

Hey!

Thanks for the great library!

We have some analytics running on our VuePress site. Currently, we're just collecting page views but would like to extend that to collect search terms too. We'll use that to align our documentation to what people are actually searching for.

What are you feelings on adding a hook to this plugin that gets called on every search? That'll be a great extension point for us to emit our metrics.

I was thinking something like this:

[
  "flexsearch",
  {
    search_options: {
      encode: "balance",
      tokenize: "reverse",
      threshold: 0,
      resolution: 3,
      depth: 3,
      doc: {
        id: "key",
        field: ["title", "headers", "content"],
      },
    },
    callbacks: {
      onSearch: (someObjectRepresentingTheSearch) => {
        // emit metrics here
      }
    }
  },
]

I don't mind doing the work, I just wanted your input whether this is something you'd like in the library and what the API should look like.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant