Skip to content

Commit

Permalink
#91 Added support of the async requests in GoogleAnalytics plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanovM committed Sep 12, 2017
1 parent 4c6445e commit 6dcbab1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
@@ -1,7 +1,7 @@
//Contributor: https://www.codeproject.com/Articles/493455/Server-side-Google-Analytics-Transactions

using System;
using System.Net;
using System.Net.Http;
using Nop.Core;

namespace Nop.Plugin.Widgets.GoogleAnalytics.Api
Expand All @@ -28,37 +28,23 @@ public class GoogleRequest

#region Utilities

private void FireRequest(string url)
private async void FireRequest(string url)
{
if (_requestCount < 500)
{
_requestCount++;

var gaRequest = WebRequest.Create(url);

var httpClient = new HttpClient();
try
{
// we don't need the response so this is the end of the request
var response = gaRequest.GetResponse();
var response = (await httpClient.GetAsync(url)).EnsureSuccessStatusCode();
}
catch (Exception exc)
{
//eat the error
}

//TODO comment the code above and uncomment the code below when the issue with multiple products is fixed
//gaRequest.BeginGetResponse(r =>
// {
// try
// {
// // we don't need the response so this is the end of the request
// var response = gaRequest.EndGetResponse(r);
// }
// catch
// {
// //eat the error
// }
// }, null);
}
}

Expand Down
Expand Up @@ -5,7 +5,7 @@
<Copyright>Copyright © Nop Solutions, Ltd</Copyright>
<Company>Nop Solutions, Ltd</Company>
<Authors>Nop Solutions, Ltd</Authors>
<Version>1.31</Version>
<Version>1.34</Version>
<Description>This plugin integrates with Google Analytics. It keeps track of statistics about the visitors and ecommerce conversion on your website</Description>
<PackageLicenseUrl></PackageLicenseUrl>
<PackageProjectUrl>http://www.nopcommerce.com/</PackageProjectUrl>
Expand Down

0 comments on commit 6dcbab1

Please sign in to comment.