public static void Track(Client client) { client.Track(userId, "Ran .NET test", new Properties() { { "Success", true }, { "When", DateTime.Now } }, DateTime.Now); }
/// <summary> /// Disposes of the current client and allows the creation of a new one /// </summary> public static void Reset() { if (Client != null) { Client.Dispose(); Client = null; } }
private void RunTests(Client client, int trials) { for (int i = 0; i < trials; i += 1) { ActionRunner.Random(client); } }
/// <summary> /// Initialized the default Segment.io client with your API secret. /// </summary> /// <param name="secret"></param> public static void Initialize(string secret, Options options) { lock (padlock) { if (Client == null) { Client = new Client(secret, options); } } }
/// <summary> /// Initialized the default Segment.io client with your API secret. /// </summary> /// <param name="secret"></param> public static void Initialize(string secret) { // avoiding double locking as recommended: // http://www.yoda.arachsys.com/csharp/singleton.html lock (padlock) { if (Client == null) { Client = new Client(secret); } } }
public static void Random(Client client) { switch (random.Next(0, 3)) { case 0: Identify(client); return; case 1: Track(client); return; case 2: Alias(client); return; } }
public static void Identify(Client client) { client.Identify(userId, new Traits() { { "Subscription Plan", "Free" }, { "Friends", 30 }, { "Joined", DateTime.Now }, { "Cool", true }, { "Company", new Props() { { "name", "Initech, Inc " } } }, { "Revenue", 40.32 }, { "Don't Submit This, Kids", new UnauthorizedAccessException() } }, new DateTime(), new Context() .SetIp("12.212.12.49") .SetLanguage("en-us") .SetProviders(new Providers() { { "all", false }, { "Mixpanel", true }, { "Salesforce", true } }) ); }
/// <summary> /// Initialized the default Segment.io client with your API secret. /// </summary> /// <param name="secret"></param> public static void Initialize(string secret) { if (Client == null) { Client = new Client(secret); } }
public static void Alias(Client client) { client.Alias("anonymous", userId); }
/// <summary> /// Initialized the default Segment.io client with your API secret. /// </summary> /// <param name="secret"></param> public static void Initialize(string secret, Options options) { if (Client == null) { Client = new Client(secret, options); } }