GithubHelp home page GithubHelp logo

hussaintamboli / event-builder Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 4 KB

Idiomatic event builder that helps you track user states from your web apps

JavaScript 100.00%
event-tracking events analytics builder-pattern

event-builder's Introduction

NPM version

ES6 client JS that helps you log events to your server very easily.

Idea

I should be able to track user events from my Web apps easily.

Install

npm install event-builder

Import

import Event from 'event-builder';

Usage

  1. Basic event builder

     let builder = new Event.Builder("http://localhost:8090/api/v1/event");
     builder = builder.app("CMS", "2.1", "en").user(234992, "Hussain", "CMS", "ade23-29df3402034-23ddl");
    
  2. Login event

     // where builder is above basic builder
     builder = builder.type("Login")
     builder.send();
    
  3. Page view

     builder = builder.type("PageView").page('Deal', 'Deal100');
     builder.send();
    
  4. Button click

     builder = builder.type("ContentUpload").page("content_upload").section("upload_button").action("click");
     builder.send();
    
  5. Create builder from json

    Basic builder is needed to send an event. But creating it everytime you want to send an event won't be feasible in your app (let's say angular app).

    You can store a json in localStorage and get it when you want to send an event. Just pass that json string to fromJson and get the builder object.

     let json = "{"url":"http://localhost:8090/api/v1/event","app_name":"CMS","version":"0.2.0","language":"en","user_id":1000,"user_info":{"name":"Hussain Tamboli","source":"Web-2","X-Authorization-Token":"293492-2932492-29349skdf-234"}}";
     let builder = new Event.Builder().fromJson(json);
     builder.send();
    
  6. Create builder from obj

     let obj = {
             "url": "http://localhost:8090/api/v1/event",
             "app_name": "CMS",
             "version": "0.2.0",
             "language": "en",
             "user_id": 1000,
             "user_info": {
                 "name": "Hussain Tamboli", 
                 "source": "Web-1", 
                 "X-Authorization-Token": "b29349-29349-293499-2934"
             }
     };
     let builder = new Event.Builder().fromObj(obj);
     builder.send();
    

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.