Skip to content
This repository was archived by the owner on Dec 13, 2019. It is now read-only.

Commit 183f9c3

Browse files
committed
init
0 parents  commit 183f9c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+8239
-0
lines changed

.babelrc

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"presets": [
3+
"stage-0",
4+
"es2015",
5+
"env"
6+
],
7+
"plugins": [
8+
[
9+
"transform-es3-property-literals",
10+
"transform-es3-member-expression-literals",
11+
[
12+
"transform-es2015-modules-commonjs",
13+
{
14+
"loose": true
15+
}
16+
],
17+
"component",
18+
[
19+
{
20+
"libraryName": "element-ui",
21+
"styleLibraryName": "~./src/editor/theme/element-ui"
22+
}
23+
]
24+
]
25+
]
26+
}

.eslintrc

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es6": true,
6+
"node": true
7+
},
8+
"globals": {
9+
"XDomainRequest": true,
10+
"window": true,
11+
"wx": true
12+
},
13+
"extends": "eslint:recommended",
14+
"parser": "babel-eslint",
15+
"parserOptions": {
16+
"ecmaVersion": 7,
17+
"ecmaFeatures": {
18+
// lambda表达式
19+
"arrowFunctions": true,
20+
// 解构赋值
21+
"destructuring": true,
22+
// class
23+
"classes": true,
24+
// http://es6.ruanyifeng.com/#docs/function#函数参数的默认值
25+
"defaultParams": true,
26+
// 块级作用域,允许使用let const
27+
"blockBindings": true,
28+
// 允许使用模块,模块内默认严格模式
29+
"modules": true,
30+
// 允许字面量定义对象时,用表达式做属性名
31+
// http://es6.ruanyifeng.com/#docs/object#属性名表达式
32+
"objectLiteralComputedProperties": true,
33+
// 允许对象字面量方法名简写
34+
/*var o = {
35+
method() {
36+
return "Hello!";
37+
}
38+
};
39+
40+
等同于
41+
42+
var o = {
43+
method: function() {
44+
return "Hello!";
45+
}
46+
};
47+
*/
48+
"objectLiteralShorthandMethods": true,
49+
/*
50+
对象字面量属性名简写
51+
var foo = 'bar';
52+
var baz = {foo};
53+
baz // {foo: "bar"}
54+
55+
// 等同于
56+
var baz = {foo: foo};
57+
*/
58+
"objectLiteralShorthandProperties": true,
59+
// http://es6.ruanyifeng.com/#docs/function#rest参数
60+
"restParams": true,
61+
// http://es6.ruanyifeng.com/#docs/function#扩展运算符
62+
"spread": true,
63+
// http://es6.ruanyifeng.com/#docs/iterator#for---of循环
64+
"forOf": true,
65+
// http://es6.ruanyifeng.com/#docs/generator
66+
"generators": true,
67+
// http://es6.ruanyifeng.com/#docs/string#模板字符串
68+
"templateStrings": true,
69+
"superInFunctions": true,
70+
// http://es6.ruanyifeng.com/#docs/object#对象的扩展运算符
71+
"experimentalObjectRestSpread": true,
72+
"experimentalDecorators": true
73+
},
74+
"sourceType": "module"
75+
},
76+
"rules": {
77+
"indent": [ 1, 2, {
78+
"SwitchCase": 1
79+
}
80+
],
81+
// 文件末尾强制换行
82+
"eol-last": 1,
83+
// 使用 === 替代 ==
84+
"eqeqeq": [
85+
1,
86+
"allow-null"
87+
],
88+
// 控制逗号在行尾出现还是在行首出现
89+
// http://eslint.org/docs/rules/comma-style
90+
"comma-style": [
91+
1,
92+
"last"
93+
],
94+
"linebreak-style": [
95+
1,
96+
"unix"
97+
],
98+
"quotes": [
99+
1,
100+
"single"
101+
],
102+
"semi": [
103+
1,
104+
"never"
105+
],
106+
"no-extra-semi": 0,
107+
"semi-spacing": 0,
108+
"no-alert": 0,
109+
"no-array-constructor": 1,
110+
"no-caller": 1,
111+
"no-catch-shadow": 0,
112+
"no-cond-assign": 1,
113+
"no-console": 0,
114+
"no-constant-condition": 0,
115+
"no-continue": 0,
116+
"no-control-regex": 1,
117+
"no-debugger": 1,
118+
"no-delete-var": 1,
119+
"no-mixed-spaces-and-tabs": 1,
120+
"no-unused-vars": 1,
121+
"comma-dangle": 1
122+
}
123+
}

.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/node_modules/
2+
/build/
3+
/libs/
4+
/lib/
5+
!/lib/.gitkeep
6+
/temp/
7+
/private/
8+
# Logs
9+
*.log
10+
.DS_Store
11+
*.rdb
12+
13+
# config etc
14+
.idea/
15+
config.js
16+
.vscode/
17+
!src/config.js
18+
19+
20+
npm-debug.log*
21+
/package-lock.json
22+
/yarn-error.log
23+
/yarn.lock

.jshintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.jshintrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"node": true,
3+
4+
"curly": true,
5+
"latedef": true,
6+
"quotmark": true,
7+
"undef": true,
8+
"unused": true,
9+
"trailing": true
10+
}

.npmignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/tests/
2+
/src/
3+
/vender/
4+
/vendor/
5+
/build/
6+
/temp/
7+
/bin/
8+
/private/
9+
/.*
10+
/*.sh
11+
12+
# === vscode ====
13+
/.vscode/
14+
15+
/.babelrc
16+
17+
# === WebStorm ===
18+
/.idea/
19+
/testServer.js
20+
/webpack.config.js
21+
/yarn-error.log
22+
/yarn.lock
23+
/config.js
24+
/sugoio-jslib-snippet.js
25+
compile

README.md

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Sugo JavaScript Library
2+
The Sugo JavaScript Library is a set of methods attached to a global `sugoio` object
3+
intended to be used by websites wishing to send data to Sugo projects. A full reference
4+
is available
5+
6+
7+
```sh
8+
npm install
9+
10+
npm run build
11+
```
12+
13+
You can then require the lib like a standard Node.js module:
14+
15+
```javascript
16+
var sugoio = require('sugo-sdk-js');
17+
18+
sugoio.init("YOUR_TOKEN");
19+
sugoio.track("An event");
20+
```
21+
22+
## Building bundles for release
23+
- Install development dependencies: `npm install`
24+
- Build: `npm run deploy`
25+
- publish `npm publish`
26+
27+
## custom config
28+
```
29+
cp config.default.js config.js
30+
//then edit config.js
31+
```
32+
## Running tests
33+
- Install development dependencies: `npm install`
34+
- Start test server: `npm test`
35+
- Browse to [http://localhost:4000/tests/](http://localhost:4000/tests/) and choose a scenario to run
36+
37+
In the future we plan to automate the last step with a headless browser to streamline development (although
38+
Sugo production releases are tested against a large matrix of browsers and operating systems).
39+
40+
```
41+
sugoio.init('TOKEN(APPID)', {
42+
 project_id: '项目ID',
43+
loaded: function(lib) {
44+
sugoio.time_event('页面停留时间')
45+
sugoio._.register_event(window, 'beforeunload', function(){
46+
sugoio.track('页面停留时间',{page: location.pathname})
47+
}, false, true)
48+
}
49+
});
50+
//给每条上报记录添加自定义维度
51+
sugoio.register({CS1:'userid',CS2: 'xxxx'});
52+
53+
//手动埋点上报数据
54+
sugoio.track("事件名称", {
55+
properties //附带属性
56+
})
57+
```
58+
59+
## SDK上报维度
60+
|维度名|维度标题|类型|iOS|Android|Web|维度描述|
61+
|:---|:---|:---:|:---:|:---:|:---:|:---|
62+
|__time | 服务端时间 | date |||| 服务端时间 |
63+
|sugo_nation | 国家 | string |||| 用户所在国家(ip反解析) |
64+
|sugo_province | 省份 | string |||| 用户所在省份(ip反解析) |
65+
|sugo_city | 城市 | string |||| 用户所在城市(ip反解析) |
66+
|sugo_district | 地区 | string |||| 用户所在地区(ip反解析) |
67+
|sugo_area | 区域 | string |||| 用户所在区域(ip反解析) |
68+
|sugo_latitude | 纬度 | string |||| 纬度(ip反解析) |
69+
|sugo_longitude | 经度 | string |||| 经度(ip反解析) |
70+
|sugo_city_timezone | 城市时区 | string |||| 所在时区代表城市(ip反解析) |
71+
|sugo_timezone | 时区 | string |||| 所在时区(ip反解析) |
72+
|sugo_phone_code | 国际区号 | string |||| 国际区号(ip反解析) |
73+
|sugo_nation_code | 国家代码 | string |||| 国家代码(ip反解析) |
74+
|sugo_continent | 所在大洲代码 | string |||| 所在大洲(ip反解析) |
75+
|sugo_administrative | 行政区划代码 | string |||| 中国行政区划代码(ip反解析) |
76+
|sugo_operator | 宽带运营商 | string |||| 用户所在运营商(ip反解析) |
77+
|sugo_ip | 客户端IP | string |||| 客户端IP(nginx)Header的X-Real-IP,或者 remote_addr |
78+
|browser | 浏览器名称 | string | x | x || 浏览器名称 |
79+
|browser_version | 浏览器版本 | string | x | x || 浏览器版本 |
80+
|app_name | 应用名称 | string ||| x | 系统或app的系统名称(应用安装后的名字) |
81+
|app_version | 应用版本 | string ||| x | 系统或app的系统版本 |
82+
|app_build_number | 应用编译版本 | string ||| x | 应用编译版本 |
83+
|session_id | 会话ID | string |||| 会话id(app每次打开自动生成,web每次打开浏览器自动生成,如果不关闭浏览器,一天后自动生成新的session_id) |
84+
|network | 网络类型 | string ||| x | 用户使用的网络类型(wifi,2g,3g,4g) |
85+
|device_id | 设备ID | string ||| x | Android: IMEI > mac > android_id/iOS: IDFA > IDFV |
86+
|bluetooth_version | 蓝牙版本 | string | x || x | 用户蓝牙版本 |
87+
|has_bluetooth | 蓝牙功能 | string | x || x | 用户是否有蓝牙 |
88+
|device_brand | 品牌 | string |||| 用户电脑、平板、或手机牌子 |
89+
|device_model | 品牌型号 | string |||| 用户电脑、平板、或手机型号 |
90+
|system_name | 操作系统名称 | string |||| 客户端操作系统名称(Android,iOS, Windows, macOS 等) |
91+
|system_version | 操作系统版本 | string |||| 客户端操作系统版本 |
92+
|radio | 通信协议 | string ||| x | 通信协议(gsm,cdma,sip等) |
93+
|carrier | 手机运营商 | string ||| x | 运营商(中国移动,中国联通等) |
94+
|screen_dpi | 屏幕DPI | int | x ||| 客户端分辨率每平方英寸的点数 |
95+
|screen_pixel | 屏幕分辨率 | string |||| 客户端屏幕分辨率(格式:屏幕宽度*屏幕高度) |
96+
|event_time | 客户端事件时间 | date |||| 客户端事件发生时间(unix毫秒数) |
97+
|current_url | 当前请求地址 | string | x | x || 客户端当前请求地址 |
98+
|referring_domain | 客户引荐域名 | string | x | x || 客户引荐域名(上一访问页面地址栏域名) |
99+
|host | 客户端域名 | string | x | x || 浏览器地址栏域名 |
100+
|distinct_id | 用户唯一ID | string |||| web首次访问生成用户唯一id并存在cookies,清除cookies算一个新的用户,app首次打开时候会生成一个用户唯一id,重装算另一个用户 |
101+
|has_nfc | NFC功能 | string | x || x | 是否有NFC功能 |
102+
|has_telephone | 电话功能 | string | x || x | 是否有电话功能 |
103+
|has_wifi | WIFI功能 | string ||| x | 是否有wifi功能 |
104+
|manufacturer | 设备制造商 | string ||| x | 设备制造商(meizu,huawei等) |
105+
|duration | 停留时间 | float |||| 页面停留时间(停留事件才有) |
106+
|sdk_version | SDK版本 | string |||| sdk版本 |
107+
|page_name | 页面名称 | string |||| 页面名称或窗口名称,可在可视化埋点界面设置,默认取title |
108+
|path_name | 页面路径 | string |||| 页面路径(web取域名之后的路径) |
109+
|event_id | 事件ID | string |||| 事件ID,可视化埋点绑定的事件才上报 |
110+
|event_name | 事件名称 | string |||| 事件名称 |
111+
|event_type | 事件类型 | string |||| 事件类型click、focus、submit、change |
112+
|event_label | 事件源文本 | string | x ||| 事件源文本(如按钮上的文字) |
113+
|sugo_lib | sdk类型 | string |||| sdk类型: web/Objective-C/Swift/Android/Wx-mini |
114+
|token | 应用ID | string |||| 应用ID |
115+
|from_binding | 是否绑定事件 | string ||| x | 是否绑定事件(null或者true)(用于区分是绑定的,还是系统自动上报的,比如浏览、启动为自动上报,绑定取值1,自动上报取值0) |
116+
|google_play_service | GooglePlay服务 | string | x || x | 是否有GooglePlay服务 |
117+
|page_category | 页面分类 | string |||| 页面分类 |
118+
|first_visit_time | 首次访问时间 | date |||| 首次访问时间(用户唯一ID的首次访问时间) |
119+
|first_login_time | 首次登陆时间 | date |||| 首次登陆时间(业务ID的首次登录时间,需要把业务ID 传给sdk) |
120+

0 commit comments

Comments
 (0)