Skip to content

Commit f3183cc

Browse files
author
Dongsik Yoo
committed
chore: reduce call of sendHostname
1 parent 713a9e4 commit f3183cc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/js/request.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ function sendHostname(applicationId) {
2020
var hostname = location.hostname;
2121
var hitType = 'event';
2222
var trackingId = 'UA-115377265-9';
23+
var applicationKeyForStorage = 'TOAST UI ' + applicationId + ' for ' + hostname + ': Statistics';
24+
var alreadySentForThisApplication = window.localStorage.getItem(applicationKeyForStorage);
2325

2426
// skip only if the flag is defined and is set to false explicitly
25-
if (!type.isUndefined(window.tui) && window.tui.usageStatistics === false) {
27+
if ((!type.isUndefined(window.tui) && window.tui.usageStatistics === false)
28+
|| alreadySentForThisApplication) {
2629
return;
2730
}
2831

32+
if (!alreadySentForThisApplication) {
33+
window.localStorage.setItem(applicationKeyForStorage, true);
34+
}
35+
2936
setTimeout(function() {
3037
if (document.readyState === 'interactive' || document.readyState === 'complete') {
3138
imagePing(url, {

0 commit comments

Comments
 (0)