mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Fix issue with sendBeacon request.
This commit is contained in:
parent
48db7708de
commit
17790aa5a8
6 changed files with 23 additions and 22 deletions
|
|
@ -47,7 +47,7 @@ import { removeTrailingSlash } from '../lib/url';
|
|||
const post = (url, data, callback) => {
|
||||
const req = new XMLHttpRequest();
|
||||
req.open('POST', url, true);
|
||||
req.setRequestHeader('Content-Type', 'application/json');
|
||||
req.setRequestHeader('Content-Type', 'text/plain');
|
||||
|
||||
req.onreadystatechange = () => {
|
||||
if (req.readyState === 4) {
|
||||
|
|
@ -114,20 +114,16 @@ import { removeTrailingSlash } from '../lib/url';
|
|||
|
||||
const sendEvent = (value, type) => {
|
||||
const payload = getPayload();
|
||||
|
||||
payload.event_type = type;
|
||||
payload.event_value = value;
|
||||
|
||||
const blob = new Blob(
|
||||
[
|
||||
JSON.stringify({
|
||||
type: 'event',
|
||||
payload,
|
||||
}),
|
||||
],
|
||||
{ type: 'application/json' },
|
||||
);
|
||||
const data = JSON.stringify({
|
||||
type: 'event',
|
||||
payload,
|
||||
});
|
||||
|
||||
navigator.sendBeacon(`${root}/api/collect`, blob);
|
||||
navigator.sendBeacon(`${root}/api/collect`, data);
|
||||
};
|
||||
|
||||
const addEvents = node => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue