Jethro85 commited on
Commit ·
8d5e3aa
1
Parent(s): edd271d
log to supabase
Browse files- app/templates/base.html +42 -5
app/templates/base.html
CHANGED
|
@@ -60,11 +60,48 @@
|
|
| 60 |
</footer>
|
| 61 |
</div>
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
|
| 64 |
{% block extra_scripts %}{% endblock %}
|
| 65 |
</body>
|
| 66 |
-
</html>
|
| 67 |
-
|
| 68 |
-
<a ... class="nav-link" data-track="nav_attacks">Privacy Attacks</a>
|
| 69 |
-
<a ... class="nav-link" data-track="nav_learning">Learning Hub</a>
|
| 70 |
-
<a ... class="nav-link" data-track="nav_playground">Playground</a>
|
|
|
|
| 60 |
</footer>
|
| 61 |
</div>
|
| 62 |
|
| 63 |
+
|
| 64 |
+
<script>
|
| 65 |
+
// ---- Visitor & Session Identity ----
|
| 66 |
+
function getVisitorId() {
|
| 67 |
+
const KEY = 'dp_sgd_visitor_id';
|
| 68 |
+
let id = localStorage.getItem(KEY);
|
| 69 |
+
if (!id) {
|
| 70 |
+
id = crypto.randomUUID();
|
| 71 |
+
localStorage.setItem(KEY, id);
|
| 72 |
+
}
|
| 73 |
+
return id;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
function getSessionId() {
|
| 77 |
+
const KEY = 'dp_sgd_session_id';
|
| 78 |
+
let id = sessionStorage.getItem(KEY);
|
| 79 |
+
if (!id) {
|
| 80 |
+
id = crypto.randomUUID();
|
| 81 |
+
sessionStorage.setItem(KEY, id);
|
| 82 |
+
}
|
| 83 |
+
return id;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
window.__visitor_id = getVisitorId();
|
| 87 |
+
window.__session_id = getSessionId();
|
| 88 |
+
|
| 89 |
+
function track(event, props = {}) {
|
| 90 |
+
fetch('/track', {
|
| 91 |
+
method: 'POST',
|
| 92 |
+
headers: { 'Content-Type': 'application/json' },
|
| 93 |
+
body: JSON.stringify({
|
| 94 |
+
event,
|
| 95 |
+
visitor_id: window.__visitor_id,
|
| 96 |
+
session_id: window.__session_id,
|
| 97 |
+
...props
|
| 98 |
+
})
|
| 99 |
+
});
|
| 100 |
+
}
|
| 101 |
+
</script>
|
| 102 |
+
|
| 103 |
+
|
| 104 |
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
|
| 105 |
{% block extra_scripts %}{% endblock %}
|
| 106 |
</body>
|
| 107 |
+
</html>
|
|
|
|
|
|
|
|
|
|
|
|