<commit_before><link rel="import" href="../polymer/polymer.html">

<!--

Custom web element for Google Analytics

##### Example

    <uqlibrary-ga trakingId='UA-1234-5' websiteUrl='http://www.test.com/app' appName='TestApp' cookieDomain='test.com'></uqlibrary-ga>

@element uqlibrary-ga
@blurb Custom web element for Google Analytics
@status alpha
@homepage http://uqlibrary.github.io/uqlibrary-ga

-->
<polymer-element name="uqlibrary-ga" attributes="webPropertyId isLocal appName">

  <script>

    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    Polymer({
    /**
    * The `trackingId` Google Analytics tracking ID
    *
    * @property trackingId
    * @type String
    */

    /** The `websiteUrl` url of website for Google Analytics
    *
    * @property websiteUrl
    * @type String
    */
    /** The `appName` application name to prefix page views
    * @property appName
    * @type String
    */

    /** The `cookieDomain` set domain for cookies
    *
    * @property cookieDomain
    * @type String
    *
    */

      trackingId : 'UA-4365437-12',
      websiteUrl: 'https://app.library.uq.edu.au',
      cookieDomain: 'app.library.uq.edu.au',
      appName: 'UQLAPP',

      //google analytics settings: clientId, siteSpeedSampleRate, forceSSL, etc
      sampleRate: 100,
      disableTracking: 'ga-disable-UA-XXX-Y',

      created: function() {
      },

      ready: function() {

        ga('create', this.trackingId,
                {
                  'cookieName'    : 'ga_' + this.appName,
                  'cookieDomain'  : document.location.origin != this.websiteUrl ? 'none' : this.cookieDomain,
                  'sampleRate'    : this.sampleRate
                });

        //check if user opted out from GA tracking
        this.disableTracking = 'ga-disable-' + this.trackingId;
        if (document.cookie.indexOf(this.disableTracking + '=true') > -1) {
          window[this.disableTracking] = true;
        }
      },

      /**
       *  The `optOut` method disables google analytics tracking and sets cookie to remember this setting
       *
       * @method optOut
       */
      optOut : function() {
          document.cookie = this.disableTracking + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
          window[this.disableTracking] = true;
      },

      /**
       *  The `addPageView` method sets current page and records a page view.
       *  Page view is recorded as '/AppName/page'
       *
       * @method addPageView
       */
      addPageView: function(page) {
        var pageHit = "/" + this.appName + "/" + page;

        ga('set', { page: pageHit, title: pageHit });
        ga('send', 'pageview');
      },

      /**
       *  The `addEvent` method records an action of the event
       *  Event is recorded with category set to 'AppName' and action set to '/AppName/action'
       *
       * @method addEvent
       */
      addEvent: function(action) {
        ga('send', 'event', this.appName, "/" + this.appName + "/" + action);
      }

    });

  </script>

</polymer-element>
<commit_msg>Add event label parameter<commit_after><link rel="import" href="../polymer/polymer.html">

<!--

Custom web element for Google Analytics

##### Example

    <uqlibrary-ga trakingId='UA-1234-5' websiteUrl='http://www.test.com/app' appName='TestApp' cookieDomain='test.com'></uqlibrary-ga>

@element uqlibrary-ga
@blurb Custom web element for Google Analytics
@status alpha
@homepage http://uqlibrary.github.io/uqlibrary-ga

-->
<polymer-element name="uqlibrary-ga" attributes="webPropertyId isLocal appName">

  <script>

    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    Polymer({
    /**
    * The `trackingId` Google Analytics tracking ID
    *
    * @property trackingId
    * @type String
    */

    /** The `websiteUrl` url of website for Google Analytics
    *
    * @property websiteUrl
    * @type String
    */
    /** The `appName` application name to prefix page views
    * @property appName
    * @type String
    */

    /** The `cookieDomain` set domain for cookies
    *
    * @property cookieDomain
    * @type String
    *
    */

      trackingId : 'UA-4365437-12',
      websiteUrl: 'https://app.library.uq.edu.au',
      cookieDomain: 'app.library.uq.edu.au',
      appName: 'UQLAPP',

      //google analytics settings: clientId, siteSpeedSampleRate, forceSSL, etc
      sampleRate: 100,
      disableTracking: 'ga-disable-UA-XXX-Y',

      created: function() {
      },

      ready: function() {

        ga('create', this.trackingId,
                {
                  'cookieName'    : 'ga_' + this.appName,
                  'cookieDomain'  : document.location.origin != this.websiteUrl ? 'none' : this.cookieDomain,
                  'sampleRate'    : this.sampleRate
                });

        //check if user opted out from GA tracking
        this.disableTracking = 'ga-disable-' + this.trackingId;
        if (document.cookie.indexOf(this.disableTracking + '=true') > -1) {
          window[this.disableTracking] = true;
        }
      },

      /**
       *  The `optOut` method disables google analytics tracking and sets cookie to remember this setting
       *
       * @method optOut
       */
      optOut : function() {
          document.cookie = this.disableTracking + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
          window[this.disableTracking] = true;
      },

      /**
       *  The `addPageView` method sets current page and records a page view.
       *  Page view is recorded as '/AppName/page'
       *
       * @method addPageView
       */
      addPageView: function(page) {
        var pageHit = "/" + this.appName + "/" + page;

        ga('set', { page: pageHit, title: pageHit });
        ga('send', 'pageview');
      },

      /**
       *  The `addEvent` method records an action of the event
       *  Event is recorded with category set to 'AppName' and action set to '/AppName/action'
       *
       * @method addEvent
       */
      addEvent: function(action, label) {
        if(typeof(label) != 'undefined'){
          ga('send', 'event', this.appName, "/" + this.appName + "/" + action, label);
        }
        else {
          ga('send', 'event', this.appName, "/" + this.appName + "/" + action);
        }
      }

    });

  </script>

</polymer-element>

{'fraction_non_alphanumeric': 0.14922564770589086, 'fraction_numerical': 0.009552757273122015, 'mean_word_length': 2.336552390149686, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2594953', 'n_tokens_mistral': 2248, 'n_tokens_neox': 2121, 'n_words': 475}