Skip to content

The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.

1.4 KB
Raw Blame
// OpenMotion only: enrich coarse location, then remove IP and precise GeoIP.
if (event.properties?.product != 'openmotion') {
    return event
}
let props := {}
for (let key, value in event.properties) {
    if (key != '$ip' and key != '$set' and key != '$set_once' and not startsWith(key, '$geoip_')) {
        props[key] := value
    }
}
props.$geoip_disable := true
props.$process_person_profile := false
props.location_source := 'unknown'
if (not event.properties?.$geoip_disable and not empty(event.properties?.$ip)) {
    let location := geoipLookup(event.properties.$ip)
    if (location) {
        props.location_source := 'geoip'
        if (location.country) {
            props.$geoip_country_code := location.country.isoCode
            props.$geoip_country_name := location.country.names?.en
        }
        if (location.location) {
            props.$geoip_time_zone := location.location.timeZone
        }
        let regionSet := false
        if (location.subdivisions) {
            for (let index, region in location.subdivisions) {
                if (not regionSet) {
                    props.$geoip_subdivision_1_code := region.isoCode
                    props.$geoip_subdivision_1_name := region.names?.en
                    regionSet := true
                }
            }
        }
    }
}
let returnEvent := event
returnEvent.properties := props
return returnEvent