"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.trackPageFields = exports.trackPageDefaultSubscription = void 0;
const actions_shared_1 = require("@segment/actions-shared");
exports.trackPageDefaultSubscription = 'type = "page"';
exports.trackPageFields = {
    name: {
        label: 'Page Name',
        description: 'The page name.',
        type: 'string',
        required: false,
        default: { '@path': '$.name' }
    },
    category: {
        label: 'Page Category',
        description: 'The page category.',
        type: 'string',
        required: false,
        default: { '@path': '$.category' }
    },
    title: {
        label: 'Page Title',
        description: 'The page title.',
        type: 'string',
        required: false,
        default: { '@path': '$.properties.title' }
    }
};
const action = {
    title: 'Track Page',
    description: 'Record when a customer visits a new page. Allow Friendbuy widget targeting by Page Name instead of URL.',
    defaultSubscription: exports.trackPageDefaultSubscription,
    platform: 'web',
    fields: exports.trackPageFields,
    perform: (friendbuyAPI, data) => {
        const friendbuyPayload = actions_shared_1.createFriendbuyPayload([
            ['name', data.payload.name || 'undefined'],
            ['category', data.payload.category],
            ['title', data.payload.title]
        ]);
        friendbuyAPI.push(['track', 'page', friendbuyPayload, true]);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map