-
Notifications
You must be signed in to change notification settings - Fork 3
feat: generate analytic events from evaluations #36
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5db0602
feat: generate events from variation methods
cwaldren-ld 9ac9564
fixing tests
cwaldren-ld 41215bd
add log tag to flush workers
cwaldren-ld d872fc1
update main.cpp
cwaldren-ld ba6b2f2
try to fix evaluation detail compilation with name conflict
cwaldren-ld 5dd97a0
experimenting with variationdetail methods
cwaldren-ld 99aace6
update value with conversion operators
cwaldren-ld a049425
add tests for Value conversion operators and Value::Array comparison ops
cwaldren-ld 9c2d0d0
fix bug in Value::Array equality comparison
cwaldren-ld 14fc011
add debug logging when client not initialized
cwaldren-ld 78c9ab3
Merge branch 'main' into cw/sc-199609/generate-analytic-events
cwaldren-ld 46216a8
fix: add operator== and operator!= for Value::Array and Value::Object
cwaldren-ld 7072861
Merge branch 'cw/array-object-equality-operators' into cw/sc-199609/g…
cwaldren-ld ec055d4
Merge branch 'main' into cw/sc-199609/generate-analytic-events
cwaldren-ld f63a88c
maybe fix ConversionOperators test?
cwaldren-ld 6da26c0
make it more elegant
cwaldren-ld 039b3f2
separate out ld headers
cwaldren-ld 7f36a00
document EvaluationDetail
cwaldren-ld d7b1eaa
fix some lints
cwaldren-ld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,82 @@ | ||
| #include <gtest/gtest.h> | ||
| #include <launchdarkly/client_side/api.hpp> | ||
| #include <map> | ||
| #include "context_builder.hpp" | ||
|
|
||
| using namespace launchdarkly; | ||
| using namespace launchdarkly::client_side; | ||
|
|
||
| TEST(ClientTest, ConstructClientWithConfig) { | ||
| tl::expected<client_side::Config, Error> config = | ||
| client_side::ConfigBuilder("sdk-123").Build(); | ||
|
|
||
| TEST(ClientTest, ClientConstructedWithMinimalConfigAndContext) { | ||
| tl::expected<Config, Error> config = ConfigBuilder("sdk-123").Build(); | ||
| ASSERT_TRUE(config); | ||
|
|
||
| auto context = ContextBuilder().kind("cat", "shadow").build(); | ||
| Context context = ContextBuilder().kind("cat", "shadow").build(); | ||
|
|
||
| Client client(std::move(*config), context); | ||
| } | ||
|
|
||
| client_side::Client client(std::move(*config), context); | ||
| TEST(ClientTest, AllFlagsIsEmpty) { | ||
| Client client(ConfigBuilder("sdk-123").Build().value(), | ||
| ContextBuilder().kind("cat", "shadow").build()); | ||
|
|
||
| ASSERT_TRUE(client.AllFlags().empty()); | ||
| ASSERT_TRUE(client.BoolVariation("cat-food", true)); | ||
| } | ||
|
|
||
| TEST(ClientTest, BoolVariationDefaultPassesThrough) { | ||
| Client client(ConfigBuilder("sdk-123").Build().value(), | ||
| ContextBuilder().kind("cat", "shadow").build()); | ||
|
|
||
| const std::string flag = "extra-cat-food"; | ||
| std::vector<bool> values = {true, false}; | ||
| for (auto const& v : values) { | ||
| ASSERT_EQ(client.BoolVariation(flag, v), v); | ||
| ASSERT_EQ(*client.BoolVariationDetail(flag, v), v); | ||
| } | ||
| } | ||
|
|
||
| TEST(ClientTest, StringVariationDefaultPassesThrough) { | ||
| Client client(ConfigBuilder("sdk-123").Build().value(), | ||
| ContextBuilder().kind("cat", "shadow").build()); | ||
| const std::string flag = "treat"; | ||
| std::vector<std::string> values = {"chicken", "fish", "cat-grass"}; | ||
| for (auto const& v : values) { | ||
| ASSERT_EQ(client.StringVariation(flag, v), v); | ||
| ASSERT_EQ(*client.StringVariationDetail(flag, v), v); | ||
| } | ||
| } | ||
|
|
||
| TEST(ClientTest, IntVariationDefaultPassesThrough) { | ||
| Client client(ConfigBuilder("sdk-123").Build().value(), | ||
| ContextBuilder().kind("cat", "shadow").build()); | ||
| const std::string flag = "weight"; | ||
| std::vector<int> values = {0, 12, 13, 24, 1000}; | ||
| for (auto const& v : values) { | ||
| ASSERT_EQ(client.IntVariation("weight", v), v); | ||
| ASSERT_EQ(*client.IntVariationDetail("weight", v), v); | ||
| } | ||
| } | ||
|
|
||
| TEST(ClientTest, DoubleVariationDefaultPassesThrough) { | ||
| Client client(ConfigBuilder("sdk-123").Build().value(), | ||
| ContextBuilder().kind("cat", "shadow").build()); | ||
| const std::string flag = "weight"; | ||
| std::vector<double> values = {0.0, 12.0, 13.0, 24.0, 1000.0}; | ||
| for (auto const& v : values) { | ||
| ASSERT_EQ(client.DoubleVariation(flag, v), v); | ||
| ASSERT_EQ(*client.DoubleVariationDetail(flag, v), v); | ||
| } | ||
| } | ||
|
|
||
| TEST(ClientTest, JsonVariationDefaultPassesThrough) { | ||
| Client client(ConfigBuilder("sdk-123").Build().value(), | ||
| ContextBuilder().kind("cat", "shadow").build()); | ||
|
|
||
| const std::string flag = "assorted-values"; | ||
| std::vector<Value> values = { | ||
| Value({"running", "jumping"}), Value(3), Value(1.0), Value(true), | ||
| Value(std::map<std::string, Value>{{"weight", 20}})}; | ||
| for (auto const& v : values) { | ||
| ASSERT_EQ(client.JsonVariation(flag, v), v); | ||
| ASSERT_EQ(*client.JsonVariationDetail(flag, v), v); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm copying the
if (reasons)part from the Go client SDK, but I'm not sure the justification and I might have it wrong - will check other SDKs. The spec says:So I'd think it should only be set if
flag.track_reason()or ifdetailedis true. Now, we can't use the former because the flag isn't present, so then it's up todetailed. But the Go SDK is using the fact that the user requestedwithReasons...