drgame-cc 1.0.61 → 1.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/drres/focus/focus_1/gesture.atlas +34 -34
- package/drres/focus/focus_2/gesture.atlas +41 -41
- package/drres/focus/focus_3/gesture.atlas +34 -34
- package/drres/focus/focus_4/gesture.atlas +20 -20
- package/drres/prefab/HelperWin.prefab +508 -508
- package/drscript/PlatformAdapter.ts +1 -1
- package/drscript/ad-sdk/README.md +78 -12
- package/drscript/ad-sdk/ad-sdk.ts +416 -0
- package/drscript/ad-sdk/{adapters/xiaomi-adapter.js.meta → ad-sdk.ts.meta} +2 -2
- package/drscript/ad-sdk/event-emitter.ts +66 -0
- package/drscript/ad-sdk/event-emitter.ts.meta +10 -0
- package/drscript/ad-sdk/leaderboard/leaderboard.ts +219 -0
- package/drscript/ad-sdk/leaderboard/leaderboard.ts.meta +10 -0
- package/drscript/ad-sdk/package.json +18 -17
- package/drscript/ad-sdk/reporters/reporter.ts +515 -0
- package/drscript/ad-sdk/reporters/reporter.ts.meta +10 -0
- package/drscript/ad-sdk/reporters/superset-lewo.ts +464 -0
- package/drscript/ad-sdk/reporters/superset-lewo.ts.meta +10 -0
- package/drscript/ad-sdk/types/enums.ts +103 -0
- package/drscript/ad-sdk/types/enums.ts.meta +10 -0
- package/drscript/ad-sdk/types/{index.d.ts → index.ts} +1 -1
- package/drscript/ad-sdk/types/index.ts.meta +10 -0
- package/drscript/ad-sdk/types/{interfaces.d.ts → interfaces.ts} +61 -10
- package/drscript/ad-sdk/types/interfaces.ts.meta +10 -0
- package/drscript/ad-sdk/user-gamedata/user-gamedata.ts +219 -0
- package/drscript/ad-sdk/user-gamedata/user-gamedata.ts.meta +10 -0
- package/drscript/ad-sdk/user-gamedata.meta +13 -0
- package/package.json +1 -1
- package/drscript/ad-sdk/ad-sdk.d.ts +0 -59
- package/drscript/ad-sdk/ad-sdk.js +0 -338
- package/drscript/ad-sdk/adapters/xiaomi-adapter.d.ts +0 -29
- package/drscript/ad-sdk/adapters/xiaomi-adapter.d.ts.meta +0 -6
- package/drscript/ad-sdk/adapters/xiaomi-adapter.js +0 -452
- package/drscript/ad-sdk/event-emitter.d.ts +0 -12
- package/drscript/ad-sdk/event-emitter.js +0 -65
- package/drscript/ad-sdk/leaderboard/leaderboard.d.ts +0 -23
- package/drscript/ad-sdk/leaderboard/leaderboard.js +0 -193
- package/drscript/ad-sdk/reporters/reporter.d.ts +0 -85
- package/drscript/ad-sdk/reporters/reporter.js +0 -500
- package/drscript/ad-sdk/reporters/superset-lewo.js +0 -574
- package/drscript/ad-sdk/types/enums.d.ts +0 -66
- package/drscript/ad-sdk/types/enums.js +0 -113
- package/drscript/ad-sdk/types/index.js +0 -15
|
@@ -1,574 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
if (typeof globalThis === 'undefined') {
|
|
3
|
-
if (typeof self !== 'undefined') self.globalThis = self;
|
|
4
|
-
else if (typeof window !== 'undefined') window.globalThis = window;
|
|
5
|
-
else if (typeof global !== 'undefined') global.globalThis = global;
|
|
6
|
-
}
|
|
7
|
-
var supersetLewo = (function () {
|
|
8
|
-
// ========== 私有常量与缓存(闭包私有,外部不可访问) ==========
|
|
9
|
-
// 设备ID本地存储Key:localStorage + cookie共用
|
|
10
|
-
var STORAGE_KEY = 'analytics.device_id.uuid_v4';
|
|
11
|
-
// 内存缓存设备UUID,避免重复读取存储
|
|
12
|
-
var memoryCache = null;
|
|
13
|
-
// 全局缓存用户/设备公共信息,上报顶层user字段统一复用
|
|
14
|
-
var globalUserInfo = {};
|
|
15
|
-
|
|
16
|
-
var initInfoFlag = false;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 生成标准 UUID v4 设备唯一标识
|
|
20
|
-
* 优先级:原生crypto.randomUUID > crypto.getRandomValues > Math.random伪随机兜底
|
|
21
|
-
* @returns {string} 小写标准UUID v4字符串
|
|
22
|
-
*/
|
|
23
|
-
function createUuidV4() {
|
|
24
|
-
// 浏览器原生高性能UUID接口
|
|
25
|
-
if (globalThis.crypto?.randomUUID) {
|
|
26
|
-
return globalThis.crypto.randomUUID().toLowerCase();
|
|
27
|
-
}
|
|
28
|
-
// 支持加密随机字节,手动构造v4规范UUID
|
|
29
|
-
if (globalThis.crypto?.getRandomValues) {
|
|
30
|
-
var bytes = new Uint8Array(16);
|
|
31
|
-
globalThis.crypto.getRandomValues(bytes);
|
|
32
|
-
// UUID v4 固定版本位 0x40、变种位 0x80
|
|
33
|
-
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
34
|
-
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
35
|
-
// 字节转两位十六进制字符串
|
|
36
|
-
var hex = Array.from(bytes, function (val) {
|
|
37
|
-
return val.toString(16).padStart(2, '0');
|
|
38
|
-
}).join('');
|
|
39
|
-
// 拼接标准UUID分隔格式
|
|
40
|
-
return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' +
|
|
41
|
-
hex.slice(12, 16) + '-' + hex.slice(16, 20) + '-' + hex.slice(20);
|
|
42
|
-
}
|
|
43
|
-
// 最低兼容兜底:Math.random生成伪随机UUID(熵较低,仅无加密API场景使用)
|
|
44
|
-
return generatePseudoUuid();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Math.random 伪随机UUID生成器,兼容极老浏览器
|
|
49
|
-
* @returns {string} 伪随机UUID v4格式字符串
|
|
50
|
-
*/
|
|
51
|
-
function generatePseudoUuid() {
|
|
52
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
53
|
-
var r = (Math.random() * 16) | 0;
|
|
54
|
-
var v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
55
|
-
return v.toString(16);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 安全读取Cookie,自动转义正则特殊字符,防止匹配失效
|
|
61
|
-
* @param {string} name cookie键名
|
|
62
|
-
* @returns {string|null} cookie值,无则返回null
|
|
63
|
-
*/
|
|
64
|
-
function getCookie(name) {
|
|
65
|
-
try {
|
|
66
|
-
// 转义 . * + ? $ 等正则特殊符号
|
|
67
|
-
var escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
68
|
-
var reg = new RegExp('(^| )' + escapedName + '=([^;]+)');
|
|
69
|
-
var match = document.cookie.match(reg);
|
|
70
|
-
return match ? match[2] : null;
|
|
71
|
-
} catch (e) {
|
|
72
|
-
// cookie读取异常直接返回空
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 设置持久化Cookie,有效期1年,自动适配HTTPS Secure标识
|
|
79
|
-
* @param {string} name cookie键名
|
|
80
|
-
* @param {string} value cookie存储值
|
|
81
|
-
*/
|
|
82
|
-
function setCookie(name, value) {
|
|
83
|
-
try {
|
|
84
|
-
var isHttps = window.location.protocol === 'https:';
|
|
85
|
-
var parts = [
|
|
86
|
-
name + '=' + value,
|
|
87
|
-
'max-age=31536000', // 有效期365天
|
|
88
|
-
'path=/', // 全站生效
|
|
89
|
-
'SameSite=Lax' // 防跨站劫持
|
|
90
|
-
];
|
|
91
|
-
// HTTPS环境追加Secure标识
|
|
92
|
-
if (isHttps) parts.push('Secure');
|
|
93
|
-
document.cookie = parts.join(';');
|
|
94
|
-
} catch (e) { }
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* 时间格式化工具,统一输出 yyyy-MM-dd HH:mm:ss
|
|
99
|
-
* @returns {string} 格式化后的标准时间字符串
|
|
100
|
-
*/
|
|
101
|
-
function formatTime() {
|
|
102
|
-
var date_t = new Date();
|
|
103
|
-
var y_t = date_t.getFullYear();
|
|
104
|
-
var m_t = String(date_t.getMonth() + 1).padStart(2, '0');
|
|
105
|
-
var d_t = String(date_t.getDate()).padStart(2, '0');
|
|
106
|
-
var h_t = String(date_t.getHours()).padStart(2, '0');
|
|
107
|
-
var min_t = String(date_t.getMinutes()).padStart(2, '0');
|
|
108
|
-
var sec_t = String(date_t.getSeconds()).padStart(2, '0');
|
|
109
|
-
return y_t + "-" + m_t + "-" + d_t + " " + h_t + ":" + min_t + ":" + sec_t;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 填充单条埋点事件默认字段,缺失字段自动补空/默认行为类型,自动填充事件时间
|
|
114
|
-
* @param {Object} eventItem 业务传入的单条埋点原始参数
|
|
115
|
-
* @returns {Object} 补全默认值后的标准事件对象
|
|
116
|
-
*/
|
|
117
|
-
function fillEventDefault(eventItem) {
|
|
118
|
-
// 事件字段默认模板,对齐后端data数组字段规范
|
|
119
|
-
var defaultEvent = {
|
|
120
|
-
element_position: "", // 产品定义元素位置编码(唯一标识)
|
|
121
|
-
position_name: "", // 元素位置中文名称
|
|
122
|
-
page_code: "", // OMS后台页面编码,无则空字符串
|
|
123
|
-
page_name: "", // OMS后台页面名称,无则空字符串
|
|
124
|
-
floor_id: "", // OMS后台楼层ID
|
|
125
|
-
floor_name: "", // OMS后台楼层名称
|
|
126
|
-
element_type: "", // 元素枚举:page/vlist/plist/res/act/link等
|
|
127
|
-
element_name: "", // 元素内部名称/标题
|
|
128
|
-
content_id: "", // 最小颗粒度内容ID(游戏/视频ID)
|
|
129
|
-
content_title: "", // 内容标题名称
|
|
130
|
-
ext_attr1: "", // 扩展属性1,存放自定义附属信息
|
|
131
|
-
ext_attr2: "", // 扩展属性2,存放附属ID类参数
|
|
132
|
-
action_type: "曝光", // 行为枚举:曝光/点击/开始播放/结束播放/分享/订购/启动/退出/切后台
|
|
133
|
-
action_value: "", // 行为附属值:播放时长填秒数、订购填金额(单位分)、无附属数据填空
|
|
134
|
-
event_time: "" // 事件发生时间,不传则自动生成当前标准时间
|
|
135
|
-
};
|
|
136
|
-
// 业务参数覆盖默认模板
|
|
137
|
-
var merged = Object.assign({}, defaultEvent, eventItem);
|
|
138
|
-
// 未传入时间自动填充当前客户端时间
|
|
139
|
-
if (!merged.event_time) merged.event_time = formatTime();
|
|
140
|
-
return merged;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// ========== 对外暴露公共API ==========
|
|
144
|
-
return {
|
|
145
|
-
// 全局埋点配置项
|
|
146
|
-
config: {
|
|
147
|
-
reportUrl: 'https://sup.daoran.tv/bi-api/api/game/lewo/batch', // 批量上报接口地址
|
|
148
|
-
// reportUrl: '/bi-api/api/game/lewo/batch', // 批量上报接口地址
|
|
149
|
-
defaultHeaders: [], // 默认全局请求头数组
|
|
150
|
-
defaultContentType: 'application/json;charset=UTF-8' // 请求体类型
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* 设置全局用户/设备公共信息(上报顶层user对象,全局复用)
|
|
155
|
-
* 页面初始化、登录、切换渠道、切换网络时调用一次即可
|
|
156
|
-
* @param {Object} userObj 用户设备公共参数集合
|
|
157
|
-
* userObj字段说明:
|
|
158
|
-
* os_type: 操作系统类型 android / ios 全小写
|
|
159
|
-
* os_version: 系统版本纯数字,如15、17.1
|
|
160
|
-
* app_version: APP完整版本号 7.3.0
|
|
161
|
-
* app_item: 渠道编码/项目编码
|
|
162
|
-
* app_name: APP展示名称
|
|
163
|
-
* app_project: 产品内部短编码
|
|
164
|
-
* province: 省份数字编码
|
|
165
|
-
* city: 城市数字编码
|
|
166
|
-
* uid: 登录用户全局UID,游客/未登录填空字符串
|
|
167
|
-
* user_id: 会员ID / cocos游客ID,无则空
|
|
168
|
-
* device_brand: 设备品牌全小写 huawei/xiaomi/apple
|
|
169
|
-
* device_model: 设备完整型号
|
|
170
|
-
* network_type: 网络类型 wifi / cellular(蜂窝流量)
|
|
171
|
-
* carrier: 运营商 移动/联通/电信/广电/未知
|
|
172
|
-
* device_id: 可选,不传内部自动生成UUID v4设备标识
|
|
173
|
-
*/
|
|
174
|
-
initUserInfo: function (userObj) {
|
|
175
|
-
if (initInfoFlag) { return }
|
|
176
|
-
initInfoFlag = true;
|
|
177
|
-
// 未传入设备ID时,自动生成持久化UUID填充
|
|
178
|
-
if (!userObj.device_id) {
|
|
179
|
-
userObj.device_id = this.createDeviceId();
|
|
180
|
-
}
|
|
181
|
-
// 合并覆盖全局缓存,保留旧字段,新参数覆盖
|
|
182
|
-
globalUserInfo = Object.assign({}, globalUserInfo, userObj);
|
|
183
|
-
|
|
184
|
-
try {
|
|
185
|
-
// 1. 异步加载 H5 专属 SDK
|
|
186
|
-
(function (w, d, s, q, i) {
|
|
187
|
-
w[q] = w[q] || [];
|
|
188
|
-
var f = d.getElementsByTagName(s)[0],
|
|
189
|
-
j = d.createElement(s);
|
|
190
|
-
j.async = true;
|
|
191
|
-
j.id = 'beacon-aplus';
|
|
192
|
-
// ✅ 使用 H5 网页专属 SDK 地址
|
|
193
|
-
j.src = 'https://d.alicdn.com/alilog/mlog/aplus/' + i + '.js';
|
|
194
|
-
f.parentNode.insertBefore(j, f);
|
|
195
|
-
})(window, document, 'script', 'aplus_queue', '203467608');
|
|
196
|
-
|
|
197
|
-
// ========= 基础配置 =========
|
|
198
|
-
// 2. 设置 AppKey (请确保与友盟后台 H5/Web 应用的 AppKey 一致)
|
|
199
|
-
aplus_queue.push({
|
|
200
|
-
action: 'aplus.setMetaInfo',
|
|
201
|
-
arguments: ['appKey', '6a55f95f6f259537c7c966c8'] // 替换你的Umini AppKey
|
|
202
|
-
});
|
|
203
|
-
// 3. 声明终端类型为 PC (关键配置)
|
|
204
|
-
aplus_queue.push({
|
|
205
|
-
action: 'aplus.setMetaInfo',
|
|
206
|
-
arguments: ['aplus-terminal', 'pc']
|
|
207
|
-
});
|
|
208
|
-
// 4. 采集模式配置
|
|
209
|
-
// 传统多页网站(PC)建议改为 'AUTO';如果是 Vue/React 单页应用(SPA)保持 'MAN'
|
|
210
|
-
aplus_queue.push({
|
|
211
|
-
action: 'aplus.setMetaInfo',
|
|
212
|
-
arguments: ['aplus-waiting', 'AUTO']
|
|
213
|
-
});
|
|
214
|
-
// 调试模式,上线务必改为false
|
|
215
|
-
aplus_queue.push({
|
|
216
|
-
action: 'aplus.setMetaInfo',
|
|
217
|
-
arguments: ['DEBUG', false]
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
// ✅【必须补充】显式初始化SDK
|
|
221
|
-
aplus_queue.push({
|
|
222
|
-
action: 'aplus.init'
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
// ⚠️【重点】aplus-idtype 说明
|
|
226
|
-
// 如果你使用业务自己device_id/uuid:值填 uuid
|
|
227
|
-
// 微信openid:openid;支付宝:alipay_id;字节:anonymousid
|
|
228
|
-
// 暂时不确定类型,可以先注释这一行,避免配置错误
|
|
229
|
-
/*
|
|
230
|
-
aplus_queue.push({
|
|
231
|
-
action: 'aplus.setMetaInfo',
|
|
232
|
-
arguments: ['aplus-idtype', 'uuid']
|
|
233
|
-
});
|
|
234
|
-
*/
|
|
235
|
-
} catch (e) {
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
try {
|
|
240
|
-
// 设置用户唯一ID(登录/游客都可以设置)
|
|
241
|
-
var u_user_id = userObj.uid || userObj.device_id || '';
|
|
242
|
-
// console.log('u_user_id', userObj, u_user_id)
|
|
243
|
-
aplus_queue.push({
|
|
244
|
-
action: 'aplus.setMetaInfo',
|
|
245
|
-
arguments: ['userId', u_user_id]
|
|
246
|
-
});
|
|
247
|
-
} catch (e) {
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* 获取当前全局缓存的user公共信息(拷贝返回,防止外部篡改缓存)
|
|
255
|
-
* @returns {Object} 完整user公参对象
|
|
256
|
-
*/
|
|
257
|
-
getUserInfo: function () {
|
|
258
|
-
return Object.assign({}, globalUserInfo);
|
|
259
|
-
},
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* 获取或生成持久化设备唯一ID
|
|
263
|
-
* 读取优先级:内存缓存 > localStorage > cookie > 新建UUID
|
|
264
|
-
* @returns {string} 小写标准UUID v4 device_id
|
|
265
|
-
*/
|
|
266
|
-
createDeviceId: function () {
|
|
267
|
-
// 内存存在直接返回,减少存储读取
|
|
268
|
-
if (memoryCache) return memoryCache;
|
|
269
|
-
// 第一步读取localStorage
|
|
270
|
-
try {
|
|
271
|
-
var storageId = localStorage.getItem(STORAGE_KEY);
|
|
272
|
-
if (storageId?.trim()) {
|
|
273
|
-
memoryCache = storageId.toLowerCase();
|
|
274
|
-
return memoryCache;
|
|
275
|
-
}
|
|
276
|
-
} catch (e) { }
|
|
277
|
-
// 第二步读取cookie
|
|
278
|
-
var cookieId = getCookie(STORAGE_KEY);
|
|
279
|
-
if (cookieId?.trim()) {
|
|
280
|
-
memoryCache = cookieId.toLowerCase();
|
|
281
|
-
// 同步写入localStorage,双存储统一
|
|
282
|
-
try { localStorage.setItem(STORAGE_KEY, memoryCache); } catch (e) { }
|
|
283
|
-
return memoryCache;
|
|
284
|
-
}
|
|
285
|
-
// 无存储记录,新建UUID并持久化
|
|
286
|
-
var newId = createUuidV4();
|
|
287
|
-
memoryCache = newId;
|
|
288
|
-
try { localStorage.setItem(STORAGE_KEY, newId); } catch (e) { }
|
|
289
|
-
setCookie(STORAGE_KEY, newId);
|
|
290
|
-
return newId;
|
|
291
|
-
},
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* 重置清除本地全部设备ID缓存(退出账号/清除游客标识场景使用)
|
|
295
|
-
* 清空内存、localStorage、cookie三处存储
|
|
296
|
-
*/
|
|
297
|
-
resetDeviceId: function () {
|
|
298
|
-
memoryCache = null;
|
|
299
|
-
// 删除本地存储
|
|
300
|
-
try { localStorage.removeItem(STORAGE_KEY); } catch (e) { }
|
|
301
|
-
// 过期销毁cookie
|
|
302
|
-
try {
|
|
303
|
-
var isHttps = window.location.protocol === 'https:';
|
|
304
|
-
var cookieParts = [STORAGE_KEY + '=', 'max-age=0', 'path=/', 'SameSite=Lax'];
|
|
305
|
-
if (isHttps) cookieParts.push('Secure');
|
|
306
|
-
document.cookie = cookieParts.join(';');
|
|
307
|
-
} catch (e) { }
|
|
308
|
-
},
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* 上报请求中转封装,调用底层ES5 ajax
|
|
312
|
-
* @param {Object} dataObj 完整上报报文 {user:{}, data:[]}
|
|
313
|
-
*/
|
|
314
|
-
supersetAjax: function (dataObj) {
|
|
315
|
-
this.ajax({
|
|
316
|
-
url: this.config.reportUrl,
|
|
317
|
-
data: dataObj,
|
|
318
|
-
type: 'post',
|
|
319
|
-
dataType: 'json',
|
|
320
|
-
headers: [],
|
|
321
|
-
success: function (xhr, rsp) {
|
|
322
|
-
// 上报成功回调,业务可自行扩展
|
|
323
|
-
},
|
|
324
|
-
error: function (xhr, rsp) {
|
|
325
|
-
console.error('[supersetLewo 埋点上报失败]', rsp);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
},
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* ES5 底层原生XMLHttpRequest AJAX封装(还原最初版本逻辑,无Promise/Beacon)
|
|
332
|
-
* @param {Object} config 请求配置对象
|
|
333
|
-
*/
|
|
334
|
-
ajax: function (config) {
|
|
335
|
-
var url = config.url;
|
|
336
|
-
var data = config.data;
|
|
337
|
-
var dataAsync = config.async !== false;
|
|
338
|
-
var type = (config.type || 'GET').toUpperCase();
|
|
339
|
-
var contentType = config.contentType || this.config.defaultContentType;
|
|
340
|
-
var dataType = config.dataType;
|
|
341
|
-
var headers = config.headers || this.config.defaultHeaders;
|
|
342
|
-
var fnSuccess = config.success || function () { };
|
|
343
|
-
var fnError = config.error || function () { };
|
|
344
|
-
var xmlhttp;
|
|
345
|
-
|
|
346
|
-
// 兼容IE低版本XMLHttpRequest
|
|
347
|
-
if (window.XMLHttpRequest) {
|
|
348
|
-
xmlhttp = new XMLHttpRequest();
|
|
349
|
-
} else {
|
|
350
|
-
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
xmlhttp.onreadystatechange = function () {
|
|
354
|
-
if (xmlhttp.readyState == 4) {
|
|
355
|
-
var rsp = xmlhttp.responseText || xmlhttp.responseXML;
|
|
356
|
-
var parseError = false;
|
|
357
|
-
// JSON解析异常捕获,防止页面报错
|
|
358
|
-
if (dataType == 'json' && typeof rsp == 'string') {
|
|
359
|
-
try {
|
|
360
|
-
rsp = JSON.parse(rsp);
|
|
361
|
-
} catch (e) {
|
|
362
|
-
parseError = true;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
if (parseError) {
|
|
366
|
-
fnError(xmlhttp, rsp);
|
|
367
|
-
} else if (xmlhttp.status == 200) {
|
|
368
|
-
fnSuccess(xmlhttp, rsp);
|
|
369
|
-
} else {
|
|
370
|
-
fnError(xmlhttp, rsp);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
xmlhttp.open(type, url, dataAsync);
|
|
376
|
-
// 追加自定义请求头
|
|
377
|
-
for (var i = 0; i < headers.length; ++i) {
|
|
378
|
-
xmlhttp.setRequestHeader(headers[i].name, headers[i].value);
|
|
379
|
-
}
|
|
380
|
-
xmlhttp.setRequestHeader('Content-Type', contentType);
|
|
381
|
-
console.log('[supersetLewo 上报数据]', data)
|
|
382
|
-
// 对象转JSON字符串发送
|
|
383
|
-
data = JSON.stringify(data);
|
|
384
|
-
xmlhttp.send(data);
|
|
385
|
-
},
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* 单条埋点事件上报
|
|
389
|
-
* @param {Object} eventParam 单条事件埋点参数,字段对齐data数组规范
|
|
390
|
-
*/
|
|
391
|
-
superBatchReport: function (eventParam) {
|
|
392
|
-
// 填充缺失默认字段与事件时间
|
|
393
|
-
var eventItem = fillEventDefault(eventParam);
|
|
394
|
-
// 组装标准上报报文
|
|
395
|
-
var reportBody = {
|
|
396
|
-
user: this.getUserInfo(), // 全局公共用户设备信息
|
|
397
|
-
data: [eventItem] // 单事件数组
|
|
398
|
-
};
|
|
399
|
-
this.supersetAjax(reportBody);
|
|
400
|
-
|
|
401
|
-
// return
|
|
402
|
-
|
|
403
|
-
try {
|
|
404
|
-
var action_type = eventParam.action_type == '点击' ? 'CLICK' : 'EXPOSURE'
|
|
405
|
-
var eventName = eventParam.element_position + '_' + action_type
|
|
406
|
-
|
|
407
|
-
// console.log('um-action_type', action_type)
|
|
408
|
-
// console.log('um-eventName', eventName)
|
|
409
|
-
// console.log('um-aplus_queue', aplus_queue)
|
|
410
|
-
aplus_queue.push({
|
|
411
|
-
action: 'aplus.record',
|
|
412
|
-
// 第二个参数事件类型:CLICK / EXPOSURE / PAGE等,常规点击用CLICK
|
|
413
|
-
arguments: [eventName, action_type, eventParam]
|
|
414
|
-
});
|
|
415
|
-
} catch (e) {
|
|
416
|
-
console.log("superBatchReport-umeng error", e)
|
|
417
|
-
}
|
|
418
|
-
},
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* 批量多条埋点事件上报(一次性上报多个行为,减少请求次数)
|
|
422
|
-
* @param {Array} eventList 多条埋点事件对象数组
|
|
423
|
-
*/
|
|
424
|
-
batchReporting: function (eventList) {
|
|
425
|
-
// 非数组/空数组直接终止上报
|
|
426
|
-
if (!Array.isArray(eventList) || eventList.length === 0) return;
|
|
427
|
-
// 批量填充每条事件默认参数
|
|
428
|
-
var filledData = [];
|
|
429
|
-
for (var i = 0; i < eventList.length; i++) {
|
|
430
|
-
filledData.push(fillEventDefault(eventList[i]));
|
|
431
|
-
|
|
432
|
-
try {
|
|
433
|
-
var action_type = eventList[i].action_type == '点击' ? 'CLICK' : 'EXPOSURE'
|
|
434
|
-
var eventName = eventList[i].element_position + '_' + action_type
|
|
435
|
-
|
|
436
|
-
aplus_queue.push({
|
|
437
|
-
action: 'aplus.record',
|
|
438
|
-
// 第二个参数事件类型:CLICK / EXPOSURE / PAGE等,常规点击用CLICK
|
|
439
|
-
arguments: [eventName, action_type, eventList[i]]
|
|
440
|
-
});
|
|
441
|
-
} catch (e) {
|
|
442
|
-
console.log("batchReporting-umeng error", e)
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
// 组装批量上报报文
|
|
446
|
-
var reportBody = {
|
|
447
|
-
user: this.getUserInfo(),
|
|
448
|
-
data: filledData
|
|
449
|
-
};
|
|
450
|
-
this.supersetAjax(reportBody);
|
|
451
|
-
},
|
|
452
|
-
|
|
453
|
-
};
|
|
454
|
-
})();
|
|
455
|
-
|
|
456
|
-
// ===================== 使用示例(带详细注释) =====================
|
|
457
|
-
/**
|
|
458
|
-
* 示例1:页面初始化/登录后 设置全局用户设备公共信息,初始化友盟埋点SDK
|
|
459
|
-
* 仅需初始化一次,后续所有superBatchReport/batchReporting自动携带user参数
|
|
460
|
-
*/
|
|
461
|
-
// console.log("initUserInfo");
|
|
462
|
-
/*supersetLewo.initUserInfo({
|
|
463
|
-
os_type: "windows", // 系统类型安卓
|
|
464
|
-
os_version: "1", // 安卓版本15
|
|
465
|
-
app_version: "1.0.0", // APP版本号
|
|
466
|
-
app_item: "", // 渠道编码
|
|
467
|
-
app_name: "", // APP展示名称
|
|
468
|
-
app_project: "", // 产品内部编码
|
|
469
|
-
province: "100", // 省份编码
|
|
470
|
-
city: "", // 城市编码
|
|
471
|
-
uid: "", // 登录用户UID,未登录填空""
|
|
472
|
-
user_id: "", // 会员/游客ID,无则填空""
|
|
473
|
-
device_id: "", // 设备唯一ID,没有或不传则自动生成
|
|
474
|
-
device_brand: "", // 手机品牌小写
|
|
475
|
-
device_model: "", // 手机完整型号
|
|
476
|
-
network_type: "", // 蜂窝流量网络
|
|
477
|
-
carrier: "", // 运营商
|
|
478
|
-
promotion_flag: "0", //推广标识(ubp接口获取,1表示推广流量,0表示自然流量),
|
|
479
|
-
user_type: "0" //用户身份类型(0游客/1注册用户/2付费用户)
|
|
480
|
-
});
|
|
481
|
-
console.log("initUserInfo", supersetLewo.getUserInfo());*/
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* 示例2:单条埋点上报 - 首页曝光事件
|
|
485
|
-
* 调用superBatchReport,仅传入当前事件独有字段,公共user自动拼接
|
|
486
|
-
*/
|
|
487
|
-
|
|
488
|
-
/*setTimeout(function () {
|
|
489
|
-
supersetLewo.superBatchReport({
|
|
490
|
-
element_position: "Main_Start", // 元素位置编码
|
|
491
|
-
position_name: "游戏主页", // 中文位置名称
|
|
492
|
-
page_code: "", // OMS后台页面编码,无则空
|
|
493
|
-
page_name: "", // OMS后台页面名称,无则空
|
|
494
|
-
element_type: "page", // 元素类型页面
|
|
495
|
-
element_name: "gamestart", // 元素标识名
|
|
496
|
-
content_id: "10001", // 当前页面绑定内容ID
|
|
497
|
-
content_title: "我和美女有个约会", // 内容标题
|
|
498
|
-
action_type: "曝光", // 行为:曝光
|
|
499
|
-
action_value: "", // 行为值,时长填秒数,订购填金额(单位:分);无时间跨度行为填空
|
|
500
|
-
event_time: '' // event_time不传,内部自动生成当前时间
|
|
501
|
-
});
|
|
502
|
-
}, 2000);*/
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* 示例3:单条埋点上报 - 游戏卡片点击事件
|
|
507
|
-
*/
|
|
508
|
-
/*
|
|
509
|
-
supersetLewo.superBatchReport({
|
|
510
|
-
element_position: "Game_Card_List",
|
|
511
|
-
position_name: "游戏列表卡片",
|
|
512
|
-
element_type: "vlist",
|
|
513
|
-
element_name: "game_item",
|
|
514
|
-
content_id: "10002",
|
|
515
|
-
content_title: "开心消消乐",
|
|
516
|
-
action_type: "点击",
|
|
517
|
-
action_value: ""
|
|
518
|
-
});
|
|
519
|
-
*/
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* 示例4:批量埋点上报,一次性上报曝光+点击两条事件,减少http请求
|
|
523
|
-
* 调用batchReporting,传入事件数组
|
|
524
|
-
*/
|
|
525
|
-
/*
|
|
526
|
-
supersetLewo.batchReporting([
|
|
527
|
-
// 第一条:首页曝光
|
|
528
|
-
{
|
|
529
|
-
element_position: "Main_Start",
|
|
530
|
-
position_name: "游戏主页",
|
|
531
|
-
element_type: "page",
|
|
532
|
-
content_id: "10001",
|
|
533
|
-
content_title: "我和美女有个约会",
|
|
534
|
-
action_type: "曝光"
|
|
535
|
-
},
|
|
536
|
-
// 第二条:游戏卡片点击
|
|
537
|
-
{
|
|
538
|
-
element_position: "Game_Card_List",
|
|
539
|
-
position_name: "游戏列表卡片",
|
|
540
|
-
element_type: "vlist",
|
|
541
|
-
content_id: "10002",
|
|
542
|
-
content_title: "开心消消乐",
|
|
543
|
-
action_type: "点击"
|
|
544
|
-
}
|
|
545
|
-
]);
|
|
546
|
-
*/
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* 示例5:播放结束埋点(携带播放时长action_value,单位秒)
|
|
550
|
-
*/
|
|
551
|
-
/*
|
|
552
|
-
supersetLewo.superBatchReport({
|
|
553
|
-
element_position: "Game_Play_Page",
|
|
554
|
-
position_name: "游戏播放页",
|
|
555
|
-
element_type: "page",
|
|
556
|
-
content_id: "10003",
|
|
557
|
-
content_title: "夏日沙滩派对",
|
|
558
|
-
action_type: "结束播放",
|
|
559
|
-
action_value: "125" // 播放总时长125秒
|
|
560
|
-
});
|
|
561
|
-
*/
|
|
562
|
-
|
|
563
|
-
/**
|
|
564
|
-
* 示例6:清除游客设备ID(切换账号/清除本地标识使用)
|
|
565
|
-
*/
|
|
566
|
-
/*
|
|
567
|
-
supersetLewo.resetDeviceId();
|
|
568
|
-
*/
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
// CommonJS 模块导出(不改动上方 IIFE 逻辑)
|
|
572
|
-
if (typeof module !== 'undefined' && module.exports) {
|
|
573
|
-
module.exports = supersetLewo;
|
|
574
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 聚合广告 SDK - 枚举类型声明
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/** 广告平台标识 */
|
|
6
|
-
export declare enum AdPlatform {
|
|
7
|
-
None = 'none',
|
|
8
|
-
Xiaomi = 'xiaomi',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** 广告类型 */
|
|
12
|
-
export declare enum AdType {
|
|
13
|
-
RewardVideo = 'reward_video',
|
|
14
|
-
Interstitial = 'interstitial',
|
|
15
|
-
Banner = 'banner',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** 广告事件 */
|
|
19
|
-
export declare enum AdEvent {
|
|
20
|
-
Loaded = 'loaded',
|
|
21
|
-
Show = 'show',
|
|
22
|
-
Click = 'click',
|
|
23
|
-
Closed = 'closed',
|
|
24
|
-
Reward = 'reward',
|
|
25
|
-
Error = 'error',
|
|
26
|
-
Exit = 'exit',
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** 广告错误码(聚合层统一) */
|
|
30
|
-
export declare enum AdErrorCode {
|
|
31
|
-
Success = 0,
|
|
32
|
-
Unknown = -1,
|
|
33
|
-
AdSwitchOff = 1001,
|
|
34
|
-
NoFill = 1002,
|
|
35
|
-
Timeout = 1003,
|
|
36
|
-
PlayFailed = 1004,
|
|
37
|
-
NoFallbackAd = 1005,
|
|
38
|
-
UserAbandoned = 1006,
|
|
39
|
-
AdInProgress = 1007,
|
|
40
|
-
NotInitialized = 2001,
|
|
41
|
-
PlatformNotSupported = 2002,
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** 设备平台 */
|
|
45
|
-
export declare enum DevicePlatform {
|
|
46
|
-
TV = 'tv',
|
|
47
|
-
Mobile = 'mobile',
|
|
48
|
-
Tablet = 'tablet',
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** 遥控器按键码 */
|
|
52
|
-
export declare enum KeyCode {
|
|
53
|
-
Up = 'up',
|
|
54
|
-
Down = 'down',
|
|
55
|
-
Left = 'left',
|
|
56
|
-
Right = 'right',
|
|
57
|
-
Enter = 'enter',
|
|
58
|
-
Back = 'back',
|
|
59
|
-
Menu = 'menu',
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** 按键动作 */
|
|
63
|
-
export declare enum KeyAction {
|
|
64
|
-
Down = 'down',
|
|
65
|
-
Up = 'up',
|
|
66
|
-
}
|