Install Gainsight PX .NET SDK
Overview
Gainsight PX introduces Desktop SDK for .NET for desktop applications. The SDK supports the ability to create, read, update, or delete User and Account records.
Key Features
The developer-friendly Gainsight PX SDK has the following features:
- Tracking back-end data and services
- Operationalize engagement lifecycle
- Fetch/update usage data and metadata
Install .NET SDK
After creating your project, add the correct version of .dll from the .zip file.
Add it as a reference to your project. Ensure that 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 about the events 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, user, or application version.
Gainsight.Client.Context = new Dict { { "boolParameter", true }, { "lang", "EN" }, { "num", 10 }, { "releasedate", new DateTime(2020, 02, 02, 7, 30, 40) } };
Enabling Offline Durable Event Tracking
Setting a disk-based cache for offline event tracking can be done by configuring a cache directory. It is recommended to set cache limit and encryption strategy.
Config config = new Config() { CacheDirectoryName = "GPX", CacheEncryption = new Base64Encryption(), CacheLimit = 1000 };
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
-