"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const baseRequestInterface_1 = __importDefault(require("../common/baseRequestInterface"));
const transforms_1 = require("../common/transforms");
const action = {
    title: 'Track Event',
    description: 'Send an event to Nudge',
    defaultSubscription: 'type = "track"',
    fields: {
        name: {
            label: 'Event Name',
            type: 'string',
            description: 'The name of the action being performed.',
            required: true,
            default: { '@path': '$.event' }
        },
        ext_id: {
            label: 'User ID',
            type: 'string',
            description: 'The ID of the user performing the action.',
            required: true,
            default: { '@path': '$.userId' }
        },
        occurred_at: {
            label: 'Event Timestamp',
            type: 'datetime',
            description: 'The time at which the event occurred',
            required: true,
            default: {
                '@path': '$.timestamp'
            }
        },
        props: {
            label: 'Properties',
            type: 'object',
            description: 'Properties of the event',
            required: false,
            default: {
                '@path': '$.properties'
            }
        }
    },
    perform: async (request, { settings, payload }) => {
        payload.ext_id = (0, transforms_1.sanitize)(payload.ext_id);
        payload.name = (0, transforms_1.sanitize)(payload.name);
        return baseRequestInterface_1.default.track(request, settings, payload);
    },
    performBatch: async (request, { settings, payload }) => {
        payload.forEach((it) => {
            it.ext_id = (0, transforms_1.sanitize)(it.ext_id);
            it.name = (0, transforms_1.sanitize)(it.name);
        });
        return baseRequestInterface_1.default.batchTrack(request, settings, payload);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map