Export events
Export events from an application.
Example
Here is an example of how to export events:
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:
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:
Event Constant userSignedUp EventType.USER_SIGNED_UP userSignedIn EventType.USER_SIGNED_IN userSignedOut EventType.USER_SIGNED_OUT tabOpened EventType.TAB_OPENED tabUrlChanged EventType.TAB_URL_CHANGED tabVisibilityChanged EventType.TAB_VISIBILITY_CHANGED locationDetected EventType.LOCATION_DETECTED clientDetected EventType.CLIENT_DETECTED pageOpened EventType.PAGE_OPENED pageLoaded EventType.PAGE_LOADED productAbandoned EventType.PRODUCT_ABANDONED productViewed EventType.PRODUCT_VIEWED cartAbandoned EventType.CART_ABANDONED cartViewed EventType.CART_VIEWED cartModified EventType.CART_MODIFIED checkoutStarted EventType.CHECKOUT_STARTED orderPlaced EventType.ORDER_PLACED nothingChanged EventType.NOTHING_CHANGED goalCompleted EventType.GOAL_COMPLETED eventOccurred EventType.EVENT_OCCURRED slotPersonalized EventType.SLOT_PERSONALIZED
Response
This endpoint returns a JSON response with the following properties:
- dataobject
The response containing exported events and pagination information.
- items
The list of exported events.
See the Event types reference for the complete event structure.
- nextCursorstring
A cursor for retrieving the next page of results.
If omitted, export starts from the beginning of the specified time window.
- metadataobject
Metadata about the workspace and application.
- organizationNamestring
The name of the organization.
- organizationSlugstring
The URL-friendly identifier of the organization.
- workspaceNamestring
The name of the workspace.
- workspaceSlugstring
The URL-friendly identifier of the workspace.
- applicationNamestring
The name of the application.
- applicationSlugstring
The URL-friendly identifier of the application.
- organizationName
Example response
Here is an example of a JSON response from this endpoint:
{ "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"}