Arnaud73 / ngx-matomo

Matomo (aka. Piwik) web analytics for Angular applications
MIT License
102 stars 47 forks source link

trackSiteSearch does not add search count when count is 0 #12

Closed VamsiDevalla closed 5 years ago

VamsiDevalla commented 5 years ago

When using the trackSiteSearch method, If we pass ) the method won't add search count to matomo url because of the inner logic:

The logic used is:

 if (!!resultsCount) {
                args.push(resultsCount);
  }

In the above code, if condition never gets satisfied when resultsCount is 0 beacuse:

if (0) {
//never comes here
console.log('HI')
}

So you can use some thing like:

if( resultsCount !== undefined&& typeof resultsCount === "number") {
   args.push(resultsCount);
}

I have created a pull request for this: Here

Arnaud73 commented 5 years ago

Hello,

Thanks for the bug report. I checked my code and I made the same mistake at least at one other place. I'm going to recheck the whole code and provide a fix.

VamsiDevalla commented 5 years ago

I gave a PR for this issue if you wanted to merge

Arnaud73 commented 5 years ago

Thanks for the bug report and the PR!

This bug, and several similar ones have been fixed in release 0.1.3.