/** * WordPress dependencies */ import { CheckboxControl, ExternalLink, RadioControl, TextControl, } from '@safe-wordpress/components'; import { createInterpolateElement } from '@safe-wordpress/element'; import { _x, sprintf } from '@safe-wordpress/i18n'; /** * Internal dependencies */ import './style.scss'; import { DEFAULT_ATTRS } from './config'; import { useAttributes } from '../hooks'; import type { FieldSettingProps } from '../types'; export const GoogleAnalyticsTrackingSetting = ( { name: settingName, disabled, }: FieldSettingProps ): JSX.Element => { const [ attributes, setAttributes ] = useAttributes( settingName, DEFAULT_ATTRS ); return (
%2$s', _x( 'Send tracking events to Google Analytics 4', 'command', 'nelio-ab-testing' ), _x( 'Read more…', 'command', 'nelio-ab-testing' ) ), { link: ( // @ts-expect-error Link text will be added later. ), } ) } checked={ attributes.enabled } onChange={ ( enabled ) => setAttributes( { enabled } ) } disabled={ disabled } /> { attributes.enabled && (
setAttributes( { trackingMethod, } ) } disabled={ disabled } /> setAttributes( { measurementId } ) } disabled={ disabled } /> setAttributes( { apiSecret } ) } disabled={ disabled } />
) }
); };