[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>
<link href="{{ cssPath }}" rel="stylesheet">
<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>
<body>
<div class="content">
@ -46,4 +49,10 @@
</div>
</div>
</body>
<script>
window.onload = function(e){
umami.track(props => ({ ...props, referrer: '{{ referrer }}' }));
console.log('{{ referrer }}')
}
</script>
</html>

View File

@ -3,22 +3,26 @@
<form id="form" method="POST" action="/">
<input name="timestamp" id="timestamp" type="number"></input>
<input name="timezone" id="timezone" type="text"></input>
<input name="referrer" id="referrer" type="text"></input>
</form>
</div>
</html>
<script src="https://umami.andrewconl.in/script.js" data-website-id="4f6190fe-ae60-4ec9-bd26-3872438971c2"></script>
<script>
window.onload = function(e){
var d = new Date();
var timestamp = Math.round(d.getTime() / 1000);
var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
var referrer = document.referrer;
ts = document.getElementById("timestamp")
ts.value = timestamp;
tz = document.getElementById("timezone")
tz.value = timezone;
ref = document.getElementById("referrer")
ref.value = referrer;
form = document.getElementById("form")
form.submit();
console.log(timestamp);
console.log(timezone);
console.log(referrer);
}
</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
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)
cssPath = url_for("static", filename="style.css")
return render_template("index.html",\
@ -211,14 +211,16 @@ def index(timestamp,timezone):
hobbitChapter=hobbitChapter,\
lat=lat,\
long=long,\
homoSapiens=homoSapiens)
homoSapiens=homoSapiens,\
referrer=referrer)
@app.route("/", methods=["GET","POST"])
def init():
if request.method == "POST":
timestamp = int(request.values.get('timestamp'))
timezone = request.values.get('timezone')
return index(timestamp,timezone)
referrer = request.values.get('referrer')
return index(timestamp,timezone,referrer)
else:
return render_template("init.html")