🐛 (googleAnalytics) Fix sendTo initial value in settings
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { TextInput } from '@/components/inputs'
|
import { NumberInput, TextInput } from '@/components/inputs'
|
||||||
import {
|
import {
|
||||||
Accordion,
|
Accordion,
|
||||||
AccordionButton,
|
AccordionButton,
|
||||||
@@ -31,10 +31,10 @@ export const GoogleAnalyticsSettings = ({
|
|||||||
|
|
||||||
const updateLabel = (label: string) => onOptionsChange({ ...options, label })
|
const updateLabel = (label: string) => onOptionsChange({ ...options, label })
|
||||||
|
|
||||||
const updateValue = (value?: string) =>
|
const updateValue = (value: number | `{{${string}}}` | undefined) =>
|
||||||
onOptionsChange({
|
onOptionsChange({
|
||||||
...options,
|
...options,
|
||||||
value: value ? parseFloat(value) : undefined,
|
value,
|
||||||
})
|
})
|
||||||
|
|
||||||
const updateSendTo = (sendTo?: string) =>
|
const updateSendTo = (sendTo?: string) =>
|
||||||
@@ -80,16 +80,17 @@ export const GoogleAnalyticsSettings = ({
|
|||||||
placeholder="Example: Campaign Z"
|
placeholder="Example: Campaign Z"
|
||||||
onChange={updateLabel}
|
onChange={updateLabel}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<NumberInput
|
||||||
|
direction="column"
|
||||||
label="Event value:"
|
label="Event value:"
|
||||||
defaultValue={options?.value?.toString() ?? ''}
|
defaultValue={options?.value}
|
||||||
placeholder="Example: 0"
|
placeholder="Example: 0"
|
||||||
onChange={updateValue}
|
onValueChange={updateValue}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
label="Send to:"
|
label="Send to:"
|
||||||
moreInfoTooltip="Useful to send a conversion event to Google Ads"
|
moreInfoTooltip="Useful to send a conversion event to Google Ads"
|
||||||
defaultValue={options?.value?.toString() ?? ''}
|
defaultValue={options?.sendTo?.toString() ?? ''}
|
||||||
placeholder="Example: AW-123456789"
|
placeholder="Example: AW-123456789"
|
||||||
onChange={updateSendTo}
|
onChange={updateSendTo}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export const sendGaEvent = (options: GoogleAnalyticsOptions) => {
|
|||||||
gtag('event', options.action, {
|
gtag('event', options.action, {
|
||||||
event_category: options.category,
|
event_category: options.category,
|
||||||
event_label: options.label,
|
event_label: options.label,
|
||||||
value: options.value,
|
value: options.value as number,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export const sendGaEvent = (options: GoogleAnalyticsOptions) => {
|
|||||||
gtag('event', options.action, {
|
gtag('event', options.action, {
|
||||||
event_category: options.category,
|
event_category: options.category,
|
||||||
event_label: options.label,
|
event_label: options.label,
|
||||||
value: options.value,
|
value: options.value as number,
|
||||||
send_to: options.sendTo,
|
send_to: options.sendTo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { blockBaseSchema } from '../baseSchemas'
|
import { blockBaseSchema } from '../baseSchemas'
|
||||||
import { IntegrationBlockType } from './enums'
|
import { IntegrationBlockType } from './enums'
|
||||||
|
import { variableStringSchema } from '../../utils'
|
||||||
|
|
||||||
export const googleAnalyticsOptionsSchema = z.object({
|
export const googleAnalyticsOptionsSchema = z.object({
|
||||||
trackingId: z.string().optional(),
|
trackingId: z.string().optional(),
|
||||||
category: z.string().optional(),
|
category: z.string().optional(),
|
||||||
action: z.string().optional(),
|
action: z.string().optional(),
|
||||||
label: z.string().optional(),
|
label: z.string().optional(),
|
||||||
value: z.number().optional(),
|
value: z.number().or(variableStringSchema).optional(),
|
||||||
sendTo: z.string().optional(),
|
sendTo: z.string().optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user