Skip to content

Commit 5abbee3

Browse files
gabrielvigil-mixpanelGabriel Vigil
andauthored
Trustarc - added integration scripts to top of head (#2285)
* added trustarc scripts to top of head * move to document head and format properly * added all needed code to document instead of relying on gtm * fixed reload script * fixed how script string is loaded * moved refresh scripts to body * add cookie preferences for testing * add correct anchor and styling * duh * add expect error * added reload script * no track youtube test * add no-cookie to csp * added -nocookie to all youtube embeds * rolling back a few of the youtube urls as they are links not embeds * removed async from auto block * updated to have footer in changelog * merge middleware * moved all loom embeds to links * removed all video in description titles, commented out page refresh scripts, added domain cookie persistence * fixed spelling lint --------- Co-authored-by: Gabriel Vigil <gabrielvigil@q95h042m26-gabrielvigil.corp.mixpanel.com>
1 parent 609412f commit 5abbee3

File tree

65 files changed

+317
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+317
-142
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ If you're making a diagram, please add it to this [Figjam](https://www.figma.com
6767

6868
Images are hard to keep up-to-date, so please use them judiciously.
6969

70+
# Adding Youtube Videos
71+
72+
Youtube videos are added through an iframe that embeds the video to the page.
73+
You can get the source of the video by going to the youtube video, selecting share then the embed option.
74+
75+
Ensure you add `-nocookie` to the url (eg: `https://www.youtube-nocookie.com/embed/sRQCfmvh3vg`) otherwise the video will not work when user blocks cookies. (youtube tracks user data by default)
76+
7077
# Previewing Changes
7178

7279
All pull requests will generate a staging link in Vercel. Here's an [example](https://github.com/mixpanel/docs/pull/33#issuecomment-1520474996). This lets you preview your changes without changing what's actually live.

components/ChangelogIndex.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const getVideoEmbedURL = (videoURL) => {
2727
const host = parsedURL.host;
2828
if (host === "www.youtube.com" || host === "youtube.com" || host === "youtu.be") {
2929
const videoId = parsedURL.searchParams.get("v") || parsedURL.pathname.split("/").pop();
30-
return `https://www.youtube.com/embed/${videoId}`;
30+
return `https://www.youtube-nocookie.com/embed/${videoId}`;
3131
} else if (host === "www.loom.com" || host === "loom.com") {
3232
const videoId = parsedURL.pathname.split("/").pop();
3333
return `https://www.loom.com/embed/${videoId}?hideEmbedTopBar=true`;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export function TrustArcHeadScripts() {
2+
const trustArcAutoBlockCoreSrc = `https://consent.trustarc.com/v2/autoblockasset/core.min.js?cmId=9iv2en`;
3+
const trustArcAutoBlockSrc = `https://consent.trustarc.com/v2/autoblock?cmId=9iv2en`;
4+
const trustArcInitScriptSrc = `https://consent.trustarc.com/v2/notice/9iv2en?pcookie`;
5+
6+
return (
7+
<>
8+
<script src={trustArcAutoBlockCoreSrc} />
9+
<script src={trustArcAutoBlockSrc} />
10+
<script type="text/javascript" async src={trustArcInitScriptSrc} />
11+
</>
12+
);
13+
}
14+
15+
export function TrustArcBodyScripts() {
16+
const reloadOnPreferencesScript = `var _STATE={};function runOnce(){!_STATE.hasRunOnce&&window.truste&&truste.eu&&truste.eu.prefclose&&(_STATE.oldValue=truste.eu.bindMap.prefCookie&&truste.eu.bindMap.prefCookie.split(":")[0].replace(/[^\\d.]/g,"-"),_STATE.oldMethod=truste.eu.prefclose,truste.eu.prefclose=function(){_STATE.oldMethod(),truste.eu.bindMap.prefCookie&&truste.eu.bindMap.prefCookie.split(":")[0].replace(/[^\\d.]/g,"-")!==_STATE.oldValue&&setTimeout(function(){window.location.reload()},20)},_STATE.hasRunOnce=!0,_STATE.i&&clearInterval(_STATE.i))}_STATE.i=setInterval(runOnce,10);`;
17+
18+
const reloadOnBannerScript = `document.body.addEventListener("click",function(t){t&&t.target&&("truste-consent-button"===t.target.id||"truste-consent-required"===t.target.id)&&setTimeout(function(){window.location.reload()},1e3)});`;
19+
20+
return (
21+
<>
22+
<script
23+
async
24+
// eslint-disable-next-line @typescript-eslint/naming-convention
25+
dangerouslySetInnerHTML={{ __html: reloadOnBannerScript }}
26+
/>
27+
<script
28+
// eslint-disable-next-line @typescript-eslint/naming-convention
29+
dangerouslySetInnerHTML={{ __html: reloadOnPreferencesScript }}
30+
/>
31+
</>
32+
);
33+
}

components/VideoButtonWithModal/VideoButtonWithModal.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ type VideoButtonModalProps = {
1515
const PLAY_BUTTON_BASE_CLASS =
1616
"nx-flex nx-items-center nx-px-2 nx-py-1 nx-text-xs nx-font-semibold nx-text-purple140 nx-shadow-sm focus-visible:nx-outline focus-visible:nx-outline-2 focus-visible:nx-outline-offset-2 focus-visible:nx-outline-purple140";
1717

18+
function getLoomShareURL(embedURL: string): string | null {
19+
if (!embedURL.includes("loom.com")) {
20+
return null;
21+
}
22+
// Convert loom.com/embed/VIDEO_ID to loom.com/share/VIDEO_ID
23+
return embedURL.replace("/embed/", "/share/");
24+
}
25+
1826
export default function VideoButtonWithModal({
1927
title = "Video about this feature",
2028
showThumbnail = true,
@@ -23,6 +31,23 @@ export default function VideoButtonWithModal({
2331
const embedURL = getVideoEmbedURL(props.src);
2432
let [isOpen, setIsOpen] = useState(false);
2533

34+
// If it's a Loom URL, return a simple link instead of the modal
35+
const loomShareURL = getLoomShareURL(embedURL);
36+
if (loomShareURL) {
37+
return (
38+
<p style={{ marginTop: "1.5rem" }}>
39+
<a
40+
href={loomShareURL}
41+
target="_blank"
42+
rel="noopener noreferrer"
43+
className="nextra-focus _text-primary-600 _underline hover:_no-underline _decoration-from-font [text-underline-position:from-font]"
44+
>
45+
Link to Demo
46+
</a>
47+
</p>
48+
);
49+
}
50+
2651
// TODO: update this style and abstract it as time allows to a single button component
2752
// https://www.figma.com/design/8kiticjQNChvsP9y7s9SRf/Product-Releases-(Copy)?node-id=982-75355&node-type=frame&t=O7vwnwoAoOx42stw-0
2853
const playButtonClass = showThumbnail

components/VideoButtonWithModal/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const getYoutubeEmbedURL = (url: string) => {
77
const videoId = url.split("v=")[1]
88
? url.split("v=")[1].split("&")[0]
99
: url.split("/").pop();
10-
return `https://www.youtube.com/embed/${videoId}`;
10+
return `https://www.youtube-nocookie.com/embed/${videoId}`;
1111
};
1212

1313
const getLoomEmbedURL = (url: string) => {

pages/_document.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Html, Head, Main, NextScript } from "next/document";
2-
import Script from "next/script";
2+
import { TrustArcHeadScripts, TrustArcBodyScripts } from "../components/TrustArcScripts/TrustArcScripts";
33

44
export default function Document() {
55
return (
66
<Html>
7-
<Head />
7+
<Head>
8+
<TrustArcHeadScripts />
9+
</Head>
810
<body>
911
<Main />
1012
<NextScript />
@@ -52,6 +54,10 @@ export default function Document() {
5254
</script>
5355
{/* Empty script tag as chrome bug fix, see https://stackoverflow.com/a/42969608/943337 */}
5456
<script> </script>
57+
{/* Trustarc - body scripts are to refresh page when user changes preferences. Removed at request of legal. Could be necessary for GDPR*/}
58+
{/* <TrustArcBodyScripts /> */}
59+
<div id="consent-banner"></div>
60+
{/* end Trustarc */}
5561
</body>
5662
</Html>
5763
);

pages/changelogs/2023-03-29-custom-alerts.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ date: "2023-03-29"
99

1010
We’ve revamped Custom Alerts to make it easier for you to notify your team when a metric significantly changes.
1111

12-
<div style={{position: 'relative', paddingBottom: '64.90384615384616%', height: 0}}><iframe src="https://www.loom.com/embed/2feb00896e90458e8d085495a2e62f14" frameBorder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowFullScreen style={{position: 'absolute', 'top': 0, 'left': 0, 'width': '100%', 'height': '100%'}}></iframe></div>
12+
[Link to Demo](https://www.loom.com/share/2feb00896e90458e8d085495a2e62f14)
13+
14+
{/* <div style={{position: 'relative', paddingBottom: '64.90384615384616%', height: 0}}><iframe src="https://www.loom.com/embed/2feb00896e90458e8d085495a2e62f14" frameBorder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowFullScreen style={{position: 'absolute', 'top': 0, 'left': 0, 'width': '100%', 'height': '100%'}}></iframe></div> */}
1315

1416
With just one click, you can set up Slack or email alerts for:
1517

pages/changelogs/2023-04-06-tables.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ date: "2023-04-06"
66

77
With Mixpanel’s revamped Tables report, you can compare your key metrics side-by-side to understand how your segments are performing.
88

9-
<div style={{position: 'relative', paddingBottom: '64.90384615384616%', height: 0}}><iframe src="https://www.loom.com/embed/f3e4791604fb48f9bfad4bee2021decf" frameBorder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowFullScreen style={{position: 'absolute', 'top': 0, 'left': 0, 'width': '100%', 'height': '100%'}}></iframe></div>
9+
[Link to Demo](https://www.loom.com/share/f3e4791604fb48f9bfad4bee2021decf)
10+
11+
{/* <div style={{position: 'relative', paddingBottom: '64.90384615384616%', height: 0}}><iframe src="https://www.loom.com/embed/f3e4791604fb48f9bfad4bee2021decf" frameBorder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowFullScreen style={{position: 'absolute', 'top': 0, 'left': 0, 'width': '100%', 'height': '100%'}}></iframe></div> */}
1012

1113
Tables are often the best visualization to process a lot of data at once — so, we made sure to include controls that can quickly get you to the most readable layout, fast:
1214

pages/changelogs/2023-04-14-discover.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ date: "2023-04-14"
66

77
Our new Discover feature makes it easier to explore popular analyses to springboard your own work. The Discover page automatically surfaces top analyses and creators and provides more search controls to filter reports & Boards.
88

9-
<div style={{position: 'relative', paddingBottom: '64.90384615384616%', height: 0}}>
9+
[Link to Demo](https://www.loom.com/share/5353fc9abb624e2685d787f43b003dc2)
10+
{/* <div style={{position: 'relative', paddingBottom: '64.90384615384616%', height: 0}}>
1011
<iframe src="https://www.loom.com/embed/5353fc9abb624e2685d787f43b003dc2"
1112
frameBorder="0"
1213
webkitallowfullscreen="true" mozallowfullscreen="true" allowFullScreen
1314
style={{position: 'absolute', 'top': 0, 'left': 0, 'width': '100%', 'height': '100%'}}>
1415
</iframe>
15-
</div>
16+
</div> */}
1617

1718
Here are a few ways to use Discover:
1819

pages/changelogs/2023-05-05-anomaly-detection-and-root-cause-analysis.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,25 @@ updatedAt: "2023-05-05T17:39:02.165Z"
77
date: "2023-05-05"
88
---
99

10-
<div style={{position: 'relative', paddingBottom: '64.90384615384616%', height: 0}}>
10+
[Anomaly Detection Demo](https://www.loom.com/share/572a0f59d22e43069ba0c3bc1b4210f4)
11+
12+
{/* <div style={{position: 'relative', paddingBottom: '64.90384615384616%', height: 0}}>
1113
<iframe src="https://www.loom.com/embed/572a0f59d22e43069ba0c3bc1b4210f4"
1214
frameBorder="0"
1315
webkitallowfullscreen="true" mozallowfullscreen="true" allowFullScreen
1416
style={{position: 'absolute', 'top': 0, 'left': 0, 'width': '100%', 'height': '100%'}}>
1517
</iframe>
16-
</div>
18+
</div> */}
19+
20+
[Root Cause Analysis Demo](https://www.loom.com/share/53fd92c89b394e0c92324a4515e88443)
1721

18-
<div style={{position: 'relative', paddingBottom: '64.90384615384616%', height: 0}}>
22+
{/* <div style={{position: 'relative', paddingBottom: '64.90384615384616%', height: 0}}>
1923
<iframe src="https://www.loom.com/embed/53fd92c89b394e0c92324a4515e88443"
2024
frameBorder="0"
2125
webkitallowfullscreen="true" mozallowfullscreen="true" allowFullScreen
2226
style={{position: 'absolute', 'top': 0, 'left': 0, 'width': '100%', 'height': '100%'}}>
2327
</iframe>
24-
</div>
28+
</div> */}
2529

2630
Introducing Anomaly Detection and Root Cause Analysis, two new features to help you save time staying on top of metrics and getting ahead of potential issues in your product, data, or company.
2731

0 commit comments

Comments
 (0)