forked from carpentries/sandpaper
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'carpentries-main' into l2d
- Loading branch information
Showing
11 changed files
with
132 additions
and
15 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
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,34 @@ | ||
processTracker <- function(string) { | ||
string <- as.character(string) | ||
|
||
# default to whatever the user supplies | ||
analytics_str <- string | ||
|
||
if (identical(string, "carpentries")) { | ||
analytics_str <- ' | ||
<!-- Matomo --> | ||
<script> | ||
var _paq = window._paq = window._paq || []; | ||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */ | ||
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]); | ||
_paq.push(["setDomains", ["*.lessons.carpentries.org","*.datacarpentry.github.io","*.datacarpentry.org","*.librarycarpentry.github.io","*.librarycarpentry.org","*.swcarpentry.github.io", "*.carpentries.github.io"]]); | ||
_paq.push(["setDoNotTrack", true]); | ||
_paq.push(["disableCookies"]); | ||
_paq.push(["trackPageView"]); | ||
_paq.push(["enableLinkTracking"]); | ||
(function() { | ||
var u="https://matomo.carpentries.org/"; | ||
_paq.push(["setTrackerUrl", u+"matomo.php"]); | ||
_paq.push(["setSiteId", "1"]); | ||
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; | ||
g.async=true; g.src="https://matomo.carpentries.org/matomo.js"; s.parentNode.insertBefore(g,s); | ||
})(); | ||
</script> | ||
<!-- End Matomo Code --> | ||
' | ||
} else if (identical(string, "")) { | ||
analytics_str <- "" | ||
} | ||
|
||
return(analytics_str) | ||
} |
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
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,10 @@ | ||
test_that("analytics carpentries tracker code generation works", { | ||
tracker_yaml <- "analytics: carpentries" | ||
|
||
YML <- yaml::yaml.load(tracker_yaml) | ||
|
||
tracker_str <- processTracker(siQuote(YML$analytics)) | ||
|
||
expect_true(length(tracker_str) > 0) | ||
expect_false(identical(tracker_str, "carpentries")) | ||
}) |
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