Skip to content

Commit

Permalink
Fix GetUrlTrackAction to send download instead of Download - fix issue
Browse files Browse the repository at this point in the history
…matomo-org#68 & change SendRequest to be public so in future, callers can build thier own url and use sendrequest to push it to matomo
  • Loading branch information
MERamadan committed May 2, 2019
1 parent 77f01cc commit 1004485
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
20 changes: 12 additions & 8 deletions Piwik.Tracker.Samples/PiwikTrackerSamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -54,6 +54,7 @@ private static void Main(string[] args)
// ** Event Tracking **
// TrackSongPlayback();

TrackDownload();
Console.ReadKey(true);
}

Expand Down Expand Up @@ -129,17 +130,19 @@ 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));

piwikTracker.SetResolution(1600, 1400);

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);

Expand Down Expand Up @@ -179,7 +182,7 @@ static private void RecordSimplePageViewWithCustomGeoLocation()
/// </summary>
static private void RecordSimplePageViewWithGenerationTime()
{
var piwikTracker = new PiwikTracker(SiteId, PiwikBaseUrl);
PiwikTracker piwikTracker = new PiwikTracker(SiteId, PiwikBaseUrl);
piwikTracker.SetUserAgent(UA);

piwikTracker.SetGenerationTime(10000);
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
Expand Down
4 changes: 2 additions & 2 deletions Piwik.Tracker/PiwikTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1004485

Please sign in to comment.