Giter VIP home page Giter VIP logo

fufu-tracker's Introduction

fufu-tracker npm build status

Description

This is a simple sdk for tracking events in your application.

Installation & Usage

npm and etc

npm install fufu-tracker
import FufuTracker from "fufu-tracker"

const tr = new FufuTracker({
  // required, your application unique key
  app_id: "ko no fufu da", 
  // required, your report url
  report_url: "http://localhost:3000/report", 
  // optional, default is all events
  events_tobe_record: ["action_click", "action_scroll"],
})

// pushEvent for custom record
tr.pushEvent({
  type: "ko no fufu da",
  target: "btn",
  action: "click",
  time: Date.now(),
})
// send for custom decide when to send
tr.send()

cdn

<!-- with esm -->
<script type="module">
  import FufuTracker from "https://cdn.jsdelivr.net/npm/fufu-tracker/lib/index.esm.js"
  const tr = new FufuTracker({...})
</script>
<!-- or -->
<script src="https://cdn.jsdelivr.net/npm/fufu-tracker/lib/index.umd.js"></script>
<script>
  const tr = new FufuTracker({...})
</script>

Features

it will send data to your report url when:

  • visibilitychange
  • beforeunload
  • send() called

the data contains:

interface Data  {
  // base info
  baseInfo: BaseInfo
  // events
  events: Event[]
}

interface BaseInfo {
  // app unique key
  app_id: string 
  // sdk version (auto filled)
  sdk_version: string 
}

interface Event {
  // event type
  type: string
  // event action
  action: string
  // event time
  time_stamp: number
  // event page url
  page_url?: string
  // event extra data, depends on event type
  data?: any
}

fufu-tracker's People

Contributors

huamurui avatar

Stargazers

 avatar

Watchers

 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.