question #2 I am trying to use a transformation t...
# support
l
question #2 I am trying to use a transformation to add geoenrichement to events ... this is my transformation, but I am not seeing geo info added to fb or bigquery... what am i doing wrong? /*** * This transformation enables customers to extract URL parameters. This * enables the data to be processed for specific destinations as well as add geo enrichment ***/ export async function transformEvent(event, metadata) { // Extract URL parameters const search = event.context?.page?.search; if (search) { event.context.page.parameters = {}; search.substring(1).split("&").forEach(parameter => { const [key, value] = parameter.split("="); event.context.page.parameters[key] = decodeURIComponent(value); }); } // Enrich with geolocation data if (event.request_ip) { try { const apiKey = "KEY"; // Replace with your actual API key const url = `https://api.ipgeolocation.io/ipgeo?apiKey=${apiKey}&ip=${event.request_ip}`; const response = await fetch(url); const geolocationData = await response.json(); if (response.ok) { event.context.geolocation = geolocationData; } else { // Handle error (e.g., log or set a default geolocation) } } catch (error) { // Handle fetch error (e.g., log the error) } } return event; }
m
Hey There! 👋 Your message has been received by the RudderStack team. We will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
h
assume you have your actual key for the api in your transform?
l
yes correct.
h
I would perhaps remove the try catch and use live events to try and diagnose where it might be failing
m
Hey Harold let me know if you are still facing this issue. Thanks