Repository: incubator-weex Updated Branches: refs/heads/master 464be58bd -> 3a0ac37de
+ [jsfm] add a simple tracker for legacy .we framework Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/73907486 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/73907486 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/73907486 Branch: refs/heads/master Commit: 7390748693617b558cbfcaecf8e3d5a63184a2e7 Parents: 1f63e1a Author: Hanks <zhanghan...@gmail.com> Authored: Thu Nov 9 20:47:32 2017 +0800 Committer: Hanks <zhanghan...@gmail.com> Committed: Thu Nov 9 20:47:32 2017 +0800 ---------------------------------------------------------------------- html5/runtime/api/init.js | 11 +++++++++++ html5/runtime/utils.js | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/73907486/html5/runtime/api/init.js ---------------------------------------------------------------------- diff --git a/html5/runtime/api/init.js b/html5/runtime/api/init.js index 0e35679..f61559c 100644 --- a/html5/runtime/api/init.js +++ b/html5/runtime/api/init.js @@ -22,6 +22,7 @@ import { receiveTasks } from '../bridge/receiver' import { registerModules } from './module' import { registerComponents } from './component' import { services, register, unregister } from './service' +import { createTracker } from '../utils' import WeexInstance from './WeexInstance' let frameworks @@ -99,6 +100,7 @@ function createInstance (id, code, config, data) { config.env = JSON.parse(JSON.stringify(global.WXEnvironment || {})) const weex = new WeexInstance(id, config) + const tracker = createTracker(weex) Object.freeze(weex) const runtimeEnv = { @@ -117,6 +119,15 @@ function createInstance (id, code, config, data) { if (!framework) { return new Error(`invalid bundle type "${bundleType}".`) } + if (bundleType === 'Weex') { + console.error(`[JS Framework] COMPATIBILITY WARNING: ` + + `Weex DSL 1.0 (.we) framework is no longer supported! ` + + `It will be removed in the next version of WeexSDK, ` + + `your page would be crash if you still using the ".we" framework. ` + + `Please upgrade it to Vue.js or Rax.`) + } + + tracker('bundleType', bundleType) // run create instance if (typeof framework.prepareInstanceContext === 'function') { http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/73907486/html5/runtime/utils.js ---------------------------------------------------------------------- diff --git a/html5/runtime/utils.js b/html5/runtime/utils.js index 9bb6917..9ba379f 100644 --- a/html5/runtime/utils.js +++ b/html5/runtime/utils.js @@ -52,3 +52,25 @@ export function base64ToBuffer (base64) { }) return array.buffer } + +export function createTracker (weex, options = {}) { + if (!weex || typeof weex.requireModule !== 'function') { + console.error(`[JS Framework] Failed to create tracker!`) + } + return function WeexJSFrameworkTracker (type, value) { + if (type && value) { + const label = `jsfm.${type}.${value}` + try { + const userTrack = weex.requireModule('userTrack') + if (userTrack && userTrack.addPerfPoint) { + const message = Object.create(null) + message[label] = '4' + userTrack.addPerfPoint(message) + } + } + catch (err) { + console.error(`[JS Framework] Failed to trace "${label}"!`) + } + } + } +}