Skip to content

Commit 7cce458

Browse files
authored
Merge pull request #2776 from ehuss/remove-google-analytics
Remove google-analytics
2 parents 84fbd67 + aef12bb commit 7cce458

File tree

5 files changed

+0
-43
lines changed

5 files changed

+0
-43
lines changed

crates/mdbook-core/src/config.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,6 @@ pub struct HtmlConfig {
522522
pub mathjax_support: bool,
523523
/// Whether to fonts.css and respective font files to the output directory.
524524
pub copy_fonts: bool,
525-
/// An optional google analytics code.
526-
pub google_analytics: Option<String>,
527525
/// Additional CSS stylesheets to include in the rendered page's `<head>`.
528526
pub additional_css: Vec<PathBuf>,
529527
/// Additional JS scripts to include at the bottom of the rendered page's
@@ -587,7 +585,6 @@ impl Default for HtmlConfig {
587585
curly_quotes: false,
588586
mathjax_support: false,
589587
copy_fonts: true,
590-
google_analytics: None,
591588
additional_css: Vec::new(),
592589
additional_js: Vec::new(),
593590
fold: Fold::default(),
@@ -804,7 +801,6 @@ mod tests {
804801
theme = "./themedir"
805802
default-theme = "rust"
806803
smart-punctuation = true
807-
google-analytics = "123456"
808804
additional-css = ["./foo/bar/baz.css"]
809805
git-repository-url = "https://foo.com/"
810806
git-repository-icon = "fa-code-fork"
@@ -850,7 +846,6 @@ mod tests {
850846
};
851847
let html_should_be = HtmlConfig {
852848
smart_punctuation: true,
853-
google_analytics: Some(String::from("123456")),
854849
additional_css: vec![PathBuf::from("./foo/bar/baz.css")],
855850
theme: Some(PathBuf::from("./themedir")),
856851
default_theme: Some(String::from("rust")),
@@ -1014,7 +1009,6 @@ mod tests {
10141009
destination = "my-book" # the output files will be generated in `root/my-book` instead of `root/book`
10151010
theme = "my-theme"
10161011
smart-punctuation = true
1017-
google-analytics = "123456"
10181012
additional-css = ["custom.css", "custom2.css"]
10191013
additional-js = ["custom.js"]
10201014
"#;
@@ -1039,7 +1033,6 @@ mod tests {
10391033
let html_should_be = HtmlConfig {
10401034
theme: Some(PathBuf::from("my-theme")),
10411035
smart_punctuation: true,
1042-
google_analytics: Some(String::from("123456")),
10431036
additional_css: vec![PathBuf::from("custom.css"), PathBuf::from("custom2.css")],
10441037
additional_js: vec![PathBuf::from("custom.js")],
10451038
..Default::default()

crates/mdbook-driver/src/mdbook.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,6 @@ impl MDBook {
6565
config.update_from_env();
6666

6767
if let Some(html_config) = config.html_config() {
68-
if html_config.google_analytics.is_some() {
69-
warn!(
70-
"The output.html.google-analytics field has been deprecated; \
71-
it will be removed in a future release.\n\
72-
Consider placing the appropriate site tag code into the \
73-
theme/head.hbs file instead.\n\
74-
The tracking code may be found in the Google Analytics Admin page.\n\
75-
"
76-
);
77-
}
7868
if html_config.curly_quotes {
7969
warn!(
8070
"The output.html.curly-quotes field has been renamed to \

crates/mdbook-html/front-end/templates/index.hbs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -275,25 +275,6 @@
275275
</script>
276276
{{/if}}
277277

278-
{{#if google_analytics}}
279-
<!-- Google Analytics Tag -->
280-
<script>
281-
const localAddrs = ["localhost", "127.0.0.1", ""];
282-
283-
// make sure we don't activate google analytics if the developer is
284-
// inspecting the book locally...
285-
if (localAddrs.indexOf(document.location.hostname) === -1) {
286-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
287-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
288-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
289-
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
290-
291-
ga('create', '{{google_analytics}}', 'auto');
292-
ga('send', 'pageview');
293-
}
294-
</script>
295-
{{/if}}
296-
297278
{{#if playground_line_numbers}}
298279
<script>
299280
window.playground_line_numbers = true;

crates/mdbook-html/src/html_handlebars/hbs_renderer.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,6 @@ fn make_data(
552552
json!(preferred_dark_theme),
553553
);
554554

555-
// Add google analytics tag
556-
if let Some(ref ga) = html_config.google_analytics {
557-
data.insert("google_analytics".to_owned(), json!(ga));
558-
}
559-
560555
if html_config.mathjax_support {
561556
data.insert("mathjax_support".to_owned(), json!(true));
562557
}

guide/src/format/configuration/renderers.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ The following configuration options are available:
132132
If `false`, the built-in fonts will not be used.
133133
This option is deprecated. If you want to define your own custom fonts,
134134
create a `theme/fonts/fonts.css` file and store the fonts in the `theme/fonts/` directory.
135-
- **google-analytics:** This field has been deprecated and will be removed in a future release.
136-
Use the `theme/head.hbs` file to add the appropriate Google Analytics code instead.
137135
- **additional-css:** If you need to slightly change the appearance of your book
138136
without overwriting the whole style, you can specify a set of stylesheets that
139137
will be loaded after the default ones where you can surgically change the

0 commit comments

Comments
 (0)