Send events

Sends a list of events to the Insights API.

You can include up to 1,000 events in a single request, but the request body must be smaller than 2 MB.

Usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import algoliasearch.api.InsightsClient
import algoliasearch.config.*

val client = InsightsClient(
  appId = "ALGOLIA_APPLICATION_ID",
  apiKey = "ALGOLIA_API_KEY",
  region = Option("ALGOLIA_APPLICATION_REGION")
)

val response = Await.result(
  client.pushEvents(
    insightsEvents = InsightsEvents(
      events = Seq(
        ClickedObjectIDsAfterSearch(
          eventType = ClickEvent.withName("click"),
          eventName = "Product Clicked",
          index = "products",
          userToken = "user-123456",
          authenticatedUserToken = Some("user-123456"),
          timestamp = Some(1641290601962L),
          objectIDs = Seq("9780545139700", "9780439784542"),
          queryID = "43b15df305339e827f0ac0bdc5ebcaa7",
          positions = Seq(7, 6)
        )
      )
    )
  ),
  Duration(100, "sec")
)
Did you find this page helpful?
Scala API clients v2