RoyAalekh commited on
Commit
71240dc
·
1 Parent(s): b845df6

fix(telemetry): normalize Supabase events to include nested user object for UI display

Browse files
Files changed (5) hide show
  1. app.py +10 -1
  2. static/index.html +2 -2
  3. static/map.html +2 -2
  4. static/sw.js +1 -1
  5. version.json +1 -1
app.py CHANGED
@@ -930,7 +930,16 @@ async def get_telemetry(limit: int = 100, user: Dict[str, Any] = Depends(require
930
  try:
931
  if getattr(db, 'connected', False):
932
  events = db.get_recent_telemetry(limit)
933
- return {"events": events, "source": "supabase", "count": len(events)}
 
 
 
 
 
 
 
 
 
934
  # Fallback to file
935
  events: List[Dict[str, Any]] = []
936
  try:
 
930
  try:
931
  if getattr(db, 'connected', False):
932
  events = db.get_recent_telemetry(limit)
933
+ # Normalize shape to always include evt.user = {username, role}
934
+ norm_events: List[Dict[str, Any]] = []
935
+ for e in (events or []):
936
+ if 'user' not in e or not e.get('user'):
937
+ username = e.get('username')
938
+ role = e.get('role')
939
+ if username or role:
940
+ e = {**e, 'user': {'username': username, 'role': role}}
941
+ norm_events.append(e)
942
+ return {"events": norm_events, "source": "supabase", "count": len(norm_events)}
943
  # Fallback to file
944
  events: List[Dict[str, Any]] = []
945
  try:
static/index.html CHANGED
@@ -917,7 +917,7 @@
917
  // Force refresh if we detect cached version
918
  (function() {
919
  const currentVersion = '5.1.1';
920
- const timestamp = '1755113842'; // Cache-busting bump
921
  const lastVersion = sessionStorage.getItem('treetrack_version');
922
  const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
923
 
@@ -1163,7 +1163,7 @@
1163
  </div>
1164
  </div>
1165
 
1166
- <script type="module" src="/static/js/tree-track-app.js?v=5.1.1&t=1755113842"></script>
1167
 
1168
  <script>
1169
  // Initialize Granim background animation on page load
 
917
  // Force refresh if we detect cached version
918
  (function() {
919
  const currentVersion = '5.1.1';
920
+ const timestamp = '1755114153'; // Cache-busting bump
921
  const lastVersion = sessionStorage.getItem('treetrack_version');
922
  const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
923
 
 
1163
  </div>
1164
  </div>
1165
 
1166
+ <script type="module" src="/static/js/tree-track-app.js?v=5.1.1&t=1755114153"></script>
1167
 
1168
  <script>
1169
  // Initialize Granim background animation on page load
static/map.html CHANGED
@@ -813,7 +813,7 @@
813
  // Force refresh if we detect cached version
814
  (function() {
815
  const currentVersion = '5.1.1';
816
- const timestamp = '1755113842'; // Current timestamp for cache busting
817
  const lastVersion = sessionStorage.getItem('treetrack_version');
818
  const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
819
 
@@ -939,7 +939,7 @@ const timestamp = '1755113842'; // Current timestamp for cache busting
939
 
940
  <!-- Leaflet JS -->
941
  <script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
942
- <script src="/static/map.js?v=5.1.1&t=1755113842">
943
 
944
  "default-state": {
945
  gradients: [
 
813
  // Force refresh if we detect cached version
814
  (function() {
815
  const currentVersion = '5.1.1';
816
+ const timestamp = '1755114153'; // Current timestamp for cache busting
817
  const lastVersion = sessionStorage.getItem('treetrack_version');
818
  const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
819
 
 
939
 
940
  <!-- Leaflet JS -->
941
  <script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
942
+ <script src="/static/map.js?v=5.1.1&t=1755114153">
943
 
944
  "default-state": {
945
  gradients: [
static/sw.js CHANGED
@@ -1,5 +1,5 @@
1
  // TreeTrack Service Worker - PWA and Offline Support
2
- const VERSION = 1755113842; // Cache busting bump - force clients to fetch new static assets and header image change
3
  const CACHE_NAME = `treetrack-v${VERSION}`;
4
  const STATIC_CACHE = `static-v${VERSION}`;
5
  const API_CACHE = `api-v${VERSION}`;
 
1
  // TreeTrack Service Worker - PWA and Offline Support
2
+ const VERSION = 1755114153; // Cache busting bump - force clients to fetch new static assets and header image change
3
  const CACHE_NAME = `treetrack-v${VERSION}`;
4
  const STATIC_CACHE = `static-v${VERSION}`;
5
  const API_CACHE = `api-v${VERSION}`;
version.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
  "version": "5.1.1",
3
- "timestamp": 1755113842
4
  }
 
1
  {
2
  "version": "5.1.1",
3
+ "timestamp": 1755114153
4
  }