static void testBase() { Console.WriteLine("Hello World222"); IConsumer consumer = new LoggingConsumer("/Users/zhangwei/consumer"); SensorsAnalytics sa = new SensorsAnalytics(consumer, true); Dictionary <string, Object> dic = new Dictionary <string, object>(); dic.Add("may_be_null1", null); dic.Add("productName", "iPhone 11"); dic.Add("productPrice", "20000"); dic.Add("may_be_null2", null); dic.Add("address", "9999999999"); dic.Add("may_be_null3", null); dic.Add("empty_str", ""); dic.Add("", "sdsd"); sa.Track("112131", "ViewProduct", dic); sa.ItemSet("item_type1111", "item_id1111", dic); sa.ItemDelete("item_type2222", "item_id2222"); sa.Flush(); sa.Shutdown(); Console.WriteLine("--End--"); }
static void testThreadClient() { IConsumer consumer = new NewClientConsumer("http://newsdktest.datasink.sensorsdata.cn/sa?project=zhangwei&token=5a394d2405c147ca", "/Users/zhangwei/consumer/sss.txt", 10, 10 * 1000); SensorsAnalytics sa = new SensorsAnalytics(consumer, true); Dictionary <string, Object> dic = new Dictionary <string, object>(); dic.Add("productName", "iPhone 11"); dic.Add("productPrice", "20000"); Console.WriteLine("1111===" + DateTime.Now.ToLongTimeString()); //sa.TrackSignUp("8888", "112131", dic); //sa.Track("112131", "ViewProduct22", dic); sa.ItemSet("item_type1111", "item_id1111", dic); //sa.ItemDelete("item_type2222", "item_id2222"); Console.WriteLine("3333===" + DateTime.Now.ToLongTimeString()); sa.Flush(); Console.WriteLine("222222"); Thread.Sleep(5000); Console.WriteLine("1231231"); sa.Shutdown(); Console.WriteLine("--End--"); }
/// <summary> /// 仅测试使用 /// </summary> static void testConsumer() { Console.WriteLine("--Start--"); //ClientConsumer 仅仅是测试使用 IConsumer consumer = new ClientConsumer("/Users/zhangwei/consumer/log.txt", "https://newsdktest.datasink.sensorsdata.cn/sa?project=zhangwei&token=5a394d2405c147ca"); SensorsAnalytics sa = new SensorsAnalytics(consumer, true); Dictionary <string, Object> dic = new Dictionary <string, object>(); dic.Add("productName", "iPhone 11"); dic.Add("productPrice", "20000"); sa.Track("112131", "ViewProduct", dic); sa.ItemSet("item_type1111", "item_id1111", dic); sa.ItemDelete("item_type2222", "item_id2222"); sa.Flush(); sa.Shutdown(); Console.WriteLine("--End--"); }