Adding activity logging to IDAA related section.

This commit is contained in:
Scott Idem
2025-06-02 19:08:37 -04:00
parent b97e4002bc
commit 8279fab244
5 changed files with 316 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
<script lang="ts">
/** @type {import('./$types').PageData} */
let log_lvl: number = 0;
let log_lvl: number = 1;
// *** Import Svelte specific
import { browser } from '$app/environment';
@@ -15,6 +15,7 @@ import { liveQuery } from "dexie";
// import { core_func } from '$lib/ae_core/ae_core_functions';
import { db_archives } from "$lib/ae_archives/db_archives";
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { core_func } from '$lib/ae_core/ae_core_functions';
import { idaa_loc, idaa_sess, idaa_slct, idaa_trig } from '$lib/ae_idaa_stores';
// import { archives_func } from '$lib/ae_archives/ae_archives_functions';
@@ -26,6 +27,7 @@ interface Props {
}
let { data }: Props = $props();
if (log_lvl) {
console.log(`ae_idaa_bb +page.svelte data:`, data);
}
@@ -46,6 +48,7 @@ let lq__archive_obj_li = $derived(liveQuery(async () => {
return results;
}));
if (browser) {
console.log('Browser environment detected.');
@@ -54,6 +57,68 @@ if (browser) {
$idaa_slct.archive_id = null;
let message = {'archive_id': $idaa_slct.archive_id};
window.parent.postMessage(message, "*");
add_activity_log(
{
action: 'idaa_archives_page',
action_with: 'browser',
}
);
}
function add_activity_log(
{
action = 'idaa_archives_page',
action_with = 'none',
}: {
action?: string,
action_with?: string,
}
) {
let last_cache_refresh_iso = new Date($ae_loc?.last_cache_refresh);
let activity_description = `
${$idaa_loc.novi_full_name ?? 'none'} ${$idaa_loc.novi_email ?? 'no-email'}
allow=${$ae_loc?.allow_access}
last_cache_refresh=${last_cache_refresh_iso.toLocaleString()}
data_route=${data?.route.toString() ?? 'unknown'}
`;
let data_kv = {
external_client_id: data?.route.id,
name: `IDAA: ${$idaa_loc.novi_full_name ?? 'none'} ${$idaa_loc.novi_email ?? ''}`,
description: activity_description ?? null,
object_type: 'archive', // archive, post, event
// object_id_random: data?.params?.archive_id ?? null,
// object_id_random: ae_acct.slct.archive_id, // data?.params?.archive_id ?? null,
url_root: data?.url.origin,
// url_full_path: data?.url.href,
url_full_path: data?.url.pathname,
url_params: data?.url.searchParams.toString(),
action: action,
action_with: action_with ?? 'none',
meta_json: {
allow_access: $ae_loc?.allow_access,
last_cache_refresh: $ae_loc?.last_cache_refresh,
last_cache_refresh_iso: last_cache_refresh_iso.toISOString(),
last_cache_refresh_locale: last_cache_refresh_iso.toLocaleString(),
access_level: $ae_loc?.access_level,
iframe: $ae_loc?.iframe,
// site_access_key: $ae_loc?.site_access_key,
// site_domain_access_key: $ae_loc?.site_domain_access_key,
// site_domain: $ae_loc?.site_domain,
// extra_data: extra_data ?? '',
// log_lvl: log_lvl,
}
};
core_func.create_ae_obj__activity_log({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: data_kv,
log_lvl: log_lvl
});
}
</script>

View File

@@ -14,7 +14,7 @@ if (log_lvl) {
console.log(`ae_idaa_bb +page.svelte data:`, data);
}
// import { browser } from '$app/environment';
import { browser } from '$app/environment';
import { Modal } from 'flowbite-svelte';
@@ -22,7 +22,7 @@ import { Modal } from 'flowbite-svelte';
// import { ae_util } from '$lib/ae_utils/ae_utils';
import { liveQuery } from "dexie";
// import { core_func } from '$lib/ae_core/ae_core_functions';
import { core_func } from '$lib/ae_core/ae_core_functions';
import { db_posts } from "$lib/ae_posts/db_posts";
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { idaa_loc, idaa_sess, idaa_slct, idaa_trig, idaa_prom } from '$lib/ae_idaa_stores';
@@ -169,6 +169,74 @@ $effect(() => {
$idaa_sess.bb.show__modal_edit__post_id = false;
}
});
if (browser) {
console.log('Browser environment detected.');
add_activity_log(
{
action: 'idaa_bb_page',
action_with: 'browser',
}
);
}
function add_activity_log(
{
action = 'idaa_bb_page',
action_with = 'none',
}: {
action?: string,
action_with?: string,
}
) {
let last_cache_refresh_iso = new Date($ae_loc?.last_cache_refresh);
let activity_description = `
${$idaa_loc.novi_full_name ?? 'none'} ${$idaa_loc.novi_email ?? 'no-email'}
allow=${$ae_loc?.allow_access}
last_cache_refresh=${last_cache_refresh_iso.toLocaleString()}
data_route=${data?.route.toString() ?? 'unknown'}
`;
let data_kv = {
external_client_id: data?.route.id,
name: `IDAA: ${$idaa_loc.novi_full_name ?? 'none'} ${$idaa_loc.novi_email ?? ''}`,
description: activity_description ?? null,
object_type: 'post', // archive, post, event
// object_id_random: data?.params?.event_id ?? null,
// object_id_random: ae_acct.slct.archive_id, // data?.params?.archive_id ?? null,
url_root: data?.url.origin,
// url_full_path: data?.url.href,
url_full_path: data?.url.pathname,
url_params: data?.url.searchParams.toString(),
action: action,
action_with: action_with ?? 'none',
meta_json: {
allow_access: $ae_loc?.allow_access,
last_cache_refresh: $ae_loc?.last_cache_refresh,
last_cache_refresh_iso: last_cache_refresh_iso.toISOString(),
last_cache_refresh_locale: last_cache_refresh_iso.toLocaleString(),
access_level: $ae_loc?.access_level,
iframe: $ae_loc?.iframe,
// site_access_key: $ae_loc?.site_access_key,
// site_domain_access_key: $ae_loc?.site_domain_access_key,
// site_domain: $ae_loc?.site_domain,
// extra_data: extra_data ?? '',
// log_lvl: log_lvl,
}
};
core_func.create_ae_obj__activity_log({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: data_kv,
log_lvl: log_lvl
});
}
</script>

View File

@@ -11,12 +11,12 @@ import { Modal } from 'flowbite-svelte';
// import type { key_val } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
import { core_func } from '$lib/ae_core/ae_core_functions';
import { idaa_loc, idaa_sess, idaa_slct, idaa_trig, idaa_prom } from '$lib/ae_idaa_stores';
// import Element_data_store from '$lib/element_data_store_v2.svelte';
// import Comp_event_session_obj_li from '../../events_pres_mgmt/ae_comp__event_session_obj_li.svelte';
import { liveQuery } from "dexie";
// import { core_func } from '$lib/ae_core/ae_core_functions';
import { add, liveQuery } from "dexie";
import { db_events } from "$lib/ae_events/db_events";
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { events_func } from '$lib/ae_events_functions';
@@ -273,6 +273,69 @@ if (browser) {
let message = {'event_id': $idaa_slct?.event_id ?? null};
window.parent.postMessage(message, "*");
add_activity_log(
{
action: 'idaa_meetings_page',
action_with: 'browser',
}
);
}
function add_activity_log(
{
action = 'idaa_meetings_page',
action_with = 'none',
}: {
action?: string,
action_with?: string,
}
) {
let last_cache_refresh_iso = new Date($ae_loc?.last_cache_refresh);
let activity_description = `
${$idaa_loc.novi_full_name ?? 'none'} ${$idaa_loc.novi_email ?? 'no-email'}
allow=${$ae_loc?.allow_access}
last_cache_refresh=${last_cache_refresh_iso.toLocaleString()}
data_route=${data?.route.toString() ?? 'unknown'}
`;
let data_kv = {
external_client_id: data?.route.id,
name: `IDAA: ${$idaa_loc.novi_full_name ?? 'none'} ${$idaa_loc.novi_email ?? ''}`,
description: activity_description ?? null,
object_type: 'event', // archive, post, event
// object_id_random: data?.params?.event_id ?? null,
// object_id_random: ae_acct.slct.archive_id, // data?.params?.archive_id ?? null,
url_root: data?.url.origin,
// url_full_path: data?.url.href,
url_full_path: data?.url.pathname,
url_params: data?.url.searchParams.toString(),
action: action,
action_with: action_with ?? 'none',
meta_json: {
allow_access: $ae_loc?.allow_access,
last_cache_refresh: $ae_loc?.last_cache_refresh,
last_cache_refresh_iso: last_cache_refresh_iso.toISOString(),
last_cache_refresh_locale: last_cache_refresh_iso.toLocaleString(),
access_level: $ae_loc?.access_level,
iframe: $ae_loc?.iframe,
// site_access_key: $ae_loc?.site_access_key,
// site_domain_access_key: $ae_loc?.site_domain_access_key,
// site_domain: $ae_loc?.site_domain,
// extra_data: extra_data ?? '',
// log_lvl: log_lvl,
}
};
core_func.create_ae_obj__activity_log({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: data_kv,
log_lvl: log_lvl
});
}
</script>
@@ -346,6 +409,13 @@ if (browser) {
$idaa_sess.recovery_meetings.show__modal_edit = false;
$idaa_sess.recovery_meetings.show__modal_view = true;
add_activity_log(
{
action: 'idaa_meetings_page',
action_with: 'cancel_edit',
}
);
}}
class="novi_btn btn btn-sm variant-ghost-warning hover:variant-filled-warning transition"
title={`View meeting: ${$lq__event_obj?.name}`}
@@ -374,6 +444,13 @@ if (browser) {
on:click={() => {
console.log('Close modal');
$idaa_sess.recovery_meetings.show__modal_edit = false;
add_activity_log(
{
action: 'idaa_meetings_page',
action_with: 'close_modal',
}
);
}}
class="novi_btn btn btn-sm variant-soft-warning hover:variant-ghost-warning"
>
@@ -410,6 +487,13 @@ if (browser) {
$idaa_sess.recovery_meetings.show__modal_view = false;
$idaa_sess.recovery_meetings.show__modal_edit = true;
add_activity_log(
{
action: 'idaa_meetings_page',
action_with: 'edit',
}
);
}}
class="novi_btn btn btn-sm variant-ghost-warning hover:variant-filled-warning transition"
title={`Edit meeting: ${$lq__event_obj?.name}`}

View File

@@ -1,10 +1,16 @@
<script lang="ts">
/** @type {import('./$types').PageData} */
export let data: any;
let log_lvl: number = 0;
// *** Import Svelte core
import { onMount } from 'svelte';
import { Spinner } from 'flowbite-svelte';
import { browser } from '$app/environment';
// *** Import Aether core variables and functions
import { ae_util } from '$lib/ae_utils/ae_utils';
import { core_func } from '$lib/ae_core/ae_core_functions';
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { idaa_loc, idaa_sess, idaa_slct } from '$lib/ae_idaa_stores';
@@ -13,6 +19,73 @@ export let lq__event_obj_li: any;
onMount(() => {
console.log('** Component Mounted: ** List - Recovery Meeting (Event) Obj');
});
if (browser) {
add_activity_log(
{
action: 'idaa_meetings_page',
action_with: 'search',
}
);
}
function add_activity_log(
{
action = 'idaa_meetings_page',
action_with = 'none',
}: {
action?: string,
action_with?: string,
}
) {
let last_cache_refresh_iso = new Date($ae_loc?.last_cache_refresh);
let activity_description = `
${$idaa_loc.novi_full_name ?? 'none'} ${$idaa_loc.novi_email ?? 'no-email'}
allow=${$ae_loc?.allow_access}
last_cache_refresh=${last_cache_refresh_iso.toLocaleString()}
data_route=${data?.route.toString() ?? 'unknown'}
`;
let data_kv = {
external_client_id: data?.route.id,
name: `IDAA: ${$idaa_loc.novi_full_name ?? 'none'} ${$idaa_loc.novi_email ?? ''}`,
description: activity_description ?? null,
object_type: 'event', // archive, post, event
// object_id_random: data?.params?.event_id ?? null,
// object_id_random: ae_acct.slct.archive_id, // data?.params?.archive_id ?? null,
url_root: data?.url.origin,
// url_full_path: data?.url.href,
url_full_path: data?.url.pathname,
url_params: data?.url.searchParams.toString(),
action: action,
action_with: action_with ?? 'none',
meta_json: {
allow_access: $ae_loc?.allow_access,
last_cache_refresh: $ae_loc?.last_cache_refresh,
last_cache_refresh_iso: last_cache_refresh_iso.toISOString(),
last_cache_refresh_locale: last_cache_refresh_iso.toLocaleString(),
access_level: $ae_loc?.access_level,
iframe: $ae_loc?.iframe,
// site_access_key: $ae_loc?.site_access_key,
// site_domain_access_key: $ae_loc?.site_domain_access_key,
// site_domain: $ae_loc?.site_domain,
// extra_data: extra_data ?? '',
// log_lvl: log_lvl,
}
};
core_func.create_ae_obj__activity_log({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: data_kv,
log_lvl: log_lvl
});
}
</script>

View File

@@ -25,23 +25,41 @@ const modalRegistry: Record<string, ModalComponent> = {
// modalComponentTwo: { ref: ModalComponentTwo },
// ...
};
let { data, children }: Props = $props();
if (browser) {
add_activity_log(
{
action: 'idaa_root_layout',
action_with: 'browser',
}
);
}
function add_activity_log(
{
action = 'idaa_root_layout',
action_with = 'none',
}: {
action?: string,
action_with?: string,
}
) {
let last_cache_refresh_iso = new Date($ae_loc?.last_cache_refresh);
let activity_description = `
${$idaa_loc.novi_full_name ?? 'none'} ${$idaa_loc.novi_email ?? 'no-email'}
allow=${$ae_loc?.allow_access}
last_cache_refresh=${last_cache_refresh_iso.toLocaleString()}
data_route=${data?.route.toString() ?? 'unknown'}
`;
let data_kv = {
external_client_id: data?.route.id,
name: `IDAA: ${$idaa_loc.novi_full_name ?? 'no-name'} ${$idaa_loc.novi_email ?? 'no-email'} allow=${$ae_loc?.allow_access}`,
name: `IDAA: ${$idaa_loc.novi_full_name ?? 'none'} ${$idaa_loc.novi_email ?? ''}`,
description: activity_description ?? null,
object_type: 'idaa', // archive, post, event
// object_id_random: data?.route,
url_root: data?.url.origin,
@@ -49,6 +67,7 @@ function add_activity_log(
url_full_path: data?.url.pathname,
url_params: data?.url.searchParams.toString(),
action: action,
action_with: action_with ?? 'none',
meta_json: {
allow_access: $ae_loc?.allow_access,
last_cache_refresh: $ae_loc?.last_cache_refresh,
@@ -72,13 +91,6 @@ function add_activity_log(
});
}
if (browser) {
add_activity_log(
{
action: 'idaa_root_layout - browser',
}
);
}
</script>