Activity log of users of app

  • Goal: I'd like to see how people interact with my app and how many people use it. The app is to be shared with tutors outside of the central company.
1 Like

hi @JojoSylvia !

not sure how in-depth you need activity details, BUT...

we are doing something very simple to get user metrics about app usage:

create schema if not exists app;

-- drop table if exists app.log;
create table if not exists app.log (
  id           bigserial primary key,
  user_id      text,
  user_name    text,
  user_email   text,
  app_name     text,
  app_uuid     text,
  app_version  text,
  created_at   timestamp default current_timestamp
);
-- database resource query in each app, runs on page load
insert into app.log (
  user_id,
  user_email,
  user_name,
  app_name,
  app_uuid,
  app_version
)
select
  '{{current_user.id}}' as user_id,
  '{{current_user.email}}' as user_email,
  '{{current_user.fullName}}' as user_name,
  '{{retoolContext.appName}}' as app_name,
  '{{retoolContext.appUuid}}' as app_uuid,
  '{{retoolContext.pageTag}}' as app_version

note: i have disabled prepared statements for this database resource (you can read about what that means here) so you may need to remove the ' around literal values if you're using default settings.

from there, we do some simple aggregations to compare the created_at values per user to see how long they spent on an app, which apps each user likes the most, the total visit counts for external users, etc.

let me know if any of that helps!

3 Likes

Nice one @trz-justin-dev.

Just linking this other topic which may be relevant and give you other ideas @JojoSylvia

1 Like

So will this work for a publically available app? Or do tutors have to login?