@@ -24,48 +24,51 @@ void printLog(Countly::LogLevel level, const string& msg) {
2424 case Countly::LogLevel::FATAL:
2525 lvl = " [FATAL]" ;
2626 break ;
27-
27+
2828 default :
2929 break ;
3030 }
31-
32- cout<< lvl<< msg<< endl;
31+
32+ cout << lvl << msg << endl;
3333}
3434
3535
3636
3737int main () {
38- cout<< " Sample App" << endl;
38+ cout << " Sample App" << endl;
3939 Countly& ct = Countly::getInstance ();
4040 ct.alwaysUsePost (true );
4141 ct.setDeviceID (" test-device-id" );
4242
43- void (*logger_function)(Countly::LogLevel level, const std::string& message);
43+ void (*logger_function)(Countly::LogLevel level, const std::string & message);
4444 logger_function = printLog;
4545 ct.setLogger (logger_function);
4646 // OS, OS_version, device, resolution, carrier, app_version);
4747 ct.SetMetrics (" Windows 10" , " 10.22" , " Mac" , " 800x600" , " Carrier" , " 1.0" );
48- ct.setCustomUserDetails ({{" Account Type" , " Basic" }, {" Employer" , " Company4" }});
4948 // Server and port
50- ct.Start ( " YOUR_APP_KEY " , " https://try .count.ly" , 443 );
49+ ct.start ( " 8c1d653f8f474be24958b282d5e9b4c4209ee552 " , " https://master .count.ly" , 443 , true );
5150 ct.SetMaxEventsPerMessage (10 );
52- ct.SetMinUpdatePeriod (10 );
53- ct.setUpdateInterval (15 );
51+ ct.setAutomaticSessionUpdateInterval (5 );
5452
5553 bool flag = true ;
5654 while (flag) {
57- cout<<" Choose your option:" <<endl;
58- cout<<" 1) Basic Event" <<endl;
59- cout<<" 2) Event with count and sum" <<endl;
60- cout<<" 3) Event with count, sum, duration" <<endl;
61- cout<<" 4) Event with sum, count, duration and segmentation" <<endl;
62- cout<<" 5) Update Session" <<endl;
63- cout<<" 0) Exit" <<endl;
55+ cout << " Choose your option:" << endl;
56+ cout << " 1) Basic Event" << endl;
57+ cout << " 2) Event with count and sum" << endl;
58+ cout << " 3) Event with count, sum, duration" << endl;
59+ cout << " 4) Event with sum, count, duration and segmentation" << endl;
60+ cout << " 5) Update Session" << endl;
61+ cout << " 6) Download remote config" << endl;
62+ cout << " 7) Send user detail to server" << endl;
63+ cout << " 8) Change device id with server merge" << endl;
64+ cout << " 9) Change device id without server merge" << endl;
65+ cout << " 10) Set user location" << endl;
66+ cout << " 0) Exit" << endl;
6467 int a;
65- cin>> a;
68+ cin >> a;
6669 switch (a) {
6770 case 1 :
68- ct.RecordEvent (" Basic Event " , 123 );
71+ ct.RecordEvent (" [CLY]_view " , 123 );
6972 break ;
7073 case 2 :
7174 ct.RecordEvent (" Event with count and sum" , 644 , 13.3 );
@@ -77,24 +80,59 @@ int main() {
7780 }
7881 case 4 : {
7982 std::map<std::string, std::string> segmentation;
80- segmentation[" height " ] = " 5.10 " ;
81- ct.RecordEvent (" Event with sum , count, duration and segmentation " , segmentation, 1 , 0 , 10 );
83+ segmentation[" name " ] = " start and end " ;
84+ ct.RecordEvent (" Event with segmentation , count and sum " , segmentation, 1 , 0 , 10 );
8285 break ;
8386 }
8487 case 5 :
8588 ct.updateSession ();
8689 break ;
90+ case 6 : {
91+ ct.updateRemoteConfig ();
92+ break ;
93+ }
94+ case 7 : {
95+ std::map<std::string, std::string> userdetail = {
96+ {" name" , " Full name" },
97+ {" username" , " username123" },
98+ 99+ {" phone" , " 222-222-222" },
100+ {" phone" , " 222-222-222" },
101+ {" picture" , " http://webresizer.com/images2/bird1_after.jpg" },
102+ {" gender" , " M" },
103+ {" byear" , " 1991" },
104+ {" organization" , " Organization" },
105+ };
106+
107+ ct.getInstance ().setUserDetails (userdetail);
108+ }
109+ break ;
110+ case 8 :
111+ ct.setDeviceID (" new-device-id" , true );
112+ break ;
113+ case 9 :
114+ ct.setDeviceID (" new-device-id" , false );
115+ break ;
116+ case 10 : {
117+ string countryCode = " us" ;
118+ string city = " Houston" ;
119+ string latitude = " 29.634933" ;
120+ string longitude = " -95.220255" ;
121+ string ipAddress = " 192.168.0.1" ;
122+
123+ ct.setLocation (countryCode, city, latitude + " ," + longitude, ipAddress);
124+ }
125+ break ;
87126 case 0 :
88127 flag = false ;
89128 break ;
90129 default :
91- cout<< " Option not found!" << endl;
130+ cout << " Option not found!" << endl;
92131 break ;
93132 }
94133 }
95134
96- // ct.updateSession();
97- ct.endSession ();
135+ ct.stop ();
98136
99137 return 0 ;
100- }
138+ }
0 commit comments