Jethro85 commited on
Commit
edd271d
·
1 Parent(s): 79d5f1b

log to supabase

Browse files
Files changed (1) hide show
  1. app/static/js/attacks.js +45 -3
app/static/js/attacks.js CHANGED
@@ -8,14 +8,36 @@ class AttackSimulator {
8
 
9
  initializeEventListeners() {
10
  // Tab switching
 
 
 
 
 
 
11
  document.querySelectorAll('.attack-tab').forEach(tab => {
12
- tab.addEventListener('click', (e) => {
13
- this.switchTab(e.target.dataset.attack);
 
 
 
 
 
 
 
 
 
 
 
 
14
  });
 
 
 
15
  });
16
 
 
17
  // Slider updates
18
- this.setupSliderUpdates();
19
 
20
  // ✅ Add this (bind events for whatever tab is active on load)
21
  this.bindAttacksPageEvents();
@@ -199,6 +221,7 @@ class AttackSimulator {
199
 
200
 
201
  switchTab(attackType) {
 
202
  // Update tab buttons
203
  document.querySelectorAll('.attack-tab').forEach(tab => {
204
  tab.classList.remove('active');
@@ -216,6 +239,14 @@ class AttackSimulator {
216
 
217
  // ✅ Add this (bind events for the newly activated tab)
218
  this.bindAttacksPageEvents(attackType);
 
 
 
 
 
 
 
 
219
  }
220
 
221
  initializeCharts() {
@@ -1215,6 +1246,17 @@ function drawCompleteNoise(ctx, width, height) {
1215
  // Initialize when page loads
1216
  document.addEventListener('DOMContentLoaded', function() {
1217
  window.attackSimulator = new AttackSimulator();
 
 
 
 
 
 
 
 
 
 
 
1218
 
1219
  // Run initial updates
1220
  window.attackSimulator.updateMembershipDemo();
 
8
 
9
  initializeEventListeners() {
10
  // Tab switching
11
+ // document.querySelectorAll('.attack-tab').forEach(tab => {
12
+ // tab.addEventListener('click', (e) => {
13
+ // this.switchTab(e.target.dataset.attack);
14
+ // });
15
+ // });
16
+
17
  document.querySelectorAll('.attack-tab').forEach(tab => {
18
+ tab.addEventListener('click', (e) => {
19
+ const attackType = e.currentTarget.dataset.attack; // use currentTarget (safer than target)
20
+
21
+ // 1) UI event (generic)
22
+ track('ui_click', {
23
+ component: 'attack_tab',
24
+ attack: attackType,
25
+ page: 'privacy_attacks'
26
+ });
27
+
28
+ // 2) Semantic event (recommended)
29
+ track('attack_tab_open', {
30
+ attack: attackType,
31
+ page: 'privacy_attacks'
32
  });
33
+
34
+ this.switchTab(attackType);
35
+ });
36
  });
37
 
38
+
39
  // Slider updates
40
+ // this.setupSliderUpdates();
41
 
42
  // ✅ Add this (bind events for whatever tab is active on load)
43
  this.bindAttacksPageEvents();
 
221
 
222
 
223
  switchTab(attackType) {
224
+ const prev = document.querySelector('.attack-tab.active')?.dataset?.attack;
225
  // Update tab buttons
226
  document.querySelectorAll('.attack-tab').forEach(tab => {
227
  tab.classList.remove('active');
 
239
 
240
  // ✅ Add this (bind events for the newly activated tab)
241
  this.bindAttacksPageEvents(attackType);
242
+
243
+ if (prev && prev !== attackType) {
244
+ track('attack_tab_switch', {
245
+ from: prev,
246
+ to: attackType,
247
+ page: 'privacy_attacks'
248
+ });
249
+ }
250
  }
251
 
252
  initializeCharts() {
 
1246
  // Initialize when page loads
1247
  document.addEventListener('DOMContentLoaded', function() {
1248
  window.attackSimulator = new AttackSimulator();
1249
+
1250
+
1251
+ // Track initial active tab
1252
+ const active = document.querySelector('.attack-tab.active');
1253
+ if (active) {
1254
+ track('attack_tab_open', {
1255
+ attack: active.dataset.attack,
1256
+ page: 'privacy_attacks',
1257
+ reason: 'page_load'
1258
+ });
1259
+ }
1260
 
1261
  // Run initial updates
1262
  window.attackSimulator.updateMembershipDemo();