public async Task TestTrackEvent()
        {
            analytics.TrackEvent("cat", "some action");

            var receivedData = await PiwikMocker.SubmitAndReceive(analytics, url);

            Assert.That(analytics.UnsentActions, Is.EqualTo(0));

            var json = JObject.Parse(receivedData);
            var main = json["requests"][0].ToString();

            Assert.That(main, Does.Not.Contain("action_name="), "events do not have an action name (checked with javascript and android sdk)");
            Assert.That(main, Does.Contain("e_a=some+action"));
            Assert.That(main, Does.Contain("e_c=cat"));
            Assert.That(main, Does.Contain("url="), "events should always send an url because piwik can be configured to drop data which are not targeted at a specific domain");
        }
Exemple #2
0
        public App()
        {
            Analytics         = new PiwikAnalytics("http://mockbin.org/bin/9ac466a2-313c-4691-bf74-f15b9ab602b2", 13);
            Analytics.Verbose = true;
            Analytics.AppUrl  = "http://demoapp";

            var content = new PiwikPage {
                Title   = "Demo",
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Center,
                    Children        =
                    {
                        new Label                                           {
                            HorizontalTextAlignment = TextAlignment.Center,
                            Text = "Xamarin.Piwik Tracker Demo App\n\nBrowse to\nhttps://goo.gl/tHhz23\nto see the api calls"
                        },
                        new Button                                          {
                            Text    = "Open SubPage",
                            Command = new Command(() =>                     {
                                MainPage.Navigation.PushAsync(new PiwikPage {
                                    Title = "SubPage",
                                });
                            }),
                        },
                        new Button                                          {
                            Text    = "Track Event",
                            Command = new Command(() => Analytics.TrackEvent("User Action", "Button Pressed")),
                        }
                    }
                }
            };

            var navigation = new NavigationPage(content);

            navigation.Pushed += (sender, e) => TrackCurrentPage();
            navigation.Popped += (sender, e) => TrackCurrentPage();
            MainPage           = navigation;
        }