Easy to use & easy to adapt to MVC The repository contains two projects: Main library and demo project in ASP.net Core where you can see all configurations and all ABTest Engine functionalities |
Implement your custom repository for get & save experiments (DB, Memory, etc).
[
{
"Id": "8dcdcfa5-d6f4-42a0-9f53-08c7e9b3db93",
"Title": "Experiment 1",
"Versions": [
{
"KeyWord": "Version3",
"Title": "title3",
"Percentage": 60,
"TimesSent": 0
},
{
"KeyWord": "Version2",
"Title": "title2",
"Percentage": 20,
"TimesSent": 0
},
{
"KeyWord": "Version1",
"Title": "title1",
"Percentage": 20,
"TimesSent": 0
}
]
},
{
"Id": "63899319-b0a0-4b00-b04c-60abb24152f2",
"Title": "Experiment 2",
"Versions": [
{
"KeyWord": "Version22",
"Title": "title3",
"Percentage": 75,
"TimesSent": 0
},
{
"KeyWord": "Version21",
"Title": "title2",
"Percentage": 25,
"TimesSent": 0
}
]
},
{
"Id": "a55625a7-8816-40c9-805a-c77b4798d50d",
"Title": "Experiment 3",
"Versions": [
{
"KeyWord": "Version31",
"Title": "title2",
"Percentage": 50,
"TimesSent": 0
},
{
"KeyWord": "Version32",
"Title": "title3",
"Percentage": 50,
"TimesSent": 0
}
]
}
]
You can implement new providers for save to user assigned versions for each experiment
Use keywords version for tracking with analytics or other statistics frameworks for measure conversions
Need manage Begin Request & End Request for all operations
app.UseMiddleware<Main.Middleware.ABTest>();
Need manage dependency injection for manage operations in middleware
services.AddSingleton<IExperimentService, ExperimentService>();
services.AddSingleton<IExperimentRepository, JsonExperimentRepository>();
All versions have KeyWord for identify custom views. Engine try to get custom view for active experiment of assigned version. If not found, return default view.
For example: Partials/ListResults.cshtml | Partials/ListResults.KeyWord Version.cshtml
services.Configure<RazorViewEngineOptions>(options => {
options.ViewLocationExpanders.Add(new ABTestViewLocationExpander());
});
if (ABTestDotNetCore.Main.Middleware.ABTest.GetKeyWordVersionAssignedFromTitle("SolrVsSQL") == "SolrVersionKeyWord")
{
<b>//To Solr</b>
}
else
{
<b>//To Sql</b>
}
Feel free for fork and contribute!
Thanks!