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

Align Statsig user config to match JS client #58261

Merged
merged 4 commits into from
Apr 29, 2024

Conversation

nicklathe
Copy link
Contributor

@nicklathe nicklathe commented Apr 25, 2024

In an effort to align the backend Statsig Metrics wrapper with the frontend wrapper, the following changes are necessary:

  • Move the user_type to the Statsig user object (previously this was a value in the metadata hash)
  • Add a get_enabled_experiments as an optional parameter, which will be a list of experiments a user might be enrolled in. The reason for this being optional is to save on db queries where experiments may not be relevant

Both of these will be values in the custom_ids hash in the StatsigUser class, per the Statsig docs.

Example usage:

metadata = {
    'some_data' => 'foo',
}
Metrics::Events.log_event(
    user: user,
    event_name: 'lti_user_signin',
    metadata: metadata,
    get_enabled_experiments: true,
)

Old formatted event:
Screenshot 2024-04-25 at 5 29 22 PM

New formatted event:
Screenshot 2024-04-26 at 12 36 12 PM

Warning!!

The AP CSP Create Performance Task is in progress. The most critical dates are from April 3 - April 30, 2024. Please consider any risk introduced by this PR that could affect our students taking AP CSP. Code.org students taking AP CSP primarily use App Lab for their Create Task, however a small percent use Game Lab. Carefully consider whether your change has any risk of alterering, changing, or breaking anything in these two labs. Even small changes, such as a different button color, are considered significant during this time period. Reach out to the Student Learning team or Curriculum team for more details.

Links

Testing story

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

  - Move user_type to user properties
  - Add enabled_experiments feature

Signed-off-by: Nick Lathe <nick.lathe@code.org>
@nicklathe nicklathe marked this pull request as ready for review April 26, 2024 00:51
@nicklathe nicklathe self-assigned this Apr 26, 2024
Copy link
Contributor

@hannahbergam hannahbergam left a comment

Choose a reason for hiding this comment

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

Yay- this looks great! @dmcavoy I'm not exactly sure how their metrics will work across client and server side integrations, but I imagine this is the closest we can get. Thanks so much for jumping on this Nick!

Copy link
Contributor

@hannahbergam hannahbergam left a comment

Choose a reason for hiding this comment

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

Actually one more thought- don't we have a way to query a user's current experiments from the backend?

@nicklathe
Copy link
Contributor Author

Actually one more thought- don't we have a way to query a user's current experiments from the backend?

Good point, let me look into that.

@nicklathe
Copy link
Contributor Author

It doesn't look like Statsig supports listing experiments, at least for server-side SDKs. It does support Feature Gates.

@hannahbergam
Copy link
Contributor

It doesn't look like Statsig supports listing experiments, at least for server-side SDKs. It does support Feature Gates.

I am referring to Code.org experiments here. Perhaps we can discuss offline?

Copy link
Contributor

@mgc1194 mgc1194 left a comment

Choose a reason for hiding this comment

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

Nice! Thanks!
Could you link in this PR where the front-end wrapper is defined?
I'm curious to compare both.

@nicklathe nicklathe merged commit fc4cd57 into staging Apr 29, 2024
2 checks passed
@nicklathe nicklathe deleted the nicklathe/align-statsig-user-config branch April 29, 2024 16:15
@nicklathe
Copy link
Contributor Author

@mgc1194 Statsig wrapper, implemented in the AnalyticsReporter

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.

None yet

3 participants