Comparing version 1.0.5 to 1.0.6
120
m.js
@@ -7,5 +7,4 @@ let initFlag = false; // 初始化完成标记 | ||
let mustKeys = ['seedId', 'actionId']; // remoteLog 必传参数 | ||
let _extParams = {} | ||
let _extParams = {}; | ||
/** | ||
@@ -25,4 +24,4 @@ * track('clickseedname', { bizType: 'Pay', ext: { productId: 'xxx' } }) | ||
param3: 'string', | ||
param4: 'string', | ||
} | ||
param4: 'string' | ||
}; | ||
@@ -32,4 +31,4 @@ function logParamsCheck(options) { | ||
if (!options[mustKeys[i]]) { | ||
console.warn(`[mas] ${mustKeys[i]}不能为空`) | ||
return true | ||
console.warn(`[mas] ${mustKeys[i]}不能为空`); | ||
return true; | ||
} | ||
@@ -53,12 +52,12 @@ } | ||
ext: {} | ||
} | ||
Object.keys(eventData).forEach(key => { | ||
}; | ||
Object.keys(eventData).forEach((key) => { | ||
if (paramsType[key]) { | ||
_evtData[key] = eventData[key] | ||
_evtData[key] = eventData[key]; | ||
} else { | ||
_evtData.ext[key] = eventData[key] | ||
_evtData.ext[key] = eventData[key]; | ||
} | ||
}) | ||
}); | ||
sendLog(eventId, _evtData) | ||
sendLog(eventId, _evtData); | ||
} | ||
@@ -68,22 +67,22 @@ | ||
* sendLog('payclick', { actionId: 'click', bizType: 'alipay', ext: {a: 1, b: 2} }) | ||
* @param {*} eventId | ||
* @param {*} eventData | ||
* @returns | ||
* @param {*} eventId | ||
* @param {*} eventData | ||
* @returns | ||
*/ | ||
function sendLog(eventId, eventData = {}) { | ||
if (!eventId) { | ||
console.warn(`[mas] eventId 不能为空`) | ||
return | ||
console.warn(`[mas] eventId 不能为空`); | ||
return; | ||
} | ||
var { ext = {}, actionId, bizType } = options; | ||
if (!actionId) { | ||
console.warn(`[mas] actionId 不能为空`) | ||
console.warn(`[mas] actionId 不能为空`); | ||
// return | ||
} | ||
let options = {} | ||
Object.keys(eventData).forEach(key => { | ||
let options = {}; | ||
Object.keys(eventData).forEach((key) => { | ||
if (paramsType[key] && paramsType[key] === typeof eventData[key]) { | ||
options[key] = eventData[key] | ||
options[key] = eventData[key]; | ||
} | ||
}) | ||
}); | ||
_remoteLog({ | ||
@@ -94,15 +93,15 @@ ...options, | ||
bizType, | ||
param4: _formatExtParams(Object.assign(_extParams, ext)), | ||
}) | ||
param4: _formatExtParams(Object.assign(_extParams, ext)) | ||
}); | ||
} | ||
function _remoteLog(options) { | ||
let apiObj = options | ||
let apiObj = options; | ||
// Object.assign(apiObj, options); | ||
if (mtrDebug) { | ||
console.log(logTag, "remoteLog", apiObj) | ||
console.log(logTag, 'remoteLog', apiObj); | ||
} | ||
// #ifdef H5 | ||
jsBridgeReady(function() { | ||
jsBridgeReady(function () { | ||
AlipayJSBridge.call('remoteLog', apiObj); | ||
@@ -112,3 +111,3 @@ }); | ||
// #ifdef MP-ALIPAY | ||
my.call("remoteLog", apiObj); | ||
my.call('remoteLog', apiObj); | ||
// #endif | ||
@@ -119,36 +118,31 @@ } | ||
let n = []; | ||
bizScenario && | ||
n.push( | ||
"mBizScenario=".concat(encodeStr(bizScenario)) | ||
); | ||
bizScenario && n.push('mBizScenario='.concat(encodeStr(bizScenario))); | ||
// #ifdef MP-ALIPAY | ||
n.push( | ||
"id=".concat(encodeStr(id)) | ||
); | ||
n.push('id='.concat(encodeStr(id))); | ||
// #endif | ||
Object.keys(t).forEach(function (e) { | ||
n.push("".concat(e, "=").concat(encodeStr(t[e]))); | ||
n.push(''.concat(e, '=').concat(encodeStr(t[e]))); | ||
}); | ||
return n.join(',') | ||
return n.join(','); | ||
} | ||
function encodeStr(e) { | ||
return "string" == typeof e | ||
? e.replace(/=|,|\^|\$\$/g, function (e) { | ||
switch (e) { | ||
case ",": | ||
return "%2C"; | ||
case "^": | ||
return "%5E"; | ||
case "$$": | ||
return "%24%24"; | ||
case "=": | ||
return "%3D"; | ||
case "&&": | ||
return "%26%26"; | ||
default: | ||
return " "; | ||
} | ||
}) | ||
: e; | ||
return 'string' == typeof e | ||
? e.replace(/=|,|\^|\$\$/g, function (e) { | ||
switch (e) { | ||
case ',': | ||
return '%2C'; | ||
case '^': | ||
return '%5E'; | ||
case '$$': | ||
return '%24%24'; | ||
case '=': | ||
return '%3D'; | ||
case '&&': | ||
return '%26%26'; | ||
default: | ||
return ' '; | ||
} | ||
}) | ||
: e; | ||
} | ||
@@ -159,3 +153,3 @@ | ||
if (!initFlag) { | ||
console.warn("[mas] 请先执行埋点初始化方法init"); | ||
console.warn('[mas] 请先执行埋点初始化方法init'); | ||
return; | ||
@@ -165,7 +159,7 @@ } | ||
sendLog(eventId, options); | ||
} | ||
}; | ||
}, | ||
init(conf = {}) { | ||
// conf: mtrDebug, bizScenario, id | ||
if(typeof conf.mtrDebug === "boolean") mtrDebug = conf.mtrDebug; | ||
if (typeof conf.mtrDebug === 'boolean') mtrDebug = conf.mtrDebug; | ||
// #ifdef MP-ALIPAY | ||
@@ -177,3 +171,3 @@ if (conf.id) { | ||
console.warn('[mas] 小程序id不能为空'); | ||
return | ||
return; | ||
} | ||
@@ -184,11 +178,11 @@ } | ||
if (typeof conf.extendParams === 'object') { | ||
_extParams = conf.extendParams | ||
_extParams = conf.extendParams; | ||
} else { | ||
console.warn("[mas] extendParams 格式错误")); | ||
console.warn('[mas] extendParams 格式错误'); | ||
} | ||
} | ||
bizScenario = conf.bizScenario; | ||
initFlag = true; | ||
} | ||
} | ||
}; |
{ | ||
"name": "a-tracker", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/joenix/a-tracker.git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26181
359