Git Product home page Git Product logo

ionic-web-analytics's Introduction

ionic-web-analytics

An Express middleware for sending request analytics data to Google BigQuery.

Usage

Download the package.

npm install driftyco/ionic-web-analytics

Generate the middleware function and use in application.

let WebAnalytics = require('ionic-web-analytics')
let analytics = WebAnalytics(appId, checkRequest, config)

app.use(analytics)

For authentication with BigQuery, ensure the BIGQUERY_CLIENT_EMAIL and BIGQUERY_PRIVATE_KEY environment variables are set. These can be pulled from the JSON keyfile generated on BigQuery for service accounts. If either environment variable is missing, analytics will be disabled and the middleware will simply pass the request along.

API

appId

Required. A string identifier of the application corresponding to the desired table on BigQuery.

checkRequest

Required. A function that takes an express request object as a parameter and returns a boolean. The function should return true if analytics should be gathered on said request and false otherwise.

config

Optional. An object containing various configuration options.

config.batchSize

Integer between 1 and 500. The number of requests to buffer before sending to BigQuery. Defaults to 1.

config.dataset

string dataset identifier for BigQuery. Defaults to Ionic_Websites.

config.errorHandler

A function that will be called on error and passed the corresponding BigQuery error object. Logs the error by default.

config.projectId

string project identifier for BigQuery. Defaults to ionic-stats-storage.

ionic-web-analytics's People

Contributors

briandennis avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.