src/app/lib/analyticsUtils/sendBeacon/index.js
import onClient from '../../utilities/onClient';
import nodeLogger from '../../logger.node';
import { ATI_LOGGING_ERROR } from '../../logger.const';
import 'isomorphic-fetch';
const logger = nodeLogger(__filename);
const sendBeacon = async url => {
if (onClient()) {
try {
await fetch(url, { credentials: 'include' }).then(res => res.text());
} catch (error) {
logger.error(ATI_LOGGING_ERROR, {
error,
});
}
}
};
export default sendBeacon;