Export events

Export events from an application.

GET
https://api.croct.io/export/events

Example

Here is an example of how to export events:

12345678910111213141516171819202122232425262728293031
import {Configuration, EventType, ExportApi} from '@croct/export';
async function exportEvents(): Promise<void> {const api = new ExportApi(new Configuration({apiKey: '<API KEY>'}));
let cursor: string | undefined = undefined;let running = true;
while (running) {const {data: {items: events, nextCursor}} = await api.exportEvents({pageSize: 100,cursor: cursor,start: 1440990000000,end: 1441076400000,events: [EventType.PRODUCT_VIEWED,EventType.CHECKOUT_STARTED,EventType.ORDER_PLACED,],});
console.log(events);
cursor = nextCursor;running = events.length > 0;}}

Headers

This endpoint requires the following HTTP headers:

X-Api-Key
string

The API key of the application from which to export events.

Parameters

This endpoint accepts the following query parameters:

start(optional)
integer

The earliest event time to include, in milliseconds since epoch.

Only events that occurred at or after this time are included.

end(optional)
integer

The latest event time to include, in milliseconds since epoch.

Only events that occurred before this time are included. If not provided, there is no upper time limit.

pageSize(optional)
integer

The maximum number of events returned per request.

Must be between 1 and 1000.

Default:100
cursor(optional)
string

A cursor for retrieving the next page of results.

If omitted, export starts from the beginning of the specified time window.

events(optional)
string[]

The list of event types to include. By default, all event types are included.

Here are the supported event types:

EventConstant
userSignedUpEventType.USER_SIGNED_UP
userSignedInEventType.USER_SIGNED_IN
userSignedOutEventType.USER_SIGNED_OUT
tabOpenedEventType.TAB_OPENED
tabUrlChangedEventType.TAB_URL_CHANGED
tabVisibilityChangedEventType.TAB_VISIBILITY_CHANGED
locationDetectedEventType.LOCATION_DETECTED
clientDetectedEventType.CLIENT_DETECTED
pageOpenedEventType.PAGE_OPENED
pageLoadedEventType.PAGE_LOADED
productAbandonedEventType.PRODUCT_ABANDONED
productViewedEventType.PRODUCT_VIEWED
cartAbandonedEventType.CART_ABANDONED
cartViewedEventType.CART_VIEWED
cartModifiedEventType.CART_MODIFIED
checkoutStartedEventType.CHECKOUT_STARTED
orderPlacedEventType.ORDER_PLACED
nothingChangedEventType.NOTHING_CHANGED
goalCompletedEventType.GOAL_COMPLETED
eventOccurredEventType.EVENT_OCCURRED
slotPersonalizedEventType.SLOT_PERSONALIZED

Response

This endpoint returns a JSON response with the following properties:

data
object

The response containing exported events and pagination information.

items

The list of exported events.

See the Event types reference for the complete event structure.

nextCursor
string

A cursor for retrieving the next page of results.

If omitted, export starts from the beginning of the specified time window.

metadata
object

Metadata about the workspace and application.

organizationName
string

The name of the organization.

organizationSlug
string

The URL-friendly identifier of the organization.

workspaceName
string

The name of the workspace.

workspaceSlug
string

The URL-friendly identifier of the workspace.

applicationName
string

The name of the application.

applicationSlug
string

The URL-friendly identifier of the application.

Example response

Here is an example of a JSON response from this endpoint:

123456789101112131415161718192021222324252627
{  "metadata": {    "organizationName": "Acme Corp",    "organizationSlug": "acme-corp",    "workspaceName": "Production",    "workspaceSlug": "production-app",    "applicationName": "E-commerce Store",    "applicationSlug": "ecommerce-store"  },  "items": [    {      "sessionId": "343dd18a-1ab1-4298-8b19-f14880ba4e9c",      "userId": "91d286ab-654a-47a3-ae3f-a0c0d661e44d",      "timestamp": 1440990000,      "context": {        "type": "web",        "tabId": "0b032685-0a7e-4cdd-9ff1-9d3af33507a4",        "url": "https://www.example.com",      },      "payload": {        "type": "linkOpened",        "link": "https://croct.com",      }    }  ],  "nextCursor": "eyJzZXNzaW9uSWQiOiIxMjM0NSIsInRpbWVzdGFtcCI6MTYwOTQ1OTMwMDAwMH0"}