"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ga4_properties_1 = require("../ga4-properties");
const ga4_functions_1 = require("../ga4-functions");
const action = {
    title: 'Purchase',
    description: 'This event signifies when one or more items is purchased by a user.',
    defaultSubscription: 'type = "track" and event = "Order Completed"',
    platform: 'web',
    fields: {
        user_id: ga4_properties_1.user_id,
        coupon: { ...ga4_properties_1.coupon, default: { '@path': '$.properties.coupon' } },
        currency: { ...ga4_properties_1.currency, required: true },
        items: {
            ...ga4_properties_1.items_multi_products,
            required: true
        },
        transaction_id: { ...ga4_properties_1.transaction_id, required: true },
        shipping: ga4_properties_1.shipping,
        tax: ga4_properties_1.tax,
        value: { ...ga4_properties_1.value, default: { '@path': '$.properties.total' } },
        user_properties: ga4_properties_1.user_properties,
        params: ga4_properties_1.params
    },
    perform: (gtag, { payload }) => {
        ga4_functions_1.updateUser(payload.user_id, payload.user_properties, gtag);
        gtag('event', 'purchase', {
            currency: payload.currency,
            transaction_id: payload.transaction_id,
            value: payload.value,
            coupon: payload.coupon,
            tax: payload.tax,
            shipping: payload.shipping,
            items: payload.items,
            ...payload.params
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map