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

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
WuQic committed Oct 8, 2018
0 parents commit 183f9c3
Show file tree
Hide file tree
Showing 52 changed files with 8,239 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"presets": [
"stage-0",
"es2015",
"env"
],
"plugins": [
[
"transform-es3-property-literals",
"transform-es3-member-expression-literals",
[
"transform-es2015-modules-commonjs",
{
"loose": true
}
],
"component",
[
{
"libraryName": "element-ui",
"styleLibraryName": "~./src/editor/theme/element-ui"
}
]
]
]
}
123 changes: 123 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"globals": {
"XDomainRequest": true,
"window": true,
"wx": true
},
"extends": "eslint:recommended",
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"ecmaFeatures": {
// lambda表达式
"arrowFunctions": true,
// 解构赋值
"destructuring": true,
// class
"classes": true,
// http://es6.ruanyifeng.com/#docs/function#函数参数的默认值
"defaultParams": true,
// 块级作用域,允许使用let const
"blockBindings": true,
// 允许使用模块,模块内默认严格模式
"modules": true,
// 允许字面量定义对象时,用表达式做属性名
// http://es6.ruanyifeng.com/#docs/object#属性名表达式
"objectLiteralComputedProperties": true,
// 允许对象字面量方法名简写
/*var o = {
method() {
return "Hello!";
}
};

等同于

var o = {
method: function() {
return "Hello!";
}
};
*/
"objectLiteralShorthandMethods": true,
/*
对象字面量属性名简写
var foo = 'bar';
var baz = {foo};
baz // {foo: "bar"}

// 等同于
var baz = {foo: foo};
*/
"objectLiteralShorthandProperties": true,
// http://es6.ruanyifeng.com/#docs/function#rest参数
"restParams": true,
// http://es6.ruanyifeng.com/#docs/function#扩展运算符
"spread": true,
// http://es6.ruanyifeng.com/#docs/iterator#for---of循环
"forOf": true,
// http://es6.ruanyifeng.com/#docs/generator
"generators": true,
// http://es6.ruanyifeng.com/#docs/string#模板字符串
"templateStrings": true,
"superInFunctions": true,
// http://es6.ruanyifeng.com/#docs/object#对象的扩展运算符
"experimentalObjectRestSpread": true,
"experimentalDecorators": true
},
"sourceType": "module"
},
"rules": {
"indent": [ 1, 2, {
"SwitchCase": 1
}
],
// 文件末尾强制换行
"eol-last": 1,
// 使用 === 替代 ==
"eqeqeq": [
1,
"allow-null"
],
// 控制逗号在行尾出现还是在行首出现
// http://eslint.org/docs/rules/comma-style
"comma-style": [
1,
"last"
],
"linebreak-style": [
1,
"unix"
],
"quotes": [
1,
"single"
],
"semi": [
1,
"never"
],
"no-extra-semi": 0,
"semi-spacing": 0,
"no-alert": 0,
"no-array-constructor": 1,
"no-caller": 1,
"no-catch-shadow": 0,
"no-cond-assign": 1,
"no-console": 0,
"no-constant-condition": 0,
"no-continue": 0,
"no-control-regex": 1,
"no-debugger": 1,
"no-delete-var": 1,
"no-mixed-spaces-and-tabs": 1,
"no-unused-vars": 1,
"comma-dangle": 1
}
}
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/node_modules/
/build/
/libs/
/lib/
!/lib/.gitkeep
/temp/
/private/
# Logs
*.log
.DS_Store
*.rdb

# config etc
.idea/
config.js
.vscode/
!src/config.js


npm-debug.log*
/package-lock.json
/yarn-error.log
/yarn.lock
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
10 changes: 10 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"node": true,

"curly": true,
"latedef": true,
"quotmark": true,
"undef": true,
"unused": true,
"trailing": true
}
25 changes: 25 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/tests/
/src/
/vender/
/vendor/
/build/
/temp/
/bin/
/private/
/.*
/*.sh

# === vscode ====
/.vscode/

/.babelrc

# === WebStorm ===
/.idea/
/testServer.js
/webpack.config.js
/yarn-error.log
/yarn.lock
/config.js
/sugoio-jslib-snippet.js
compile
120 changes: 120 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Sugo JavaScript Library
The Sugo JavaScript Library is a set of methods attached to a global `sugoio` object
intended to be used by websites wishing to send data to Sugo projects. A full reference
is available


```sh
npm install

npm run build
```

You can then require the lib like a standard Node.js module:

```javascript
var sugoio = require('sugo-sdk-js');

sugoio.init("YOUR_TOKEN");
sugoio.track("An event");
```

## Building bundles for release
- Install development dependencies: `npm install`
- Build: `npm run deploy`
- publish `npm publish`

## custom config
```
cp config.default.js config.js
//then edit config.js
```
## Running tests
- Install development dependencies: `npm install`
- Start test server: `npm test`
- Browse to [http://localhost:4000/tests/](http://localhost:4000/tests/) and choose a scenario to run

In the future we plan to automate the last step with a headless browser to streamline development (although
Sugo production releases are tested against a large matrix of browsers and operating systems).

```
sugoio.init('TOKEN(APPID)', {
 project_id: '项目ID',
loaded: function(lib) {
sugoio.time_event('页面停留时间')
sugoio._.register_event(window, 'beforeunload', function(){
sugoio.track('页面停留时间',{page: location.pathname})
}, false, true)
}
});
//给每条上报记录添加自定义维度
sugoio.register({CS1:'userid',CS2: 'xxxx'});
//手动埋点上报数据
sugoio.track("事件名称", {
properties //附带属性
})
```

## SDK上报维度
|维度名|维度标题|类型|iOS|Android|Web|维度描述|
|:---|:---|:---:|:---:|:---:|:---:|:---|
|__time | 服务端时间 | date |||| 服务端时间 |
|sugo_nation | 国家 | string |||| 用户所在国家(ip反解析) |
|sugo_province | 省份 | string |||| 用户所在省份(ip反解析) |
|sugo_city | 城市 | string |||| 用户所在城市(ip反解析) |
|sugo_district | 地区 | string |||| 用户所在地区(ip反解析) |
|sugo_area | 区域 | string |||| 用户所在区域(ip反解析) |
|sugo_latitude | 纬度 | string |||| 纬度(ip反解析) |
|sugo_longitude | 经度 | string |||| 经度(ip反解析) |
|sugo_city_timezone | 城市时区 | string |||| 所在时区代表城市(ip反解析) |
|sugo_timezone | 时区 | string |||| 所在时区(ip反解析) |
|sugo_phone_code | 国际区号 | string |||| 国际区号(ip反解析) |
|sugo_nation_code | 国家代码 | string |||| 国家代码(ip反解析) |
|sugo_continent | 所在大洲代码 | string |||| 所在大洲(ip反解析) |
|sugo_administrative | 行政区划代码 | string |||| 中国行政区划代码(ip反解析) |
|sugo_operator | 宽带运营商 | string |||| 用户所在运营商(ip反解析) |
|sugo_ip | 客户端IP | string |||| 客户端IP(nginx)Header的X-Real-IP,或者 remote_addr |
|browser | 浏览器名称 | string | x | x || 浏览器名称 |
|browser_version | 浏览器版本 | string | x | x || 浏览器版本 |
|app_name | 应用名称 | string ||| x | 系统或app的系统名称(应用安装后的名字) |
|app_version | 应用版本 | string ||| x | 系统或app的系统版本 |
|app_build_number | 应用编译版本 | string ||| x | 应用编译版本 |
|session_id | 会话ID | string |||| 会话id(app每次打开自动生成,web每次打开浏览器自动生成,如果不关闭浏览器,一天后自动生成新的session_id) |
|network | 网络类型 | string ||| x | 用户使用的网络类型(wifi,2g,3g,4g) |
|device_id | 设备ID | string ||| x | Android: IMEI > mac > android_id/iOS: IDFA > IDFV |
|bluetooth_version | 蓝牙版本 | string | x || x | 用户蓝牙版本 |
|has_bluetooth | 蓝牙功能 | string | x || x | 用户是否有蓝牙 |
|device_brand | 品牌 | string |||| 用户电脑、平板、或手机牌子 |
|device_model | 品牌型号 | string |||| 用户电脑、平板、或手机型号 |
|system_name | 操作系统名称 | string |||| 客户端操作系统名称(Android,iOS, Windows, macOS 等) |
|system_version | 操作系统版本 | string |||| 客户端操作系统版本 |
|radio | 通信协议 | string ||| x | 通信协议(gsm,cdma,sip等) |
|carrier | 手机运营商 | string ||| x | 运营商(中国移动,中国联通等) |
|screen_dpi | 屏幕DPI | int | x ||| 客户端分辨率每平方英寸的点数 |
|screen_pixel | 屏幕分辨率 | string |||| 客户端屏幕分辨率(格式:屏幕宽度*屏幕高度) |
|event_time | 客户端事件时间 | date |||| 客户端事件发生时间(unix毫秒数) |
|current_url | 当前请求地址 | string | x | x || 客户端当前请求地址 |
|referring_domain | 客户引荐域名 | string | x | x || 客户引荐域名(上一访问页面地址栏域名) |
|host | 客户端域名 | string | x | x || 浏览器地址栏域名 |
|distinct_id | 用户唯一ID | string |||| web首次访问生成用户唯一id并存在cookies,清除cookies算一个新的用户,app首次打开时候会生成一个用户唯一id,重装算另一个用户 |
|has_nfc | NFC功能 | string | x || x | 是否有NFC功能 |
|has_telephone | 电话功能 | string | x || x | 是否有电话功能 |
|has_wifi | WIFI功能 | string ||| x | 是否有wifi功能 |
|manufacturer | 设备制造商 | string ||| x | 设备制造商(meizu,huawei等) |
|duration | 停留时间 | float |||| 页面停留时间(停留事件才有) |
|sdk_version | SDK版本 | string |||| sdk版本 |
|page_name | 页面名称 | string |||| 页面名称或窗口名称,可在可视化埋点界面设置,默认取title |
|path_name | 页面路径 | string |||| 页面路径(web取域名之后的路径) |
|event_id | 事件ID | string |||| 事件ID,可视化埋点绑定的事件才上报 |
|event_name | 事件名称 | string |||| 事件名称 |
|event_type | 事件类型 | string |||| 事件类型click、focus、submit、change |
|event_label | 事件源文本 | string | x ||| 事件源文本(如按钮上的文字) |
|sugo_lib | sdk类型 | string |||| sdk类型: web/Objective-C/Swift/Android/Wx-mini |
|token | 应用ID | string |||| 应用ID |
|from_binding | 是否绑定事件 | string ||| x | 是否绑定事件(null或者true)(用于区分是绑定的,还是系统自动上报的,比如浏览、启动为自动上报,绑定取值1,自动上报取值0) |
|google_play_service | GooglePlay服务 | string | x || x | 是否有GooglePlay服务 |
|page_category | 页面分类 | string |||| 页面分类 |
|first_visit_time | 首次访问时间 | date |||| 首次访问时间(用户唯一ID的首次访问时间) |
|first_login_time | 首次登陆时间 | date |||| 首次登陆时间(业务ID的首次登录时间,需要把业务ID 传给sdk) |

Loading

0 comments on commit 183f9c3

Please sign in to comment.