2
0

🐛 (googleAnalytics) Fix sendTo initial value in settings

This commit is contained in:
Baptiste Arnaud
2023-05-02 13:46:49 -04:00
parent e58016e43a
commit e2836f305c
4 changed files with 12 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
import { TextInput } from '@/components/inputs'
import { NumberInput, TextInput } from '@/components/inputs'
import {
Accordion,
AccordionButton,
@@ -31,10 +31,10 @@ export const GoogleAnalyticsSettings = ({
const updateLabel = (label: string) => onOptionsChange({ ...options, label })
const updateValue = (value?: string) =>
const updateValue = (value: number | `{{${string}}}` | undefined) =>
onOptionsChange({
...options,
value: value ? parseFloat(value) : undefined,
value,
})
const updateSendTo = (sendTo?: string) =>
@@ -80,16 +80,17 @@ export const GoogleAnalyticsSettings = ({
placeholder="Example: Campaign Z"
onChange={updateLabel}
/>
<TextInput
<NumberInput
direction="column"
label="Event value:"
defaultValue={options?.value?.toString() ?? ''}
defaultValue={options?.value}
placeholder="Example: 0"
onChange={updateValue}
onValueChange={updateValue}
/>
<TextInput
label="Send to:"
moreInfoTooltip="Useful to send a conversion event to Google Ads"
defaultValue={options?.value?.toString() ?? ''}
defaultValue={options?.sendTo?.toString() ?? ''}
placeholder="Example: AW-123456789"
onChange={updateSendTo}
/>

View File

@@ -38,7 +38,7 @@ export const sendGaEvent = (options: GoogleAnalyticsOptions) => {
gtag('event', options.action, {
event_category: options.category,
event_label: options.label,
value: options.value,
value: options.value as number,
})
}

View File

@@ -39,7 +39,7 @@ export const sendGaEvent = (options: GoogleAnalyticsOptions) => {
gtag('event', options.action, {
event_category: options.category,
event_label: options.label,
value: options.value,
value: options.value as number,
send_to: options.sendTo,
})
}

View File

@@ -1,13 +1,14 @@
import { z } from 'zod'
import { blockBaseSchema } from '../baseSchemas'
import { IntegrationBlockType } from './enums'
import { variableStringSchema } from '../../utils'
export const googleAnalyticsOptionsSchema = z.object({
trackingId: z.string().optional(),
category: z.string().optional(),
action: z.string().optional(),
label: z.string().optional(),
value: z.number().optional(),
value: z.number().or(variableStringSchema).optional(),
sendTo: z.string().optional(),
})