-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add matomo tracking #148
Merged
+56
−9
Merged
add matomo tracking #148
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2060f11
add matomo tracking
32ddc2f
fix based on feedback
4c5b1f0
Merge branch 'develop' of https://github.com/uwcirg/AHRQ-CDS-Connect-…
8ca30ce
use user info from access token
4e7ab82
add comment
b62fbbf
fix typo per feedback
113d817
fix typo per feedback
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta charset="utf-8" /> | ||
<!-- Use Internet Explorer Edge Standards mode --> | ||
<meta http-equiv="x-ua-compatible" content="IE=edge" > | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<meta name="theme-color" content="#000000"> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> | ||
<meta http-equiv="x-ua-compatible" content="IE=edge" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1, shrink-to-fit=no" | ||
/> | ||
<meta name="theme-color" content="#000000" /> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<title>Washington Opioid Clinical Assessment</title> | ||
</head> | ||
<body> | ||
<noscript> | ||
You need to enable JavaScript to run this app. | ||
</noscript> | ||
<noscript> You need to enable JavaScript to run this app. </noscript> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ import moment from "moment"; | |
import { toBlob, toJpeg } from "html-to-image"; | ||
import { getEnv, ENV_VAR_PREFIX } from "../utils/envConfig"; | ||
import reportSummarySections from "../config/report_config"; | ||
import { getTokenInfoFromStorage } from "./timeout"; | ||
|
||
/* | ||
* return number of days between two dates | ||
|
@@ -707,3 +708,45 @@ export function dedupArrObjects(arr, key) { | |
return acc; | ||
}, []); | ||
} | ||
|
||
export function getMamotoTrackingSiteId() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @achen2401 another Mamoto gremlin here :) - and a call to it below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you @mcjustin! This should be fixed too. |
||
return getEnv(`${ENV_VAR_PREFIX}_MATOMO_SITE_ID`); | ||
} | ||
|
||
export function getUserIdFromAccessToken() { | ||
const accessToken = getTokenInfoFromStorage(); | ||
if (!accessToken) return null; | ||
if (accessToken.profile) return accessToken.profile; | ||
if (accessToken.fhirUser) return accessToken.fhirUser; | ||
return accessToken["preferred_username"]; | ||
} | ||
|
||
export function addMamotoTracking() { | ||
// already generated script, return | ||
if (document.querySelector("#matomoScript")) return; | ||
window._paq = []; | ||
window._paq.push(["trackPageView"]); | ||
window._paq.push(["enableLinkTracking"]); | ||
const userId = getUserIdFromAccessToken(); | ||
// no user Id return | ||
if (!userId) return; | ||
const siteId = getMamotoTrackingSiteId(); | ||
// no site Id return | ||
if (!siteId) return; | ||
|
||
window._paq.push(["setSiteId", siteId]); | ||
window._paq.push(["setUserId", userId]); | ||
|
||
let u = "https://piwik.cirg.washington.edu/"; | ||
window._paq.push(["setTrackerUrl", u + "matomo.php"]); | ||
let d = document, | ||
g = d.createElement("script"), | ||
headElement = document.querySelector("head"); | ||
g.type = "text/javascript"; | ||
g.async = true; | ||
g.defer = true; | ||
g.setAttribute("src", u + "matomo.js"); | ||
g.setAttribute("id", "matomoScript"); | ||
headElement.appendChild(g); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@achen2401 it's Matomo, not Mamoto - can you please edit so it's easier to find :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you @mcjustin for noticing the typo! I fixed it now.