From 1004485490321bd5b0a8693db646a1cde37c832e Mon Sep 17 00:00:00 2001 From: Mohamed Ramadan Date: Wed, 1 May 2019 15:57:23 +0400 Subject: [PATCH] Fix GetUrlTrackAction to send download instead of Download - fix issue #68 & change SendRequest to be public so in future, callers can build thier own url and use sendrequest to push it to matomo --- Piwik.Tracker.Samples/PiwikTrackerSamples.cs | 20 +++++++++++-------- .../Piwik.Tracker.Web.Samples.csproj.user | 3 +++ Piwik.Tracker/PiwikTracker.cs | 4 ++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Piwik.Tracker.Samples/PiwikTrackerSamples.cs b/Piwik.Tracker.Samples/PiwikTrackerSamples.cs index 9a72789..2723b44 100644 --- a/Piwik.Tracker.Samples/PiwikTrackerSamples.cs +++ b/Piwik.Tracker.Samples/PiwikTrackerSamples.cs @@ -10,7 +10,7 @@ namespace Piwik.Tracker.Samples internal class PiwikTrackerSamples { private const string UA = "Firefox"; - private static readonly string PiwikBaseUrl = "http://piwik.local"; + private static readonly string PiwikBaseUrl = "http://10.10.158.189:9090"; private static readonly int SiteId = 1; private static void Main(string[] args) @@ -54,6 +54,7 @@ private static void Main(string[] args) // ** Event Tracking ** // TrackSongPlayback(); + TrackDownload(); Console.ReadKey(true); } @@ -129,7 +130,7 @@ static private void RecordSimplePageViewWithCustomProperties() piwikTracker.SetResolution(1600, 1400); piwikTracker.SetIp("192.168.52.64"); - piwikTracker.SetVisitorId("33c31B01394bdc65"); + piwikTracker.SetUserId("33c31B01394bdc65"); piwikTracker.SetForceVisitDateTime(new DateTime(2011, 10, 23, 10, 20, 50, DateTimeKind.Utc)); @@ -137,9 +138,11 @@ static private void RecordSimplePageViewWithCustomProperties() piwikTracker.SetTokenAuth("XYZ"); - var browserPluginsToSet = new BrowserPlugins(); - browserPluginsToSet.Silverlight = true; - browserPluginsToSet.Flash = true; + var browserPluginsToSet = new BrowserPlugins + { + Silverlight = true, + Flash = true + }; piwikTracker.SetPlugins(browserPluginsToSet); piwikTracker.SetBrowserHasCookies(true); @@ -179,7 +182,7 @@ static private void RecordSimplePageViewWithCustomGeoLocation() /// static private void RecordSimplePageViewWithGenerationTime() { - var piwikTracker = new PiwikTracker(SiteId, PiwikBaseUrl); + PiwikTracker piwikTracker = new PiwikTracker(SiteId, PiwikBaseUrl); piwikTracker.SetUserAgent(UA); piwikTracker.SetGenerationTime(10000); @@ -231,8 +234,9 @@ static private void TrackDownload() { var piwikTracker = new PiwikTracker(SiteId, PiwikBaseUrl); piwikTracker.SetUserAgent(UA); - - var response = piwikTracker.DoTrackAction("http://piwik.org/path/again/latest.zip", ActionType.Download); + var url = "http://10.10.158.246/piwik.org/path/again/latest.zip"; + piwikTracker.SetUrl(url); + var response = piwikTracker.DoTrackAction(url, ActionType.Download); DisplayDebugInfo(response); } diff --git a/Piwik.Tracker.Web.Samples/Piwik.Tracker.Web.Samples.csproj.user b/Piwik.Tracker.Web.Samples/Piwik.Tracker.Web.Samples.csproj.user index b8e4aa5..7d4266e 100644 --- a/Piwik.Tracker.Web.Samples/Piwik.Tracker.Web.Samples.csproj.user +++ b/Piwik.Tracker.Web.Samples/Piwik.Tracker.Web.Samples.csproj.user @@ -1,5 +1,8 @@  + + Debug|Any CPU + diff --git a/Piwik.Tracker/PiwikTracker.cs b/Piwik.Tracker/PiwikTracker.cs index c53bc9e..85c0747 100644 --- a/Piwik.Tracker/PiwikTracker.cs +++ b/Piwik.Tracker/PiwikTracker.cs @@ -1099,7 +1099,7 @@ public string GetUrlTrackGoal(int idGoal, float revenue = 0) public string GetUrlTrackAction(string actionUrl, ActionType actionType) { var url = GetRequest(IdSite); - url += "&" + actionType + "=" + UrlEncode(actionUrl); + url += "&" + actionType.ToString().ToLower() + "=" + UrlEncode(actionUrl); return url; } @@ -1420,7 +1420,7 @@ public void DisableCookieSupport() _configCookiesDisabled = true; } - private TrackingResponse SendRequest(string url, string method = "GET", string data = null, bool force = false) + public TrackingResponse SendRequest(string url, string method = "GET", string data = null, bool force = false) { // if doing a bulk request, store the url if (_doBulkRequests && !force)