2023-03-15 12:21:52 +01:00
|
|
|
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
|
|
|
|
import { deepParseVariables } from '@/features/variables/deepParseVariable'
|
2023-03-15 08:35:16 +01:00
|
|
|
import { GoogleAnalyticsBlock, SessionState } from '@typebot.io/schemas'
|
2022-11-29 10:02:40 +01:00
|
|
|
|
|
|
|
|
export const executeGoogleAnalyticsBlock = (
|
|
|
|
|
{ typebot: { variables } }: SessionState,
|
2023-01-27 10:54:59 +01:00
|
|
|
block: GoogleAnalyticsBlock,
|
|
|
|
|
lastBubbleBlockId?: string
|
2022-11-29 10:02:40 +01:00
|
|
|
): ExecuteIntegrationResponse => ({
|
|
|
|
|
outgoingEdgeId: block.outgoingEdgeId,
|
2023-01-26 15:26:42 +01:00
|
|
|
clientSideActions: [
|
|
|
|
|
{
|
2023-05-03 18:09:25 -04:00
|
|
|
googleAnalytics: deepParseVariables(variables, {
|
|
|
|
|
guessCorrectType: true,
|
|
|
|
|
})(block.options),
|
2023-01-27 10:54:59 +01:00
|
|
|
lastBubbleBlockId,
|
2023-01-26 15:26:42 +01:00
|
|
|
},
|
|
|
|
|
],
|
2022-11-29 10:02:40 +01:00
|
|
|
})
|