mixpanel-lite icon indicating copy to clipboard operation
mixpanel-lite copied to clipboard

Add `.env` property to tracking events

Open john-doherty opened this issue 11 months ago • 0 comments

mixpanel-lite adds multiple environment properties to each tracking event. Because they are not name-spaced, there is a risk the user could overwrite these values with tracking data. The best approach would be to move all custom tracking properties into a single object .env, for example:

{
  "event": "test-event-1710232673997",
  "properties": {
    "env": {
        "connectionType": "4g",
        "offline": true,
        "automated": true,
        "local": true,
        "language": "en-US",
        "bot": false
    },
    "token": "test-token-1710232673997",
    "distinct_id": "18e31cf9ed114-0647c79ecddabf-6e23185c-1d73c0-18e31cf9ed316",
    "$device_id": "18e31cf9ed416-087be401914ac4-6e23185c-1d73c0-18e31cf9ed416",
    "$insert_id": "pm9r6d4sgok3pirb",
    "$os": "Mac OS X",
    "$browser": "Chrome",
    "$browser_version": 91,
    "$screen_height": 1117,
    "$screen_width": 1728,
    "mp_lib": "mixpanel-lite",
    "$lib_version": "1.0.0",
    "time": 1710232674
  }
}

Ideally, we'd use $env but there is a risk Mixpanel add something like this in future.

john-doherty avatar Mar 12 '24 08:03 john-doherty