text: 'use strict';
  
  /* eslint-env browser, serviceworker */
  
  importScripts('./scripts/libs/idb-keyval.js');
  importScripts('./scripts/analytics-sw.js');
  
  self.analytics.trackingId = 'UA-77119321-2';
  
  self.addEventListener('push', function (event) {
    console.log('Received push');
    var notificationTitle = 'Hello';
    var notificationOptions = {
      body: 'Thanks for sending this push msg.',
      icon: './images/pp.jpg',
      badge: './images/pp.jpg',
      tag: 'simple-push-demo-notification',
      data: {
        url: 'https://developers.google.com/web/fundamentals/getting-started/push-notifications/'
      }
    };
  
    if (event.data) {
      var dataText = event.data.text();
      notificationTitle = 'Received Payload';
      notificationOptions.body = 'Push data: \'' + dataText + '\'';
    }
  
    event.waitUntil(Promise.all([self.registration.showNotification(notificationTitle, notificationOptions), self.analytics.trackEvent('push-received')]));
  });
  
  self.addEventListener('notificationclick', function (event) {
    event.notification.close();
  
    var clickResponsePromise = Promise.resolve();
    if (event.notification.data && event.notification.data.url) {
      clickResponsePromise = clients.openWindow(event.notification.data.url);
    }
  
    event.waitUntil(Promise.all([clickResponsePromise, self.analytics.trackEvent('notification-click')]));
  });
  
  self.addEventListener('notificationclose', function (event) {
    event.waitUntil(Promise.all([self.analytics.trackEvent('notification-close')]));
  });