UNPKG

@botonic/plugin-flow-builder

Version:

Use Flow Builder to show your contents

42 lines 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FlowBotAction = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const core_1 = require("@botonic/core"); const tracking_1 = require("../tracking"); const content_fields_base_1 = require("./content-fields-base"); class FlowBotAction extends content_fields_base_1.ContentFieldsBase { static fromHubtypeCMS(cmsBotAction, cmsApi) { const newBotAction = new FlowBotAction(cmsBotAction.id); newBotAction.code = cmsBotAction.code; newBotAction.payload = cmsApi.createPayloadWithParams(cmsBotAction); newBotAction.followUp = cmsBotAction.follow_up; return newBotAction; } trackFlow(request) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } = (0, tracking_1.getCommonFlowContentEventArgsForContentId)(request, this.id); const eventBotAction = { action: core_1.EventAction.BotAction, flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId, flowNodeIsMeaningful: false, payload: this.payload, }; const { action } = eventBotAction, eventArgs = tslib_1.__rest(eventBotAction, ["action"]); yield (0, tracking_1.trackEvent)(request, action, eventArgs); }); } doBotAction(request) { request.session._botonic_action = `${core_1.BotonicAction.Redirect}:${this.payload}`; } toBotonic() { return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}); } } exports.FlowBotAction = FlowBotAction; //# sourceMappingURL=flow-bot-action.js.map