Giter Club home page Giter Club logo

ga-lite's Introduction

@aleclarson/ga-lite npm

Fork of google-analytics-lite

Changelog

  • 0.3.0
    • Make the pageView method send a "screenview" hit when called from a non-web environment (22fb94e)
    • Add inline documentation to every GAParameters property (13f8e9b)
    • Add debug option (c74c765)
    • Remove social and exception methods (a11b4cd)
    • Use uid for code reuse (c9fe40a)
    • ๐Ÿ› Pass &t for "pageview" and "event" hits (531442d)
  • 0.2.3
    • Stop using @lukeed/uuid for React Native compatibility (4aa7051)
  • 0.2.2
    • Stop using URLSearchParams for React Native compatibility (b443793)
    • Add shouldSend option to constructor (39579e7)
    • Make it easier to pass GAParameters to event method (3b9965e)
  • 0.2.1
  • 0.2.0
    • Remove random and getUUID exports (e12c8a6)
    • Rename default export to GoogleAnalytics (ec77a0e)
    • Remove Object.assign polyfill (22bb893)
    • Remove fetch property (0abd7a1)
    • Add an options argument to GoogleAnalytics (bbf722c)
      • Added the GAOptions type
      • Added the opts property
      • Added the opts.fetch property
      • Moved the baseURL property to opts.baseURL
      • Renamed the defaultValues property to params
      • Removed the GAAllParameters type
    • Use @lukeed/uuid for speed and code reuse (72fd64a)

ga-lite's People

Contributors

aleclarson avatar dependabot[bot] avatar shirasawasama avatar

Watchers

 avatar

ga-lite's Issues

Support SSR environments

๐Ÿ‘‹ really cool package! Thanks for continuing the work on google-analytics-lite.

Trying to use this with Gatsby but builds aren't happy with isWeb:

"window" is not available during server side rendering.

See our docs page for more info on this error: https://gatsby.dev/debug-html


  1 | import randomId from 'uid';
> 2 | const isWeb = typeof window.document !== 'undefined';
    | ^
  3 | /**
  4 |  * https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
  5 |  */


  WebpackError: ReferenceError: window is not defined

Would it be possible to do an undefined check on window first? Not sure what isWeb should be in a SSR environment. Alternatively, that check could just be moved into pageView which should only be called on the client.

Use burst limiting for delayed requests

When shouldSend is used to delay requests (ie: because the network is down), it can result in a huge burst of API calls, which can lead to rate limiting. Instead, when a delayed request is resumed, it should be added to a queue that is drained at a specified rate.

Add "shouldRetry" option

This option is only called after network errors. Invalid requests are never retried.

When shouldRetry can return a promise to delay the retry until the desired time. This makes it a great integration point for libraries, allowing this package to remain lightweight.

Use case

To avoid dropping data!

While the shouldSend option can avoid sending requests while the network is down, it can't retry requests that were sent before the network went down. That's where shouldRetry comes in handy.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.