AmplitudeSharp 1.0.5
See the version list below for details.
dotnet add package AmplitudeSharp --version 1.0.5
NuGet\Install-Package AmplitudeSharp -Version 1.0.5
<PackageReference Include="AmplitudeSharp" Version="1.0.5" />
paket add AmplitudeSharp --version 1.0.5
#r "nuget: AmplitudeSharp, 1.0.5"
// Install AmplitudeSharp as a Cake Addin #addin nuget:?package=AmplitudeSharp&version=1.0.5 // Install AmplitudeSharp as a Cake Tool #tool nuget:?package=AmplitudeSharp&version=1.0.5
AmplitudeSharp
A simple to use Amplitude analytics logging library for C#
NOTE: this library is early development stages, many changes are planned (including better documentation) use at your own risk
Features
- Simple setup
- Native Amplitude API (instead of going through some other service, such as segment.io)
- Automatic identification of hardware
- Support for offline scenarios (events are queued and stored offline to be sent later)
Setup
- If you don't have an Amplitude account already, head over to Amplitude and create an account.
- Once created, note your project API key, you can find this information in Settings > Projects section, note each project will have a different API key. I also recommend that you have
dev
andprod
environments/projects. - Install the nuget package
- Initialize the library on app start and uninitialize the library when the app quits (here is a WPF app example):
using AmplitudeSharp;
public partial class App : Application
{
private AmplitudeService analytics;
protected override void OnStartup(StartupEventArgs e)
{
// Only call this once per lifetime of the object
analytics = AmplitudeService.Initialize("<YOUR API KEY>");
base.OnStartup(e);
}
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
// Terminate the analytics upload thread
analytics.Dispose();
}
}
- Identify your user:
// Setup our user properties:
UserProperties userProps = new UserProperties();
userProps.UserId = "testuser_2";
userProps.ExtraProperties.Add("email", "test2@example.com");
// Note that userProps.AppVersion is automatically inferred from the
// version of the calling assembly, but can be overriden here, e.g:
// userProps.AppVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
// Setup our device properties:
DeviceProperties devProps = new DeviceProperties();
// It's a good idea to set a device ID, that way you can tell how many devices
// a give user uses. Best way is to generate a device ID on first start and stash it
// in the settings of the app
devProps.DeviceId = "<SOME PERSISTED GUID>";
AmplitudeService.Instance.Identify(userProps, devProps);
Track events
There are two types of events you can track: with and without parameters. Events without parameters require only a name to be logged, like so:
AmplitudeService.Instance.Track("simple_event");
Events with parameters can be logged as follows:
AmplitudeService.Instance.Track("event_with_properties", new { count = 4, category = "some value" });
Session management
A session is automatically created when the library is initialized, however you may want to create a new session without restarting the app. Let's say you want to create a new session when a user opens a new project/file/etc in your application, to do that, simple call:
AmplitudeService.Instance.NewSession();
This will allow you track session length on Amplitude and measure engagement of your users over time
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
- Newtonsoft.Json (>= 10.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.22 | 20,192 | 7/24/2018 |
1.0.21 | 6,089 | 6/14/2018 |
1.0.20 | 1,160 | 6/14/2018 |
1.0.15 | 1,030 | 6/13/2018 |
1.0.14 | 1,199 | 5/1/2018 |
1.0.13 | 1,056 | 4/18/2018 |
1.0.12 | 1,074 | 4/18/2018 |
1.0.11 | 1,094 | 4/11/2018 |
1.0.10 | 1,073 | 4/10/2018 |
1.0.9 | 1,043 | 4/10/2018 |
1.0.8 | 1,106 | 4/3/2018 |
1.0.7 | 1,064 | 3/29/2018 |
1.0.6 | 1,078 | 3/29/2018 |
1.0.5 | 1,139 | 3/28/2018 |
1.0.4 | 1,097 | 3/28/2018 |
1.0.3 | 1,073 | 3/28/2018 |
Initial release.