"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.trackSignUpDefaultSubscription = exports.browserTrackSignUpFields = 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.browserTrackSignUpFields = actions_shared_2.trackSignUpFields({ requireCustomerId: true, requireEmail: true });
exports.trackSignUpDefaultSubscription = 'event = "Signed Up"';
const trackSignUpPub = {
    fields: {
        coupon: { name: 'couponCode' },
        attributionId: actions_shared_1.COPY,
        referralCode: actions_shared_1.COPY,
        customerId: { name: 'id', convert: actions_shared_3.enjoinString },
        anonymousID: actions_shared_1.COPY,
        isNewCustomer: actions_shared_1.COPY,
        loyaltyStatus: actions_shared_1.COPY,
        email: 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 }
    },
    unmappedFieldObject: actions_shared_1.ROOT
};
const action = {
    title: 'Track Sign Up',
    description: 'Record when a customer signs up for a service.',
    defaultSubscription: exports.trackSignUpDefaultSubscription,
    platform: 'web',
    fields: exports.browserTrackSignUpFields,
    perform: (friendbuyAPI, { payload }) => {
        actions_shared_3.addName(payload);
        const friendbuyPayload = actions_shared_1.mapEvent(trackSignUpPub, payload);
        friendbuyAPI.push(['track', 'sign_up', friendbuyPayload, true]);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map