Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat: add analytics tracking for website (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzl authored and tilmx committed May 20, 2019
1 parent ebaa736 commit 9e4baa3
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 21 deletions.
4 changes: 3 additions & 1 deletion docs/privacypolicy.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ We only use Google Analytics with IP anonymisation enabled. This means that the

The IP address transmitted by the user’s browser is not merged with other Google data. Users can prevent the storage of cookies by setting their browser software accordingly. In addition, you can disable the cookie’s sending of the data it has created concerning your use of this website (including your IP address) to Google and the processing of this data by Google if you download and install the browser plugin that is available under the following link: https://tools.google.com/dlpage/gaoptout?hl=en.

To opt-out from Google Analytics tracking for this site, visit https://www.meetalva.io and click "opt-out tracking" in the footer at the end of the page.

Our legitimate interest in data processing also lies in these purposes. The legal basis for the use of Google Analytics is § 15 para. 3 TMG and Art. 6 para. 1 lit. f GDPR. The data sent by us and linked to cookies, user-identifiers (e.g. User-IDs) or advertising-identifiers are automatically deleted after 26 months. Data whose retention period has been reached is automatically deleted once a month.

## Link to third parties
Expand All @@ -180,4 +182,4 @@ You will find links to other websites on this website, directly or indirectly by

We hereby expressly distance ourselves from all contents of these sites to which links are established and do not adopt these contents as our own. We do not have any influence on changes of the linked content. Our website may contain links to other providers’ websites, which are not covered by this data protection policy. To the extent that the use of websites of other providers involves the capture, processing and use of personal data, please refer to the data protection policy of the relevant provider.

Version: September 2018
Version: May 2019
5 changes: 3 additions & 2 deletions packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
},
"dependencies": {
"@emotion/styled": "^10.0.6",
"@meetalva/alva-design": "^1.6.2",
"@meetalva/alva-design": "^1.6.3",
"@types/react": "16.4.11",
"@types/react-helmet": "5.0.6",
"react": "16.4.2",
"react-dom": "16.4.2",
"react-helmet": "5.2.0"
"react-helmet": "5.2.0",
"react-ga":"2.5.7"
},
"devDependencies": {
"@meetalva/tools": "1.0.0"
Expand Down
43 changes: 33 additions & 10 deletions packages/site/src/releases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as Path from 'path';
import * as D from '@meetalva/alva-design';
import styled from '@emotion/styled';
import data from './releases-data';
const ReactGA = require('react-ga');

enum Os {
macOS = 'macOS ',
Expand All @@ -26,9 +27,19 @@ const StyledLink =
color: ${props => (props.white ? D.Color.White : 'inherit')};
`;

const Link: React.SFC<{ href: string; white: boolean }> = props => {
const Link: React.SFC<{
href: string;
white: boolean;
onClick?: React.MouseEventHandler;
}> = props => {
return (
<StyledLink href={props.href} target="_blank" rel="noopener" white={props.white}>
<StyledLink
href={props.href}
onClick={props.onClick}
target="_blank"
rel="noopener"
white={props.white}
>
{props.children}
</StyledLink>
);
Expand Down Expand Up @@ -64,22 +75,34 @@ export class Releases extends React.Component {
getReleaseLink(stable, Os.Linux)
].filter(l => l.os !== stableLink.os);

console.log({
releases: releases.map(r => r.tag_name),
alphaReleases: alphaReleases.map(a => a!.tag_name),
stableReleases: stableReleases.map(s => s!.tag_name)
});

return (
<div>
<div style={{ display: 'flex' }}>
<Link href={stableLink.link} white={false}>
<Link
href={stableLink.link}
white={false}
onClick={() =>
ReactGA.event({
category: 'conversion',
action: 'Download Alva ' + this.state.os
})
}
>
<D.Button order={D.ButtonOrder.Primary}>
Get Alva {this.state.os !== Os.Unknown ? `for` : ' '} {this.state.os}
</D.Button>
</Link>
<D.Space size={D.SpaceSize.XS} />
<Link href={alphaLink.link} white={false}>
<Link
href={alphaLink.link}
white={false}
onClick={() =>
ReactGA.event({
category: 'conversion',
action: 'Download Canary ' + this.state.os
})
}
>
<D.Button order={D.ButtonOrder.Secondary}>Get Alva Canary</D.Button>
</Link>
</div>
Expand Down
70 changes: 66 additions & 4 deletions packages/site/src/site.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ import * as D from '@meetalva/alva-design';
import { Releases } from './releases';
import { CookieNotice } from './cookie-notice';

const ReactGA = require('react-ga');

const gaProperty = 'UA-111449801-1';
const disableStr = 'ga-disable-' + gaProperty;

if (typeof window !== 'undefined') {
if (document.cookie.indexOf(disableStr + '=true') > -1) {
window[disableStr] = true;
}
}

function gaOptout() {
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[disableStr] = true;
alert('Tracking is deactivated!');
}

ReactGA.initialize('UA-111449801-1');
ReactGA.set({ anonymizeIp: true });
ReactGA.pageview('/');

export * from './render';

const Page: React.StatelessComponent<void> = (): JSX.Element => {
Expand Down Expand Up @@ -47,27 +68,51 @@ const Page: React.StatelessComponent<void> = (): JSX.Element => {
rel="noopener"
href="./doc/docs/start"
title="Open Getting Started Tutorial"
onClick={() =>
ReactGA.event({
category: 'menu',
action: 'Get started'
})
}
/>
<D.MenuItem
linkName="Twitter"
target="_blank"
rel="noopener"
href="https://twitter.com/meetalva"
title="Find us on Twitter"
onClick={() =>
ReactGA.event({
category: 'menu',
action: 'Twitter'
})
}
/>
<D.MenuItem
linkName="Github"
linkName="GitHub"
target="_blank"
rel="noopener"
href="https://github.com/meetalva/alva"
title="Find us on Github"
onClick={() =>
ReactGA.event({
category: 'menu',
action: 'GitHub'
})
}
/>
<D.MenuItem
linkName="Gitter"
linkName="Chat with us"
target="_blank"
rel="noopener"
href="https://gitter.im/meetalva/Lobby"
title="Chat with us on Gitter"
onClick={() =>
ReactGA.event({
category: 'menu',
action: 'Chat with us'
})
}
/>
</D.Menu>
<D.Section backgroundColor={D.Color.Black} textColor={D.Color.White}>
Expand Down Expand Up @@ -300,8 +345,17 @@ const Page: React.StatelessComponent<void> = (): JSX.Element => {
</D.Copy>
</D.Layout>
<D.Space size={D.SpaceSize.M} />
<a href="./doc/docs/start" target="_blank" rel="noopener">
<D.Button order={D.ButtonOrder.Secondary} color={D.Color.White}>
<a href="./doc/docs/guides/start?guides-enabled=true" target="_blank" rel="noopener">
<D.Button
order={D.ButtonOrder.Secondary}
color={D.Color.White}
onClick={() =>
ReactGA.event({
category: 'conversion',
action: 'Find our guides'
})
}
>
Find our Guides
</D.Button>
</a>
Expand All @@ -314,6 +368,12 @@ const Page: React.StatelessComponent<void> = (): JSX.Element => {
target="_blank"
rel="noopener"
href="https://sinnerschrader.com"
onClick={() =>
ReactGA.event({
category: 'menu',
action: 'S2'
})
}
/>
<D.MenuItem
linkName="Legal notice"
Expand All @@ -327,6 +387,8 @@ const Page: React.StatelessComponent<void> = (): JSX.Element => {
rel="noopener"
href="./doc/docs/privacypolicy?guides-enabled=true"
/>
<D.Space size={D.SpaceSize.S} />
<D.Link onClick={() => gaOptout()}>Opt-out tracking</D.Link>
</D.Footer>
<CookieNotice />
</div>
Expand Down
13 changes: 9 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1013,10 +1013,10 @@
mkdirp "^0.5.1"
rimraf "^2.5.2"

"@meetalva/alva-design@^1.6.2":
version "1.6.2"
resolved "https://registry.yarnpkg.com/@meetalva/alva-design/-/alva-design-1.6.2.tgz#c9890817b8cfa443e99bcb72994a7d6d50babd64"
integrity sha512-XnpY/WA/TYluWftDoKybhFPzWViRFQg83aYDEbU7uILLgrWYe1zPWVf+nJztrpr+1PYR5r6iisWpDoqhcIhm5g==
"@meetalva/alva-design@^1.6.3":
version "1.6.3"
resolved "https://registry.yarnpkg.com/@meetalva/alva-design/-/alva-design-1.6.3.tgz#ed8809654b5d6388d922cb91ae2e917fc86923ad"
integrity sha512-5MkRoB5kl+OZVrjeqMB7boeikr0GIarX4xAO4WQ5TM0zQK+USqP2B8uWsbPZQ0Sx5kgSvK0+CKUyLMA4EvvOAg==
dependencies:
"@emotion/core" "^10.0.6"
"@emotion/styled" "^10.0.6"
Expand Down Expand Up @@ -10083,6 +10083,11 @@ react-feather@^1.1.0, react-feather@^1.1.5:
resolved "https://registry.yarnpkg.com/react-feather/-/react-feather-1.1.5.tgz#f7f9384c17d2d061b5b8298f46efc0e497f48469"
integrity sha512-hAPWatSFnhTNp9Ub96B7LMgOnWzXonA/LxqC2ANfUuc57jJocuWyO96yow2flUUDpitodh9mf6iOZzkyGYmAng==

react-ga@2.5.7:
version "2.5.7"
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-2.5.7.tgz#1c80a289004bf84f84c26d46f3a6a6513081bf2e"
integrity sha512-UmATFaZpEQDO96KFjB5FRLcT6hFcwaxOmAJZnjrSiFN/msTqylq9G+z5Z8TYzN/dbamDTiWf92m6MnXXJkAivQ==

react-helmet@5.2.0, react-helmet@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-5.2.0.tgz#a81811df21313a6d55c5f058c4aeba5d6f3d97a7"
Expand Down

1 comment on commit 9e4baa3

@marionebl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.