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: get variation details by variation type #90

Merged
merged 31 commits into from
Sep 5, 2024

Conversation

duyhungtnn
Copy link
Collaborator

@duyhungtnn duyhungtnn commented Jun 22, 2024

Related bucketeer-io/bucketeer#886

Changes

  • Added a new data class BKTEvaluationDetail<T> to support getting variation details by variation type.
  • Added a new data class BKTValue to reference a JSON node value
  • Introduce a new interface to get variation details by variation type
func objectVariation(featureId: String, defaultValue: BKTValue) -> BKTValue
func intVariationDetails(featureId: String, defaultValue: Int) -> BKTEvaluationDetail<Int> {}
func doubleVariationDetails(featureId: String, defaultValue: Double) -> BKTEvaluationDetail<Double> {}
func boolVariationDetails(featureId: String, defaultValue: Bool) -> BKTEvaluationDetail<Bool> {}
func stringVariationDetails(featureId: String, defaultValue: String) -> BKTEvaluationDetail<String> {}
func objectVariationDetails(featureId: String, defaultValue: BKTValue) -> BKTEvaluationDetail<BKTValue> {}
  • The class BKTEvaluation & the methods getEvaluationDetails, jsonVariation will be deprecated after this PR.

@duyhungtnn duyhungtnn self-assigned this Jun 22, 2024
@duyhungtnn duyhungtnn marked this pull request as ready for review June 23, 2024 09:19
@duyhungtnn
Copy link
Collaborator Author

@cre8ivejp please help me to take a look on this PR

@cre8ivejp cre8ivejp requested a review from kakcy June 25, 2024 07:06
Copy link
Contributor

@kakcy kakcy left a comment

Choose a reason for hiding this comment

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

thank you!
I have made some comments, please check them out.

Bucketeer/Sources/Public/BKTClient.swift Outdated Show resolved Hide resolved
public let variationValue: T
public let reason: Reason

public enum Reason: String, Codable, Hashable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Although it is similar to the ReasonType definition, it is not very desirable to have the same definition in multiple places, so I would like you to consider using it uniformly if possible. Or consider removing the definition if you don't need it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ReasonType

is for internal use only. I maintain the same approach like before

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would like to keep this. The Android SDK has something like this as well. @kakcy

case offVariation = "OFF_VARIATION"
case prerequisite = "PREREQUISITE"

public static func fromString(value: String) -> Reason {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be good to have a test for the fromString().

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will add them

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated in d170ebe

Bucketeer/Sources/Public/BKTEvaluation.swift Outdated Show resolved Hide resolved
Bucketeer/Sources/Public/BKTEvaluation.swift Outdated Show resolved Hide resolved
@@ -200,6 +238,7 @@ extension BKTClient {
}
}

@available(*, deprecated, message: "use stringEvaluationDetails<T> instead")
Copy link
Contributor

Choose a reason for hiding this comment

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

??

Suggested change
@available(*, deprecated, message: "use stringEvaluationDetails<T> instead")
@available(*, deprecated, message: "use getVariationDetail<T> instead")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hi @kakcy ,

getVariationDetail is for internal use only. It can not be accessed from outside.
But I will remote the <T> from the stringEvaluationDetails<T>

Copy link
Collaborator Author

@duyhungtnn duyhungtnn Jun 25, 2024

Choose a reason for hiding this comment

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

I updated it to

@available(*, deprecated, message: "use stringVariationDetails(featureId:, defaultValue:) instead")

duyhungtnn and others added 7 commits June 25, 2024 17:50
@duyhungtnn
Copy link
Collaborator Author

@kakcy thank you for reviewing.
I updated the PR with some changes from your suggestion.
Also, I changed the interface a little in this commit 12cbd20

as they are a new requirement bucketeer-io/android-client-sdk#180 (comment)

@duyhungtnn duyhungtnn requested a review from kakcy June 25, 2024 14:34
kakcy
kakcy previously approved these changes Jun 26, 2024
Copy link
Contributor

@kakcy kakcy left a comment

Choose a reason for hiding this comment

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

Thank you for your responses 👍

@cre8ivejp cre8ivejp changed the title feat: new detailed evaluation interface feat: get evaluation details interface Jun 26, 2024
@cre8ivejp cre8ivejp changed the title feat: get evaluation details interface feat: get variation details by variation type Jun 26, 2024
cre8ivejp
cre8ivejp previously approved these changes Jul 5, 2024
Copy link
Member

@cre8ivejp cre8ivejp left a comment

Choose a reason for hiding this comment

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

Thank you!
I'll merge next week.

@cre8ivejp cre8ivejp marked this pull request as draft July 5, 2024 12:25
@duyhungtnn duyhungtnn dismissed stale reviews from cre8ivejp and kakcy via 8ac1c4f July 31, 2024 02:38
@duyhungtnn duyhungtnn force-pushed the feat/new-detailed-evaluation-interface branch from 9e2ecd9 to d990311 Compare August 1, 2024 08:47
@duyhungtnn duyhungtnn marked this pull request as ready for review August 2, 2024 01:16
@duyhungtnn
Copy link
Collaborator Author

duyhungtnn commented Aug 2, 2024

hi @cre8ivejp , @kakcy
Please help me to take a look at this PR.
I added changes from the latest review. These changes make our interface closest to OpenFeatue specification

Changes

public func objectVariationDetails(featureId: String, defaultValue:BKTValue)
  • Removed jsonVariationDetail
  • Deprecated the method jsonVariation

@duyhungtnn
Copy link
Collaborator Author

Although this PR seems ready for review. However, I found some edge cases when finalizing the same changes in the Android PR.

I will add some new tests to this PR.

@duyhungtnn
Copy link
Collaborator Author

duyhungtnn commented Aug 21, 2024

New changes

  • Added support to return intValue even when the underlying value is a double 8d576f2
  • Created BKTValue.number to hold JSON number value 58a6bb7

@duyhungtnn
Copy link
Collaborator Author

New changes

  • keep the detail interface right after the non-detail interface 3515534

Comment on lines 25 to 34
public struct BKTEvaluationDetails<T:Equatable>: Equatable {
public let featureId: String
public let featureVersion: Int
public let userId: String
public let variationId: String
public let variationName: String
public let variationValue: T
public let reason: Reason

public enum Reason: String, Codable, Hashable {
Copy link
Member

Choose a reason for hiding this comment

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

@duyhungtnn, WDYT of adding the BKTEvaluationDetails to a new file like you did in the Android SDK?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's good.
I updated 6e761ac

Copy link
Member

@cre8ivejp cre8ivejp left a comment

Choose a reason for hiding this comment

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

Thank you!

@cre8ivejp cre8ivejp merged commit 5a79914 into main Sep 5, 2024
7 checks passed
@cre8ivejp cre8ivejp deleted the feat/new-detailed-evaluation-interface branch September 5, 2024 23:47
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.

3 participants