Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
prepare 1.1.0 release (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-darkly authored Oct 17, 2019
1 parent b4eda77 commit d6d246f
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 11 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to the LaunchDarkly Client-side SDK for Xamarin will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org).

## [1.1.0] - 2019-10-17
### Added:
- Added support for upcoming LaunchDarkly experimentation features. See `ILdClient.Track(string, LdValue, double)`.
- `User.AnonymousOptional` and `IUserBuilder.AnonymousOptional` allow treating the `Anonymous` property as nullable (necessary for consistency with other SDKs). See note about this under Fixed.
- Added `LaunchDarkly.Logging.ConsoleAdapter` as a convenience for quickly enabling console logging; this is equivalent to `Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter`, but the latter is not available on some platforms.

### Fixed:
- `Configuration.Builder` was not setting a default value for the `BackgroundPollingInterval` property. As a result, if you did not set the property explicitly, the SDK would throw an error when the application went into the background on mobile platforms.
- `IUserBuilder` was incorrectly setting the user's `Anonymous` property to `null` even if it had been explicitly set to `false`. Null and false behave the same in terms of LaunchDarkly's user indexing behavior, but currently it is possible to create a feature flag rule that treats them differently. So `IUserBuilder.Anonymous(false)` now correctly sets it to `false`, just as the deprecated method `UserExtensions.WithAnonymous(false)` would.
- `LdValue.Convert.Long` was mistakenly converting to an `int` rather than a `long`. (CommonSdk [#32](https://github.com/launchdarkly/dotnet-sdk-common/issues/32))

## [1.0.0] - 2019-09-13

First GA release.
Expand Down
4 changes: 2 additions & 2 deletions src/LaunchDarkly.XamarinSdk/ConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ internal sealed class ConfigurationBuilder : IConfigurationBuilder
internal static readonly HttpMessageHandler DefaultHttpMessageHandlerInstance = new HttpClientHandler();

internal bool _allAttributesPrivate = false;
internal TimeSpan _backgroundPollingInterval;
internal TimeSpan _backgroundPollingInterval = Configuration.DefaultBackgroundPollingInterval;
internal Uri _baseUri = Configuration.DefaultUri;
internal TimeSpan _connectionTimeout = Configuration.DefaultConnectionTimeout;
internal bool _enableBackgroundUpdating = true;
Expand All @@ -303,7 +303,7 @@ internal sealed class ConfigurationBuilder : IConfigurationBuilder
internal TimeSpan _readTimeout = Configuration.DefaultReadTimeout;
internal TimeSpan _reconnectTime = Configuration.DefaultReconnectTime;
internal Uri _streamUri = Configuration.DefaultStreamUri;
internal bool _useReport;
internal bool _useReport = false;
internal int _userKeysCapacity = Configuration.DefaultUserKeysCapacity;
internal TimeSpan _userKeysFlushInterval = Configuration.DefaultUserKeysFlushInterval;

Expand Down
22 changes: 20 additions & 2 deletions src/LaunchDarkly.XamarinSdk/ILdClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ public interface ILdClient : IDisposable
/// <returns>an <c>EvaluationDetail</c> object</returns>
EvaluationDetail<LdValue> JsonVariationDetail(string key, LdValue defaultValue);

/// <summary>
/// Tracks that current user performed an event for the given event name.
/// </summary>
/// <param name="eventName">the name of the event</param>
void Track(string eventName);

/// <summary>
/// Tracks that the current user performed an event for the given event name, with additional JSON data.
/// </summary>
Expand All @@ -223,10 +229,22 @@ public interface ILdClient : IDisposable
void Track(string eventName, LdValue data);

/// <summary>
/// Tracks that the current user performed an event for the given event name.
/// Tracks that the current user performed an event for the given event name, and associates it with a
/// numeric metric value.
/// </summary>
/// <remarks>
/// As of this version’s release date, the LaunchDarkly service does not support the <c>metricValue</c>
/// parameter. As a result, calling this overload of <c>Track</c> will not yet produce any different
/// behavior from calling <see cref="Track(String, LdValue)"/> without a <c>metricValue</c>.
/// Refer to the <a href="https://docs.launchdarkly.com/docs/xamarin-sdk-reference#section-track">SDK reference guide</a>
/// for the latest status.
/// </remarks>
/// <param name="eventName">the name of the event</param>
void Track(string eventName);
/// <param name="data">a JSON value containing additional data associated with the event; pass
/// <see cref="LdValue.Null"/> if you do not need this value</param>
/// <param name="metricValue">this value is used by the LaunchDarkly experimentation feature in
/// numeric custom metrics, and will also be returned as part of the custom event for Data Export</param>
void Track(string eventName, LdValue data, double metricValue);

/// <summary>
/// Returns a map from feature flag keys to <see cref="LdValue"/> feature flag values for the current user.
Expand Down
4 changes: 2 additions & 2 deletions src/LaunchDarkly.XamarinSdk/LaunchDarkly.XamarinSdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' and '$(LD_TARGET_FRAMEWORKS)' == '' ">netstandard1.6;netstandard2.0;net45;Xamarin.iOS10;MonoAndroid71;MonoAndroid80;MonoAndroid81;</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' and '$(LD_TARGET_FRAMEWORKS)' == '' ">netstandard1.6;netstandard2.0;Xamarin.iOS10;MonoAndroid71;MonoAndroid80;MonoAndroid81;</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' and '$(LD_TARGET_FRAMEWORKS)' != '' ">$(LD_TARGET_FRAMEWORKS)</TargetFrameworks>
<Version>1.0.0</Version>
<Version>1.1.0</Version>
<OutputType>Library</OutputType>
<AssemblyName>LaunchDarkly.XamarinSdk</AssemblyName>
<PackageId>LaunchDarkly.XamarinSdk</PackageId>
Expand Down Expand Up @@ -33,7 +33,7 @@
<Folder Include="Properties\" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="Common.Logging" Version="3.4.1" />
<PackageReference Include="LaunchDarkly.CommonSdk" Version="4.0.1" />
<PackageReference Include="LaunchDarkly.CommonSdk" Version="4.2.0" />
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.6.60" PrivateAssets="All" />
<Compile Include="*.cs" />
<Compile Include="Properties\*.cs" />
Expand Down
6 changes: 6 additions & 0 deletions src/LaunchDarkly.XamarinSdk/LdClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,12 @@ public IDictionary<string, LdValue> AllFlags()
.ToDictionary(p => p.Key, p => p.Value.value);
}

/// <inheritdoc/>
public void Track(string eventName, LdValue data, double metricValue)
{
eventProcessor.SendEvent(_eventFactoryDefault.NewCustomEvent(eventName, User, data, metricValue));
}

/// <inheritdoc/>
public void Track(string eventName, LdValue data)
{
Expand Down
37 changes: 37 additions & 0 deletions tests/LaunchDarkly.XamarinSdk.Tests/ConfigurationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,43 @@ namespace LaunchDarkly.Xamarin.Tests
{
public class ConfigurationTest : BaseTest
{
[Fact]
public void TestDefaultsFromDefaultFactoryMethod()
{
VerifyDefaults(Configuration.Default("my-key"));
}

[Fact]
public void TestDefaultsFromBuilder()
{
VerifyDefaults(Configuration.Builder("my-key").Build());
}

private void VerifyDefaults(Configuration c)
{
Assert.False(c.AllAttributesPrivate);
Assert.Equal(Configuration.DefaultBackgroundPollingInterval, c.BackgroundPollingInterval);
Assert.Equal(Configuration.DefaultUri, c.BaseUri);
Assert.Equal(Configuration.DefaultConnectionTimeout, c.ConnectionTimeout);
Assert.True(c.EnableBackgroundUpdating);
Assert.False(c.EvaluationReasons);
Assert.Equal(Configuration.DefaultEventCapacity, c.EventCapacity);
Assert.Equal(Configuration.DefaultEventFlushInterval, c.EventFlushInterval);
Assert.Equal(Configuration.DefaultEventsUri, c.EventsUri);
Assert.False(c.InlineUsersInEvents);
Assert.True(c.IsStreamingEnabled);
Assert.False(c.Offline);
Assert.True(c.PersistFlagValues);
Assert.Equal(Configuration.DefaultPollingInterval, c.PollingInterval);
Assert.Null(c.PrivateAttributeNames);
Assert.Equal(Configuration.DefaultReadTimeout, c.ReadTimeout);
Assert.Equal(Configuration.DefaultReconnectTime, c.ReconnectTime);
Assert.Equal(Configuration.DefaultStreamUri, c.StreamUri);
Assert.False(c.UseReport);
Assert.Equal(Configuration.DefaultUserKeysCapacity, c.UserKeysCapacity);
Assert.Equal(Configuration.DefaultUserKeysFlushInterval, c.UserKeysFlushInterval);
}

[Fact]
public void CanOverrideConfiguration()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class FeatureFlagRequestorTests : BaseTest
private const string _mobileKey = "FAKE_KEY";

private static readonly User _user = User.WithKey("foo");
private const string _userJson = "{\"key\":\"foo\",\"anonymous\":false}";
private const string _encodedUser = "eyJrZXkiOiJmb28iLCJhbm9ueW1vdXMiOmZhbHNlLCJjdXN0b20iOnt9fQ==";
private const string _userJson = "{\"key\":\"foo\"}";
private const string _encodedUser = "eyJrZXkiOiJmb28iLCJBbm9ueW1vdXMiOmZhbHNlLCJjdXN0b20iOnt9fQ==";
// Note that in a real use case, the user encoding may vary depending on the target platform, because the SDK adds custom
// user attributes like "os". But the lower-level FeatureFlagRequestor component does not do that.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="LaunchDarkly.CommonSdk" Version="4.0.1" />
<PackageReference Include="LaunchDarkly.CommonSdk" Version="4.2.0" />
<PackageReference Include="WireMock.Net" Version="1.0.22" />
</ItemGroup>
<ItemGroup>
Expand Down
41 changes: 40 additions & 1 deletion tests/LaunchDarkly.XamarinSdk.Tests/LdClientEventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,57 @@ public void IdentifySendsIdentifyEvent()

[Fact]
public void TrackSendsCustomEvent()
{
using (LdClient client = MakeClient(user, "{}"))
{
client.Track("eventkey");
Assert.Collection(eventProcessor.Events,
e => CheckIdentifyEvent(e, user),
e => {
CustomEvent ce = Assert.IsType<CustomEvent>(e);
Assert.Equal("eventkey", ce.Key);
Assert.Equal(user.Key, ce.User.Key);
Assert.Equal(LdValue.Null, ce.Data);
Assert.Null(ce.MetricValue);
});
}
}

[Fact]
public void TrackWithDataSendsCustomEvent()
{
using (LdClient client = MakeClient(user, "{}"))
{
LdValue data = LdValue.Of("hi");
client.Track("eventkey", data);
Assert.Collection(eventProcessor.Events,
Assert.Collection(eventProcessor.Events,
e => CheckIdentifyEvent(e, user),
e => {
CustomEvent ce = Assert.IsType<CustomEvent>(e);
Assert.Equal("eventkey", ce.Key);
Assert.Equal(user.Key, ce.User.Key);
Assert.Equal(data, ce.Data);
Assert.Null(ce.MetricValue);
});
}
}

[Fact]
public void TrackWithMetricValueSendsCustomEvent()
{
using (LdClient client = MakeClient(user, "{}"))
{
LdValue data = LdValue.Of("hi");
double metricValue = 1.5;
client.Track("eventkey", data, metricValue);
Assert.Collection(eventProcessor.Events,
e => CheckIdentifyEvent(e, user),
e => {
CustomEvent ce = Assert.IsType<CustomEvent>(e);
Assert.Equal("eventkey", ce.Key);
Assert.Equal(user.Key, ce.User.Key);
Assert.Equal(data, ce.Data);
Assert.Equal(metricValue, ce.MetricValue);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class MobileStreamingProcessorTests : BaseTest
"}";

private readonly User user = User.WithKey("me");
private const string encodedUser = "eyJrZXkiOiJtZSIsImFub255bW91cyI6ZmFsc2UsImN1c3RvbSI6e319";
private const string encodedUser = "eyJrZXkiOiJtZSIsIkFub255bW91cyI6ZmFsc2UsImN1c3RvbSI6e319";

private EventSourceMock mockEventSource;
private TestEventSourceFactory eventSourceFactory;
Expand Down

0 comments on commit d6d246f

Please sign in to comment.