"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const request_params_1 = require("../request-params");
const action = {
    title: 'Identify User',
    description: 'Starts a new GWEN user session. Provide the users IP and userAgent to improve the GWEN experience',
    defaultSubscription: 'type = "identify"',
    fields: {
        userId: {
            label: 'User ID',
            description: "The user's id. (Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)",
            type: 'string',
            format: 'uuid',
            required: true,
            default: {
                '@path': '$.userId'
            }
        },
        ip: {
            label: 'User IP Address',
            description: 'The IP address of the user',
            type: 'string',
            required: false,
            default: {
                '@path': '$.context.ip'
            }
        },
        userAgent: {
            label: 'User Agent',
            description: 'The userAgent string of the user',
            type: 'string',
            required: false,
            default: {
                '@path': '$.context.userAgent'
            }
        }
    },
    perform: async (request, { payload }) => {
        const { userId, ip, userAgent } = payload;
        await request(request_params_1.baseURL, {
            ...request_params_1.defaultRequestParams,
            body: JSON.stringify({
                operationName: 'UserSession',
                query: `mutation UserSession($userId: UUID!, $session: UserSessionInput) {
          userSession(userId: $userId, data: $session) {
            timestamp
          }
        }`,
                variables: {
                    userId,
                    session: {
                        ip,
                        userAgent
                    }
                }
            })
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map