This repository houses the .Net based C# SDK for Optimizely Full Stack.
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.
See the Optimizely Full Stack developer documentation to learn how to set up your first Full Stack project and use the SDK.
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.
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.
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.
The sample project contains unit tests as well which can be run from the built-in Visual Studio Test Runner.
Please see CONTRIBUTING.
Optimizely SDK uses third party software: murmurhash-signed, Newtonsoft.Json, and NJsonSchema. Optimizely's NuGet package digitally signs these third party DLL's. Third party software licenses are included in the folder Licenses when Optimizely is installed.