Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/logmatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@
queue(payload);
};

var flush = function() {
_lingerManager.reset();
post();
}

var queue = function (payload) {
// Set metas
assign(_metas, payload);
Expand Down Expand Up @@ -422,7 +427,8 @@
setIPTracking: setIPTracking,
setUserAgentTracking: setUserAgentTracking,
setURLTracking: setURLTracking,
setBulkOptions: setBulkOptions
setBulkOptions: setBulkOptions,
flush: flush
};
}))
;
2 changes: 1 addition & 1 deletion src/logmatic.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/logmatic.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions test/test-client.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
logmatic.log('Button clicked', { name: 'My button name' });
}

function btnFlushClicked () {
logmatic.log('Flushing');
logmatic.flush();
}

function fireError () {
foo();
}
Expand All @@ -40,6 +45,11 @@
console.info('This is a fake console.info!!');
console.warn('This is a fake console.warn!!');
}

window.onbeforeunload = function(e) {
logmatic.log('Unloading window');
logmatic.flush();
}
</script>
</head>
<body>
Expand All @@ -48,5 +58,9 @@
<button id="error" onclick="fireError()">Fire an error</button>
<br>
<button id="consolelog" onclick="consoleLog()">Write a console log</button>
<br>
<button id="sendlogWithFlush" onclick="btnFlushClicked()">Send one log with flush</button>
<br>
<a href="https://github.com/logmatic/logmatic-js">logmatic-js</a>
</body>
</html>