2
0

Add Meta Pixel block

Closes #582
This commit is contained in:
Baptiste Arnaud
2023-06-28 09:52:03 +02:00
parent 92f7f3cbe2
commit 033f8f99dd
39 changed files with 826 additions and 38 deletions

View File

@@ -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,
},
],
}