Optimizely C# SDK
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:
- Activate
- Track
- 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:
IEventDispatcher
handles the HTTP requests to Optimizely. The default implementation is an asynchronous "fire and forget".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.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.