2023-01-26 15:26:42 +01:00
|
|
|
import { executeChatwoot } from '@/features/blocks/integrations/chatwoot'
|
|
|
|
|
import { executeGoogleAnalyticsBlock } from '@/features/blocks/integrations/googleAnalytics/utils/executeGoogleAnalytics'
|
|
|
|
|
import { executeRedirect } from '@/features/blocks/logic/redirect'
|
2023-01-27 15:58:05 +01:00
|
|
|
import { executeScript } from '@/features/blocks/logic/script/executeScript'
|
2023-01-26 18:23:09 +01:00
|
|
|
import { executeWait } from '@/features/blocks/logic/wait/utils/executeWait'
|
2023-01-26 15:26:42 +01:00
|
|
|
import type { ChatReply } from 'models'
|
|
|
|
|
|
|
|
|
|
export const executeClientSideAction = async (
|
|
|
|
|
clientSideAction: NonNullable<ChatReply['clientSideActions']>[0]
|
|
|
|
|
) => {
|
|
|
|
|
if ('chatwoot' in clientSideAction) {
|
|
|
|
|
executeChatwoot(clientSideAction.chatwoot)
|
|
|
|
|
}
|
|
|
|
|
if ('googleAnalytics' in clientSideAction) {
|
|
|
|
|
executeGoogleAnalyticsBlock(clientSideAction.googleAnalytics)
|
|
|
|
|
}
|
2023-01-27 15:58:05 +01:00
|
|
|
if ('scriptToExecute' in clientSideAction) {
|
|
|
|
|
await executeScript(clientSideAction.scriptToExecute)
|
2023-01-26 15:26:42 +01:00
|
|
|
}
|
|
|
|
|
if ('redirect' in clientSideAction) {
|
|
|
|
|
executeRedirect(clientSideAction.redirect)
|
|
|
|
|
}
|
2023-01-26 18:23:09 +01:00
|
|
|
if ('wait' in clientSideAction) {
|
|
|
|
|
await executeWait(clientSideAction.wait)
|
|
|
|
|
}
|
2023-01-26 15:26:42 +01:00
|
|
|
}
|