@@ -1,23 +1,21 @@
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
||||
import { deepParseVariables } from '@/features/variables/deepParseVariable'
|
||||
import { isNotEmpty } from '@typebot.io/lib'
|
||||
import { GoogleAnalyticsBlock, SessionState } from '@typebot.io/schemas'
|
||||
|
||||
export const executeGoogleAnalyticsBlock = (
|
||||
{ typebot: { variables } }: SessionState,
|
||||
{ typebot: { variables }, result }: SessionState,
|
||||
block: GoogleAnalyticsBlock
|
||||
): ExecuteIntegrationResponse => {
|
||||
const googleAnalytics = deepParseVariables(variables)(block.options)
|
||||
if (!result) return { outgoingEdgeId: block.outgoingEdgeId }
|
||||
const googleAnalytics = deepParseVariables(variables, {
|
||||
guessCorrectTypes: true,
|
||||
removeEmptyStrings: true,
|
||||
})(block.options)
|
||||
return {
|
||||
outgoingEdgeId: block.outgoingEdgeId,
|
||||
clientSideActions: [
|
||||
{
|
||||
googleAnalytics: {
|
||||
...googleAnalytics,
|
||||
value: isNotEmpty(googleAnalytics.value as string)
|
||||
? Number(googleAnalytics.value)
|
||||
: undefined,
|
||||
},
|
||||
googleAnalytics,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user