Symplify.Conversion.SDK 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Symplify.Conversion.SDK --version 0.1.0
NuGet\Install-Package Symplify.Conversion.SDK -Version 0.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Symplify.Conversion.SDK" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Symplify.Conversion.SDK --version 0.1.0
#r "nuget: Symplify.Conversion.SDK, 0.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Symplify.Conversion.SDK as a Cake Addin
#addin nuget:?package=Symplify.Conversion.SDK&version=0.1.0

// Install Symplify.Conversion.SDK as a Cake Tool
#tool nuget:?package=Symplify.Conversion.SDK&version=0.1.0

Symplify Server-Side Testing SDK for C#

This is the C# implementation of the Symplify Server-Side Testing SDK.

It is a cross platform .NET Core library, to enable integration regardless of e.g. web frameworks used for building applications.

Changes

See CHANGELOG.md.

Requirements

Installing

Using the dotnet CLI:

dotnet add package Symplify.Conversion.SDK

https://www.nuget.org/packages/Symplify.Conversion.SDK has installation instructions for the different .NET development environments.

Usage

On your application startup:

  1. Create an SDK instance (it's meant to be used as a singleton, you can wrap it in a service).
  2. Call LoadConfig to start its config updater loop.
// `yourWebsiteID` comes from your config.
// `httpClient` is an HttpClient, probably injected.
// `LoadConfig` is async and an await ensures the initial configuration loading is complete but as long as you call it it will eventually be loaded, so awaiting is not strictly necessary.
var sstSDK = new SymplifyClient(yourWebsiteID, httpClient);
await sstSDK.LoadConfig();

On each request where you want to use variations:

  1. Call findVariation, providing a CookieJar (see below)
// `cookieJar` is an ICookieJar you need to create, see the CookieJar section
sstSDK.FindVariation("my ab-test", cookieJar)

See the project Symplify.Conversion.SDK.DemoApp for more elaborate example code. Running instructions for it are in CONTRIBUTING.md.

CookieJar

In order to assign variations stably in face of configuration changes, we need to persist the allocation for each user somehow. The SST SDK uses cookies for this (which also helps integration with the frontend js-sdk).

To be compatible with any web framework, the SDK uses an interface ICookieJar which you implement to provide reading and writing of cookies. Here is an example using IHttpContextAccessor which you can use in eveyr request you handle:

using Microsoft.AspNetCore.Http;
using Symplify.Conversion.SDK.Cookies;

class HttpContextCookieJar : ICookieJar
{
    private readonly string domain;
    private readonly IHttpContextAccessor accessor;

    public HttpContextCookieJar(string domain, IHttpContextAccessor accessor)
    {
        this.domain = domain;
        this.accessor = accessor;
    }

    public string GetCookie(string name)
    {
        return accessor.HttpContext.Request.Cookies[name];
    }

    public void SetCookie(string name, string value, uint expireInDays)
    {
        CookieOptions opts = new();
        opts.Domain = domain;
        opts.Expires = DateTimeOffset.Now.AddDays(expireInDays);
        accessor.HttpContext.Response.Cookies.Append(name, value, opts);
    }
}

If you run test on a site with multiple subdomains, you will need to use a common "parent" domain for the cookies, such as ".example.com" for e.g. "b2b.example.com" and "store.example.com".

SDK Development

See CONTRIBUTING.md or RELEASING.md.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.5.3 217 6/9/2023
0.5.2 203 3/20/2023
0.5.1 347 11/1/2022
0.5.0 314 11/1/2022
0.3.0 369 8/12/2022
0.2.0 360 6/23/2022
0.1.0 385 6/21/2022
0.0.1-preview03 119 6/17/2022