Skip to content

Log user last activity on in GraphQL

Andy Schoenen requested to merge graphql_log_user_last_activity_on into master

What does this MR do?

Related to #195990 (closed)

It updates the User#last_activity_on field on every GraphQL request when user is logged in and last_activity_on was earlier than today. I added the same to the REST API (!21725 (merged)). It was behind a feature flag because there were some performance concerns. If a user does the first request on a day, it would trigger one additional SQL query. This might cause spikes on the beginning of the day. But rolling out the feauture flag showed that it didn't have a visible effect. I expect a low impact on GraphQL too because it's mainly used on frontend and in this case the user would be already logged in and have last_activity_on updated.

How to test on Staging

  1. Create a test user on staging with an API token
  2. Wait until the next day.
  3. Go to staging.gitlab.com/admin/users
  4. Search for the test user
  5. Make sure Last activity is not the date of today
  6. Make a GraphQL call with the test user token curl --location --request POST 'https://staging.gitlab.com/api/graphql' --header 'Authorization: Bearer TEST_USER_TOKEN' --header 'Content-Type: application/json' --data-raw '{"query":"query{project(fullPath:\"gitlab-org/gitlab\"){name issues {nodes {title}}}}","variables":{}}'
  7. Reload the admin users page and check that Last activity was updated to the date of today

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖

Merge request reports