Code Monkey home page Code Monkey logo

node-simple-ga's People

Contributors

ringoldsdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

lkbr

node-simple-ga's Issues

Create tests

  • ApiHelper
  • Client
  • DimensionFilter
  • MetricFilter
  • ObjectBuilder
  • Request
  • ResultParser

Create a Github page for the project

It should contain a brief description about the package, a list of variables supported by Google Analytics Reporting API 4, typical use cases and an advanced example or two.

Implement returning of raw results

If there's no need for a processed query where all values are combined with proper metric and dimension names and returned as a new result object, make it possible to do so.

Examples:

  1. There's only 1 dimension and 1 metric,
  2. Running the request takes a long time and it's faster not to parse the result

bounceRate and exitRate always coming back 0 or 100

Thanks for this repo. It really makes dealing with the Google Analytics API a lot easier.

I'm running into an issue where bounceRate and exitRate are always coming back either 0 or 100 when using node-simple-ga, but it wasn't doing that when I was using the GA api directly. Any ideas? I've tried camelCase and all lowercase but still get the same data back

Request:

const request = Request()
  .select(
    'pagepath',
    'pageviews',
    'users',
    'sessions',
    'avgtimeonpage',
    'bouncerate',
    'exitrate'
  )
  .from(XXXXXXX)
  .where('pagepath')
  .is('/')
  .period('2021-12-01', '2021-12-21')

const response = await analytics.run(request)

Response:

[{
  users: 1627,
  exitRate: 0,
  pagePath: '/',
  sessions: 1951,
  pageviews: 2296,
  bounceRate: 0,
  avgTimeOnPage: 65
}]

unhandled promise rejection when using .catch()

  var request = Request()
    .select("pagepath", "pageviews", "users")
    .from(12345)
    .during("2017-10-31", "2018-10-31")
    .results(3)
    .orderDesc("users");


  let promise = analytics.run(request);

  promise.catch(err => {
    console.log("caught the error: ", err)
  });

Since i supplied a view id i don't have access to (12345), i would expect that the catch block occurs and the console says "caught the error", but instead, i get:


(node:99630) UnhandledPromiseRejectionWarning: Error: User does not have sufficient permissions for this profile.
    at createError (/test/node_modules/node-simple-ga/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/test/node_modules/node-simple-ga/node_modules/axios/lib/core/settle.js:18:12)
    at Unzip.handleStreamEnd (/test/node_modules/node-simple-ga/node_modules/axios/lib/adapters/http.js:201:11)
    at emitNone (events.js:111:20)
    at Unzip.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
(node:99630) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

I'm more comfortable with promise methods like .then and .catch rather than async / await. If analytics.run() actually returns a promise (which it does, according when.isPromiseLike()), then it's natural to expect .catch to work for error handling, isn't it?

Implement pagination for multiple batched requests

Currently only one request is supported. Note that GoogleAnalytics only supports up to 5 concurrent requests.

High level explanation of how it would work.

  1. Create requests
  2. Run them
  3. Before running, identify each request (generate an identifier based on hashed and stringified request without the page token, since it's the only part that changes)
  4. Get all the results and append them to the request buffer
  5. Check if there's additional data and more pages are needed
  6. Add those requests that fit the criteria
  7. Run and get results
  8. Repeat until no requests can be made
  9. Return all results

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.