const getIPAddress = async () => { try { const response = await fetch('https://api.ipify.org?format=json'); if (!response.ok) { throw new Error('Network response was not ok'); } const data = await response.json(); return data.ip; } catch (error) { console.error('Error fetching the IP address:', error); throw error; } }; document.addEventListener('DOMContentLoaded', async () => { // Replace this UUID with the one of the Short text field you added const ipInput = document.getElementById('6ee61ed3-a626-4068-b320-7c5b87305362'); if (!ipInput) { return; } // Hide the input so it's not visible in the form ipInput.style.display = 'none'; // Get the IP address of the visitor const ip = await getIPAddress(); // This is necessary to bubble the event up to the input and update the React app state const nativeInputValueSetter = Object.getOwnPropertyDescriptor( window.HTMLInputElement.prototype, 'value', ).set; nativeInputValueSetter.call(ipInput, ip); ipInput.dispatchEvent(new Event('input', { bubbles: true })); });