fix(launcher): resolve heartbeat timezone shift and enable browser testing
- Removed manual 'Z' suffix addition in device processing to fix incorrect offsets. - Switched heartbeat payload to standard UTC ISO strings. - Enabled background timers in non-native environments for easier verification. - Hardened telemetry gathering to skip Electron-only APIs when running in a browser.
This commit is contained in:
@@ -480,9 +480,8 @@ export async function process_ae_obj__event_device_props({
|
|||||||
obj_type: 'event_device',
|
obj_type: 'event_device',
|
||||||
log_lvl,
|
log_lvl,
|
||||||
specific_processor: (obj) => {
|
specific_processor: (obj) => {
|
||||||
if (obj.heartbeat) {
|
// Note: V3 API returns proper ISO strings.
|
||||||
obj.heartbeat = obj.heartbeat + 'Z';
|
// We no longer manually append 'Z' to avoid timezone corruption.
|
||||||
}
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,8 +36,6 @@
|
|||||||
let show_monitor = $state(false);
|
let show_monitor = $state(false);
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (!$ae_loc.is_native) return;
|
|
||||||
|
|
||||||
const dev = $ae_loc.native_device || {};
|
const dev = $ae_loc.native_device || {};
|
||||||
|
|
||||||
// Load timings from device config
|
// Load timings from device config
|
||||||
@@ -46,6 +44,7 @@
|
|||||||
loop_info.location = dev.check_event_location_loop_period || 30000;
|
loop_info.location = dev.check_event_location_loop_period || 30000;
|
||||||
loop_info.session = dev.check_event_session_loop_period || 10000;
|
loop_info.session = dev.check_event_session_loop_period || 10000;
|
||||||
|
|
||||||
|
// Timers run in both browser and native for dev/testing
|
||||||
timer__event = setInterval(() => run_sync_cycle(), loop_info.event);
|
timer__event = setInterval(() => run_sync_cycle(), loop_info.event);
|
||||||
timer__device = setInterval(() => run_device_heartbeat(), loop_info.device);
|
timer__device = setInterval(() => run_device_heartbeat(), loop_info.device);
|
||||||
timer__location = setInterval(() => refresh_location_config(), loop_info.location);
|
timer__location = setInterval(() => refresh_location_config(), loop_info.location);
|
||||||
@@ -69,7 +68,7 @@
|
|||||||
const cache_root = $ae_loc.local_file_cache_path;
|
const cache_root = $ae_loc.local_file_cache_path;
|
||||||
const prefix_len = $ae_loc.native_device?.hash_prefix_length || 2;
|
const prefix_len = $ae_loc.native_device?.hash_prefix_length || 2;
|
||||||
|
|
||||||
if (!location_id || !cache_root || is_syncing) return;
|
if (!location_id || !cache_root || is_syncing || !$ae_loc.is_native) return;
|
||||||
|
|
||||||
is_syncing = true;
|
is_syncing = true;
|
||||||
try {
|
try {
|
||||||
@@ -144,22 +143,31 @@
|
|||||||
if (log_lvl > 1) console.log(`Sync: Running heartbeat for device: ${device_id}`);
|
if (log_lvl > 1) console.log(`Sync: Running heartbeat for device: ${device_id}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const info = await native.get_device_info();
|
let info = null;
|
||||||
if (!info) return;
|
if ($ae_loc.is_native) {
|
||||||
|
info = await native.get_device_info();
|
||||||
|
}
|
||||||
|
|
||||||
const update_payload = {
|
const update_payload: any = {
|
||||||
heartbeat: ae_util.iso_datetime_formatter(new Date(), 'datetime_iso'),
|
// Use standard toISOString() for unambiguous UTC on server
|
||||||
info_hostname: info.hostname,
|
heartbeat: new Date().toISOString()
|
||||||
info_ip_list: info.ip_addresses.join(', '),
|
};
|
||||||
meta_json: {
|
|
||||||
|
if (info) {
|
||||||
|
update_payload.info_hostname = info.hostname;
|
||||||
|
update_payload.info_ip_list = info.ip_addresses.join(', ');
|
||||||
|
update_payload.meta_json = {
|
||||||
platform: info.platform,
|
platform: info.platform,
|
||||||
release: info.release,
|
release: info.release,
|
||||||
arch: info.arch,
|
arch: info.arch,
|
||||||
cpus: info.cpus,
|
cpus: info.cpus,
|
||||||
total_mem: Math.round(info.total_mem / (1024 * 1024)) + 'MB',
|
total_mem: Math.round(info.total_mem / (1024 * 1024)) + 'MB',
|
||||||
free_mem: Math.round(info.free_mem / (1024 * 1024)) + 'MB'
|
free_mem: Math.round(info.free_mem / (1024 * 1024)) + 'MB'
|
||||||
}
|
};
|
||||||
};
|
} else {
|
||||||
|
update_payload.info_hostname = 'Web Browser';
|
||||||
|
update_payload.notes = 'Heartbeat from non-native web session.';
|
||||||
|
}
|
||||||
|
|
||||||
await events_func.update_ae_obj__event_device({
|
await events_func.update_ae_obj__event_device({
|
||||||
api_cfg: $ae_api,
|
api_cfg: $ae_api,
|
||||||
|
|||||||
Reference in New Issue
Block a user