-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
57 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
const Core = {}; | ||
|
||
Core.version = '____F2_VERSION____'; | ||
Core.Global = require('./global'); | ||
const Global = require('./global'); | ||
Core.Global = Global; | ||
Core.Chart = require('./chart/chart'); | ||
Core.Shape = require('./geom/shape/shape'); | ||
Core.G = require('./graphic/index'); | ||
Core.Util = require('./util/common'); | ||
|
||
Core.track = function(enable) { | ||
Global.trackable = enable; | ||
}; | ||
require('./track'); | ||
|
||
module.exports = Core; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @fileOverview track f2 | ||
* @author sima.zhang1990@gmail.com | ||
*/ | ||
const Global = require('./global'); | ||
const Util = require('./util/common'); | ||
const SERVER_URL = 'https://kcart.alipay.com/web/bi.do'; | ||
|
||
// 延迟发送请求 | ||
setTimeout(function() { | ||
if (Global.trackable && Util.isBrowser) { // 只对 h5 环境下进行统计 | ||
const image = new Image(); | ||
const newObj = { | ||
pg: document.URL, | ||
r: new Date().getTime(), | ||
f2: true, | ||
version: Global.version, | ||
page_type: 'syslog' | ||
}; | ||
const d = encodeURIComponent(JSON.stringify([ newObj ])); | ||
image.src = `${SERVER_URL}?BIProfile=merge&d=${d}`; | ||
} | ||
}, 3000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const expect = require('chai').expect; | ||
const Core = require('../../src/core'); | ||
|
||
describe('Core', function() { | ||
it('Keys', function() { | ||
expect(Core).to.have.all.keys([ 'Global', 'Chart', 'Shape', 'G', 'Util', 'track' ]); | ||
}); | ||
|
||
it('close track', function() { | ||
expect(Core.Global.trackable).to.be.true; // default is open | ||
|
||
Core.track(false); | ||
expect(Core.Global.trackable).to.be.false; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const expect = require('chai').expect; | ||
const Global = require('../../src/global'); | ||
const pkg = require('../../package.json'); | ||
|
||
describe('Global', () => { | ||
it('version sync', () => { | ||
expect(Global.version).equal(pkg.version); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters