25 lines
762 B
TypeScript
25 lines
762 B
TypeScript
import { ExecuteIntegrationResponse } from '../../../types'
|
|
import { GoogleAnalyticsBlock, SessionState } from '@typebot.io/schemas'
|
|
import { deepParseVariables } from '../../../variables/deepParseVariables'
|
|
|
|
export const executeGoogleAnalyticsBlock = (
|
|
state: SessionState,
|
|
block: GoogleAnalyticsBlock
|
|
): ExecuteIntegrationResponse => {
|
|
const { typebot, resultId } = state.typebotsQueue[0]
|
|
if (!resultId || state.whatsApp)
|
|
return { outgoingEdgeId: block.outgoingEdgeId }
|
|
const googleAnalytics = deepParseVariables(typebot.variables, {
|
|
guessCorrectTypes: true,
|
|
removeEmptyStrings: true,
|
|
})(block.options)
|
|
return {
|
|
outgoingEdgeId: block.outgoingEdgeId,
|
|
clientSideActions: [
|
|
{
|
|
googleAnalytics,
|
|
},
|
|
],
|
|
}
|
|
}
|