Skip to content

Commit

Permalink
refactor(plugin-flow-builder): track all follow ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Iru89 committed Jun 20, 2024
1 parent fe8958f commit a28c694
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/botonic-plugin-flow-builder/src/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ export async function trackFlowContent(
) {
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
const cmsApi = flowBuilderPlugin.cmsApi
const firstNodeContent = cmsApi.getNodeById<HtNodeWithContent>(contents[0].id)
const flowName = flowBuilderPlugin.getFlowName(firstNodeContent.flow_id)
const eventArgs = getContentEventArgs(request, {
code: firstNodeContent.code,
flowId: firstNodeContent.flow_id,
flowName,
id: firstNodeContent.id,
isMeaningful: firstNodeContent.is_meaningful ?? false,
})
await trackEvent(request, EventAction.FlowNode, eventArgs)
for (const content of contents) {
const nodeContent = cmsApi.getNodeById<HtNodeWithContent>(content.id)
const eventArgs = getContentEventArgs(request, {
code: nodeContent.code,
flowId: nodeContent.flow_id,
flowName: flowBuilderPlugin.getFlowName(nodeContent.flow_id),
id: nodeContent.id,
isMeaningful: nodeContent.is_meaningful ?? false,
})
await trackEvent(request, EventAction.FlowNode, eventArgs)
}
}

export function getContentEventArgs(
function getContentEventArgs(
request: ActionRequest,
contentInfo: {
code: string
Expand All @@ -59,12 +60,11 @@ export function getContentEventArgs(
isMeaningful: boolean
}
) {
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
const flowThreadId = request.session.flow_thread_id ?? uuid()
return {
flowThreadId,
flowId: contentInfo.flowId,
flowName: flowBuilderPlugin.getFlowName(contentInfo.flowId),
flowName: contentInfo.flowName,
flowNodeId: contentInfo.id,
flowNodeContentId: contentInfo.code,
flowNodeIsMeaningful: contentInfo.isMeaningful,
Expand Down

0 comments on commit a28c694

Please sign in to comment.