[2025-04-15] Pass referrer through POST request, remove analytics from init

This commit is contained in:
Andrew Conlin 2025-04-15 14:26:51 +01:00
parent 5cf5670fa1
commit 943e0a5f79
3 changed files with 20 additions and 5 deletions

View File

@ -2,7 +2,10 @@
<head> <head>
<link href="{{ cssPath }}" rel="stylesheet"> <link href="{{ cssPath }}" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<script defer src="https://umami.andrewconl.in/script.js" data-website-id="4f6190fe-ae60-4ec9-bd26-3872438971c2"></script> <script defer src="https://umami.andrewconl.in/script.js"
data-website-id="4f6190fe-ae60-4ec9-bd26-3872438971c2"
data-auto-track="false"
></script>
</head> </head>
<body> <body>
<div class="content"> <div class="content">
@ -46,4 +49,10 @@
</div> </div>
</div> </div>
</body> </body>
<script>
window.onload = function(e){
umami.track(props => ({ ...props, referrer: '{{ referrer }}' }));
console.log('{{ referrer }}')
}
</script>
</html> </html>

View File

@ -3,22 +3,26 @@
<form id="form" method="POST" action="/"> <form id="form" method="POST" action="/">
<input name="timestamp" id="timestamp" type="number"></input> <input name="timestamp" id="timestamp" type="number"></input>
<input name="timezone" id="timezone" type="text"></input> <input name="timezone" id="timezone" type="text"></input>
<input name="referrer" id="referrer" type="text"></input>
</form> </form>
</div> </div>
</html> </html>
<script src="https://umami.andrewconl.in/script.js" data-website-id="4f6190fe-ae60-4ec9-bd26-3872438971c2"></script>
<script> <script>
window.onload = function(e){ window.onload = function(e){
var d = new Date(); var d = new Date();
var timestamp = Math.round(d.getTime() / 1000); var timestamp = Math.round(d.getTime() / 1000);
var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
var referrer = document.referrer;
ts = document.getElementById("timestamp") ts = document.getElementById("timestamp")
ts.value = timestamp; ts.value = timestamp;
tz = document.getElementById("timezone") tz = document.getElementById("timezone")
tz.value = timezone; tz.value = timezone;
ref = document.getElementById("referrer")
ref.value = referrer;
form = document.getElementById("form") form = document.getElementById("form")
form.submit(); form.submit();
console.log(timestamp); console.log(timestamp);
console.log(timezone); console.log(timezone);
console.log(referrer);
} }
</script> </script>

View File

@ -194,7 +194,7 @@ def getTemplate(timestamp,timezone):
return now.year, nowTime, nowDate, round(yearPercent*100,2), footballMinute, workDay, workTime, marathonMile, abbeyRoadSong, hobbitChapter, lat, long, homoSapiens return now.year, nowTime, nowDate, round(yearPercent*100,2), footballMinute, workDay, workTime, marathonMile, abbeyRoadSong, hobbitChapter, lat, long, homoSapiens
def index(timestamp,timezone): def index(timestamp,timezone,referrer):
year, nowTime, nowDate, yearPercent, footballMinute, workDay, workTime, marathonMile, abbeyRoadSong, hobbitChapter, lat, long, homoSapiens = getTemplate(timestamp,timezone) year, nowTime, nowDate, yearPercent, footballMinute, workDay, workTime, marathonMile, abbeyRoadSong, hobbitChapter, lat, long, homoSapiens = getTemplate(timestamp,timezone)
cssPath = url_for("static", filename="style.css") cssPath = url_for("static", filename="style.css")
return render_template("index.html",\ return render_template("index.html",\
@ -211,14 +211,16 @@ def index(timestamp,timezone):
hobbitChapter=hobbitChapter,\ hobbitChapter=hobbitChapter,\
lat=lat,\ lat=lat,\
long=long,\ long=long,\
homoSapiens=homoSapiens) homoSapiens=homoSapiens,\
referrer=referrer)
@app.route("/", methods=["GET","POST"]) @app.route("/", methods=["GET","POST"])
def init(): def init():
if request.method == "POST": if request.method == "POST":
timestamp = int(request.values.get('timestamp')) timestamp = int(request.values.get('timestamp'))
timezone = request.values.get('timezone') timezone = request.values.get('timezone')
return index(timestamp,timezone) referrer = request.values.get('referrer')
return index(timestamp,timezone,referrer)
else: else:
return render_template("init.html") return render_template("init.html")