You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@flagon.apache.org by "EandrewJones (via GitHub)" <gi...@apache.org> on 2024/01/17 20:52:16 UTC
[I] Auth headers ignored for sendOnClose (flagon-useralejs)
EandrewJones opened a new issue, #399:
URL: https://github.com/apache/flagon-useralejs/issues/399
## Problem
The `sendOnClose` method to flush logs before the user closes/tabs away from the client app does not utilize any header information, nor can it.
```
/**
* Attempts to flush the remaining logs when the window is closed.
* @param {Array} logs Array of logs to be flushed.
* @param {Object} config Configuration object to be read from.
*/
export function sendOnClose(logs, config) {
window.addEventListener("pagehide", function () {
if (config.on && logs.length > 0) {
navigator.sendBeacon(config.url, JSON.stringify(logs));
logs.splice(0); // clear log queue
}
});
}
```
## Cause
`navigator.sendBeacon` does not support auth headers, so this will fail if auth is required.
## Solution
The alternative is to use `fetch()` with `keepalive: true` as per [official docs](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon#description) and [SO suggestions](https://stackoverflow.com/a/73062712/9263449).
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@flagon.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@flagon.apache.org
For additional commands, e-mail: notifications-help@flagon.apache.org
Re: [I] Bug(authHeaders): Auth headers ignored for sendOnClose (flagon-useralejs)
Posted by "EandrewJones (via GitHub)" <gi...@apache.org>.
EandrewJones closed issue #399: Bug(authHeaders): Auth headers ignored for sendOnClose
URL: https://github.com/apache/flagon-useralejs/issues/399
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@flagon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@flagon.apache.org
For additional commands, e-mail: notifications-help@flagon.apache.org
Re: [I] Bug(authHeaders): Auth headers ignored for sendOnClose (flagon-useralejs)
Posted by "rc10house (via GitHub)" <gi...@apache.org>.
rc10house commented on issue #399:
URL: https://github.com/apache/flagon-useralejs/issues/399#issuecomment-2102889678
Created Pull Request
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@flagon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@flagon.apache.org
For additional commands, e-mail: notifications-help@flagon.apache.org
Re: [I] Bug(authHeaders): Auth headers ignored for sendOnClose (flagon-useralejs)
Posted by "EandrewJones (via GitHub)" <gi...@apache.org>.
EandrewJones commented on issue #399:
URL: https://github.com/apache/flagon-useralejs/issues/399#issuecomment-2098931940
Assigned to @rc10house
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@flagon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@flagon.apache.org
For additional commands, e-mail: notifications-help@flagon.apache.org