UncleGedd opened a new pull request #91:
URL: https://github.com/apache/incubator-flagon-useralejs/pull/91


   ## Fixes [Issue 
#65](https://github.com/apache/incubator-flagon-useralejs/issues/65)
   Basically, the issue is that `sendBeacon` POSTs data with 
`Content-Type:text/plain;charset=UTF-8` instead of `application/json`
   
   The problem and potential solutions are pretty well described in this [SO 
post](https://stackoverflow.com/questions/31355128/how-to-receive-data-posted-by-navigator-sendbeacon-on-node-js-server).
 In our case, two potential solutions are as follows:
   
   1. Server-side fix: Allow the Express server to parse text payloads and 
perform some logic to parse the `logs` queue out of the text payload when 
necessary. The downside is that the onus is on the user to check for text data 
on the backend
   2. Client-side fix: Use the `Blob` API to wrap `JSON.stringify(logs)` in the 
`sendBeacon` callback. The downside is that `Blob` is undefined in our test 
suite and would require a polyfill/mock
   
   This PR uses the first option as it was a quick and easy fix server-side. 
However, it's probably best to fix this using the second option so it doesn't 
affect users who may not be doing much processing on the server side


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to