:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
[
{
"shipped": "2025-01-16",
"eligible": false,
"source": "\n// Define the properties to be added to the event\nlet geoipProperties := {\n 'city_name': null,\n 'city_confidence': null,\n 'subdivision_2_name': null,\n 'subdivision_2_code': null,\n 'subdivision_1_name': null,\n 'subdivision_1_code': null,\n 'country_name': null,\n 'country_code': null,\n 'continent_name': null,\n 'continent_code': null,\n 'postal_code': null,\n 'latitude': null,\n 'longitude': null,\n 'accuracy_radius': null,\n 'time_zone': null\n}\n// Check if the event has an IP address l\nif (event.properties?.$geoip_disable or empty(event.properties?.$ip)) {\n print('geoip disabled or no ip', event.properties, event.properties?.$ip)\n return event\n}\nlet ip := event.properties.$ip\nif (ip == '127.0.0.1') {\n ip := '13.106.122.3' // Spoofing an Australian IP address for local development\n}\nlet response := geoipLookup(ip)\nprint(response)\nif (not response) {\n return event\n}\nlet location := {}\nif (response.city) {\n location['city_name'] := response.city.names?.en\n}\nprint(location)\nif (response.country) {\n location['country_name'] := response.country.names?.en\n location['country_code'] := response.country.isoCode\n}\nif (response.continent) {\n location['continent_name'] := response.continent.names?.en\n location['continent_code'] := response.continent.code\n}\nif (response.postal) {\n location['postal_code'] := response.postal.code\n}\nif (response.location) {\n location['latitude'] := response.location?.latitude\n location['longitude'] := response.location?.longitude\n location['accuracy_radius'] := response.location?.accuracyRadius\n location['time_zone'] := response.location?.timeZone\n}\nif (response.subdivisions) {\n for (let index, subdivision in response.subdivisions) {\n location[f'subdivision_{index + 1}_code'] := subdivision.isoCode\n location[f'subdivision_{index + 1}_name'] := subdivision.names?.en\n }\n}\nlet returnEvent := event\nreturnEvent.properties := returnEvent.properties ?? {}\nreturnEvent.properties.$set := returnEvent.properties.$set ?? {}\nreturnEvent.properties.$set_once := returnEvent.properties.$set_once ?? {}\nfor (let key, value in geoipProperties) {\n if (value != null) {\n returnEvent.properties.$set[f'$geoip_{key}'] := value\n returnEvent.properties.$set_once[f'$initial_geoip_{key}'] := value\n }\n returnEvent.properties.$set[f'$geoip_{key}'] := value\n returnEvent.properties.$set_once[f'$initial_geoip_{key}'] := value\n}\nfor (let key, value in location) {\n returnEvent.properties[f'$geoip_{key}'] := value\n returnEvent.properties.$set[f'$geoip_{key}'] := value\n returnEvent.properties.$set_once[f'$initial_geoip_{key}'] := value\n}\nreturn returnEvent\n "
},
{
"shipped": "2025-01-17",
"eligible": false,
"source": "\n// Define the properties to be added to the event\nlet geoipProperties := {\n 'city_name': null,\n 'city_confidence': null,\n 'subdivision_2_name': null,\n 'subdivision_2_code': null,\n 'subdivision_1_name': null,\n 'subdivision_1_code': null,\n 'country_name': null,\n 'country_code': null,\n 'continent_name': null,\n 'continent_code': null,\n 'postal_code': null,\n 'latitude': null,\n 'longitude': null,\n 'accuracy_radius': null,\n 'time_zone': null\n}\n// Check if the event has an IP address l\nif (event.properties?.$geoip_disable or empty(event.properties?.$ip)) {\n print('geoip disabled or no ip', event.properties, event.properties?.$ip)\n return event\n}\nlet ip := event.properties.$ip\nif (ip == '127.0.0.1') {\n print('spoofing ip for local development', ip)\n ip := '89.160.20.129'\n}\nlet response := geoipLookup(ip)\nif (not response) {\n print('geoip lookup failed for ip', ip)\n return event\n}\nlet location := {}\nif (response.city) {\n location['city_name'] := response.city.names?.en\n}\nif (response.country) {\n location['country_name'] := response.country.names?.en\n location['country_code'] := response.country.isoCode\n}\nif (response.continent) {\n location['continent_name'] := response.continent.names?.en\n location['continent_code'] := response.continent.code\n}\nif (response.postal) {\n location['postal_code'] := response.postal.code\n}\nif (response.location) {\n location['latitude'] := response.location?.latitude\n location['longitude'] := response.location?.longitude\n location['accuracy_radius'] := response.location?.accuracyRadius\n location['time_zone'] := response.location?.timeZone\n}\nif (response.subdivisions) {\n for (let index, subdivision in response.subdivisions) {\n location[f'subdivision_{index + 1}_code'] := subdivision.isoCode\n location[f'subdivision_{index + 1}_name'] := subdivision.names?.en\n }\n}\nprint('geoip location data for ip:', location) \nlet returnEvent := event\nreturnEvent.properties := returnEvent.properties ?? {}\nreturnEvent.properties.$set := returnEvent.properties.$set ?? {}\nreturnEvent.properties.$set_once := returnEvent.properties.$set_once ?? {}\nfor (let key, value in geoipProperties) {\n if (value != null) {\n returnEvent.properties.$set[f'$geoip_{key}'] := value\n returnEvent.properties.$set_once[f'$initial_geoip_{key}'] := value\n }\n returnEvent.properties.$set[f'$geoip_{key}'] := value\n returnEvent.properties.$set_once[f'$initial_geoip_{key}'] := value\n}\nfor (let key, value in location) {\n returnEvent.properties[f'$geoip_{key}'] := value\n returnEvent.properties.$set[f'$geoip_{key}'] := value\n returnEvent.properties.$set_once[f'$initial_geoip_{key}'] := value\n}\nreturn returnEvent\n "
},
{
"shipped": "2025-01-30",
"eligible": true,
"source": "\n// Define the properties to be added to the event\nlet geoipProperties := {\n 'city_name': null,\n 'city_confidence': null,\n 'subdivision_2_name': null,\n 'subdivision_2_code': null,\n 'subdivision_1_name': null,\n 'subdivision_1_code': null,\n 'country_name': null,\n 'country_code': null,\n 'continent_name': null,\n 'continent_code': null,\n 'postal_code': null,\n 'latitude': null,\n 'longitude': null,\n 'accuracy_radius': null,\n 'time_zone': null\n}\n// Check if the event has an IP address\nif (event.properties?.$geoip_disable or empty(event.properties?.$ip)) {\n print('geoip disabled or no ip.')\n return event\n}\nlet ip := event.properties.$ip\nif (ip == '127.0.0.1') {\n print('spoofing ip for local development', ip)\n ip := '89.160.20.129'\n}\nlet response := geoipLookup(ip)\nif (not response) {\n print('geoip lookup failed for ip', ip)\n return event\n}\nlet location := {}\nif (response.city) {\n location['city_name'] := response.city.names?.en\n}\nif (response.country) {\n location['country_name'] := response.country.names?.en\n location['country_code'] := response.country.isoCode\n}\nif (response.continent) {\n location['continent_name'] := response.continent.names?.en\n location['continent_code'] := response.continent.code\n}\nif (response.postal) {\n location['postal_code'] := response.postal.code\n}\nif (response.location) {\n location['latitude'] := response.location?.latitude\n location['longitude'] := response.location?.longitude\n location['accuracy_radius'] := response.location?.accuracyRadius\n location['time_zone'] := response.location?.timeZone\n}\nif (response.subdivisions) {\n for (let index, subdivision in response.subdivisions) {\n location[f'subdivision_{index + 1}_code'] := subdivision.isoCode\n location[f'subdivision_{index + 1}_name'] := subdivision.names?.en\n }\n}\nprint('geoip location data for ip:', location) \nlet returnEvent := event\nreturnEvent.properties := returnEvent.properties ?? {}\nreturnEvent.properties.$set := returnEvent.properties.$set ?? {}\nreturnEvent.properties.$set_once := returnEvent.properties.$set_once ?? {}\nfor (let key, value in geoipProperties) {\n if (value != null) {\n returnEvent.properties.$set[f'$geoip_{key}'] := value\n returnEvent.properties.$set_once[f'$initial_geoip_{key}'] := value\n }\n returnEvent.properties.$set[f'$geoip_{key}'] := value\n returnEvent.properties.$set_once[f'$initial_geoip_{key}'] := value\n}\nfor (let key, value in location) {\n returnEvent.properties[f'$geoip_{key}'] := value\n returnEvent.properties.$set[f'$geoip_{key}'] := value\n returnEvent.properties.$set_once[f'$initial_geoip_{key}'] := value\n}\nreturn returnEvent\n "
},
{
"shipped": "2026-01-08",
"eligible": true,
"source": "\n// Define the properties to be added to the event\nlet geoipProperties := {\n 'city_name': null,\n 'city_confidence': null,\n 'subdivision_2_name': null,\n 'subdivision_2_code': null,\n 'subdivision_1_name': null,\n 'subdivision_1_code': null,\n 'country_name': null,\n 'country_code': null,\n 'continent_name': null,\n 'continent_code': null,\n 'postal_code': null,\n 'latitude': null,\n 'longitude': null,\n 'accuracy_radius': null,\n 'time_zone': null\n}\n// Check if the event has an IP address\nif (event.properties?.$geoip_disable or empty(event.properties?.$ip)) {\n print('geoip disabled or no ip.')\n return event\n}\nlet ip := event.properties.$ip\n// Check for localhost and common private network IPs\nif (ip == '127.0.0.1' or substring(ip, 1, 8) == '192.168.') {\n print('spoofing ip for local development', ip)\n ip := '89.160.20.129'\n}\nlet response := geoipLookup(ip)\nif (not response) {\n print('geoip lookup failed for ip', ip)\n return event\n}\nlet location := {}\nif (response.city) {\n location['city_name'] := response.city.names?.en\n}\nif (response.country) {\n location['country_name'] := response.country.names?.en\n location['country_code'] := response.country.isoCode\n}\nif (response.continent) {\n location['continent_name'] := response.continent.names?.en\n location['continent_code'] := response.continent.code\n}\nif (response.postal) {\n location['postal_code'] := response.postal.code\n}\nif (response.location) {\n location['latitude'] := response.location?.latitude\n location['longitude'] := response.location?.longitude\n location['accuracy_radius'] := response.location?.accuracyRadius\n location['time_zone'] := response.location?.timeZone\n}\nif (response.subdivisions) {\n for (let index, subdivision in response.subdivisions) {\n location[f'subdivision_{index + 1}_code'] := subdivision.isoCode\n location[f'subdivision_{index + 1}_name'] := subdivision.names?.en\n }\n}\nprint('geoip location data for ip:', location) \nlet returnEvent := event\nreturnEvent.properties := returnEvent.properties ?? {}\nreturnEvent.properties.$set := returnEvent.properties.$set ?? {}\nreturnEvent.properties.$set_once := returnEvent.properties.$set_once ?? {}\nfor (let key, value in geoipProperties) {\n if (value != null) {\n returnEvent.properties.$set[f'$geoip_{key}'] := value\n returnEvent.properties.$set_once[f'$initial_geoip_{key}'] := value\n }\n returnEvent.properties.$set[f'$geoip_{key}'] := value\n returnEvent.properties.$set_once[f'$initial_geoip_{key}'] := value\n}\nfor (let key, value in location) {\n returnEvent.properties[f'$geoip_{key}'] := value\n returnEvent.properties.$set[f'$geoip_{key}'] := value\n returnEvent.properties.$set_once[f'$initial_geoip_{key}'] := value\n}\nreturn returnEvent\n "
}
]