log

前端日志研究

MIT License

Stars
9

log

Topic1: Log lib

js, ``, . , send, :

var page = Log.create();
page.send('id', 1);

    • debug.js,
  • urlencode

debug.js, . , , debug.js.

| | --- | --- | --- | | | | | | | | urlencode | |

Api

/**
 * 
 *
 * @param {string} url gif
 * @param {Object} options 
 *
 * @return {Object} 
 */
Log.create(url, options);

/**
 * 
 *
 * @param  {Object|string} key   key, . , string
 * @param  {string|undefined} value 
 *
 * @return {Object}       this
 */
#send(key, value);

// a
var clickLog = Log.create('/.gif', {
    page: 'a',
    type: 'click'
});

// apv
var pvLog = Log.create('/.gif', {
    page: 'a',
    type: 'pv'
});


// 
clickLog.send({
    id: 1,
    width: 120
});
clickLog.send('xxxx', 1);

// pv
pvLog.send({
    id: 1
});
pvLog.send('xxxx', 1);

1.

debug.js, ,

2.

, , : selenium

3.

json, string, send, json

4. ?

send, , ,

Topic2:

  1. ,
  2. mark:
    1.
    2.
    2.
    3.
    1. scroll
    2. resize
    3. focus
    4. blur
    5. visibilitychange
  3. cli,
  4. alias,
const App = Log(options);

// 
App.use('index.html');

// , 
App.mark('DOM_READY');

// , 
App.mark('ON_LOAD');

//  + 
let scrollTimer = null;
$(window).on('scroll.log', () => {
    clearTimeout(scrollTimer);
    scrollTimer = setTimeout(() => {
        App.mark('READ_HEIGHT', window.scrollY);
        App.mark('MAX_HEIGHT', window.scrollY, Log.markType.MAX);
    }, 300);
});

// id
page.on('', () => {
    App.mark('ARTICLE_ID', page.article_id, Log.markType.TIME);
});

// 
page.on('', () => {
    App.mark('ARTICLE_PAGE', page.current_page);
});


Badges
Extracted from project README
code style fecs Build Status Test Coverage MIT license
Related Projects