-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(plugin-gtag): update gtag plugin to modern SPA recommendatio…
…ns (#8143) Co-authored-by: Lane Goolsby <lanegoolsby@rocketmortgage.com> Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com> Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
- Loading branch information
1 parent
5ddcbf4
commit e411332
Showing
7 changed files
with
50 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
*/ | ||
|
||
/// <reference types="@docusaurus/plugin-ideal-image" /> | ||
/// <reference types="@types/gtag.js" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment was marked as off-topic.
Sorry, something went wrong.