🐛 (ga) Fix invalid variable parsing
This commit is contained in:
@@ -6,14 +6,18 @@ export const executeGoogleAnalyticsBlock = (
|
||||
{ typebot: { variables } }: SessionState,
|
||||
block: GoogleAnalyticsBlock,
|
||||
lastBubbleBlockId?: string
|
||||
): ExecuteIntegrationResponse => ({
|
||||
outgoingEdgeId: block.outgoingEdgeId,
|
||||
clientSideActions: [
|
||||
{
|
||||
googleAnalytics: deepParseVariables(variables, {
|
||||
guessCorrectType: true,
|
||||
})(block.options),
|
||||
lastBubbleBlockId,
|
||||
},
|
||||
],
|
||||
})
|
||||
): ExecuteIntegrationResponse => {
|
||||
const googleAnalytics = deepParseVariables(variables)(block.options)
|
||||
return {
|
||||
outgoingEdgeId: block.outgoingEdgeId,
|
||||
clientSideActions: [
|
||||
{
|
||||
googleAnalytics: {
|
||||
...googleAnalytics,
|
||||
value: Number(googleAnalytics.value),
|
||||
},
|
||||
lastBubbleBlockId,
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,11 @@ import {
|
||||
parseVariables,
|
||||
ParseVariablesOptions,
|
||||
} from './parseVariables'
|
||||
import { parseGuessedValueType } from './parseGuessedValueType'
|
||||
|
||||
export const deepParseVariables =
|
||||
(
|
||||
variables: Variable[],
|
||||
options: ParseVariablesOptions & {
|
||||
guessCorrectType?: boolean
|
||||
} = defaultParseVariablesOptions
|
||||
options: ParseVariablesOptions = defaultParseVariablesOptions
|
||||
) =>
|
||||
<T extends Record<string, unknown>>(object: T): T =>
|
||||
Object.keys(object).reduce<T>((newObj, key) => {
|
||||
@@ -21,9 +18,7 @@ export const deepParseVariables =
|
||||
const parsedVariable = parseVariables(variables, options)(currentValue)
|
||||
return {
|
||||
...newObj,
|
||||
[key]: options.guessCorrectType
|
||||
? parseGuessedValueType(parsedVariable)
|
||||
: parsedVariable,
|
||||
[key]: parsedVariable,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user