Nevett / csharp-sdk

This repository houses the .Net based C# SDK for Optimizely Full Stack.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimizely C# SDK

Semantic Build Status NuGet Apache 2.0

This repository houses the .Net based C# SDK for Optimizely Full Stack.

Getting Started

Installing the SDK

The SDK can be installed through NuGet:

PM> Install-Package Optimizely.SDK

An ASP.Net MVC sample project demonstrating how to use the SDK is available as well:

PM> Install-Package Optimizely.SDK.Sample

Simply compile and run the Sample application to see it in use. Note that the way the Demo App stores data in memory is not recommended for production use and is merely illustrates how to use the SDK.

Using the SDK

Documentation

See the Optimizely Full Stack developer documentation to learn how to set up your first Full Stack project and use the SDK.

Initialization

Create the Optimizely Client, for example:

private static Optimizely Optimizely =
    new Optimizely(
        datafile: myProjectConfig,
        eventDispatcher: myEventDispatcher,
        logger: myLogger,
        errorHandler: myErrorHandler,
        skipJsonValidation: false);

Since this class parses the Project Config file, you should not create this per request.

APIs

This class exposes three main calls:

  1. Activate
  2. Track
  3. GetVariation

Activate and Track are used in the demonstration app. See the Optimizely documentation regarding how to use these.

Plug-in Interfaces

The Optimizely client object accepts the following plug-ins:

  1. IEventDispatcher handles the HTTP requests to Optimizely. The default implementation is an asynchronous "fire and forget".
  2. ILogger exposes a single method, Log, to record activity in the SDK. An example of a class to bridge the SDK's Log to Log4Net is provided in the Demo Application.
  3. IErrorHandler allows you to implement custom logic when Exceptions are thrown. Note that Exception information is already included in the Log.

These are optional plug-ins and default behavior is implement if none are provided.

Development

Unit tests

The sample project contains unit tests as well which can be run from the built-in Visual Studio Test Runner.

Contributing

Please see CONTRIBUTING.

Third Party Licenses

Optimizely SDK uses third party software: murmurhash-signed, Newtonsoft.Json, and NJsonSchema.

About

This repository houses the .Net based C# SDK for Optimizely Full Stack.

License:Apache License 2.0


Languages

Language:C# 55.9%Language:JavaScript 43.5%Language:PowerShell 0.4%Language:Shell 0.2%Language:CSS 0.1%Language:ASP 0.0%