electerious / ackee-tracker

Transfer data to Ackee.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parse UA on the server-side

omBratteng opened this issue · comments

Why is the parsing of the UA done on the client side, and not the server side?
You could potentially save 15kB (~8kB gzip). It's not much, but it can be done server side.

The main reason was that Ackee shouldn't process the user agent / shouldn't even receive the user agent when detailed tracking is disabled. This however doesn't make sense, because browsers send the UA anyway.

The seconds reason was that detailed also includes data that isn't part of the UA. This would mean that we need an API that parses the UA + accepts some additional data. That could work, but we would need to make sure that the UA is only parsed on the server when the detailed mode is enabled (for privacy reasons). That's also why the detailed option is part of ackee-tracker and not of Ackee, because the server should never see the detailed data when it doesn't have to.

It could work if we find a good API declaration for it, but it's also not as clean & simple as it is right now.

I would like to keep the current API unchanged. It's good for apps where a UA isn't a thing. The UA could be an optional GraphQL query parameter that get's parsed when available.

Data + UA = Parses UA. Fields specified in the data will overwrite fields parsed from the UA. In the case it's like a fallback, but it would allow us to remove the platform library from ackee-tracker.
Data only = Just like it is now.

The main reason was that Ackee shouldn't process the user agent / shouldn't even receive the user agent when detailed tracking is disabled. This however doesn't make sense, because browsers send the UA anyway.

Yeah, most internet capable device sends a User-Agent string to the server on each request. I also understand that Ackee shouldn't process the data, unless the user has given their permission.
My issue is that platform.js is a few kB of unnecessary data, because it has to detect all quirks with different UAs.

The feature didn't made it into v3, but it's something I'm planning for a future release.

What if the platform.js library is loaded on demand externally instead?

If a developer turns on detailed mode ackee-tracker can download and load platform.js. This would require little to no change in the tracker and we can shave off a couple of KBs in the process (for non-detailed mode at least).

@thecodrr that would increase load time, as another js file has to be downloaded and parsed

My plan is to add an optional userAgent parameter to the createRecord mutation.

Data + UA = Parses UA. Fields specified in the data will overwrite fields parsed from the UA. In the case it's like a fallback, but it would allow us to remove the platform library from ackee-tracker.
Data only = Just like it is now.