-
Notifications
You must be signed in to change notification settings - Fork 42
feat: sendHostname can works after 7 days and change GA Tracking ID #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
f3183cc
f3d11f3
e694675
af5a7ee
2d0542f
d9002a3
d5df0e8
1313b4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,28 @@ | |
|
|
||
| var object = require('./object'); | ||
| var collection = require('./collection'); | ||
| var type = require('./type'); | ||
|
|
||
| var trackingIdMap = { | ||
| 'editor': 'UA-129966929-1', | ||
| 'grid': 'UA-129951906-1', | ||
| 'calendar': 'UA-129951699-1', | ||
| 'chart': 'UA-129983528-1', | ||
| 'image-editor': 'UA-129999381-1', | ||
| 'component': 'UA-129987462-1' | ||
| }; | ||
| var ms7days = 7 * 24 * 60 * 60 * 1000; | ||
|
|
||
| /** | ||
| * Check if the date has passed 7 days | ||
| * @param {number} date - milliseconds | ||
| * @returns {boolean} | ||
| * @ignore | ||
| */ | ||
| function isExpired(date) { | ||
| var now = new Date().getTime(); | ||
|
|
||
| return now - date > ms7days; | ||
| } | ||
|
|
||
| /** | ||
| * Send hostname on DOMContentLoaded. | ||
|
|
@@ -19,13 +40,23 @@ function sendHostname(applicationId) { | |
| var url = 'https://www.google-analytics.com/collect'; | ||
| var hostname = location.hostname; | ||
| var hitType = 'event'; | ||
| var trackingId = 'UA-115377265-9'; | ||
| var eventCategory = 'use'; | ||
| var trackingId = trackingIdMap[applicationId] || trackingIdMap.component; | ||
| var applicationKeyForStorage = 'TOAST UI ' + applicationId + ' for ' + hostname + ': Statistics'; | ||
|
||
| var date = window.localStorage.getItem(applicationKeyForStorage); | ||
|
|
||
| // skip if the flag is defined and is set to false explicitly | ||
| if (tui.usageStatistics === false) { | ||
| return; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if using the global
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also not sure that |
||
|
|
||
| // skip only if the flag is defined and is set to false explicitly | ||
| if (!type.isUndefined(window.tui) && window.tui.usageStatistics === false) { | ||
| // skip if not pass seven days old | ||
| if (date && !isExpired(date)) { | ||
| return; | ||
| } | ||
|
|
||
| window.localStorage.setItem(applicationKeyForStorage, new Date().getTime()); | ||
|
|
||
| setTimeout(function() { | ||
| if (document.readyState === 'interactive' || document.readyState === 'complete') { | ||
| imagePing(url, { | ||
|
|
@@ -34,7 +65,9 @@ function sendHostname(applicationId) { | |
| tid: trackingId, | ||
| cid: hostname, | ||
| dp: hostname, | ||
| dh: applicationId | ||
| dh: applicationId, | ||
| el: applicationId, | ||
| ec: eventCategory | ||
| }); | ||
| } | ||
| }, 1000); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아이디는 여기서들고 있는것이 아니라 사용하는 쪽에서 들고 있어야 할것 같아요.
새 프로젝트가 추가되거나 ga 트래킹을 안 하던 프로젝트가 추가되게 되면 불필요하게 codesnippet도 배포해야 하니까요..
웹스토리지 키를 만드는것 때문에 필요하다면 이름도 추가하면 될것 같아요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이름과 아이디를 받는 형식으로 수정하겠습니다.