exportEvents
Export events from your application.
This method exports application events from a workspace, with optional filtering by event type and time window.
Signature
This method has the following signature:
exportEvents(options: EventExportOptions): Promise<{data: EventResponse}>Example
Here is an example of how to use this method:
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; }}Parameters
The following list describes the supported parameters:
- optionsEventExportOptions
The options to filter and paginate events.
- 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
- start(optional)
Return
This method returns the following response:
- 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