A Segment.io REST client
Наследование: IDisposable
Пример #1
0
 public static void Track(Client client)
 {
     client.Track(userId, "Ran .NET test", new Properties() {
             { "Success", true },
             { "When", DateTime.Now }
         }, DateTime.Now);
 }
Пример #2
0
 /// <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;
     }
 }
Пример #3
0
 private void RunTests(Client client, int trials)
 {
     for (int i = 0; i < trials; i += 1)
     {
         ActionRunner.Random(client);
     }
 }
Пример #4
0
 /// <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);
         }
     }
 }
Пример #5
0
 /// <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);
         }
     }
 }
Пример #6
0
 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;
     }
     
 }
Пример #7
0
 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 }
                     })
             );
 }
Пример #8
0
 /// <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);
     }
 }
Пример #9
0
 public static void Alias(Client client)
 {
     client.Alias("anonymous", userId);
 }
Пример #10
0
        /// <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);
			}
       }
Пример #11
0
        /// <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);
			}
        }