Пример #1
0
        public void ReportAction_AllInformation()
        {
            var sink = new PiwikSink(defaultOptions);

            Api.PiwikEventInfo calledEventInfo = null;
            mockApi
            .Setup(api => api.ReportEventAsync(It.IsAny <Api.PiwikEventInfo>()))
            .Returns(Task.FromResult(true))
            .Callback <Api.PiwikEventInfo>(ei => calledEventInfo = ei);

            sink.Location.CurrentUrl  = new Uri(sink.BaseAppUrl, "some/url");
            sink.Location.ReferrerUrl = new Uri(sink.BaseAppUrl, "another/url");

            var actionInfo = new Core.ActionInfo()
            {
                Name     = "Test",
                Category = "Some category",
                Verb     = "Some verb"
            };

            telemetryProvider.Activity.ReportActionAsync(actionInfo);

            Assert.IsNotNull(calledEventInfo);
            Assert.AreEqual("Some category", calledEventInfo.Category);
            Assert.AreEqual("Some verb", calledEventInfo.Action);
            Assert.AreEqual("Test", calledEventInfo.Name);
            Assert.AreEqual(sink.Location.CurrentUrl.ToString(), calledEventInfo.Url);
            Assert.AreEqual(sink.Location.ReferrerUrl.ToString(), calledEventInfo.ReferrerUrl);
            Assert.AreSame(sink.Session, calledEventInfo.Session);
            Assert.AreSame(sink.EnvironmentInfo, calledEventInfo.EnvironmentInfo);
        }
Пример #2
0
        public void ReportAction_MinimalInformation()
        {
            var sink = new PiwikSink(defaultOptions);

            Api.PiwikEventInfo calledEventInfo = null;
            mockApi
            .Setup(api => api.ReportEventAsync(It.IsAny <Api.PiwikEventInfo>()))
            .Returns(Task.FromResult(true))
            .Callback <Api.PiwikEventInfo>(ei => calledEventInfo = ei);

            var actionInfo = new Core.ActionInfo()
            {
                Name = "Test"
            };

            telemetryProvider.Activity.ReportActionAsync(actionInfo);

            Assert.IsNotNull(calledEventInfo);
            Assert.AreEqual("Unknown", calledEventInfo.Category);
            Assert.AreEqual("Test", calledEventInfo.Action);
            Assert.AreEqual("Test", calledEventInfo.Name);
            Assert.AreEqual(sink.BaseAppUrl.ToString(), calledEventInfo.Url);
            Assert.IsNull(calledEventInfo.ReferrerUrl);
            Assert.AreSame(sink.Session, calledEventInfo.Session);
            Assert.AreSame(sink.EnvironmentInfo, calledEventInfo.EnvironmentInfo);
        }
Пример #3
0
 private async Task Activity_OnReportActionAsync(object sender, Core.ActionInfo action)
 {
     using (await padlock.ReaderLockAsync())
     {
         await options.Api.ReportEventAsync(new Api.PiwikEventInfo(Location.CurrentUrl?.ToString() ?? BaseAppUrl.ToString(), action.Category ?? "Unknown", action.Verb ?? action.Name)
         {
             Name            = action.Name,
             ReferrerUrl     = Location.ReferrerUrl?.ToString(),
             Session         = Session,
             EnvironmentInfo = EnvironmentInfo
         });
     }
 }