Example #1
0
        /// <summary>
        /// Sends a GA event and waits for the request to complete.
        /// </summary>
        public void TrackEventSynchronously(Session session, string category, string action, string label, long value = 1)
        {
            session.Log("Sending GA Event");
            var cid = GetInfo.GetOrCreateNewCid(session);

            var cd = new GACustomDimensions(session, cid);

            if (cd.productVersion == "0.0.0")
            {
                session.Log("Not tracking events when version is 0.0.0");
                return;
            }

            session.Log("Sending event {0}/{1}/{2} for cid={3} (custom dimension 1: {4})", category, action, label, cid, cd.productVersion);
            var t = Task.WhenAll(
                TrackEventAsync(session, cid, category, action, label, cd, value),
                TrackS3Event(session, cid, cd.sessionID, category, action, label)
                );
            var completed = t.Wait(TimeSpan.FromSeconds(15));

            if (!completed)
            {
                session.Log("Abandoning tracking event task after timeout.");
            }
        }