Skip to content

Commit

Permalink
chore: move from ga to simpleanalytics
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomontalbano committed May 16, 2024
1 parent 8360a6a commit a9c76a1
Show file tree
Hide file tree
Showing 13 changed files with 10 additions and 148 deletions.
1 change: 0 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
NODE_ENV=development
USE_HIGH_QUALITY=false
CLOUDINARY_URL=
GA_TRACKING_ID=
SITE_ID=
NETLIFY_ACCESS_TOKEN=
FACEBOOK_ACCESS_TOKEN=
3 changes: 1 addition & 2 deletions .posthtmlrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ module.exports = {
}),
require('posthtml-expressions')({
locals: {
NODE_ENV: process.env.NODE_ENV,
GA_TRACKING_ID: process.env.GA_TRACKING_ID,
NODE_ENV: process.env.NODE_ENV
}
})
]
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ cp .env.sample .env
```

* `CLOUDINARY_URL` ( **required** ) - this is the `API Environment variable` that you can get from your Cloudinary dashboard inside the **Account Details** section.
* `GA_TRACKING_ID` ( _optional_ ) - this is a Google Analytics Tracking ID. Can be used if you need to track page views and events.
* `NETLIFY_ACCESS_TOKEN` ( _optional_ ) - this a Netlify Access Token. In combination with the `SITE_ID` can be used to display the **API Usage** in the website.
* `SITE_ID` ( _optional_ ) - this the Netlify Site ID. In combination with the `NETLIFY_ACCESS_TOKEN` can be used to display the **API Usage** in the website.
* `USE_HIGH_QUALITY` ( _optional_ ) - this is a boolean flag. If `true`, the generated images will be stored in Contenful with hi-res quality (default to `false`)
Expand All @@ -100,11 +99,6 @@ pnpm dev

## Privacy

Google Analytics is used to record the following:

* [Basic visit data](https://support.google.com/analytics/answer/6004245?ref_topic=2919631).
* `referer` or `video url` to track api usage.

All images are generated via [Cloudinary] and stored in it.
In this way the generated images are cached so we can avoid to call Netlify functions again thus reducing the quota consumption.

Expand Down
1 change: 0 additions & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
[template.environment]
CLOUDINARY_URL = "Cloudinary URL"
USE_HIGH_QUALITY = "Use High Quality (boolean)"
GA_TRACKING_ID = "Google Analytics Tracking ID"

[[redirects]]
from = "https://video-to-markdown.netlify.app/*"
Expand Down
25 changes: 0 additions & 25 deletions netlify/functions/classes/google-ua.js

This file was deleted.

57 changes: 0 additions & 57 deletions netlify/functions/classes/google-ua.test.js

This file was deleted.

4 changes: 0 additions & 4 deletions netlify/functions/image-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import VideoWrapper from './classes/VideoWrapper.js';
import cloudinary from './classes/cloudinary.js';

import { sendLambdaEvent } from './classes/google-ua.js';

const isProduction = process.env.NODE_ENV === 'production';

const throwException = (statusCode, message) => {
Expand All @@ -26,8 +24,6 @@ const getParam = (event, paramName) => {
};

export const handler = async (event, context, callback) => {
sendLambdaEvent(event);

const url = getParam(event, 'url');

if (url === undefined || url === null) {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
"node-html-parser": "^6.1.13",
"nprogress": "^0.2.0",
"prismjs": "^1.29.0",
"process": "^0.11.10",
"universal-analytics": "^0.5.3"
"process": "^0.11.10"
},
"scripts": {
"preinstall": "npx only-allow pnpm",
Expand Down
20 changes: 0 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 5 additions & 10 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,7 @@
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="./images/favicon/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<script>
(function() {
if ('{{ NODE_ENV }}' === 'production' && '{{GA_TRACKING_ID}}' !== 'undefined') {
window.ga = window.ga || function () { (ga.q = ga.q || []).push(arguments) }; ga.l = +new Date;
ga('create', '{{GA_TRACKING_ID}}', 'auto');
ga('send', 'pageview');
}
})();
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<script>window.sa_event = window.sa_event || function () { var a = [].slice.call(arguments); window.sa_event.q ? window.sa_event.q.push(a) : window.sa_event.q = [a] };</script>
</head>
<body>

Expand All @@ -49,5 +40,9 @@
</div>

<script type="module" src="./index.js"></script>

<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js" data-collect-dnt="true"></script>
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
<script async src="https://scripts.simpleanalyticscdn.com/auto-events.js"></script>
</body>
</html>
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { loadStats } from './web/netlify';
import { load as loadAnalytics } from './web/analytics';
import { load as loadDisclaimer } from './web/disclaimer';
import { load as loadApp } from './web/app';

loadStats();
loadAnalytics();
loadDisclaimer();
loadApp();
12 changes: 0 additions & 12 deletions src/web/analytics.js

This file was deleted.

9 changes: 3 additions & 6 deletions src/web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,9 @@ export const load = () => {

NProgress.start();

typeof ga !== 'undefined' &&
ga('send', 'event', {
eventCategory: 'V2M',
eventAction: 'convert',
eventLabel: domElements.url,
});
if (typeof sa_event !== 'undefined') {
sa_event('click_convert', { url: domElements.url });
}

const newMemoFormSubmit = `${domElements.url}|${domElements.showPlayIcon}`;
if (memoFormSubmit === newMemoFormSubmit) {
Expand Down

0 comments on commit a9c76a1

Please sign in to comment.