"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.trackCustomerDefaultSubscription = 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.trackCustomerDefaultSubscription = 'type = "identify"';
const trackCustomerPub = {
    fields: {
        customerId: { name: 'id', convert: actions_shared_3.enjoinString },
        anonymousID: actions_shared_1.COPY,
        email: actions_shared_1.COPY,
        isNewCustomer: actions_shared_1.COPY,
        loyaltyStatus: actions_shared_1.COPY,
        firstName: actions_shared_1.COPY,
        lastName: actions_shared_1.COPY,
        name: actions_shared_1.COPY,
        age: { convert: actions_shared_3.enjoinInteger },
        birthday: { convert: actions_shared_3.parseDate },
        language: actions_shared_1.COPY,
        addressCountry: { name: 'country' },
        addressState: { name: 'state' },
        addressCity: { name: 'city' },
        addressPostalCode: { name: 'zipCode', convert: actions_shared_3.enjoinString }
    },
    unmappedFieldObject: actions_shared_1.ROOT
};
const action = {
    title: 'Track Customer',
    description: 'Create a new customer profile or update an existing customer profile.',
    defaultSubscription: exports.trackCustomerDefaultSubscription,
    platform: 'web',
    fields: actions_shared_2.trackCustomerFields,
    perform: (friendbuyAPI, { payload }) => {
        actions_shared_3.addName(payload);
        const friendbuyPayload = actions_shared_1.mapEvent(trackCustomerPub, payload);
        friendbuyAPI.push(['track', 'customer', friendbuyPayload, true]);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map