forked from shen100/wemall
-
Notifications
You must be signed in to change notification settings - Fork 9
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
刘珅
committed
Apr 8, 2017
1 parent
4cc5d60
commit 39fc973
Showing
13 changed files
with
360 additions
and
7 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
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
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
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
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,3 +1,5 @@ | ||
import 'isomorphic-fetch'; | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
|
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,67 @@ | ||
import UAParser from 'ua-parser-js'; | ||
import storage from '../storage'; | ||
import uuid from './uuid'; | ||
|
||
let ua; | ||
|
||
function init() { | ||
ua = new UAParser().getResult(); | ||
|
||
let lang = navigator.language | ||
|| navigator.browserLanguage | ||
|| navigator.systemLanguage | ||
|| navigator.userLanguage | ||
|| ''; | ||
let country = ''; | ||
let language = ''; | ||
let index = lang.indexOf('-'); | ||
if (index > 0) { | ||
country = lang.substr(index + 1).toUpperCase(); | ||
language = lang.substr(0, index); | ||
} | ||
ua.country = country; | ||
ua.language = language; | ||
ua.device.screenWidth = window.screen.width; | ||
ua.device.screenHeight = window.screen.height; | ||
ua.device.model = ua.device.model || ''; | ||
} | ||
|
||
init(); | ||
|
||
export default { | ||
pv() { | ||
const LOCAL_DATA = 'analyzeLS'; | ||
const LOCAL_DATA_VERSION = 'v1.0'; | ||
|
||
var localData = storage.getItem(LOCAL_DATA); | ||
if (!localData || localData.version < LOCAL_DATA_VERSION) { | ||
localData = { | ||
clientId : uuid(), | ||
version : LOCAL_DATA_VERSION | ||
}; | ||
storage.setItem(LOCAL_DATA, localData); | ||
} | ||
|
||
let params = { | ||
clientId : localData.clientId, | ||
osName : ua.os.name, | ||
osVersion : ua.os.version, | ||
language : ua.language, | ||
country : ua.country, | ||
deviceModel : ua.device.model, | ||
deviceWidth : ua.device.screenWidth, | ||
deviceHeight : ua.device.screenHeight, | ||
referrer : encodeURIComponent(document.referrer), | ||
url : encodeURIComponent(location.href), | ||
browserName : ua.browser.name, | ||
browserVersion : ua.browser.version | ||
}; | ||
let paramArr = []; | ||
for (let key in params) { | ||
paramArr.push(key + '=' + params[key]); | ||
} | ||
let url = pageConfig.apiURL + '/visit?' + paramArr.join('&'); | ||
fetch(url) | ||
.then(response => response.json()) | ||
} | ||
}; |
Oops, something went wrong.