-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathProgram.cs
More file actions
59 lines (52 loc) · 2.13 KB
/
Program.cs
File metadata and controls
59 lines (52 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using DesktopAnalytics;
namespace SampleApp
{
class Program
{
static int Main(string[] args)
{
if (args.Length != 2)
{
Console.WriteLine("Usage: SampleApp <analyticsApiSecret> <Segment|Mixpanel|???>");
return 1;
}
if (!Enum.TryParse<ClientType>(args[1], true, out var clientType))
{
Console.WriteLine($"Usage: SampleApp <analyticsApiSecret> <Segment|Mixpanel|???>{Environment.NewLine}Unrecognized client type: {args[1]}");
return 1;
}
var userInfo = new UserInfo
{
FirstName = "John",
LastName = "Smith",
Email="john@example.com",
UILanguageCode= "fr"
};
userInfo.OtherProperties.Add("HowIUseIt",
"This is a really long explanation of how I use this product to see how much you would be able to extract from Mixpanel.\r\nAnd a second line of it.");
var propsForEveryEvent = new Dictionary<string, string> {{"channel", "beta"}};
using (new Analytics(args[0], userInfo, propertiesThatGoWithEveryEvent: propsForEveryEvent, clientType: clientType))
{
Thread.Sleep(3000);
//note that anything we set from here on didn't make it into the initial "Launch" event. Things we want to
//be in that event should go in the propertiesThatGoWithEveryEvent parameter of the constructor.
Analytics.SetApplicationProperty("TimeSinceLaunch", "3 seconds");
Analytics.Track("SomeEvent", new Dictionary<string, string> {{"SomeValue", "62"}});
Debug.WriteLine("Sleeping for 20 seconds to give it all a chance to send an event in the background...");
Thread.Sleep(20000);
Analytics.SetApplicationProperty("TimeSinceLaunch", "23 seconds");
Analytics.Track("SomeEvent", new Dictionary<string, string> {{"SomeValue", "42"}});
Console.WriteLine("Sleeping for another 20 seconds to give it all a chance to send an event in the background...");
Thread.Sleep(20000);
Console.WriteLine($"Succeeded: {Analytics.Statistics.Succeeded}; " +
$"Submitted: {Analytics.Statistics.Submitted}; " +
$"Failed: {Analytics.Statistics.Failed}");
return 0;
}
}
}
}