Skip to content

Safe implementation of stats request#7696

Open
acwhite211 wants to merge 11 commits intomainfrom
issue-7693
Open

Safe implementation of stats request#7696
acwhite211 wants to merge 11 commits intomainfrom
issue-7693

Conversation

@acwhite211
Copy link
Member

@acwhite211 acwhite211 commented Feb 12, 2026

Fixes #7693

This PR hardens front-end stats reporting so lambda telemetry cannot slow down app behavior and is not sent more than once every 24 hours per collection. The web client stats request to the lambda could run too often and could also hold up other front-end work if the request was slow. For this stats request, each instance only needs to send once per day, with the aggregated stats fields:

  • collection count
  • user count
  • collection object count

We also need to make sure stats reporting does not impact normal Specify behavior. If the stats request fails or runs long, it should not block anything else. Here's the front-end stats flow:

  1. The lambda stats request is sent no more than once every 24 hours, using a localStorage timestamp key scoped by collection.
  2. The lambda request runs in the background, such that it does not block other front-end operations.
  3. A client timeout is applied, so that the request is cut off if it runs too long.
  4. Errors are handled silently and do not affect other app functionality.
  5. Stats parameters include collection count, user count, and collection object count.

We discussed moving stats submission to the back-end, but decided using a browser localStorage timestamp for gating is sufficient for this use case and keeps the implementation straightforward.

Added the lambda function for the stats aggregator to the data management repo https://github.com/specify/data-management/blob/main/lambda_functions/sp7_stats_aggregator.py

The new stats server has been setup at https://sp7-stats.specifycloud.org/

I also figured out how to get CNAME records to work between dreamhost and aws lambda functions so that the stats lambda function can have a permanent specify cloud url. stats-2.specifycloud.org

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list

Testing instructions

  • Open the Specify main page. In the network tab, see that the api request to the sp7-stats.specifycloud.org/capture endpoint was successful.
  • Try refreshing the page and then immediately try doing other tasks, like opening a tree. Make sure that the app doesn't expereince any irregular slow down due to slow/hanging stats requests.

@acwhite211 acwhite211 marked this pull request as ready for review February 17, 2026 22:26
@acwhite211 acwhite211 requested review from a team February 17, 2026 22:26
@acwhite211 acwhite211 added this to the 7.12.0 milestone Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

New stats client request functionality

1 participant