2
0
Files
bot/apps/viewer/src/features/blocks/integrations/googleAnalytics/executeGoogleAnalyticsBlock.ts

25 lines
793 B
TypeScript
Raw Normal View History

import { ExecuteIntegrationResponse } from '@/features/chat/types'
import { deepParseVariables } from '@/features/variables/deepParseVariable'
2023-05-05 13:21:04 -04:00
import { isNotEmpty } from '@typebot.io/lib'
import { GoogleAnalyticsBlock, SessionState } from '@typebot.io/schemas'
2022-11-29 10:02:40 +01:00
export const executeGoogleAnalyticsBlock = (
{ typebot: { variables } }: SessionState,
block: GoogleAnalyticsBlock
): ExecuteIntegrationResponse => {
const googleAnalytics = deepParseVariables(variables)(block.options)
return {
outgoingEdgeId: block.outgoingEdgeId,
clientSideActions: [
{
googleAnalytics: {
...googleAnalytics,
2023-05-05 13:21:04 -04:00
value: isNotEmpty(googleAnalytics.value as string)
? Number(googleAnalytics.value)
: undefined,
},
},
],
}
}