datag
v0.0.4
Published
A Vue plugin collects some data from user environment and actions
Downloads
4
Readme
datag
datag is a Vue plugin can gather enviroment and user movement information.
install
Using npm
$ npm install datag
Using yarn
$ yarn add datag
Using jsDelivr CDN:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/index.min.js"></script>
Using unpkg CDN:
<script src="https://unpkg.com/[email protected]/index.js"></script>
Using
First: install datag
Second: import datag and register on vue like this.
import datag from 'datag'
Vue.use(datag)
Third: register the command v-listen
to the item you`d like to monitor.
<Item
v-listen:[parantType] = "{direction: [direction], subType: [subType]}"
>
</Item>
Description
datag registered a Vue
command named v-listen
,and it is use on the item you`d like to monitor.
and you are suppose to pass the parentType to the arg of the command(v-listen:[parentType]
),and pass the subType to the value of the command(v-listen:[parentType] = "{direction: [direction], subType: [subType]}"
)。
direction
:
- description: datag can monitor visible items and this property controls whether direction datag divide important part.
- default: 'bottom'
- value:
- 'bottom': from bottom
- 'top': from top
subType
:
- description: the sub type of your data.
- required
API
environment information
enviData(Type)
//script in xxx.vue
//baseData
let baseData = this.$datag.enviData()
/*baseData type can be ignored
*let baseData = this.$datag.enviData(0)
*/
//advancedData
this.$datag.enviData(1).then((advancedData) => {
//use advancedData here
...
})
//mixData
this.$datag.enviData(2).then((mixData) => {
//use mixData here
...
})
introduce
you can get the information even you don`t register the v-command.And there are three kinds of information.
- base data: It includes some base information:
engine
: the engien of the browser.browser
: the browser type.device
: the device brand and type(special for Mobile platform).os
: Operation system .lang
: the language.onLine
: the online status.date
: the timeStamp of gather time.
- advanced data: It include some advanced feature of the client device.includes:
bluetooth
: the ability for bluetooth.position
: the position(permission are required).isTouch
: the ability of touch screen.screenHeight
: the screen hight.screenWidth
: the screen width.colorDepth
: the color depth of the screen.screenType
: the screen type.
- mix data: includes all the information mentioned above.
note:
type 1 will return a
object
includes its content.type 2 and type 3 will return a
promise
includes the information.
click data
clickData()
//script in xxx.vue
let clickData = this.$datag.clickData()
introduce
datag is going to gather the click data of the items been monitored by putting the v-listen
command on.
It return a object contains two part:
byTime: gather click data by every time the user clicks.And it contains following data:
eventType
: click type such as "mousedown"isTrusted
: whether it is created by JavaScript.mainType
: mainType passed by command.srcNode
: the trigger HTML node.subType
: subType passed by command.timeStamp
: click timeStampx
: left screen margin of click positiony
: top screen margin of click position
byType: an object contains parent type and it`s sub type click times such as :
china : { south: 2, north: 3, west: 4 }
scroll data
the main function of datag
,datag
divide the visible screen into two part :inportant
, unimportance
.And datag
will calculate the time it remains in the important
part. And datag
will processing the data on an appropriate time. And the data processed will stored in the scrollData
.
you can get the data by this:
//script in xxx.vue
let scrollData = this.$datag.scrollData
Besides,you can get the row data of scroll data by this:
//script in xxx.vue
let scrollData = this.$datag.watchData()
It will return the row data of scroll includes:
1. `timeGap`: the time gap user watched this time.
2. `vatalType`: the sub types remain in the visible part.