The activity log is almost working.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { ae_loc } from '$lib/stores/ae_stores';
|
||||
import { create_ae_obj__activity_log } from '$lib/ae_core/core__activity_log';
|
||||
|
||||
interface Props {
|
||||
data: any;
|
||||
@@ -42,6 +43,43 @@
|
||||
let meeting_start_time: Date | null = $state(null);
|
||||
let meeting_duration: string = $state('00:00:00');
|
||||
let duration_timer_id: any = $state(null);
|
||||
let reporting_timer_id: any = $state(null);
|
||||
|
||||
async function report_meeting_stats() {
|
||||
if (!is_moderator) {
|
||||
console.log('Jitsi: Not a moderator, skipping stats report.');
|
||||
// If for some reason the timer is running for a non-mod, kill it.
|
||||
if (reporting_timer_id) clearInterval(reporting_timer_id);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Jitsi: Preparing to report meeting stats...');
|
||||
const participants_array = Array.from(meeting_participants.values());
|
||||
|
||||
const data_kv = {
|
||||
source: 'idaa_jitsi_meeting',
|
||||
activity: 'live_stats_update',
|
||||
name: room_name,
|
||||
data_json: {
|
||||
duration: meeting_duration,
|
||||
participants: participants_array,
|
||||
participant_count: participants_array.length
|
||||
}
|
||||
};
|
||||
|
||||
console.log('Jitsi: Stats payload being sent:', JSON.stringify(data_kv, null, 2));
|
||||
|
||||
try {
|
||||
const result = await create_ae_obj__activity_log({
|
||||
api_cfg: $ae_loc.auth.api_cfg,
|
||||
account_id: $ae_loc.auth.account.account_id_random,
|
||||
data_kv: data_kv
|
||||
});
|
||||
console.log('Jitsi: Activity log API call successful.', result);
|
||||
} catch (error) {
|
||||
console.error('Jitsi: Error calling create_ae_obj__activity_log:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function add_jitsi_event_listeners(api: any) {
|
||||
api.on('videoConferenceJoined', (data: { id: string; displayName: string }) => {
|
||||
@@ -84,6 +122,15 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// If moderator, start reporting stats
|
||||
if (is_moderator) {
|
||||
console.log('Jitsi: User is a moderator. Starting stats reporting timer...');
|
||||
if (reporting_timer_id) clearInterval(reporting_timer_id);
|
||||
reporting_timer_id = setInterval(report_meeting_stats, 30000); // Report every 30 seconds
|
||||
} else {
|
||||
console.log('Jitsi: User is not a moderator. Stats reporting will not start.');
|
||||
}
|
||||
});
|
||||
|
||||
api.on('participantJoined', (participant: { id: string; displayName: string }) => {
|
||||
@@ -264,6 +311,7 @@
|
||||
|
||||
onDestroy(() => {
|
||||
if (duration_timer_id) clearInterval(duration_timer_id);
|
||||
if (reporting_timer_id) clearInterval(reporting_timer_id);
|
||||
if (jitsi_api) {
|
||||
console.log('Jitsi: Disposing of Jitsi API instance on component destroy.');
|
||||
jitsi_api.dispose();
|
||||
@@ -395,6 +443,7 @@
|
||||
async function init_jitsi() {
|
||||
// Clear stats and timers
|
||||
if (duration_timer_id) clearInterval(duration_timer_id);
|
||||
if (reporting_timer_id) clearInterval(reporting_timer_id);
|
||||
meeting_participants.clear();
|
||||
meeting_start_time = null;
|
||||
meeting_duration = '00:00:00';
|
||||
|
||||
Reference in New Issue
Block a user