Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion apps/sdk-contract-tests/include/definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigClientSideParams,
evaluationReasons,
useReport);

struct ConfigTags {
std::optional<std::string> applicationId;
std::optional<std::string> applicationVersion;
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigTags,
applicationId,
applicationVersion);

struct ConfigParams {
std::string credential;
std::optional<uint32_t> startWaitTimeMs;
Expand All @@ -89,6 +97,7 @@ struct ConfigParams {
std::optional<ConfigEventParams> events;
std::optional<ConfigServiceEndpointsParams> serviceEndpoints;
std::optional<ConfigClientSideParams> clientSide;
std::optional<ConfigTags> tags;
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigParams,
credential,
Expand All @@ -98,7 +107,8 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigParams,
polling,
events,
serviceEndpoints,
clientSide);
clientSide,
tags);

struct ContextSingleParams {
std::optional<std::string> kind;
Expand Down
9 changes: 9 additions & 0 deletions apps/sdk-contract-tests/src/entity_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ std::optional<std::string> EntityManager::create(ConfigParams const& in) {
datasource.UseReport(*in.clientSide->useReport);
}

if (in.tags) {
if (in.tags->applicationId) {
config_builder.AppInfo().Identifier(*in.tags->applicationId);
}
if (in.tags->applicationVersion) {
config_builder.AppInfo().Version(*in.tags->applicationVersion);
}
}

auto config = config_builder.Build();
if (!config) {
LD_LOG(logger_, LogLevel::kWarn)
Expand Down
1 change: 0 additions & 1 deletion apps/sdk-contract-tests/test-suppressions.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
events/summary events/basic counter behavior
events/summary events/reset after each flush
tags/disallowed characters

# The Client doesn't need to know how to deserialize users.
context type/convert/old user to context/{"key": ""}
Expand Down
4 changes: 4 additions & 0 deletions libs/client-sdk/src/data_sources/polling_data_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ static network::HttpRequest MakeRequest(Config const& config,

builder.Header("authorization", config.SdkKey());

if (auto app_tag = config.ApplicationTag()) {
builder.Header("x-launchdarkly-tags", *app_tag);
}

// If no URL is set, then we will fail the request.
return {url.value_or(""), method, builder.Build(), body};
}
Expand Down
5 changes: 5 additions & 0 deletions libs/client-sdk/src/data_sources/streaming_data_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ StreamingDataSource::StreamingDataSource(
context_(std::move(context)),
http_config_(config.HttpProperties()),
data_source_config_(config.DataSourceConfig()),
app_tags_(config.ApplicationTag()),
sdk_key_(config.SdkKey()),
streaming_endpoint_(config.ServiceEndpoints().StreamingBaseUrl()) {}

Expand Down Expand Up @@ -108,6 +109,10 @@ void StreamingDataSource::Start() {
}
client_builder.header("user-agent", http_config_.UserAgent());

if (app_tags_) {
client_builder.header("x-launchdarkly-tags", *app_tags_);
}

// TODO: Handle proxy support.

auto weak_self = weak_from_this();
Expand Down
2 changes: 2 additions & 0 deletions libs/client-sdk/src/data_sources/streaming_data_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class StreamingDataSource final

config::shared::built::HttpProperties http_config_;

std::optional<std::string> app_tags_;

std::string sdk_key_;

Logger const& logger_;
Expand Down