0.0.6 • Published 3 months ago

fufu-tracker v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

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
}
0.0.5

3 months ago

0.0.6

3 months ago

0.0.4

4 months ago

0.0.3

4 months ago

0.0.2

4 months ago

0.0.1

4 months ago