Sending app logs
Lamion can automatically send logs.
This feature enabled by default.
To disable it, init the library with autoFlush: false:
useBrowserLamion({
...,
autoFlush: false,
});
After this you can send logs manually using flush:
const { flush } = useBrowserLamion({ ... });
function flushMyLogs() {
flush();
}
Example usage
Here are some examples of possible use:
1. Send logs before tab closes:
window.addEventListener("beforeunload", function (e) {
flush();
});
2. Send logs on route change (if you are using framework like nuxt, react, etc):
const route = useRoute();
watch(
() => route.fullPath,
() => {
flush();
}
);
3. Set interval:
const sendLogsIntervalSeconds = 10;
setInterval(() => flush(), sendLogsIntervalSeconds * 1000);
You can come up with new uses for sending logs. Your only limit is yourself.
