Gainsight PX C# SDK
Gainsight PX C-Sharp SDK is a powerful collection of APIs that allows you to track users from a .NET runtime.
Getting Started
Install
After creating your project, add the correct version of .dll from the .zip file.
Add it as a reference to your project. Please make sure you also have Newtonsoft.Json as Nuget dependency in your project. (Additional dependencies if required are listed below)
Initialize
Create an instance of the Gainsight.Client
with your API key and Configuration to start sending events data.
Config config = new Config(){ //Override default session timeout(30 minutes) to 45 minutes: SessionTimeout = new System.TimeSpan(0, 45, 0) }; // Please update the product key below String _gainsightPxProductKey = "AP-XXXXXXXX-2"; Gainsight.Initialize(_gainsightPxProductKey, config);
Identify
Pass the user information on log-in
string userid = Guid.NewGuid().ToString(); string accountid = Guid.NewGuid().ToString(); Gainsight.Client.Identify( new User(userid) { Email = "user@email.com", FirstName = "User", }, new Account(accountid) { Name = "Gainsight", WebSite = "www.gainsight.com" });
Custom Events
Send custom events with information on what happened on your app.
//This method will be named Track Gainsight.Client.Track("FileUpload", new Dict { { "title", "Software" }, { "name", "PX" }, { "size", 9000 }, { "uploaded", new DateTime(2002, 7, 7, 9, 30, 50) } });
Global Context
Set up information for all events regarding the state of your app, your user, or application version.
Gainsight.Client.Context = new Dict { { "boolParameter", true }, { "lang", "EN" }, { "num", 10 }, { "releasedate", new DateTime(2020, 02, 02, 7, 30, 40) } };
Dependencies
For all versions:
-
Newtonsoft.Json - 12.0.3v
-
For netstandard1.3:
-
System.Threading.Thread - 4.3.0v
-
System.Text.RegularExpressions - 4.3.1v
-
-
For net35:
-
AsyncBridge.Net35 - 0.2.0v
-
jnm2.ReferenceAssemblies.net35 - 1.0.0v
-
-
For net45:
-
System.Net.Http - 4.3.4v
-
Microsoft.NETFramework.ReferenceAssemblies - 1.0.0v
-
-
For net461:
-
System.Net.Http - 4.3.4v
-
Microsoft.NETFramework.ReferenceAssemblies - 1.0.0v
-