CardinalPath / gas

Google Analytics on Steroids. A Google Analytics implementation with more power features.
Other
593 stars 78 forks source link

_gasTrackDownloads fails when opts.category only is present #67

Open googleanalyticsresoneo opened 10 years ago

googleanalyticsresoneo commented 10 years ago

_gas.push(['_gasTrackDownloads', {category: 'Téléchargements'}]); will fail because opts['extensions'] is never created when only a category option is present

var _trackDownloads = function (opts) {
    var gh = this;
    if (!gh._downloadTracked) {
        gh._downloadTracked = true;
    } else {
        //Oops double tracking detected.
        return false;
    }
    if (!opts) {
        opts = {'extensions': []};
    } else if (typeof opts === 'string') {
        // support legacy opts as String of extensions
        opts = {'extensions': opts.split(',')};
    } else if (opts.length >= 1) {
        // support legacy opts Array of extensions
        opts = {'extensions': opts};
    }
    opts['category'] = opts['category'] || 'Download';

    var ext = 'xls,xlsx,doc,docx,ppt,pptx,pdf,txt,zip';
    ext += ',rar,7z,exe,wma,mov,avi,wmv,mp3,csv,tsv';
    ext = ext.split(',');
    opts['extensions'] = opts['extensions'].concat(ext);

Exception TypeError : Cannot call method 'concat'0 of undefined

tomfuertes commented 10 years ago

Good find! Would you like to take at the PR on this one?

googleanalyticsresoneo commented 10 years ago

Sorry Tom but what does PR mean ? (I'm not so used to github processes)

googleanalyticsresoneo commented 10 years ago

A Pull Request ?! https://help.github.com/articles/using-pull-requests I can give it a try, but feel free to revise it completely :-)

tomfuertes commented 10 years ago

Yep a Pull Request! :) Happy to revise.

googleanalyticsresoneo commented 10 years ago

From which branch should I perform the edit ?

tomfuertes commented 10 years ago

Develop

-Tom (via phone)

On Mar 11, 2014, at 12:36 PM, RESONEO Google Analytics notifications@github.com wrote:

From which branch should I perform the edit ?

— Reply to this email directly or view it on GitHub.