Giter Site home page Giter Site logo

prometheus's Introduction

Prometheus Long Logo

Prometheus.js

Bringing Firebase-powered CRM and analytics to all of humanity.

  • Track user-specific and event-based data.
  • Separate business logic from app logic.
  • Manage analytics from a customizable dashboard.

Prometheus ships with Pandora's Box, an analytics dashboard that can release experimental features and promotions to specific users.

Stories in Ready Join the chat at https://gitter.im/vingkan/prometheus

Demo

This visitor filled out a contact form with an invalid email address. Normally, the website owner would not be able to get in touch with them. But, Prometheus lights the way by associating the form submission with the visiting user. Now the owner can find them!

Prometheus Demo: Contact Form Mishap

Setup

Download the latest version of Prometheus.js (or npm install prometheusjs) and include it in your project. Prometheus.js depends on the Firebase JavaScript library.

<script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"></script>
<script src="prometheus.js"></script>

On each page that tracks data, create a new instance of Prometheus.

var prometheus = Prometheus({
  apiKey: "apiKey",
  authDomain: "projectId.firebaseapp.com",
  databaseURL: "https://databaseName.firebaseio.com"
});

You can auto-generate the config above by following the instructions on Firebase's web setup page. Additional configuration options are:

  • locator (boolean): whether or not to track geolocation data (defaults to true).
  • noScreenshots (boolean): whether or not to turn off screenshots (defaults to false).
  • localhost (boolean): whether or not to track events on localhost (defaults to true).

API

Logon

prometheus.logon(uid, userData, metaProps)

Begins tracking a user. If user data (such as name, email, profile picture, etc.) are provided, it will update that information in Firebase. Call this function as close to the login auth in your website as possible. When .logon() is called, Prometheus.js will continue to track that user until the browser's localStorage is cleared.

  • uid (string): unique identifier of user to track.
    • Note: If no unique user identification is available, for whatever reason, Prometheus.js will save data at the Firebase endpoint /ANONYMOUS_USER.
  • userData (object, optional): user properties to save or update.
  • metaProps (array, optional): metadata to save with event, see Metadata

Saves an event of type 'LOGON' with the user's visit list.

Save

prometheus.save(dataObj, metaProps)

Appends a new event to the list of the user's visits in Firebase. As long as .logon() or .trackUser() has been called, .save() will associate the visit event with the current user's data in Firebase. This is the most versatile tracking method because it stores custom data passed into the dataObj argument. The other tracking methods are built on top of save() and also allow custom data to be passed in.

  • dataObj (object, optional): customizable information to record with event.
  • metaProps (array, optional): metadata to save with event, see Metadata

Specify what type the saved event should be by setting type in the dataObj argument. Examples: {type: "CONTACT_FORM_SUBMISSION"} or {type: "SETTINGS_PAGE"}. Choose descriptive event type names that will help you analyze the data tracked by Prometheus effectively.

Capture

prometheus.capture(dataObj)

Takes a "snapshot" of the user's screen using the html2canvas library. For more information about what the screenshot represents, consult that libraries' documentation. Only saves images if noScreenshots is false in the config. Otherwise, the saved event will have a property img_note that has the value "NONE_TAKEN".

  • dataObj (object, optional): customizable information to record with event.

Saves an event of type 'SCREEN_CAPTURE' with the user's visit list with a property img whose value is the screenshot data.

Error

prometheus.error(errorObj)

Records errors experienced by the user. Triggered automatically by window.onerror events, but can also be called explicitly.

  • errorObj (object): data about error, should include:
    • message (string): message accompanying error
    • url (string): URL of file where the error occurred
    • line (integer): line number where error occurred

Saves an event of type 'ERROR' with the user's visit list.

Timer

prometheus.timer(timerID)

Retrieves timer object of the given id.

  • timerID (string): id of timer/action being timed

See Timer object methods below.

Timer Object

prometheus.Timer

Timer objects track how long users take to complete certain actions. Each action, behavior, or section of your website/app that will be tracked should have a unique, well-named ID. Prometheus can track timer durations by referencing that ID with its timer() method. The timer returned by that method has two public methods:

Methods

  • start(data): starts timing target action, accepts preliminary data
  • stop(data): stops timing target action, accepts additional data, new data with the same property name as the preliminary data will override the preliminary data

If stop() is called on a timer, an event of the type "TIMER" will be saved in the user's events list. It will include the following data:

  • start (timestamp): unix timestamp of start time
  • end (timestamp): unix timestamp of end time
  • timerID (string): ID of timer and target action
  • Any additional data saved via the start() and stop() arguments

Metadata

Prometheus.js can retrieve four types of metadata about the user's visit to your site. When the argument metaProps is present, you can specify what metadata to save in Firebase with the visit by passing in an array of tags. Underneath each tag in the bulleted list below is the metadata returned for that category.

  • 'browser'
    • device: type of device (desktop, tablet, mobile, or unknown)
    • height: height of screen (pixels)
    • width: width of screen (pixels)
    • name: browser name
    • version: browser version
  • 'location'
    • Note: if locator is false in the config, this will contain "NO_GEOLOCATION_EXCEPTION"
    • city: approximate city from geoip data
    • country: country from geoip data
    • latitude: approximate latitude coordinates
    • longitude: approximate longitude coordinates
    • ip: device IP address
  • 'datetime'
    • timestamp: Unix timestamp for instant of event
    • timezoneOffset: offset for user's timezone
  • 'page'
    • title: title of page/document
    • url: URL of page/document

Using the 'all' tag instead of a list of tags will return save all four types of metadata. If no metaProps argument is given, this is the default functionality.

Has

prometheus.has(featureID)

Synchronously checks if user has access to the given feature.

  • featureID (string): id of feature to check for
  • @returns (boolean): whether or not user has access to the feature

Can

prometheus.can(featureID, callback, fallback)

Asynchronously checks if user has access to the given feature and runs the appropriate function. The can() method should be used when no changes need to be made to user data, i.e., only a validate (explained below) function is called from Firebase.

  • featureID (string): id of feature stored at prometheus/features/{featureID}. Must have a validate function.
  • callback (function, required): function to run if user does have access to feature. Receives any data passed back from the validation as an argument.
  • fallback (function, recommended): function to run if user does not have access to feature. Receives any data passed back from the validation as an argument.

Validate Function

The .can() method runs a function stored in your Firebase to validate feature acccess. Thus, each feature entry must have a validate function that checks if the user can access the given feature, based on their data properties. The function definition can also choose what user data, if any, to pass back to the client.

Sample validate function for a video calling feature check:

if(userData.videoCalls){
    return {
        allowed: true,
        data: {
            lastCall: userData.lastVideoCallTimestamp
        }
    };
}
else{
    return {
        allowed: false
    };
}

This screenshot shows where to store the validate function in Firebase. Sample Feature Validation Entry in Firebase

Deliver

prometheus.deliver(featureID, callback, fallback)

Asynchronously checks if user has access to the given feature and runs the appropriate function. The deliver() method should be used when changes need to be made to user data, i.e., a process (explained below) function is called from Firebase.

  • featureID (string): id of feature stored at prometheus/features/{featureID}. Should have a process function.
  • callback (function, required): function to run if user does have access to feature. Receives any data passed back from the processing as an argument.
  • fallback (function, recommended): function to run if user does not have access to feature. Receives any data passed back from the processing as an argument.

Process Function

The .deliver() method runs a function stored in your Firebase to process feature acccess. Thus, each feature entry may have a process function that edits the user's data according to the given feature. The function definition can also choose what user data, if any, to pass back to the client.

Sample process function for a create meeting feature delivery request:

// TO-DO: Check if user has `createCredits` data property
if (userData.createCredits > 0) {
	userData.createCredits--;
	return {
		allowed: true,
		changed: true,
		data: {
		    createCredits: userData.createCredits
		}
	};
} else {
	return {
		allowed: false,
		data: {
		    createCredits: userData.createCredits
		}
	};
}

See the screenshot from the .can() section to see where to store the process function in Firebase. It must be saved with the key process.

Redeem

prometheus.redeem(promoCode, callback, fallback, settings)

Looks up a given promo code and runs the promo code's redeem function on the user's feature data.

  • promoCode (string, required): promo code stored at prometheus/promos/{promoCode}. Must have a redeem function.
  • callback (function, recommended): function to run if code is redeemed. Callback receives the information stored with the code in Firebase as its only argument, if any.
  • fallback (function, recommended): function to run if code is not found or is unredeemable. Fallback receives error type and error message.
  • settings (object, optional): extra settings for redeeming promo codes, currently only one setting:
    • silent (boolean, optional): whether or not to record when users attempt to re-use codes (defaults to false)

Redeem Function

Each promo code entry must have a redeem function that updates the users' data according to the promotion. Here is a sample redeem function for a create meeting credit promo code:

userData.createCredits += 5;
return userData;

This screenshot shows where to store the redeem function in Firebase. Sample Promo Code Entry in Firebase

Notify

prometheus.notify(noteID, note, callback)

Sends popups to specific users via web notifications.

  • noteID (string, required): id used to group receiving users and notification return information, stored at prometheus/features/{noteID}. Must have a validate function to determine if user should recieve notification.
  • note (object, required):
    • title (string, optional): notification title.
    • message (string, optional): notification body.
    • icon (string, optional): notication icon.
  • callback (function, optional): code to run if a user clicks on the notification body

See Note object methods below.

Note Object

prometheus.Note

Callback functions for notify() include a Note object that has two methods for the developer to access. Keep in mind that the notifications functionality is built on top of deliver(), so each notification should be defined at prometheus/features/{noteID} and have at least a validate function.

Methods

  • seen(): saves a Prometheus "NOTIFICATION_CLICKED" event for the user
  • terminate(): removes the notification ID from the user's data: they will not receive this notification unless it is reassigned to them

Pandora's Box Dashboard

Explore the data saved by Prometheus.js with a customizable, local dashboard! Instructions to use the analytics dashboard with your Prometheus-tracked data are here.

About Us

Prometheus.js and PandorasBox.js were created by the development team at Omnipointment: the omnipotent appointment scheduling tool.

prometheus's People

Contributors

bbatliner avatar gitter-badger avatar vingkan avatar waffle-iron avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

prometheus's Issues

Module: Users Overview

Show all/most important user data on main dashboard page. Maybe some sort of leaderboard.

Minified Scriptlet

Rather than explicitly initializing the object, can we give Prometheus users a minified scriptlet that they can paste on all pages?

Prometheus webmasters will still be able to use Prometheus' functionality to make custom tracking calls, but this would track all page visits, with reference to issue #9 about not having access to page flow analytics if the webmaster did not call Prometheus on that page.

If we elevate this to a #Site issue, then maybe we could have a minified scriptlet generator on the Prometheus website where webmasters can enter their Firebase URL and have the code they need created for them.

Less.js for Style Customization

Let's try the stylesheet for the analytics dashboard completely in LESS. No more of this compile to CSS crap. Users will be able to choose custom colors and maybe even logos for their dashboard.

User Screenshots

Try to replace the functionality of Inspectlet by taking static screenshots of user's screen. Can phantom.js be used for this, or does that mean it has to run from server-side?
Do we need to find a third-party method of storing images or can we use blob storage in Firebase?

Sample Terms Agreement

Users of sites implementing Prometheus.js agree to have their information tracked and correlated. Create a sample agreement text that users of Prometheus can add to their Terms and Conditions.

Specifically reference that beta testers should consent to this.

Duration Timer

Allow Prometheus webmasters to track duration spent on pages as well as duration for users to complete a certain operation or interact with a certain feature. This means that a timer may have to extend over more than one page: is that a permissible use of sessionStorage?
"Timer" most likely means storing the start time and the end time, and then finding the difference.

Error Reporting

Catch errors in the console and save the error information with a specific user's data in Firebase so that the webmaster can follow up with users.

Server-Side Prometheus

My god I don't event know what this entails. But it would make tracking user logon events easier. Maybe we want to release an npm module? npm is satan

Firebase Security Rules

Configure Firebase so that only master users can access an app's information from their dashboard. Do we need to have private keys for this?

After reading through Firebase tutorials on secured read/write access, it may be helpful to either copy the link to their tutorial or create one of our own for Prometheus users. This would be a new #Site issue.

Page Flow Analytics

Basically rip off Google Analytics' page flow by using the visit events saved by Prometheus. Statistics about approximate time on page, drop offs, and previous and following page (werk dat linked list bois) would be helpful. Note that right now, this flow map would only show visits when Prometheus users have chosen to track a page.

Module: Individual User

Show data and tracked visits for a specific user. Find this page from search or from dashboard main page.

GeoIP for Location

Less-intrusive, rougher estimate of user location. Does not require pop up permissions.

Backup Data

Allow webmasters to save information from Firebase so that they don't exceed data limits. Perhaps save as a text file? Is there a way to check how much data is being used and assess if a backup should be made?

Try out Prometheus on your site!

We would love it if you could try out Prometheus on your website. If you add the code to your site and leave us your email, we'll send you your analytics dashboard as soon as possible!

  • Landing Page
  • Documentation
    Are you planning to use Prometheus to track sensitive data? Help us with issue #3: writing up a sample user agreement and #4: implementing Firebase security rules so only you can get into your dashboard.

Set Analytics Milestones

Set default goals as well as allow for custom goals.
Maybe set custom goals with JSON or a JavaScript file for more flexibility?
If JSON can be read, we can eventually set up a GUI for writing goals and milestones.

Modules as Widgets and Pages

How can we structure dashboard modules for content like user leaderboards and milestones so that they can flexibly be displayed as both:

  • Widgets in a larger dashboard page
  • and Pages on their own
    There's gotta be a better way than iFrames - perhaps just using responsive styling will allow this to work based on what type of div the module content is inserted into.

Fake User Authentication

For demo purposes, find a way to authenticate fake users on the Prometheus landing page. That way when we run unit tests, demo the Analytics Dashboard, or any other time we would need to crawl the site, we can use an account other than our own.

Can use the random personality generator, or just develop 5-10 preset fake users for use when crawling the site.

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.