ackee-tracker icon indicating copy to clipboard operation
ackee-tracker copied to clipboard

Parse UA on the server-side

Open omBratteng opened this issue 5 years ago • 7 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.

omBratteng avatar Nov 27 '20 12:11 omBratteng

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.

electerious avatar Nov 28 '20 19:11 electerious

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.

electerious avatar Nov 28 '20 19:11 electerious

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.

omBratteng avatar Nov 29 '20 00:11 omBratteng

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

electerious avatar Jan 23 '21 15:01 electerious

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 avatar Jan 23 '21 20:01 thecodrr

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

omBratteng avatar Feb 11 '21 12:02 omBratteng

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.

electerious avatar Feb 14 '21 11:02 electerious