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
import Insights

let client = try InsightsClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)

let response = try await client
    .pushEvents(insightsEvents: InsightsEvents(events: [
        EventsItems
            .clickedObjectIDsAfterSearch(ClickedObjectIDsAfterSearch(
                eventName: "Product Clicked",
                eventType: ClickEvent.click,
                index: "products",
                objectIDs: ["9780545139700", "9780439784542"],
                positions: [7, 6],
                queryID: "43b15df305339e827f0ac0bdc5ebcaa7",
                userToken: "user-123456",
                authenticatedUserToken: "user-123456",
                timestamp: Int64(1_641_290_601_962)
            )),
    ]))
Did you find this page helpful?
Swift API clients v9