private void RunTests(Client client, int trials) { for (int i = 0; i < trials; i += 1) { Actions.Random(client); } }
/// <summary> /// Initialized the default Segment.io client with your API writeKey. /// </summary> /// <param name="writeKey"></param> public static void Initialize(string writeKey, Config config) { lock (padlock) { if (Client == null) { Client = new Client(writeKey, config); } } }
/// <summary> /// Disposes of the current client and allows the creation of a new one /// </summary> public static void Dispose() { lock (padlock) { if (Client != null) { Client.Dispose(); Client = null; } } }
/// <summary> /// Initialized the default Segment.io client with your API writeKey. /// </summary> /// <param name="writeKey"></param> public static void Initialize(string writeKey) { // avoiding double locking as recommended: // http://www.yoda.arachsys.com/csharp/singleton.html lock (padlock) { if (Client == null) { Client = new Client(writeKey); } } }
public static void Main (string[] args) { Console.WriteLine ("Started!"); Debugger.Break (); using (Client analytics = new Client("r7bxis28wy")) { analytics.Identify ("user123", new Traits () { { "hey", 123 } }); analytics.Track ("user123", "Ran away"); analytics.Track ("user123", "Engaged a bear", new Properties () { { "bearWeight", 865 } }); analytics.Track ("user123", "Engaged a bear", new Options () .SetContext (new Context () { { "app", new Dict() { { "name", "test" } }} })); analytics.Track ("user123", "Is Not Alive", new Properties () { { "why", "bear attack" } }, new Options() .SetIntegration("Salesforce", true) ); analytics.Track ("user123", "Is Not Alive", new Properties () { { "why", "bear attack" } }, new Options() .SetIntegration("Salesforce", true) .SetAnonymousId("cookie-id") .SetContext(new Context() .Add("ip", "192.144.23.2")) ); analytics.Flush (); } }
public static void Random(Client client) { switch (random.Next(0, 6)) { case 0: Identify(client); return; case 1: Track(client); return; case 2: Alias(client); return; case 3: Group(client); return; case 4: Page(client); return; case 5: Screen(client); return; } }
public void Init() { client = new Client("foo"); }
public static void Screen(Client client) { client.Screen("user", "name", "category", Properties(), Options()); }
public static void Page(Client client) { client.Page("user", "name", "category", Properties(), Options()); }
public static void Alias(Client client) { client.Alias("previousId", "to"); }
public static void Track(Client client) { client.Track("user", "Ran .NET test", Properties(), Options()); }
public static void Group(Client client) { client.Group("user", "group", Traits(), Options()); Analytics.Client.Flush(); }
public static void Identify(Client client) { client.Identify("user", Traits(), Options()); Analytics.Client.Flush(); }