Skip to content

Commit

Permalink
Merge pull request #32 from jordanopensource/feat/setup-matomo
Browse files Browse the repository at this point in the history
Feat: setup matomo
  • Loading branch information
thamudi authored Feb 6, 2024
2 parents ff03f82 + e7ff721 commit a489964
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
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

0 comments on commit a489964

Please sign in to comment.