New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

electron-google-analytics

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-google-analytics

A library to implement Google Analytics in desktop apps.

  • 0.0.16
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Google Analytics - Measurement Protocol API

travis-ci

The main purpose of this was to be used with Electron built apps.

Features
  • Pageview
  • Event
  • Screenview
  • Transaction
  • Social
  • Exception
  • Refund
  • Item
  • User Timing Tracking
  • Custom function for the rest (send)
Getting started

Installation

npm i electron-google-analytics
  • Init

    Analytics(trackingID, { userAgent, debug, version })

    import Analytics from 'electron-google-analytics';
    const analytics = new Analytics('UA-XXXXXXXX-X');
    
  • Pageview

    Analytics#pageview(hostname, url, title, clientID)

    return analytics.pageview('http://example.com', '/home', 'Example')
      .then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
    

    If you want to keep the session you need to specify the clientID.

  • Event

    Analytics#event(evCategory, evAction, { evLabel, evValue, clientID })

    return analytics.event('Video', 'play', { evLabel: 'holiday', evValue: 300})
      .then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
    
  • Screenview

    Analytics#screen(appName, appVer, appID, appInstallerID, screenName, clientID)

    return analytics.screen('test', '1.0.0', 'com.app.test', 'com.app.installer', 'Test')
      .then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
    
  • Transaction

    Analytics#transaction(trnID, { trnAffil, trnRev, trnShip, trnTax, currCode } = {}, clientID)

    return analytics.transaction(123).then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
    
  • Social

    Analytics#social(socialAction, socialNetwork, socialTarget, clientID)

    return analytics.social('like', 'facebook', 'home').then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
    
  • Exception

    Analytics#exception(exDesc, exFatal, clientID)

    return analytics.exception('IOException', 1).then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
    
  • Refund

    Analytics#refund(transactionID, evCategory = 'Ecommerce', evAction = 'Refund', nonInteraction = 1, clientID)

    return analytics.refund('T123').then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
    
  • Item

    Analytics#item(trnID, itemName, { itemPrice, itemQty, itemSku, itemVariation, currCode } = {}, clientID)

    return analytics.item(123, 'Test item').then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
    
  • User Timing Tracking

    Analytics#timingTrk(timingCtg, timingVar, timingTime, { timingLbl, dns, pageDownTime, redirTime, tcpConnTime, serverResTime } = {}, clientID)

    return analytics.timingTrk('Category', 'jsonLoader').then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
    
  • Send (for everything else for now)

    Analytics#send(hitType, params, clientID)

    return analytics.send('social', { sa: 'social', sn: 'facebook', st: 'home' })
      .then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
    
Tests
cross-env TRACKING_ID='UA-XXXXXXXX-X' npm test

MIT

Keywords

FAQs

Package last updated on 14 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc