Skip to content

Commit

Permalink
feat: add "click_issue_report" event
Browse files Browse the repository at this point in the history
Signed-off-by: azu <azuciao@gmail.com>
  • Loading branch information
azu committed Sep 5, 2023
1 parent 09173ab commit 01b545c
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions source/_layouts/website/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
</script>
<script type="module">
// コンソールUIでコード実行したらイベントとして送信する
const config = { childList: true };
const onExecuteCode = (scriptType) => {
gtag('event','execute_code', {
'event_category': 'console',
'event_label': 'execute_code',
'script_type': scriptType || 'unknown'
gtag("event", "execute_code", {
"event_category": "console",
"event_label": "execute_code",
"script_type": scriptType || "unknown"
});
};
let observer;
Expand All @@ -38,14 +37,35 @@
}
};
observer = new MutationObserver(callback);
const targetNode = document.body;
observer.observe(targetNode, config);
observer.observe(document.body, { childList: true });
};
const eventMap = new WeakMap();
// 問題を報告ボタンを押したらイベントとして送信する
const onClickIssueReport = () => {
console.log("click_issue_report");
gtag("event", "click_issue_report", {
"event_category": "contribution",
"event_label": "click_issue_report"
});
};
const observeIssueReport = () => {
const targetButton = document.querySelector(".gitbook-plugin-github-issue-feedback");
// すでにイベントが登録されていたら何もしない
if (eventMap.has(targetButton)) {
return;
}
if (targetButton) {
targetButton.addEventListener("click", onClickIssueReport);
eventMap.set(targetButton, onClickIssueReport);
}
};
window.addEventListener("DOMContentLoaded", function() {
gitbook.events.on("page.change", function() {
observeEvalEvent();
observeIssueReport();
});
});

</script>
<meta name="google-site-verification" content="bMotEbgYwkzA3k4PkuyK_NUdz0bKh-Phz0oUwNmRSVo"/>
<style>
Expand Down

0 comments on commit 01b545c

Please sign in to comment.