Пример #1
0
        private async void Launched()
        {
            //create the Countly init object
            CountlySDK.CountlyCommon.CountlyBase.IsLoggingEnabled = true;
            var cc = new CountlyConfig
            {
                serverUrl  = "SERVER_URL",
                appKey     = "APP_KEY",
                appVersion = "1.2.3",
            };

            try
            {
                await Countly.Instance.Init(cc);

                await Countly.Instance.SessionBegin();

                await Countly.RecordEvent("qwedqwe");

                await Countly.Instance.RecordView("Some View");
            }
            catch (Exception exception)
            {
                Debug.WriteLine("Some exception found!" + exception);
            }
        }
Пример #2
0
        private async void TrackingCheck_Checked(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (initialized)
            {
                string ServerUrl = "http://try.count.ly";
                string AppKey    = null;

                if (ServerUrl == null)
                {
                    throw new ArgumentNullException("Type your ServerUrl");
                }
                if (AppKey == null)
                {
                    throw new ArgumentNullException("Type your AppKey");
                }

                await Countly.StartSession(ServerUrl, AppKey, "1.0", FileSystem.Current);

                RecordBasicEvent.IsEnabled        = true;
                RecordEventSum.IsEnabled          = true;
                RecordEventSegmentation.IsEnabled = true;
                UserNameText.IsEnabled            = true;
                UploadUserPictureButton.IsEnabled = true;
                CrashButton.IsEnabled             = true;
            }
        }
Пример #3
0
 /// <summary>
 /// Test setup
 /// </summary>
 public ConsentTests()
 {
     CountlyImpl.SetPCLStorageIfNeeded();
     Countly.Halt();
     TestHelper.CleanDataFiles();
     Countly.Instance.deferUpload = false;
 }
        public async void ChengeDeviceIDNoMergeMultiple()
        {
            bool res;

            String dId = await Countly.Instance.DeviceData.GetDeviceId();

            Assert.NotNull(dId);
            Assert.NotEqual(0, dId.Length);

            String newId = "qweqwe";

            await Countly.Instance.ChangeDeviceId(newId + "1", false);

            res = await Countly.RecordEvent("Some event user2", 123);

            await Countly.Instance.ChangeDeviceId(newId + "2", false);

            res = await Countly.RecordEvent("Some event user2", 123);

            await Countly.Instance.ChangeDeviceId(newId + "3", false);

            res = await Countly.RecordEvent("Some event user2", 123);

            await Countly.Instance.ChangeDeviceId(newId + "4", false);

            res = await Countly.RecordEvent("Some event user2", 123);

            Assert.True(res);
        }
        public async void MultipleEvents()
        {
            bool res;

            res = await Countly.RecordEvent("Some event0");

            Assert.True(res);

            res = await Countly.RecordEvent("Some event1", 123);

            Assert.True(res);

            res = await Countly.RecordEvent("Some event2", 123, 456);

            Assert.True(res);

            res = await Countly.RecordEvent("Some event3", 4234, 1236.12, 234.5, null);

            Assert.True(res);

            Segmentation segm = new Segmentation();

            segm.Add("oneKey", "SomeValue");
            segm.Add("anotherKey", "SomeOtherValue");

            res = await Countly.RecordEvent("Some event4", 123, 456, segm);

            res = await Countly.RecordEvent("Some event5", 123, 456, 42.54, segm);

            Assert.True(res);
        }
Пример #6
0
        private void TrackingCheck_Checked(object sender, System.Windows.RoutedEventArgs e)
        {
            if (initialized)
            {
                string ServerUrl = null;
                string AppKey    = null;

                if (ServerUrl == null)
                {
                    throw new ArgumentNullException("Type your ServerUrl");
                }
                if (AppKey == null)
                {
                    throw new ArgumentNullException("Type your AppKey");
                }

                Countly.StartSession(ServerUrl, AppKey);

                // Countly.StartSession("http://YOUR_SERVER", "YOUR_APP_KEY");

                RecordBasicEvent.IsEnabled        = true;
                RecordEventSum.IsEnabled          = true;
                RecordEventSegmentation.IsEnabled = true;
            }
        }
Пример #7
0
        public async void BasicDeserialization_18_1()
        {
            String targetPath = await Storage.Instance.GetFolderPath(Storage.Instance.folder) + "\\";

            String sourceFolder = TestHelper.testDataLocation + "\\SampleDataFiles\\18_1\\";

            File.Copy(sourceFolder + "sessions.xml", targetPath + "sessions.xml");
            File.Copy(sourceFolder + "userdetails.xml", targetPath + "userdetails.xml");
            File.Copy(sourceFolder + "events.xml", targetPath + "events.xml");
            File.Copy(sourceFolder + "exceptions.xml", targetPath + "exceptions.xml");
            File.Copy(sourceFolder + "devicePCL.xml", targetPath + "device.xml");

            Countly.Instance.deferUpload = true;
            await CountlyImpl.StartLegacyCountlySession(ServerInfo.serverURL, ServerInfo.appKey, ServerInfo.appVersion);

            Assert.Equal(50, Countly.Instance.Events.Count);
            Assert.Equal(50, Countly.Instance.Exceptions.Count);
            Assert.Equal(3, Countly.Instance.Sessions.Count);
            Assert.Empty(Countly.Instance.StoredRequests);
            Assert.Equal("B249FB85668941FAA8301E2A5CA95901", await Countly.GetDeviceId());

            CountlyUserDetails cud = Countly.UserDetails;

            Assert.Equal(56, cud.BirthYear);
            Assert.Equal("f", cud.Email);
            Assert.Equal("t", cud.Gender);
            Assert.Equal("g", cud.Name);
            Assert.Equal("s", cud.Organization);
            Assert.Equal("p", cud.Phone);
            Assert.Equal("1t", cud.Picture);
            Assert.Equal("u", cud.Username);
        }
Пример #8
0
        public async void BasicDeserialization_002()
        {
            String targetPath = await Storage.Instance.GetFolderPath(Storage.Instance.folder) + "\\";

            String sourceFolder = TestHelper.testDataLocation + "\\SampleDataFiles\\Test_002\\";

            File.Copy(sourceFolder + "sessions.xml", targetPath + "sessions.xml", true);
            File.Copy(sourceFolder + "userdetails.xml", targetPath + "userdetails.xml", true);
            File.Copy(sourceFolder + "events.xml", targetPath + "events.xml", true);
            File.Copy(sourceFolder + "exceptions.xml", targetPath + "exceptions.xml", true);
            File.Copy(sourceFolder + "device.xml", targetPath + "device.xml", true);
            File.Copy(sourceFolder + "storedRequests.xml", targetPath + "storedRequests.xml", true);

            Countly.Instance.deferUpload = true;
            CountlyConfig cc = TestHelper.CreateConfig();
            await Countly.Instance.Init(cc);

            Assert.Equal(100, Countly.Instance.Events.Count);
            Assert.Equal(100, Countly.Instance.Exceptions.Count);
            Assert.Equal(102, Countly.Instance.Sessions.Count);
            Assert.Equal(150, Countly.Instance.StoredRequests.Count);
            Assert.Equal("SDSDSD1570501868", await Countly.GetDeviceId());

            CountlyUserDetails cud = Countly.UserDetails;

            Assert.Equal(975, cud.BirthYear);
            Assert.Equal("g", cud.Email);
            Assert.Equal("1t", cud.Gender);
            Assert.Equal("12g", cud.Name);
            Assert.Equal("12s", cud.Organization);
            Assert.Equal("1p", cud.Phone);
            Assert.Equal("12t", cud.Picture);
            Assert.Equal("1u", cud.Username);
        }
Пример #9
0
        public async void LegacyInitSimpleFail()
        {
            Exception exToCatch = null;

            try
            {
                await CountlyImpl.StartLegacyCountlySession(null, "234", "345");
            }
            catch (Exception ex) { exToCatch = ex; }

            Assert.NotNull(exToCatch);
            exToCatch = null;
            Countly.Halt();

            try
            {
                await CountlyImpl.StartLegacyCountlySession("123", null, "345");
            }
            catch (Exception ex) { exToCatch = ex; }

            Assert.NotNull(exToCatch);
            exToCatch = null;
            Countly.Halt();

            try
            {
                await CountlyImpl.StartLegacyCountlySession(null, null, null);
            }
            catch (Exception ex) { exToCatch = ex; }

            Assert.NotNull(exToCatch);
            exToCatch = null;
        }
Пример #10
0
 /// <summary>
 /// Test setup
 /// </summary>
 public LegacyInitTests()
 {
     CountlyImpl.SetPCLStorageIfNeeded();
     Countly.Halt();
     TestHelper.CleanDataFiles();
     CountlyImpl.StartLegacyCountlySession(ServerInfo.serverURL, ServerInfo.appKey, ServerInfo.appVersion).Wait();
 }
Пример #11
0
        private void TrackingCheck_Checked(object sender, System.Windows.RoutedEventArgs e)
        {
            if (initialized)
            {
                string ServerUrl = "https://cloud.count.ly";
                string AppKey    = null;

                if (ServerUrl == null)
                {
                    throw new ArgumentNullException("Type your ServerUrl");
                }
                if (AppKey == null)
                {
                    throw new ArgumentNullException("Type your AppKey");
                }

                Countly.StartSession(ServerUrl, AppKey);

                RecordBasicEvent.IsEnabled        = true;
                RecordEventSum.IsEnabled          = true;
                RecordEventSegmentation.IsEnabled = true;
                UserNameText.IsEnabled            = true;
                UploadUserPictureButton.IsEnabled = true;
                CrashButton.IsEnabled             = true;
            }
        }
Пример #12
0
        private void TrackingCheck_Unchecked(object sender, System.Windows.RoutedEventArgs e)
        {
            Countly.Halt();

            RecordBasicEvent.IsEnabled        = false;
            RecordEventSum.IsEnabled          = false;
            RecordEventSegmentation.IsEnabled = false;
        }
Пример #13
0
 public static CountlyRequest CreateUpdateSession()
 {
     return(new CountlyRequest
     {
         Duration = Countly.GetSessionDuration(),
         TimeStamp = TimeHelper.ToUnixTime(),
     });
 }
Пример #14
0
        /// <summary>
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// </summary>
        /// <param name="sender">The source of the suspend request.</param>
        /// <param name="e">Details about the suspend request.</param>
        private async void OnSuspending(object sender, SuspendingEventArgs e)
        {
            var deferral = e.SuspendingOperation.GetDeferral();

            await Countly.EndSession();

            deferral.Complete();
        }
Пример #15
0
 private void RecordBasicEvent_1000_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     System.Diagnostics.Debug.WriteLine("Creating 1000 basic events");
     for (int a = 0; a < 1000; a++)
     {
         Countly.AddBreadCrumb("Basic event x1000");
         Countly.RecordEvent("seconds", DateTime.Now.Second + 1);
     }
 }
Пример #16
0
        private void UserNameText_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
        {
            if (Countly.UserDetails.Name != UserNameText.Text)
            {
                Countly.UserDetails.Name = UserNameText.Text;

                Countly.AddBreadCrumb("username updated: " + UserNameText.Text);
            }
        }
Пример #17
0
        private void RecordEventSegmentation_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Segmentation segmentation = new Segmentation();

            segmentation.Add("country", "Ukraine");
            segmentation.Add("app_version", "1.2");

            Countly.RecordEvent("seconds", DateTime.Now.Second, segmentation);
        }
Пример #18
0
        private async void OnResuming(object sender, object e)
        {
            Debug.WriteLine("Calling [OnResuming]");
            await Countly.Instance.SessionBegin();

            await Countly.RecordEvent("qwedqwe");

            await Countly.Instance.RecordView("Some View");
        }
Пример #19
0
        public void SendErrorEvent(string errorMessage, string method)
        {
            Dictionary <String, String> segmentation = new Dictionary <String, String>();

            segmentation.Add("error", errorMessage);
            segmentation.Add("method", method);

            Countly.SharedInstance().RecordEvent("Show_Generic_Error", segmentation, 1);
        }
Пример #20
0
        public async Task SendException()
        {
            Countly.UserDetails.Name = UserName;
            await Countly.StartSession(Server, ApiKey);

            await Countly.RecordException("Oh no!", "this is a trace\nmorelines\n");

            await Countly.EndSession();
        }
Пример #21
0
        public async Task StartCountly()
        {
            Debug.WriteLine("Initializing Countly");
            Countly.IsLoggingEnabled = true;
            await Countly.StartSession(serverURL, appKey, "1.234", Countly.DeviceIdMethod.multipleFields);

            Countly.RecordEvent("SomeKey");
            Thread.Sleep(2000);
        }
Пример #22
0
 private async void CrashButton_1000_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     System.Diagnostics.Debug.WriteLine("Recording 1000 exceptions");
     for (int a = 0; a < 1000; a++)
     {
         Countly.AddBreadCrumb("Recording exception x1000");
         bool x = await Countly.RecordException("Some exception text");
     }
 }
        /// <summary>
        /// Used for testing legacy session control
        /// </summary>
        public CountlyTestCases()
        {
            CountlyImpl.SetPCLStorageIfNeeded();
            Countly.Halt();
            TestHelper.CleanDataFiles();
            CountlyConfig cc = TestHelper.CreateConfig();

            Countly.Instance.Init(cc).Wait();
            Countly.Instance.SessionBegin().Wait();
        }
Пример #24
0
 private void Start_Session_Button_Click(object sender, RoutedEventArgs e)
 {
     if (ApiKeyBox.Text == "" || ApiKeyBox.Text == "Enter API Key")
     {
         MessageBox.Show("Please enter an API Key.");
     }
     else
     {
         Countly.StartSession("http://cloud.count.ly", ApiKeyBox.Text);
     }
 }
Пример #25
0
 private void Fire_Event_Button_Click(object sender, RoutedEventArgs e)
 {
     if (EventTextBox.Text == "Enter test event name." || EventTextBox.Text == "")
     {
         MessageBox.Show("Please enter an event name for testing.");
     }
     else
     {
         Countly.RecordEvent(EventTextBox.Text);
     }
 }
Пример #26
0
        protected override void OnStop()
        {
            MainActivity.IsActive = false;

            Countly.SharedInstance().OnStop();

            PackageService.IsNeedRequestPackages = true;
            EventService.IsNeedSendEvents        = false;

            base.OnStop();
        }
Пример #27
0
        private void RecordEventSegmentation_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            Segmentation segmentation = new Segmentation();

            segmentation.Add("country", "Ukraine");
            segmentation.Add("app_version", "1.2");

            Countly.RecordEvent("seconds", DateTime.Now.Second + 1, segmentation);

            Countly.AddBreadCrumb("segmentation event");
        }
Пример #28
0
 public void TestMethod1()
 {
     try
     {
         Countly.StartSession("http://cloud.count.ly", "87e43ddcc40b5cd0d4ac857a71d250e1750847f0");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Пример #29
0
 private async void Button_Click_0(object sender, RoutedEventArgs e)
 {
     //Record Handled Crash
     try
     {
         throw new DivideByZeroException();
     }
     catch (Exception ex)
     {
         await Countly.RecordException(ex.Message, ex.StackTrace);
     }
 }
Пример #30
0
        private async void OnPhotoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                if (await Countly.UserDetails.UploadUserPicture(e.ChosenPhoto))
                {
                    Countly.AddBreadCrumb("user picture updated");

                    MessageBox.Show("Picture uploaded successfully");
                }
            }
        }
Пример #31
0
    public static void Emit(Countly.Event e)
    {
        Countly.Manager instance = Instance;

        if (instance != null)
        {
          instance.RecordEvent(e);
        }
    }