Esempio n. 1
0
        /// <summary>
        /// Tracks an event defined by an index
        /// </summary>
        /// <param name="index"></param>
        private async void TrackEvent(int index)
        {
            try
            {
                switch (index)
                {
                case 0: Analytics.Snowplow.TrackSelfDescribing(); break;

                case 1: Analytics.Snowplow.TrackPageView(); break;

                case 2: Analytics.Snowplow.TrackScreenView(); break;

                case 3: Analytics.Snowplow.TrackTiming(); break;

                case 4: Analytics.Snowplow.TrackStructEvent(); break;

                case 5: Analytics.Snowplow.TrackEcommerceTransaction(); break;

                default: throw new ArgumentException("Event tracking index not yet supported!");
                }

                _statisticsTableSection.UpdateStatistics();
            }
            catch (Exception e)
            {
                await DisplayAlert("Error", e.Message, "OK");
            }
        }
        // --- Components

        /// <summary>
        /// Constructs the Table responsible for sending events and
        /// showing statistics about the Tracker
        /// </summary>
        /// <returns></returns>
        private StackLayout BuildTrackFunctionsView()
        {
            // --- Send Buttons

            var floodCell = new ActionImageCell("Send all event types", IconLoader.Load(Utils.Icon.Send));

            floodCell.Tapped += (s, e) => { TrackEvents(); };

            // --- Statistics

            _statisticsTableSection = new StatisticsTableSection();
            _statisticsTableSection.StartUpdater();
            _statisticsTableSection.UpdateStatistics();

            // --- Assemblew View

            var settingsTable = new TableView
            {
                Intent = TableIntent.Settings,
                Root   = new TableRoot
                {
                    new TableSection("Track Functions")
                    {
                        floodCell
                    },
                    _statisticsTableSection.Section
                }
            };

            return(new StackLayout
            {
                Children = { settingsTable },
                VerticalOptions = LayoutOptions.FillAndExpand
            });
        }
Esempio n. 3
0
        // --- Components

        /// <summary>
        /// Constructs the Table responsible for sending events and
        /// showing statistics about the Tracker
        /// </summary>
        /// <returns></returns>
        private StackLayout BuildTrackFunctionsView()
        {
            // --- Send Buttons

            var icSendImage = IconLoader.Load(Utils.Icon.Send);

            var selfDescribingCell = new ActionImageCell("TrackSelfDescribing", icSendImage);

            selfDescribingCell.Tapped += (s, e) => { TrackEvent(0); };
            var pageViewCell = new ActionImageCell("TrackPageView", icSendImage);

            pageViewCell.Tapped += (s, e) => { TrackEvent(1); };
            var screenViewCell = new ActionImageCell("TrackScreenView", icSendImage);

            screenViewCell.Tapped += (s, e) => { TrackEvent(2); };
            var timingCell = new ActionImageCell("TrackTiming", icSendImage);

            timingCell.Tapped += (s, e) => { TrackEvent(3); };
            var structCell = new ActionImageCell("TrackStructEvent", icSendImage);

            structCell.Tapped += (s, e) => { TrackEvent(4); };
            var ecommerceTransactionCell = new ActionImageCell("TrackEcommerceTransaction", icSendImage);

            ecommerceTransactionCell.Tapped += (s, e) => { TrackEvent(5); };

            // --- Statistics

            _statisticsTableSection = new StatisticsTableSection();
            _statisticsTableSection.StartUpdater();
            _statisticsTableSection.UpdateStatistics();

            // --- Assemblew View

            var settingsTable = new TableView
            {
                Intent = TableIntent.Settings,
                Root   = new TableRoot
                {
                    new TableSection("Event Track Functions")
                    {
                        selfDescribingCell,
                        pageViewCell,
                        screenViewCell,
                        timingCell,
                        structCell,
                        ecommerceTransactionCell
                    },
                    _statisticsTableSection.Section
                }
            };

            return(new StackLayout
            {
                Children = { settingsTable },
                VerticalOptions = LayoutOptions.FillAndExpand
            });
        }
        /// <summary>
        /// Tracks all event types
        /// </summary>
        private async void TrackEvents()
        {
            try
            {
                Analytics.Snowplow.TrackSelfDescribing();
                Analytics.Snowplow.TrackPageView();
                Analytics.Snowplow.TrackScreenView();
                Analytics.Snowplow.TrackTiming();
                Analytics.Snowplow.TrackStructEvent();
                Analytics.Snowplow.TrackEcommerceTransaction();

                _statisticsTableSection.UpdateStatistics();
            }
            catch (Exception e)
            {
                await DisplayAlert("Error", e.Message, "OK");
            }
        }