Skip to content

Commit 8844a25

Browse files
author
sanbo
committed
init version 4.3.0-alpha
1 parent 793aa27 commit 8844a25

File tree

94 files changed

+34564
-0
lines changed

Some content is hidden

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

94 files changed

+34564
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.eslintrc.json
2+
.babelrc
3+
package-lock.json
4+
node_modules/

AnalysysAgent_JS_SDK.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
# Argo JavaScript SDK
3+
4+
========
5+
6+
This is the official JavaScript SDK for Argo.
7+
8+
## Learn More
9+
10+
please visit [more](https://ark.analysys.cn/docs/sdk-js.html)
11+
12+
13+
## License
14+
15+
[gpl-3.0](https://www.gnu.org/licenses/gpl-3.0.txt)
16+

demo/index.html

Lines changed: 477 additions & 0 deletions
Large diffs are not rendered by default.

demo/javascript/console.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
console.oldLog = console.log
2+
console.log = a = function () {
3+
if (console.constructor === Object && console.log) {
4+
try {
5+
console.oldLog.apply(console, arguments);
6+
} catch (e) {
7+
console.oldLog(arguments[0]);
8+
}
9+
}
10+
// console.log(arguments)
11+
if(arguments[0]&&arguments[0].constructor === String&&arguments[0].indexOf("Send")>-1){
12+
try {
13+
document.getElementById("upLog").innerText = arguments[0]
14+
15+
} catch (e) {
16+
return
17+
}
18+
}
19+
}

demo/javascript/index.js

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/**
2+
* [pageView description] 页面事件
3+
* @param {[type]} pageName [description] 页面标识,支持类型:String;最大长度255字符
4+
* @param {[type]} pageInfo [description] 页面信息,支持类型:Object/Array;页面信息最多包含100条;Object类型内key以字母或$开头,包括大小写字母、数字、下划线和$,最大长度125字符,不支持乱码和中文;Object/Array中的value,支持类型:String;则最大长度255字符
5+
*/
6+
function pageView(pageName, pageInfo) {
7+
AnalysysAgent.pageView(pageName, pageInfo)
8+
}
9+
/**
10+
* [track description] 点击事件
11+
* @param {[type]} eventName [description] 事件名称。支持类型:String。以字母或$开头,可以包含大小写字母/数字/下划线,不支持中文,不支持乱码,最大长度99字符。
12+
* @param {[type]} eventInfo [description] 事件属性,支持类型:Object/Array;事件属性最多包含100条;Object类型内key以字母或$开头,包括大小写字母、数字、下划线和$,最大长度125字符,不支持乱码和中文;Object/Array中的value,支持类型:String;则最大长度255字符
13+
*/
14+
function track(eventName, eventInfo) {
15+
AnalysysAgent.track(eventName, eventInfo);
16+
}
17+
/**
18+
* [registerSuperProperty description] 注册通用属性
19+
* @param {[type]} uperPropertyName [description] 属性名称 支持类型:String。以字母或$开头,可以包含大小写字母/数字/下划线,不支持中文,不支持乱码,最大长度99字符。
20+
* @param {[type]} superPropertyValue [description] 事件属性,支持类型:String;则最大长度255字符
21+
*/
22+
function registerSuperProperty(superPropertyName, superPropertyValue) {
23+
AnalysysAgent.registerSuperProperty(superPropertyName, superPropertyValue);
24+
}
25+
26+
/**
27+
* [registerSuperProperties description] 注册通用属性
28+
* @param {[type]} superProperties [description] 属性集合 支持类型:Object。key以字母或$开头,可以包含大小写字母/数字/下划线,不支持中文,不支持乱码,最大长度99字符,value支持类型:String;则最大长度255字符。
29+
*/
30+
function registerSuperProperties(superProperties) {
31+
AnalysysAgent.registerSuperProperties(superProperties);
32+
}
33+
/**
34+
* [unregisterSuperProperty description] 删除单个通用属性
35+
* @param {[type]} superPropertyName [description] 属性名称 支持类型:String。以字母或$开头,可以包含大小写字母/数字/下划线,不支持中文,不支持乱码,最大长度99字符。
36+
*/
37+
function unRegisterSuperProperty(superPropertyName) {
38+
AnalysysAgent.unRegisterSuperProperty(superPropertyName);
39+
}
40+
/**
41+
* [clearSuperProperties description] 清除所有通用属性
42+
*/
43+
function clearSuperProperties() {
44+
AnalysysAgent.clearSuperProperties();
45+
}
46+
/**
47+
* [clearSuperProperties description] 获取单个通用属性
48+
*/
49+
function getSuperProperty(superPropertyName) {
50+
AnalysysAgent.getSuperProperty(superPropertyName);
51+
}
52+
/**
53+
* [clearSuperProperties description] 获取所有通用属性
54+
*/
55+
function getSuperProperties() {
56+
AnalysysAgent.getSuperProperties();
57+
}
58+
/**
59+
* [identify description] 用户ID设置
60+
* @param {[type]} distinctId [description] 唯一身份标识,支持类型:String;长度大于0且小于255字符
61+
*/
62+
function identify(distinctId) {
63+
AnalysysAgent.identify(distinctId);
64+
}
65+
/**
66+
* [alias description]用户关联 新distinctID关联到原有originalID,originalID为原始id.
67+
* @param {[type]} aliasId [description] 支持类型:String;长度大于0,且小于255字符
68+
* @param {[type]} originalId [description] 可以是现在使用也可以是历史使用的id,不局限于本地正使用的distinctId,若为空则使用本地的distinctId,支持类型:String;长度大于0且小于255字符
69+
*/
70+
function alias(aliasId, originalId) {
71+
AnalysysAgent.alias(aliasId, originalId);
72+
}
73+
/**
74+
* [profileSet description] 设置用户属性
75+
* @param {[type]} propertyName [description] 支持类型:String;以字母或`$`开头,可包含大小写字母/数字/`_`/`$`,最大长度125字符,不支持乱码和中文
76+
* @param {[type]} propertyValue [description]支持类型:String/Number/Boolean/Object/Array;若为字符串,则最大长度255字符;若为数组或集合,则最多包含100条,且key约束条件与属性名称一致,value最大长度255字符
77+
*/
78+
function profileSet(propertyName, propertyValue) {
79+
AnalysysAgent.profileSet(propertyName, propertyValue);
80+
}
81+
/**
82+
* [profileSetOnce description] 在首次设置时有效的属性
83+
* @param {[type]} propertyName [description] 支持类型:String;以字母或`$`开头,可包含大小写字母/数字/`_`/`$`,最大长度125字符,不支持乱码和中文
84+
* @param {[type]} propertyValue [description] 支持类型:String/Number/Boolean/Object/Array;若为字符串,则最大长度255字符;若为数组或集合,则最多包含100条,且key约束条件与属性名称一致,value最大长度255字符
85+
*/
86+
function profileSetOnce(propertyName, propertyValue) {
87+
AnalysysAgent.profileSetOnce(propertyName, propertyValue);
88+
}
89+
/**
90+
* [profileIncrement description] 设置用户属性相对变化值
91+
* @param {[type]} propertyName [description] 属性名称 支持类型:String;以字母或`$`开头,可包含大小写字母/数字/`_`/`$`,最大长度125字符,不支持乱码和中文
92+
* @param {[type]} propertyValue [description] 属性值 支持类型:String/Number/Boolean/Object/Array;若为字符串,则最大长度255字符;若为数组或集合,则最多包含100条,且key约束条件与属性名称一致,value最大长度255字符
93+
*/
94+
function profileIncrement(propertyName, propertyValue) {
95+
AnalysysAgent.profileIncrement(propertyName, propertyValue)
96+
}
97+
/**
98+
* [profileAppend description]设置单个列表类型的属性
99+
* @param {[type]} propertyName [description] 属性名称 支持类型:String;以字母或`$`开头,可包含大小写字母/数字/`_`/`$`,最大长度125字符,不支持乱码和中文
100+
* @param {[type]} propertyValue [description] 属性值 支持类型:String/Number/Boolean;最大长度255字符;
101+
*/
102+
function profileAppend(propertyName, propertyValue) {
103+
AnalysysAgent.profileAppend(propertyName, propertyValue);
104+
}
105+
/**
106+
* [profileUnset description] 删除设置的属性
107+
* @param {[type]} property [description] 属性名称 支持类型:String;以字母或`$`开头,可包含大小写字母/数字/`_`/`$`,最大长度125字符,不支持乱码和中文
108+
*/
109+
function profileUnset(property) {
110+
AnalysysAgent.profileUnset(property);
111+
}
112+
/**
113+
* [profileDelete description] 要清除已经设置的所有属性
114+
*/
115+
function profileDelete() {
116+
AnalysysAgent.profileDelete();
117+
}
118+
/**
119+
* [reset description] 清除本地设置
120+
*/
121+
function reset() {
122+
AnalysysAgent.reset();
123+
}
124+
125+
/**
126+
* [historyPage description] 修改history记录跳转页面
127+
* @param {[type]} page [description] 跳转页面地址
128+
* @return {[type]} [description]
129+
*/
130+
function historyPage(page) {
131+
document.title = 'historyPage' //跳转后的页面title
132+
history.pushState(null, null, page)
133+
}
134+
/**
135+
* [historyPage description] 修改hash值跳转页面
136+
* @param {[type]} page [description] 跳转页面地址
137+
* @return {[type]} [description]
138+
*/
139+
function hashPage(page) {
140+
document.title = 'hashPage'
141+
location.href = page
142+
}
143+
144+
function arrayTrack() {
145+
var productList = [{
146+
"OrderId": "123456",
147+
"ProductName": "Iphone 6s plus",
148+
"ProductTotalPrice": "10000"
149+
},
150+
{
151+
"OrderId": "123456",
152+
"ProductName": "Iphone 7s plus",
153+
"ProductTotalPrice": "20000"
154+
}
155+
]
156+
var ShopName = "天猫旗舰店"
157+
for(var i=0;i<productList.length;i++){
158+
productList[i]["ShopName"]=ShopName
159+
AnalysysAgent.track("buy",productList[i])
160+
}
161+
}

demo/javascript/initSdk.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
function checkURL(URL) {
2+
var str = URL;
3+
//判断URL地址的正则表达式为:http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
4+
//下面的代码中应用了转义字符"\"输出一个字符"/"
5+
var Expression = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
6+
var objExp = new RegExp(Expression);
7+
if (objExp.test(str) == true) {
8+
return true;
9+
} else {
10+
return false;
11+
}
12+
}
13+
function getQueryString(name) {
14+
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
15+
var r = window.location.search.substr(1).match(reg);
16+
if (r != null) return unescape(r[2]);
17+
return null;
18+
}
19+
var appkey = getQueryString("appkey");
20+
if (!appkey) {
21+
appkey = "commondebug"
22+
}
23+
var uploadURL = getQueryString("uploadURL");
24+
if (!uploadURL||!checkURL(uploadURL)) {
25+
uploadURL = 'https://sdk.analysys.cn:4089/'
26+
}
27+
(function(config) {
28+
window.AnalysysAgent = window.AnalysysAgent || []
29+
window.AnalysysAgent.methods = 'identify alias reset track profileSet profileSetOnce profileIncrement profileAppend profileUnset profileDelete registerSuperProperty registerSuperProperties unRegisterSuperProperty clearSuperProperties getSuperProperty getSuperProperties pageView debugMode auto appkey name uploadURL hash visitorConfigURL autoProfile autoWebstay encryptType pageProperty'.split(' ');
30+
31+
function factory(b) {
32+
return function() {
33+
var a = Array.prototype.slice.call(arguments);
34+
a.unshift(b);
35+
window.AnalysysAgent.push(a);
36+
return window.AnalysysAgent;
37+
}
38+
};
39+
for (var i = 0; i < AnalysysAgent.methods.length; i++) {
40+
var key = window.AnalysysAgent.methods[i];
41+
AnalysysAgent[key] = factory(key);
42+
}
43+
for (var key in config) {
44+
AnalysysAgent[key](config[key])
45+
}
46+
})({
47+
appkey: appkey, //APPKEY
48+
debugMode:2,
49+
uploadURL: uploadURL,
50+
visitorConfigURL: uploadURL,
51+
})

0 commit comments

Comments
 (0)