"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.browserTrackCustomEventFields = void 0;
const actions_shared_1 = require("@segment/actions-shared");
const actions_shared_2 = require("@segment/actions-shared");
const actions_shared_3 = require("@segment/actions-shared");
exports.browserTrackCustomEventFields = actions_shared_2.trackCustomEventFields({});
const trackCustomEventPub = {
    fields: {
        eventType: actions_shared_1.DROP,
        deduplicationId: actions_shared_1.COPY,
        customerId: { name: ['customer', 'id'], convert: actions_shared_3.enjoinString },
        anonymousId: { name: ['customer', 'anonymousId'] },
        email: { name: ['customer', 'email'] },
        isNewCustomer: { name: ['customer', 'isNewCustomer'] },
        loyaltyStatus: { name: ['customer', 'loyaltyStatus'] },
        firstName: { name: ['customer', 'firstName'] },
        lastName: { name: ['customer', 'lastName'] },
        name: { name: ['customer', 'name'] },
        age: { name: ['customer', 'age'], convert: actions_shared_3.enjoinInteger },
        birthday: { name: ['customer', 'birthday'], convert: actions_shared_3.parseDate }
    },
    unmappedFieldObject: actions_shared_1.ROOT
};
const action = {
    title: 'Track Custom Event',
    description: 'Record when a customer completes any custom event that you define.',
    platform: 'web',
    fields: exports.browserTrackCustomEventFields,
    perform: (friendbuyAPI, { payload }) => {
        const analyticsPayload = actions_shared_3.moveEventPropertiesToRoot(payload);
        actions_shared_3.addName(analyticsPayload);
        const friendbuyPayload = actions_shared_1.mapEvent(trackCustomEventPub, analyticsPayload);
        friendbuyAPI.push(['track', payload.eventType, friendbuyPayload]);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map