|
@@ -7,7 +7,22 @@ import { logType } from './logEnum.js';
|
|
* @extParams 最终上报到阿里云以json字符串存储的参数,如果extparams传入的不是obj会转换成obj
|
|
* @extParams 最终上报到阿里云以json字符串存储的参数,如果extparams传入的不是obj会转换成obj
|
|
*/
|
|
*/
|
|
export function reportLog(eventData = {}, extParams = {}) {
|
|
export function reportLog(eventData = {}, extParams = {}) {
|
|
- paramsPretreatmentAndRequest(logType.denet, eventData, extParams)
|
|
|
|
|
|
+ if (chrome && chrome.tabs) {
|
|
|
|
+ chrome.tabs.getCurrent((tab) => {
|
|
|
|
+ let isMobile = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
|
|
|
|
+ let { url = '' } = tab;
|
|
|
|
+ let platform = isMobile ? `mobile` : `pc`;
|
|
|
|
+ let extData = {
|
|
|
|
+ url,
|
|
|
|
+ platform,
|
|
|
|
+ browser: window.navigator.appName,
|
|
|
|
+ ...extParams,
|
|
|
|
+ }
|
|
|
|
+ paramsPretreatmentAndRequest(logType.denet, eventData, extData)
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ paramsPretreatmentAndRequest(logType.denet, eventData, extParams)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
function paramsPretreatmentAndRequest(logType, eventData, extParams) {
|
|
function paramsPretreatmentAndRequest(logType, eventData, extParams) {
|