"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const action = {
    title: 'Track',
    description: 'Send user events to Ripe',
    defaultSubscription: 'type = "track"',
    fields: {
        anonymousId: {
            type: 'string',
            allowNull: true,
            description: 'An anonymous identifier',
            label: 'Anonymous ID',
            default: { '@path': '$.anonymousId' }
        },
        userId: {
            type: 'string',
            required: false,
            description: 'The ID associated with the user',
            label: 'User ID',
            default: { '@path': '$.userId' }
        },
        event: {
            type: 'string',
            required: true,
            description: 'The event name',
            label: 'Event Name',
            default: { '@path': '$.event' }
        },
        context: {
            type: 'object',
            label: 'Context',
            description: 'Device context',
            required: false,
            default: { '@path': '$.context' }
        },
        properties: {
            type: 'object',
            required: false,
            description: 'Properties to send with the event',
            label: 'Event properties',
            default: { '@path': '$.properties' }
        },
        timestamp: {
            type: 'string',
            format: 'date-time',
            required: false,
            description: 'The timestamp of the event',
            label: 'Timestamp',
            default: { '@path': '$.timestamp' }
        },
        messageId: {
            type: 'string',
            required: false,
            description: 'The Segment messageId',
            label: 'MessageId',
            default: { '@path': '$.messageId' }
        }
    },
    perform: (request, { payload, settings }) => {
        return request(`${settings.endpoint}/track`, {
            method: 'post',
            json: {
                name: payload.event,
                anonymousId: payload.anonymousId,
                userId: payload.userId,
                context: payload.context,
                properties: payload.properties,
                event: payload.event,
                messageId: payload.messageId,
                timestamp: payload.timestamp ?? new Date()
            }
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map