Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add next_log_created_at to analytics_log to allow time tracking per card #2314

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

Mike-Heneghan
Copy link
Contributor

@Mike-Heneghan Mike-Heneghan commented Oct 16, 2023

What:

  • Catch when a component is transitioned and a new analytics_log record is created.
  • Store the created_at of this against newLogCreatedAt
  • Use the lastAnalyticsLog to mutate the last log with the new newLogCreatedAtstored against the new next_log_created_at column.

Why:

  • We want to be able to track how long users spend on each card
  • When querying we can compare the difference between created_at and next_log_created_at to have a number for how long was take on the card in the context of a user in a session.
  • Allow null to show that user's don't always proceed in the flow and might "resume" later kicking off a new session.

Rationale:

  • Is this a logical way to store this information

    • Shares the same format as existing data
    • Based on the system time which avoid conversion issues
    • I believe it will be easy to interrogate the data with SQL.
    • Also, nullable as sometimes there is no time spent on cards and there's not guarantee another log will be added in the session hence the field remains null.
  • Is it actually representative of how long was spent on a card

    • Yes as it's scoped to a session
  • How do we handle auto answer questions which create instances of analytics_logs but aren't even shown to the user.

    • I don't think we do need to handle this as card which effectively have no time on them can be filtered out of the query.

    Screen Recording:

Screen.Recording.2023-10-17.at.15.01.17.mov

@Mike-Heneghan Mike-Heneghan self-assigned this Oct 16, 2023
@Mike-Heneghan
Copy link
Contributor Author

How do we handle auto answer questions which create instances of analytics_logs but aren't even shown to the user?

On this point I don't think it's necessarily a problem that we still create records for components which the user doesn't actually see and in these cases the next_log_created_at is null as the time spend should effectively be 0s.

I do wonder whether it would be worth adding an auto_answered flag to these analytics_log instances? It definitely took me a while to figure out what was happening in these circumstances although this could be more related to familiarity with the codebase.

…ecord on next_log_created_at

- Add next_log_created_at column to analytics_log
- Update permissions to allow created_at to be read via graphql select
- On component transition when an analytics log is created store the created at
- Update the last log with this value
- Should allow us to infer the time spent per card in a single session
@Mike-Heneghan Mike-Heneghan force-pushed the mh/analytics-track-time-on-each-card branch from 97800c6 to d174255 Compare October 17, 2023 12:06
@github-actions
Copy link

github-actions bot commented Oct 17, 2023

🤖 Hasura Change Summary compared a subset of table metadata including permissions:

Updated Tables (1)

  • public.analytics_logs permissions:

    insert select update delete
    public / /
    2 added column permissions
    insert select update
    public ➕ created_at ➕ next_log_created_at

@Mike-Heneghan
Copy link
Contributor Author

In the course of this ticket noticed a warning around in the console around setting state:

Screenshot 2023-10-17 at 13 07 02

@Mike-Heneghan
Copy link
Contributor Author

Another warning:

Screenshot 2023-10-17 at 13 08 27

@github-actions
Copy link

github-actions bot commented Oct 17, 2023

Removed vultr server and associated DNS entries

@Mike-Heneghan Mike-Heneghan changed the title feat: track time on each card feat: add next_log_created_at to analytics_log to allow time tracking per card Oct 17, 2023
@Mike-Heneghan Mike-Heneghan requested a review from a team October 17, 2023 14:04
@Mike-Heneghan Mike-Heneghan marked this pull request as ready for review October 17, 2023 14:04
@Mike-Heneghan
Copy link
Contributor Author

Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good 👌 I think we covered most of this yesterday - nothing more to add!

@Mike-Heneghan Mike-Heneghan merged commit d86cd87 into main Oct 18, 2023
12 checks passed
@Mike-Heneghan Mike-Heneghan deleted the mh/analytics-track-time-on-each-card branch October 18, 2023 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants