/
analytics.tsx
36 lines (33 loc) · 1.04 KB
/
analytics.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import Layout from '@theme/Layout';
// See https://github.com/facebook/docusaurus/issues/6337#issuecomment-1012913647
export default function Analytics(): JSX.Element {
return (
<Layout>
<h1>Test Analytics</h1>
<div>
<button
type="button"
onClick={() => {
window.gtag('event', 'docusaurus-test-event', {
event_category: 'docusaurus-test-event-category"',
event_label: 'docusaurus-test-event-label',
});
const FALSE = false; // I don't want gtag to run with bad params
if (FALSE) {
// @ts-expect-error: gtag usage is type safe, failure expected
window.gtag('this-does-not-exist');
}
}}>
Submit custom gtag event!
</button>
</div>
</Layout>
);
}