Skip to content
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

Feat: setup matomo #32

Merged
merged 5 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ steps:
image: plugins/docker
settings:
repo: josaorg/safepass
build_args:
[
MATOMO_URL=https://track.josa.ngo/,
MATOMO_SITE_ID=15,
]
tags:
- ${DRONE_COMMIT_SHA}
- stable
Expand Down
12 changes: 12 additions & 0 deletions snappass/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
HOST_OVERRIDE = os.environ.get('HOST_OVERRIDE', None)
TOKEN_SEPARATOR = '~'

# Get environment variables for matomo
MATOMO_URL = os.environ.get('MATOMO_URL', None)
SITE_ID = os.environ.get('MATOMO_SITE_ID', None)
MATOMO_DATA = {
'matomo_url': MATOMO_URL,
'site_id': SITE_ID
}

# Initialize Flask Application
app = Flask(__name__)
Expand Down Expand Up @@ -153,6 +160,11 @@ def clean_input():

return TIME_CONVERSION[time_period], request.form['password']

# inject matomo data in all templates
@app.context_processor
def injectMatomoData():
return MATOMO_DATA


@app.route('/', methods=['GET'])
def index():
Expand Down
41 changes: 35 additions & 6 deletions snappass/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<title>SafePass - Share Secrets Safely!</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<link href="{{ config.STATIC_URL }}/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="{{ config.STATIC_URL }}/fontawesome/css/font-awesome.min.css?v=4.7.0" rel="stylesheet">
<link href="{{ config.STATIC_URL }}/snappass/css/custom.css" rel="stylesheet">
<link
href="{{ config.STATIC_URL }}/bootstrap/css/bootstrap.min.css"
rel="stylesheet"
/>
<link
href="{{ config.STATIC_URL }}/fontawesome/css/font-awesome.min.css?v=4.7.0"
rel="stylesheet"
/>
<link
href="{{ config.STATIC_URL }}/snappass/css/custom.css"
rel="stylesheet"
/>

<!-- Matomo -->
<script>
let _paq = (window._paq = window._paq || []);
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function () {
const u = "{{matomo_url}}";
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(["setTrackerUrl", u + "/matomo.php"]);
_paq.push(["setSiteId", "{{site_id}}"]);
let d = document,
g = d.createElement("script"),
s = d.getElementsByTagName("script")[0];
g.async = true;
g.src = u + "/matomo.js";
s.parentNode.insertBefore(g, s);
})();
</script>
<!-- End Matomo Code -->
</head>
<body>
<nav class="navbar navbar-default navbar-static-top">
Expand Down
Loading