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: AssignmentTrackingProvider used to track local evaluation assignment events #14

Merged
merged 8 commits into from
Feb 15, 2024

Conversation

tyiuhc
Copy link
Collaborator

@tyiuhc tyiuhc commented Feb 9, 2024

Summary

  • AssignmentTrackingProvider interface

    • Implementation needs to be passed to AssignmentConfig to send assignment events from local evaluations to Amplitude
    • The track method takes in an Assignment object, which represents an assignment event
    • Sending an event to Amplitude
      • see developer docs for more details
      • Assignment::toJSONPayload can be used to convert an Assignment to a JSON string representation of the payload required to send an event to Amplitude
      • Assignment::toJSONString can be used to convert an Assignment to a JSON string representation of an assignment event - this is equivalent to an object in the events array in the payload
  • DefaultAssignmentTrackingProvider

    • A default implementation of the AssignmentTrackingProvider interface which uses the synchronous internal Amplitude package
    • Recommended for use of testing and applications where latency is less of a concern
  • Refactors

    • minIdLength (minimum permitted length for user_id and device_id fields for assignment event) added to AssignmentConfig
    • Internal Amplitude package is no longer automatically used to send assignment events
    • logger added to AmplitudeConfig instead of being passed via LocaEvaluationClient
    • toEvent moved from AssignmentService to Assignment

@tyiuhc tyiuhc requested a review from bgiori February 13, 2024 00:45
@marco-perrullo
Copy link

On PR summary comment you mention that we could do Assignment::toJSONPayload or Assignment::toJSONString but this methods are not static so I guess that we should do something like:

$assignment = new Assignment($user,$variants,$apiKey);
$assignment->toJSONString();

Is this correct?

@tyiuhc
Copy link
Collaborator Author

tyiuhc commented Feb 14, 2024

On PR summary comment you mention that we could do Assignment::toJSONPayload or Assignment::toJSONString but this methods are not static so I guess that we should do something like:

$assignment = new Assignment($user,$variants,$apiKey);
$assignment->toJSONString();

Is this correct?

Yes, that is correct.

@tyiuhc tyiuhc merged commit 62a6696 into main Feb 15, 2024
6 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 15, 2024
# [0.5.0](0.4.0...0.5.0) (2024-02-15)

### Features

* AssignmentTrackingProvider used to track local evaluation assignment events ([#14](#14)) ([62a6696](62a6696))
Copy link

🎉 This PR is included in version 0.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants