keytops-game-framework 2.0.0 → 2.1.1
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/dist/app/module/analytics/ALiAnalyticsSender.d.ts +3 -2
- package/dist/app/module/analytics/AnalyticsAble.d.ts +33 -22
- package/dist/app/module/analytics/AnalyticsEvent.d.ts +39 -0
- package/dist/app/module/analytics/KeytopsAnalyticsSender.d.ts +3 -2
- package/dist/app/module/analytics/ad/ADBehaviorReporter.d.ts +1 -1
- package/dist/app/module/analytics/firebase/FirebaseAnalyticsSender.d.ts +39 -0
- package/dist/app/module/analytics/index.d.ts +31 -0
- package/dist/app/module/analytics/level/LevelAnalyticsAble.d.ts +1 -1
- package/dist/app/module/analytics/level/LevelBehaviorReporter.d.ts +7 -7
- package/dist/app/module/analytics/pay/PayAnalyticsAble.d.ts +27 -0
- package/dist/app/module/analytics/social/SocialAnalyticsAble.d.ts +11 -0
- package/dist/app/module/analytics/tutorial/TutorialAnalyticsAble.d.ts +16 -0
- package/dist/app/module/publisher/IShareAble.d.ts +2 -2
- package/dist/app/module/publisher/native/NativeAnalyticsSender.d.ts +3 -2
- package/dist/app/module/publisher/tk/TKAnalyticsSender.d.ts +3 -2
- package/dist/app/module/publisher/tt/TTAnalyticsSender.d.ts +3 -2
- package/dist/app/module/publisher/wx/WXAnalyticsSender.d.ts +3 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +679 -164
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1416,7 +1416,10 @@ class EmptyAnalyticsSender {
|
|
|
1416
1416
|
}
|
|
1417
1417
|
return true;
|
|
1418
1418
|
}
|
|
1419
|
-
|
|
1419
|
+
mapEvent(eventName, eventData) {
|
|
1420
|
+
return { eventName, data: Object.assign({}, eventData) };
|
|
1421
|
+
}
|
|
1422
|
+
send(eventName, eventData, userProperties) {
|
|
1420
1423
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1421
1424
|
});
|
|
1422
1425
|
}
|
|
@@ -1452,44 +1455,14 @@ class AnalyticsAble {
|
|
|
1452
1455
|
for (let i = 0; i < senders.length; i++) {
|
|
1453
1456
|
const sender = senders[i];
|
|
1454
1457
|
this._senderList.push(sender);
|
|
1455
|
-
this.
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
_usesSenderUserProperties(sender) {
|
|
1459
|
-
if (sender.userPropertyMode !== "sender") {
|
|
1460
|
-
return false;
|
|
1461
|
-
}
|
|
1462
|
-
if (typeof sender.setUserProperty === "function") {
|
|
1463
|
-
return true;
|
|
1458
|
+
if (this._hasSetUserId && typeof sender.setUserId === "function") {
|
|
1459
|
+
sender.setUserId(this._userId);
|
|
1460
|
+
}
|
|
1464
1461
|
}
|
|
1465
|
-
this._debugMode && console.error("[Analytics] userPropertyMode=sender 的 Sender 必须实现 setUserProperty,已回退为 event 模式。");
|
|
1466
|
-
return false;
|
|
1467
1462
|
}
|
|
1468
1463
|
_getUserProperties() {
|
|
1469
1464
|
return Object.assign({}, this._userOnceProperties || {}, this._userAddProperties || {}, this._userProperties || {});
|
|
1470
1465
|
}
|
|
1471
|
-
_syncSenderUserState(sender) {
|
|
1472
|
-
if (this._hasSetUserId && typeof sender.setUserId === "function") {
|
|
1473
|
-
sender.setUserId(this._userId);
|
|
1474
|
-
}
|
|
1475
|
-
if (!this._usesSenderUserProperties(sender)) {
|
|
1476
|
-
return;
|
|
1477
|
-
}
|
|
1478
|
-
const properties = this._getUserProperties();
|
|
1479
|
-
for (const key in properties) {
|
|
1480
|
-
if (Object.prototype.hasOwnProperty.call(properties, key)) {
|
|
1481
|
-
sender.setUserProperty(key, properties[key]);
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
_notifyUserProperty(key, value) {
|
|
1486
|
-
for (let i = 0; i < this._senderList.length; i++) {
|
|
1487
|
-
const sender = this._senderList[i];
|
|
1488
|
-
if (this._usesSenderUserProperties(sender)) {
|
|
1489
|
-
sender.setUserProperty(key, value);
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
1466
|
/**
|
|
1494
1467
|
* 设置排除
|
|
1495
1468
|
* @param excludeEvents 排除事件名称或者名称列表。
|
|
@@ -1509,11 +1482,11 @@ class AnalyticsAble {
|
|
|
1509
1482
|
}
|
|
1510
1483
|
}
|
|
1511
1484
|
_onAppShow() {
|
|
1512
|
-
this.time("
|
|
1513
|
-
this.report("
|
|
1485
|
+
this.time("app.hide");
|
|
1486
|
+
this.report("app.show", publisher.publisher.enterOptions.getAllOption());
|
|
1514
1487
|
}
|
|
1515
1488
|
_onAppHide() {
|
|
1516
|
-
this.report("
|
|
1489
|
+
this.report("app.hide");
|
|
1517
1490
|
}
|
|
1518
1491
|
/**
|
|
1519
1492
|
* 设置所有上报事件的基础属性
|
|
@@ -1632,7 +1605,6 @@ class AnalyticsAble {
|
|
|
1632
1605
|
console.warn(`用户属性中已经存在${key}:${this._userProperties[key]}, 将替换为${value}`);
|
|
1633
1606
|
}
|
|
1634
1607
|
this._userProperties[key] = value;
|
|
1635
|
-
this._notifyUserProperty(key, value);
|
|
1636
1608
|
}
|
|
1637
1609
|
/**
|
|
1638
1610
|
* 如果您要上传的用户属性只要设置一次,则可以调用 userSetOnce 来进行设置。
|
|
@@ -1662,12 +1634,10 @@ class AnalyticsAble {
|
|
|
1662
1634
|
if (storageValue != null && storageValue != "") {
|
|
1663
1635
|
this._debugMode && console.info(`用户属性中已经存在once属性${key}:${storageValue}`);
|
|
1664
1636
|
this._userOnceProperties[key] = typeof value === "number" ? Number(storageValue) : storageValue;
|
|
1665
|
-
this._notifyUserProperty(key, this._userOnceProperties[key]);
|
|
1666
1637
|
return;
|
|
1667
1638
|
}
|
|
1668
1639
|
storage.setUValue(`analytics_user_once_${key}`, value);
|
|
1669
1640
|
this._userOnceProperties[key] = value;
|
|
1670
|
-
this._notifyUserProperty(key, value);
|
|
1671
1641
|
}
|
|
1672
1642
|
/**
|
|
1673
1643
|
*设置用户累积属性,当您要上传数值型的属性时,您可以调用 userAdd 来对该属性进行累加操作,
|
|
@@ -1690,7 +1660,6 @@ class AnalyticsAble {
|
|
|
1690
1660
|
let total = Number(this._userAddProperties[key] || storage.getUValue(`analytics_user_add_${key}`, 0) || 0);
|
|
1691
1661
|
this._userAddProperties[key] = total + value;
|
|
1692
1662
|
storage.setUValue(`analytics_user_add_${key}`, total + value);
|
|
1693
|
-
this._notifyUserProperty(key, total + value);
|
|
1694
1663
|
}
|
|
1695
1664
|
/**
|
|
1696
1665
|
* 移除用户属性。当您要清空用户的用户属性值时,您可以调用 userUnset 来对指定属性进行清空操作,如果该属性还未在集群中被创建,则 user_unset 不会创建该属性
|
|
@@ -1702,14 +1671,13 @@ class AnalyticsAble {
|
|
|
1702
1671
|
this._userAddProperties && delete this._userAddProperties[key];
|
|
1703
1672
|
storage.removeUValue(`analytics_user_once_${key}`);
|
|
1704
1673
|
storage.removeUValue(`analytics_user_add_${key}`);
|
|
1705
|
-
this._notifyUserProperty(key, null);
|
|
1706
1674
|
}
|
|
1707
1675
|
/**
|
|
1708
1676
|
* 上报错误
|
|
1709
1677
|
* @param error 错误信息
|
|
1710
1678
|
*/
|
|
1711
1679
|
error(error) {
|
|
1712
|
-
this.report("
|
|
1680
|
+
this.report("app.error", { error: error });
|
|
1713
1681
|
}
|
|
1714
1682
|
/**
|
|
1715
1683
|
* 开始事件计时
|
|
@@ -1794,16 +1762,170 @@ class AnalyticsAble {
|
|
|
1794
1762
|
return Promise.all(this._senderList
|
|
1795
1763
|
.filter((sender) => sender.sendAble(eventName))
|
|
1796
1764
|
.map((sender) => {
|
|
1797
|
-
const
|
|
1798
|
-
if (!
|
|
1799
|
-
|
|
1765
|
+
const mapped = sender.mapEvent(eventName, Object.assign({}, data));
|
|
1766
|
+
if (!sender.sendAble(mapped.eventName)) {
|
|
1767
|
+
return Promise.resolve();
|
|
1800
1768
|
}
|
|
1801
|
-
return sender.send(eventName,
|
|
1769
|
+
return sender.send(mapped.eventName, Object.assign({}, mapped.data), Object.assign({}, userProperties));
|
|
1802
1770
|
})).then();
|
|
1803
1771
|
});
|
|
1804
1772
|
}
|
|
1805
1773
|
}
|
|
1806
1774
|
|
|
1775
|
+
/**
|
|
1776
|
+
* 框架内部统一使用的业务语义事件名。
|
|
1777
|
+
* Sender 负责将它们转换成统计平台实际接收的事件名和参数。
|
|
1778
|
+
*/
|
|
1779
|
+
var AnalyticsBehavior;
|
|
1780
|
+
(function (AnalyticsBehavior) {
|
|
1781
|
+
AnalyticsBehavior["APP_LAUNCH"] = "app.launch";
|
|
1782
|
+
AnalyticsBehavior["APP_SHOW"] = "app.show";
|
|
1783
|
+
AnalyticsBehavior["APP_HIDE"] = "app.hide";
|
|
1784
|
+
AnalyticsBehavior["APP_ERROR"] = "app.error";
|
|
1785
|
+
AnalyticsBehavior["SESSION_LOGIN"] = "session.login";
|
|
1786
|
+
AnalyticsBehavior["LEVEL_START"] = "level.start";
|
|
1787
|
+
AnalyticsBehavior["LEVEL_END"] = "level.end";
|
|
1788
|
+
AnalyticsBehavior["LEVEL_PAUSE"] = "level.pause";
|
|
1789
|
+
AnalyticsBehavior["LEVEL_TIMEOUT"] = "level.timeout";
|
|
1790
|
+
AnalyticsBehavior["LEVEL_ITEM_USE"] = "level.item_use";
|
|
1791
|
+
AnalyticsBehavior["AD_LIFECYCLE"] = "ad.lifecycle";
|
|
1792
|
+
AnalyticsBehavior["AD_IMPRESSION"] = "ad.impression";
|
|
1793
|
+
AnalyticsBehavior["SOCIAL_SHARE"] = "social.share";
|
|
1794
|
+
AnalyticsBehavior["SOCIAL_SUBSCRIBE_SHOW"] = "social.subscribe_show";
|
|
1795
|
+
AnalyticsBehavior["SOCIAL_SUBSCRIBE"] = "social.subscribe";
|
|
1796
|
+
AnalyticsBehavior["TUTORIAL_BEGIN"] = "tutorial.begin";
|
|
1797
|
+
AnalyticsBehavior["TUTORIAL_COMPLETE"] = "tutorial.complete";
|
|
1798
|
+
AnalyticsBehavior["TUTORIAL_SKIP"] = "tutorial.skip";
|
|
1799
|
+
AnalyticsBehavior["PAY_BEGIN"] = "pay.begin";
|
|
1800
|
+
AnalyticsBehavior["PAY_PURCHASE"] = "pay.purchase";
|
|
1801
|
+
AnalyticsBehavior["PAY_PENDING"] = "pay.pending";
|
|
1802
|
+
AnalyticsBehavior["PAY_CANCEL"] = "pay.cancel";
|
|
1803
|
+
AnalyticsBehavior["PAY_FAIL"] = "pay.fail";
|
|
1804
|
+
})(AnalyticsBehavior || (AnalyticsBehavior = {}));
|
|
1805
|
+
const LEVEL_RESULT_EVENT = {
|
|
1806
|
+
success: "lv_success",
|
|
1807
|
+
fail: "lv_fail",
|
|
1808
|
+
leave: "lv_leave",
|
|
1809
|
+
skip: "lv_skip",
|
|
1810
|
+
revive: "lv_revive",
|
|
1811
|
+
break: "lv_break",
|
|
1812
|
+
retry: "lv_retry",
|
|
1813
|
+
};
|
|
1814
|
+
const SHARE_PHASE_MESSAGE = {
|
|
1815
|
+
begin: "发起",
|
|
1816
|
+
success: "成功",
|
|
1817
|
+
fail: "失败",
|
|
1818
|
+
};
|
|
1819
|
+
function move(data, source, target) {
|
|
1820
|
+
if (data[source] !== undefined) {
|
|
1821
|
+
data[target] = data[source];
|
|
1822
|
+
delete data[source];
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
/**
|
|
1826
|
+
* Keytops/Ali 当前服务端仍使用的物理协议。
|
|
1827
|
+
* 兼容逻辑集中在 Sender 边界,业务层无需继续依赖旧事件字符串。
|
|
1828
|
+
*/
|
|
1829
|
+
function mapCanonicalEventToLegacy(eventName, eventData) {
|
|
1830
|
+
const data = Object.assign({}, eventData);
|
|
1831
|
+
let mappedName = eventName;
|
|
1832
|
+
switch (eventName) {
|
|
1833
|
+
case AnalyticsBehavior.APP_LAUNCH:
|
|
1834
|
+
case AnalyticsBehavior.APP_SHOW:
|
|
1835
|
+
case AnalyticsBehavior.APP_HIDE:
|
|
1836
|
+
case AnalyticsBehavior.APP_ERROR:
|
|
1837
|
+
case AnalyticsBehavior.SESSION_LOGIN:
|
|
1838
|
+
mappedName = eventName.replace(".", "_");
|
|
1839
|
+
if (eventName === AnalyticsBehavior.SESSION_LOGIN) {
|
|
1840
|
+
mappedName = "login";
|
|
1841
|
+
move(data, "options", "msg");
|
|
1842
|
+
}
|
|
1843
|
+
break;
|
|
1844
|
+
case AnalyticsBehavior.LEVEL_START:
|
|
1845
|
+
mappedName = "lv_enter";
|
|
1846
|
+
break;
|
|
1847
|
+
case AnalyticsBehavior.LEVEL_END:
|
|
1848
|
+
mappedName = LEVEL_RESULT_EVENT[String(data.result || "")] || "lv_leave";
|
|
1849
|
+
delete data.result;
|
|
1850
|
+
break;
|
|
1851
|
+
case AnalyticsBehavior.LEVEL_PAUSE:
|
|
1852
|
+
mappedName = "lv_leave";
|
|
1853
|
+
break;
|
|
1854
|
+
case AnalyticsBehavior.LEVEL_TIMEOUT:
|
|
1855
|
+
mappedName = "lv_timeout";
|
|
1856
|
+
break;
|
|
1857
|
+
case AnalyticsBehavior.LEVEL_ITEM_USE:
|
|
1858
|
+
mappedName = "lv_item";
|
|
1859
|
+
break;
|
|
1860
|
+
case AnalyticsBehavior.AD_LIFECYCLE:
|
|
1861
|
+
case AnalyticsBehavior.AD_IMPRESSION:
|
|
1862
|
+
mappedName = "ad";
|
|
1863
|
+
move(data, "adType", "_adtype");
|
|
1864
|
+
move(data, "lifecycle", "_adevent");
|
|
1865
|
+
move(data, "message", "msg");
|
|
1866
|
+
delete data.group;
|
|
1867
|
+
break;
|
|
1868
|
+
case AnalyticsBehavior.SOCIAL_SHARE:
|
|
1869
|
+
mappedName = "share";
|
|
1870
|
+
if (data.itemId !== undefined && data.name === undefined) {
|
|
1871
|
+
data.name = data.itemId;
|
|
1872
|
+
}
|
|
1873
|
+
if (data.phase !== undefined) {
|
|
1874
|
+
data.msg = SHARE_PHASE_MESSAGE[String(data.phase)] || String(data.phase);
|
|
1875
|
+
}
|
|
1876
|
+
break;
|
|
1877
|
+
case AnalyticsBehavior.SOCIAL_SUBSCRIBE_SHOW:
|
|
1878
|
+
mappedName = "subscribe_show";
|
|
1879
|
+
break;
|
|
1880
|
+
case AnalyticsBehavior.SOCIAL_SUBSCRIBE:
|
|
1881
|
+
mappedName = "subscribe";
|
|
1882
|
+
break;
|
|
1883
|
+
case AnalyticsBehavior.TUTORIAL_BEGIN:
|
|
1884
|
+
case AnalyticsBehavior.TUTORIAL_COMPLETE:
|
|
1885
|
+
case AnalyticsBehavior.TUTORIAL_SKIP:
|
|
1886
|
+
case AnalyticsBehavior.PAY_BEGIN:
|
|
1887
|
+
case AnalyticsBehavior.PAY_PURCHASE:
|
|
1888
|
+
case AnalyticsBehavior.PAY_PENDING:
|
|
1889
|
+
case AnalyticsBehavior.PAY_CANCEL:
|
|
1890
|
+
case AnalyticsBehavior.PAY_FAIL:
|
|
1891
|
+
mappedName = eventName.replace(".", "_");
|
|
1892
|
+
break;
|
|
1893
|
+
}
|
|
1894
|
+
if (eventName === AnalyticsBehavior.LEVEL_START ||
|
|
1895
|
+
eventName === AnalyticsBehavior.LEVEL_END ||
|
|
1896
|
+
eventName === AnalyticsBehavior.LEVEL_PAUSE ||
|
|
1897
|
+
eventName === AnalyticsBehavior.LEVEL_TIMEOUT ||
|
|
1898
|
+
eventName === AnalyticsBehavior.LEVEL_ITEM_USE) {
|
|
1899
|
+
move(data, "levelId", "id");
|
|
1900
|
+
move(data, "levelIndex", "index");
|
|
1901
|
+
move(data, "gameId", "type");
|
|
1902
|
+
move(data, "repeatCount", "code");
|
|
1903
|
+
move(data, "averageThinkTimeMs", "time");
|
|
1904
|
+
move(data, "itemName", "name");
|
|
1905
|
+
if (eventName === AnalyticsBehavior.LEVEL_TIMEOUT) {
|
|
1906
|
+
data.name = "超时";
|
|
1907
|
+
delete data.reason;
|
|
1908
|
+
}
|
|
1909
|
+
else if (eventName === AnalyticsBehavior.LEVEL_PAUSE) {
|
|
1910
|
+
data.name = "切出游戏";
|
|
1911
|
+
delete data.reason;
|
|
1912
|
+
}
|
|
1913
|
+
else {
|
|
1914
|
+
move(data, "reason", "name");
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
return { eventName: mappedName, data };
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* 小游戏平台通常不接受点号事件名,统一转换为下划线。
|
|
1921
|
+
*/
|
|
1922
|
+
function mapCanonicalEventToFlatName(eventName, eventData) {
|
|
1923
|
+
return {
|
|
1924
|
+
eventName: eventName.replace(/\./g, "_"),
|
|
1925
|
+
data: Object.assign({}, eventData),
|
|
1926
|
+
};
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1807
1929
|
const ALI_ANALYTICS_EVENT_CACHE = "ALI_ANALYTICS_EVENT_CACHE";
|
|
1808
1930
|
/**
|
|
1809
1931
|
* 内部阿里云日志事件上报器
|
|
@@ -1898,10 +2020,13 @@ class ALiAnalyticsSender extends EmptyAnalyticsSender {
|
|
|
1898
2020
|
return false;
|
|
1899
2021
|
}
|
|
1900
2022
|
}
|
|
1901
|
-
|
|
2023
|
+
mapEvent(eventName, eventData) {
|
|
2024
|
+
return mapCanonicalEventToLegacy(eventName, eventData);
|
|
2025
|
+
}
|
|
2026
|
+
send(eventName, eventData, userProperties) {
|
|
1902
2027
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1903
|
-
const payload =
|
|
1904
|
-
? Object.assign({},
|
|
2028
|
+
const payload = eventData && typeof eventData === "object" && !Array.isArray(eventData)
|
|
2029
|
+
? Object.assign(Object.assign({}, userProperties), eventData) : Object.assign({}, userProperties);
|
|
1905
2030
|
payload['_event'] = eventName;
|
|
1906
2031
|
let msg_data = {
|
|
1907
2032
|
appid: publisher.appId,
|
|
@@ -2235,7 +2360,7 @@ class ADBehaviorReporter {
|
|
|
2235
2360
|
* @param from 广告来源
|
|
2236
2361
|
*/
|
|
2237
2362
|
onShowComplete(type, from) {
|
|
2238
|
-
this.report(type, ADEvent.SHOW_COMPLETE, from);
|
|
2363
|
+
this.report(type, ADEvent.SHOW_COMPLETE, from, undefined, true);
|
|
2239
2364
|
}
|
|
2240
2365
|
/**
|
|
2241
2366
|
* 广告显示失败
|
|
@@ -2261,20 +2386,20 @@ class ADBehaviorReporter {
|
|
|
2261
2386
|
* @param from 广告来源
|
|
2262
2387
|
* @param msg 广告失败原因
|
|
2263
2388
|
*/
|
|
2264
|
-
report(type, event, from, msg) {
|
|
2265
|
-
|
|
2266
|
-
const group =
|
|
2267
|
-
|
|
2268
|
-
from._adtype = type;
|
|
2269
|
-
from._adevent = event;
|
|
2389
|
+
report(type, event, from, msg, impression = false) {
|
|
2390
|
+
const source = Object.assign({}, (from || {}));
|
|
2391
|
+
const group = source.group || "game";
|
|
2392
|
+
delete source.group;
|
|
2270
2393
|
if (!this._groupCount[group]) {
|
|
2271
2394
|
this._groupCount[group] = 0;
|
|
2272
2395
|
}
|
|
2273
|
-
|
|
2396
|
+
const data = Object.assign(Object.assign({}, source), { group, adType: type, lifecycle: event, count: event == ADEvent.SHOW_COMPLETE
|
|
2397
|
+
? ++this._groupCount[group]
|
|
2398
|
+
: this._groupCount[group] });
|
|
2274
2399
|
if (msg) {
|
|
2275
|
-
|
|
2400
|
+
data.message = msg;
|
|
2276
2401
|
}
|
|
2277
|
-
this.baseAble.report(
|
|
2402
|
+
this.baseAble.report(impression ? AnalyticsBehavior.AD_IMPRESSION : AnalyticsBehavior.AD_LIFECYCLE, data);
|
|
2278
2403
|
}
|
|
2279
2404
|
}
|
|
2280
2405
|
|
|
@@ -2942,13 +3067,13 @@ LevelOnlineConfig = __decorate([
|
|
|
2942
3067
|
|
|
2943
3068
|
var GameLeaveType;
|
|
2944
3069
|
(function (GameLeaveType) {
|
|
2945
|
-
GameLeaveType["success"] = "
|
|
2946
|
-
GameLeaveType["fail"] = "
|
|
2947
|
-
GameLeaveType["leave"] = "
|
|
2948
|
-
GameLeaveType["skip"] = "
|
|
2949
|
-
GameLeaveType["revive"] = "
|
|
2950
|
-
GameLeaveType["break"] = "
|
|
2951
|
-
GameLeaveType["retry"] = "
|
|
3070
|
+
GameLeaveType["success"] = "success";
|
|
3071
|
+
GameLeaveType["fail"] = "fail";
|
|
3072
|
+
GameLeaveType["leave"] = "leave";
|
|
3073
|
+
GameLeaveType["skip"] = "skip";
|
|
3074
|
+
GameLeaveType["revive"] = "revive";
|
|
3075
|
+
GameLeaveType["break"] = "break";
|
|
3076
|
+
GameLeaveType["retry"] = "retry";
|
|
2952
3077
|
})(GameLeaveType || (GameLeaveType = {}));
|
|
2953
3078
|
/**
|
|
2954
3079
|
* 关卡行为自动上报器
|
|
@@ -2967,7 +3092,7 @@ class LevelBehaviorReporter {
|
|
|
2967
3092
|
this.reset();
|
|
2968
3093
|
this._setTimers();
|
|
2969
3094
|
App.onHide(this._leaveApp, this);
|
|
2970
|
-
this.baseAble.report(
|
|
3095
|
+
this.baseAble.report(AnalyticsBehavior.LEVEL_START, context);
|
|
2971
3096
|
}
|
|
2972
3097
|
end(type, data) {
|
|
2973
3098
|
const context = this._getContext();
|
|
@@ -2978,7 +3103,7 @@ class LevelBehaviorReporter {
|
|
|
2978
3103
|
const levelsession = this._game.getCurrentLevelSession();
|
|
2979
3104
|
// 有效操作的平均思考时间
|
|
2980
3105
|
const time = levelsession.stepsUsed > 0 ? Math.floor(levelsession.thinkTimeTotal / levelsession.stepsUsed) : 0;
|
|
2981
|
-
this.baseAble.report(
|
|
3106
|
+
this.baseAble.report(AnalyticsBehavior.LEVEL_END, Object.assign(Object.assign(Object.assign({}, context), data), { result: type, averageThinkTimeMs: time }));
|
|
2982
3107
|
this.reset();
|
|
2983
3108
|
}
|
|
2984
3109
|
reportLeave(data) {
|
|
@@ -2986,47 +3111,39 @@ class LevelBehaviorReporter {
|
|
|
2986
3111
|
if (!context) {
|
|
2987
3112
|
return;
|
|
2988
3113
|
}
|
|
2989
|
-
this.baseAble.report(
|
|
3114
|
+
this.baseAble.report(AnalyticsBehavior.LEVEL_PAUSE, Object.assign(Object.assign(Object.assign({}, context), { reason: "app_hide" }), data));
|
|
2990
3115
|
}
|
|
2991
3116
|
reportTimeout(data) {
|
|
2992
3117
|
const context = this._getContext();
|
|
2993
3118
|
if (!context) {
|
|
2994
3119
|
return;
|
|
2995
3120
|
}
|
|
2996
|
-
this.baseAble.report(
|
|
3121
|
+
this.baseAble.report(AnalyticsBehavior.LEVEL_TIMEOUT, Object.assign(Object.assign(Object.assign({}, context), { reason: "timeout" }), data));
|
|
2997
3122
|
}
|
|
2998
3123
|
reportItem(name, data) {
|
|
2999
3124
|
const context = this._getContext();
|
|
3000
3125
|
if (!context) {
|
|
3001
3126
|
return;
|
|
3002
3127
|
}
|
|
3003
|
-
this.baseAble.report(
|
|
3128
|
+
this.baseAble.report(AnalyticsBehavior.LEVEL_ITEM_USE, Object.assign(Object.assign(Object.assign({}, context), { itemName: name.toLocaleLowerCase() }), data));
|
|
3004
3129
|
}
|
|
3005
3130
|
reset() {
|
|
3006
|
-
this.baseAble.cancelTime(
|
|
3007
|
-
this.baseAble.cancelTime(
|
|
3008
|
-
this.baseAble.cancelTime(
|
|
3009
|
-
this.baseAble.cancelTime(
|
|
3010
|
-
this.baseAble.cancelTime(
|
|
3011
|
-
this.baseAble.cancelTime(GameLeaveType.break);
|
|
3012
|
-
this.baseAble.cancelTime(GameLeaveType.retry);
|
|
3013
|
-
this.baseAble.cancelTime("lv_timeout");
|
|
3014
|
-
this.baseAble.cancelTime("ad");
|
|
3131
|
+
this.baseAble.cancelTime(AnalyticsBehavior.LEVEL_END);
|
|
3132
|
+
this.baseAble.cancelTime(AnalyticsBehavior.LEVEL_PAUSE);
|
|
3133
|
+
this.baseAble.cancelTime(AnalyticsBehavior.LEVEL_TIMEOUT);
|
|
3134
|
+
this.baseAble.cancelTime(AnalyticsBehavior.AD_LIFECYCLE);
|
|
3135
|
+
this.baseAble.cancelTime(AnalyticsBehavior.AD_IMPRESSION);
|
|
3015
3136
|
App.offHide(this._leaveApp, this);
|
|
3016
3137
|
}
|
|
3017
3138
|
_leaveApp() {
|
|
3018
3139
|
this.reportLeave();
|
|
3019
3140
|
}
|
|
3020
3141
|
_setTimers() {
|
|
3021
|
-
this.baseAble.time(
|
|
3022
|
-
this.baseAble.time(
|
|
3023
|
-
this.baseAble.time(
|
|
3024
|
-
this.baseAble.time(
|
|
3025
|
-
this.baseAble.time(
|
|
3026
|
-
this.baseAble.time(GameLeaveType.break, false);
|
|
3027
|
-
this.baseAble.time(GameLeaveType.retry, false);
|
|
3028
|
-
this.baseAble.time("lv_timeout", false);
|
|
3029
|
-
this.baseAble.time("ad", false);
|
|
3142
|
+
this.baseAble.time(AnalyticsBehavior.LEVEL_END, false);
|
|
3143
|
+
this.baseAble.time(AnalyticsBehavior.LEVEL_PAUSE, false);
|
|
3144
|
+
this.baseAble.time(AnalyticsBehavior.LEVEL_TIMEOUT, false);
|
|
3145
|
+
this.baseAble.time(AnalyticsBehavior.AD_LIFECYCLE, false);
|
|
3146
|
+
this.baseAble.time(AnalyticsBehavior.AD_IMPRESSION, false);
|
|
3030
3147
|
}
|
|
3031
3148
|
_getContext() {
|
|
3032
3149
|
return this._game.getCurrentBehaviorContext();
|
|
@@ -3810,7 +3927,7 @@ class GameDimension extends BaseDimension {
|
|
|
3810
3927
|
if (!this._currentLevelSession) {
|
|
3811
3928
|
return null;
|
|
3812
3929
|
}
|
|
3813
|
-
return Object.assign({
|
|
3930
|
+
return Object.assign(Object.assign({}, this._currentEnterParams), { levelId: this._currentLevelSession.levelId.toString(), levelIndex: this._currentLevelSession.levelIndex, gameId: this._gameFlag, progress: this._currentLevelSession.progress, repeatCount: Number((_b = (_a = this._currentEnterParams) === null || _a === void 0 ? void 0 : _a.repeat) !== null && _b !== void 0 ? _b : 0) });
|
|
3814
3931
|
}
|
|
3815
3932
|
onLevelStart(id, index, data) {
|
|
3816
3933
|
this._currentEnterParams = data;
|
|
@@ -4109,7 +4226,7 @@ class LaunchAnalyticsAble {
|
|
|
4109
4226
|
* 标记应用准备就绪,开始统计启动时间
|
|
4110
4227
|
*/
|
|
4111
4228
|
ready() {
|
|
4112
|
-
this._baseAble.time(
|
|
4229
|
+
this._baseAble.time(AnalyticsBehavior.APP_LAUNCH);
|
|
4113
4230
|
}
|
|
4114
4231
|
/**
|
|
4115
4232
|
* 上报启动事件
|
|
@@ -4118,7 +4235,7 @@ class LaunchAnalyticsAble {
|
|
|
4118
4235
|
*/
|
|
4119
4236
|
report(name, data) {
|
|
4120
4237
|
const payload = Object.assign(Object.assign({}, (data || {})), { name });
|
|
4121
|
-
this._baseAble.report(
|
|
4238
|
+
this._baseAble.report(AnalyticsBehavior.APP_LAUNCH, payload);
|
|
4122
4239
|
}
|
|
4123
4240
|
}
|
|
4124
4241
|
|
|
@@ -4336,7 +4453,9 @@ class SessionAnalyticsAble {
|
|
|
4336
4453
|
this._dimension = new SessionDimension();
|
|
4337
4454
|
}
|
|
4338
4455
|
recordLogin() {
|
|
4339
|
-
this._baseAble.report(
|
|
4456
|
+
this._baseAble.report(AnalyticsBehavior.SESSION_LOGIN, {
|
|
4457
|
+
options: JSON.stringify(publisher.publisher.enterOptions.getAllOption()),
|
|
4458
|
+
});
|
|
4340
4459
|
this._dimension.recordLogin();
|
|
4341
4460
|
}
|
|
4342
4461
|
updateSessionDuration() {
|
|
@@ -4418,9 +4537,15 @@ class SocialAnalyticsAble {
|
|
|
4418
4537
|
this._baseAble = baseAble;
|
|
4419
4538
|
this._socialDimension = new SocialDimension();
|
|
4420
4539
|
}
|
|
4540
|
+
share(data) {
|
|
4541
|
+
this._baseAble.report(AnalyticsBehavior.SOCIAL_SHARE, data);
|
|
4542
|
+
data.phase === "success" && this._socialDimension.recordShare();
|
|
4543
|
+
}
|
|
4544
|
+
/**
|
|
4545
|
+
* @deprecated 请改用 share,并明确传入分享阶段。
|
|
4546
|
+
*/
|
|
4421
4547
|
recordShare(data) {
|
|
4422
|
-
this.
|
|
4423
|
-
this._socialDimension.recordShare();
|
|
4548
|
+
this.share(Object.assign(Object.assign({}, data), { phase: "success" }));
|
|
4424
4549
|
}
|
|
4425
4550
|
recordInvite(success = false) {
|
|
4426
4551
|
this._socialDimension.recordInvite(success);
|
|
@@ -4432,16 +4557,104 @@ class SocialAnalyticsAble {
|
|
|
4432
4557
|
this._socialDimension.recordInteraction();
|
|
4433
4558
|
}
|
|
4434
4559
|
recordSubscribeShow(name) {
|
|
4435
|
-
this._baseAble.report(
|
|
4560
|
+
this._baseAble.report(AnalyticsBehavior.SOCIAL_SUBSCRIBE_SHOW, { name });
|
|
4436
4561
|
}
|
|
4437
4562
|
recordSubscribe(name, code) {
|
|
4438
|
-
this._baseAble.report(
|
|
4563
|
+
this._baseAble.report(AnalyticsBehavior.SOCIAL_SUBSCRIBE, { name, code });
|
|
4439
4564
|
}
|
|
4440
4565
|
getMetrics() {
|
|
4441
4566
|
return this._socialDimension.getMetrics();
|
|
4442
4567
|
}
|
|
4443
4568
|
}
|
|
4444
4569
|
|
|
4570
|
+
/**
|
|
4571
|
+
* 新手引导统计能力。只提供稳定的业务动作,不维护引导流程状态。
|
|
4572
|
+
*/
|
|
4573
|
+
class TutorialAnalyticsAble {
|
|
4574
|
+
constructor(_baseAble) {
|
|
4575
|
+
this._baseAble = _baseAble;
|
|
4576
|
+
}
|
|
4577
|
+
begin(data) {
|
|
4578
|
+
this._baseAble.report(AnalyticsBehavior.TUTORIAL_BEGIN, data);
|
|
4579
|
+
}
|
|
4580
|
+
complete(data) {
|
|
4581
|
+
this._baseAble.report(AnalyticsBehavior.TUTORIAL_COMPLETE, data);
|
|
4582
|
+
}
|
|
4583
|
+
skip(data) {
|
|
4584
|
+
this._baseAble.report(AnalyticsBehavior.TUTORIAL_SKIP, data);
|
|
4585
|
+
}
|
|
4586
|
+
}
|
|
4587
|
+
|
|
4588
|
+
/**
|
|
4589
|
+
* 支付漏斗统计能力。价格由业务提供,value 由框架按商品明细统一计算。
|
|
4590
|
+
*/
|
|
4591
|
+
class PayAnalyticsAble {
|
|
4592
|
+
constructor(_baseAble) {
|
|
4593
|
+
this._baseAble = _baseAble;
|
|
4594
|
+
}
|
|
4595
|
+
begin(data) {
|
|
4596
|
+
this.report(AnalyticsBehavior.PAY_BEGIN, data);
|
|
4597
|
+
}
|
|
4598
|
+
purchase(data) {
|
|
4599
|
+
this.report(AnalyticsBehavior.PAY_PURCHASE, data);
|
|
4600
|
+
}
|
|
4601
|
+
pending(data) {
|
|
4602
|
+
this.report(AnalyticsBehavior.PAY_PENDING, data);
|
|
4603
|
+
}
|
|
4604
|
+
cancel(data) {
|
|
4605
|
+
this.report(AnalyticsBehavior.PAY_CANCEL, data);
|
|
4606
|
+
}
|
|
4607
|
+
fail(data) {
|
|
4608
|
+
this.report(AnalyticsBehavior.PAY_FAIL, data);
|
|
4609
|
+
}
|
|
4610
|
+
report(eventName, data) {
|
|
4611
|
+
const normalized = this.normalize(data);
|
|
4612
|
+
if (!normalized) {
|
|
4613
|
+
return;
|
|
4614
|
+
}
|
|
4615
|
+
this._baseAble.report(eventName, normalized);
|
|
4616
|
+
}
|
|
4617
|
+
normalize(data) {
|
|
4618
|
+
const transactionId = String(data && data.transactionId || "").trim();
|
|
4619
|
+
const currency = String(data && data.currency || "").trim().toUpperCase();
|
|
4620
|
+
const items = data && data.items;
|
|
4621
|
+
if (!transactionId) {
|
|
4622
|
+
return this.invalid("transactionId 不能为空");
|
|
4623
|
+
}
|
|
4624
|
+
if (!/^[A-Z]{3}$/.test(currency)) {
|
|
4625
|
+
return this.invalid(`currency 必须是三位大写货币代码: ${currency}`);
|
|
4626
|
+
}
|
|
4627
|
+
if (!Array.isArray(items) || items.length === 0) {
|
|
4628
|
+
return this.invalid("items 不能为空");
|
|
4629
|
+
}
|
|
4630
|
+
const normalizedItems = [];
|
|
4631
|
+
let value = 0;
|
|
4632
|
+
for (let i = 0; i < items.length; i++) {
|
|
4633
|
+
const item = items[i];
|
|
4634
|
+
const itemId = String(item && item.itemId || "").trim();
|
|
4635
|
+
const price = Number(item && item.price);
|
|
4636
|
+
const quantity = item && item.quantity === undefined
|
|
4637
|
+
? 1
|
|
4638
|
+
: Number(item.quantity);
|
|
4639
|
+
if (!itemId || !Number.isFinite(price) || price < 0) {
|
|
4640
|
+
return this.invalid(`items[${i}] 的 itemId/price 无效`);
|
|
4641
|
+
}
|
|
4642
|
+
if (!Number.isInteger(quantity) || quantity <= 0) {
|
|
4643
|
+
return this.invalid(`items[${i}] 的 quantity 必须是正整数`);
|
|
4644
|
+
}
|
|
4645
|
+
const normalizedItem = Object.assign(Object.assign({}, item), { itemId, price, quantity });
|
|
4646
|
+
normalizedItems.push(normalizedItem);
|
|
4647
|
+
value += price * quantity;
|
|
4648
|
+
}
|
|
4649
|
+
return Object.assign(Object.assign({}, data), { transactionId,
|
|
4650
|
+
currency, items: normalizedItems, value: Math.round(value * 1000000) / 1000000 });
|
|
4651
|
+
}
|
|
4652
|
+
invalid(message) {
|
|
4653
|
+
console.warn(`[Analytics.pay] ${message},本次事件已忽略。`);
|
|
4654
|
+
return null;
|
|
4655
|
+
}
|
|
4656
|
+
}
|
|
4657
|
+
|
|
4445
4658
|
/**
|
|
4446
4659
|
* 请求进度改变时调度。
|
|
4447
4660
|
* @eventType Event.PROGRESS
|
|
@@ -6214,10 +6427,13 @@ class KeytopsAnalyticsSender extends EmptyAnalyticsSender {
|
|
|
6214
6427
|
}
|
|
6215
6428
|
});
|
|
6216
6429
|
}
|
|
6217
|
-
|
|
6430
|
+
mapEvent(eventName, eventData) {
|
|
6431
|
+
return mapCanonicalEventToLegacy(eventName, eventData);
|
|
6432
|
+
}
|
|
6433
|
+
send(eventName, eventData, userProperties) {
|
|
6218
6434
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6219
|
-
const payload =
|
|
6220
|
-
? Object.assign({},
|
|
6435
|
+
const payload = eventData && typeof eventData === "object" && !Array.isArray(eventData)
|
|
6436
|
+
? Object.assign(Object.assign({}, userProperties), eventData) : Object.assign({}, userProperties);
|
|
6221
6437
|
let msg_data = {
|
|
6222
6438
|
appid: publisher.appId,
|
|
6223
6439
|
openid: String(storage.userId || publisher.login.openID || ""),
|
|
@@ -6238,6 +6454,276 @@ class KeytopsAnalyticsSender extends EmptyAnalyticsSender {
|
|
|
6238
6454
|
}
|
|
6239
6455
|
}
|
|
6240
6456
|
|
|
6457
|
+
/*
|
|
6458
|
+
@name: NativeHelper
|
|
6459
|
+
@desc: 原生函数调用代理
|
|
6460
|
+
@author: timoo
|
|
6461
|
+
@date: 2022/11/26
|
|
6462
|
+
*/
|
|
6463
|
+
class NativeHelper {
|
|
6464
|
+
static call(className, methodName, ...args) {
|
|
6465
|
+
NativeHelper.impl.call(className, methodName, ...args);
|
|
6466
|
+
}
|
|
6467
|
+
static callWithReturnType(className, methodName, returnType, ...args) {
|
|
6468
|
+
return NativeHelper.impl.callWithReturnType(className, methodName, returnType, ...args);
|
|
6469
|
+
}
|
|
6470
|
+
static registerCallback(caller, method, times, ...args) {
|
|
6471
|
+
return NativeHelper.impl.registerCallback(caller, method, times, ...args);
|
|
6472
|
+
}
|
|
6473
|
+
static registerCallbackOnce(caller, method, ...args) {
|
|
6474
|
+
return NativeHelper.impl.registerCallback(caller, method, 1, ...args);
|
|
6475
|
+
}
|
|
6476
|
+
static get impl() {
|
|
6477
|
+
if (this._impl == null) {
|
|
6478
|
+
this._impl = Injector.getInject(NativeHelper.KEY);
|
|
6479
|
+
}
|
|
6480
|
+
if (this._impl == null) {
|
|
6481
|
+
throw new Error(NativeHelper.KEY + " 未注入!");
|
|
6482
|
+
}
|
|
6483
|
+
return this._impl;
|
|
6484
|
+
}
|
|
6485
|
+
}
|
|
6486
|
+
NativeHelper.KEY = "NativeHelper";
|
|
6487
|
+
|
|
6488
|
+
const DEFAULT_IGNORED_PARAMETERS = [
|
|
6489
|
+
"device_system",
|
|
6490
|
+
"device_platform",
|
|
6491
|
+
"device_brand",
|
|
6492
|
+
"device_model",
|
|
6493
|
+
"app_version",
|
|
6494
|
+
];
|
|
6495
|
+
const RESERVED_PREFIXES = ["firebase_", "google_", "ga_"];
|
|
6496
|
+
const RESERVED_USER_PROPERTIES = new Set([
|
|
6497
|
+
"first_open_time",
|
|
6498
|
+
"first_visit_time",
|
|
6499
|
+
"last_deep_link_referrer",
|
|
6500
|
+
"user_id",
|
|
6501
|
+
"first_open_after_install",
|
|
6502
|
+
]);
|
|
6503
|
+
const FIREBASE_EVENT_NAMES = {
|
|
6504
|
+
[AnalyticsBehavior.SESSION_LOGIN]: "login",
|
|
6505
|
+
[AnalyticsBehavior.LEVEL_START]: "level_start",
|
|
6506
|
+
[AnalyticsBehavior.LEVEL_END]: "level_end",
|
|
6507
|
+
[AnalyticsBehavior.AD_IMPRESSION]: "ad_impression",
|
|
6508
|
+
[AnalyticsBehavior.TUTORIAL_BEGIN]: "tutorial_begin",
|
|
6509
|
+
[AnalyticsBehavior.TUTORIAL_COMPLETE]: "tutorial_complete",
|
|
6510
|
+
[AnalyticsBehavior.TUTORIAL_SKIP]: "tutorial_skip",
|
|
6511
|
+
[AnalyticsBehavior.PAY_BEGIN]: "begin_checkout",
|
|
6512
|
+
[AnalyticsBehavior.PAY_PURCHASE]: "purchase",
|
|
6513
|
+
[AnalyticsBehavior.PAY_PENDING]: "purchase_pending",
|
|
6514
|
+
[AnalyticsBehavior.PAY_CANCEL]: "purchase_cancel",
|
|
6515
|
+
[AnalyticsBehavior.PAY_FAIL]: "purchase_fail",
|
|
6516
|
+
};
|
|
6517
|
+
/**
|
|
6518
|
+
* Firebase Android Analytics 上报器。
|
|
6519
|
+
*
|
|
6520
|
+
* TS 端属于框架,Java Bridge 仍由具体游戏工程提供。非原生环境会安全忽略调用。
|
|
6521
|
+
*/
|
|
6522
|
+
class FirebaseAnalyticsSender extends EmptyAnalyticsSender {
|
|
6523
|
+
constructor(config, exclude) {
|
|
6524
|
+
super(exclude);
|
|
6525
|
+
this._lastUserProperties = {};
|
|
6526
|
+
if (!config || !String(config.bridgeClassName || "").trim()) {
|
|
6527
|
+
throw new Error("FirebaseAnalyticsSender.bridgeClassName 不能为空");
|
|
6528
|
+
}
|
|
6529
|
+
this._config = {
|
|
6530
|
+
bridgeClassName: String(config.bridgeClassName).trim(),
|
|
6531
|
+
collectionEnabled: config.collectionEnabled !== false,
|
|
6532
|
+
ignoredParameters: config.ignoredParameters || DEFAULT_IGNORED_PARAMETERS,
|
|
6533
|
+
maxParameters: Math.min(Math.max(config.maxParameters || 25, 1), 25),
|
|
6534
|
+
supportsStructuredItems: !!config.supportsStructuredItems,
|
|
6535
|
+
debug: !!config.debug,
|
|
6536
|
+
};
|
|
6537
|
+
this._ignoredParameters = new Set(this._config.ignoredParameters);
|
|
6538
|
+
if (this.canSend) {
|
|
6539
|
+
NativeHelper.call(this._config.bridgeClassName, "setCollectionEnabled", this._config.collectionEnabled);
|
|
6540
|
+
}
|
|
6541
|
+
}
|
|
6542
|
+
get canSend() {
|
|
6543
|
+
var _a;
|
|
6544
|
+
const target = globalThis;
|
|
6545
|
+
const sys = target.cc && target.cc.sys;
|
|
6546
|
+
if (sys) {
|
|
6547
|
+
return !!(sys.isNative &&
|
|
6548
|
+
sys.os === ((_a = sys.OS) === null || _a === void 0 ? void 0 : _a.ANDROID) &&
|
|
6549
|
+
(target.jsb || target.native));
|
|
6550
|
+
}
|
|
6551
|
+
return !!(target.jsb || target.native);
|
|
6552
|
+
}
|
|
6553
|
+
setUserId(userId) {
|
|
6554
|
+
const normalized = userId == null ? null : String(userId).trim();
|
|
6555
|
+
const nextUserId = normalized ? this.truncate(normalized, 256) : null;
|
|
6556
|
+
if (this._lastUserId === nextUserId) {
|
|
6557
|
+
return;
|
|
6558
|
+
}
|
|
6559
|
+
this._lastUserId = nextUserId;
|
|
6560
|
+
if (!this.canSend) {
|
|
6561
|
+
return;
|
|
6562
|
+
}
|
|
6563
|
+
NativeHelper.call(this._config.bridgeClassName, nextUserId ? "setUserId" : "clearUserId", ...(nextUserId ? [nextUserId] : []));
|
|
6564
|
+
}
|
|
6565
|
+
mapEvent(eventName, eventData) {
|
|
6566
|
+
const data = this.mapParameters(eventName, eventData);
|
|
6567
|
+
let mappedName = FIREBASE_EVENT_NAMES[eventName] || eventName.replace(/\./g, "_");
|
|
6568
|
+
if (eventName === AnalyticsBehavior.SOCIAL_SHARE) {
|
|
6569
|
+
const phase = String(data.phase || "");
|
|
6570
|
+
mappedName = phase === "success" ? "share" : `share_${phase || "unknown"}`;
|
|
6571
|
+
}
|
|
6572
|
+
else if (eventName === AnalyticsBehavior.AD_LIFECYCLE) {
|
|
6573
|
+
mappedName = "ad_lifecycle";
|
|
6574
|
+
}
|
|
6575
|
+
return { eventName: mappedName, data };
|
|
6576
|
+
}
|
|
6577
|
+
send(eventName, eventData, userProperties) {
|
|
6578
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6579
|
+
if (!this.canSend || !this._config.collectionEnabled) {
|
|
6580
|
+
return;
|
|
6581
|
+
}
|
|
6582
|
+
if (!this.isValidName(eventName, 40)) {
|
|
6583
|
+
this.warn(`忽略无效 Firebase 事件名: ${eventName}`);
|
|
6584
|
+
return;
|
|
6585
|
+
}
|
|
6586
|
+
if ((eventName === "purchase" || eventName === "begin_checkout") &&
|
|
6587
|
+
Array.isArray(eventData.items) &&
|
|
6588
|
+
!this._config.supportsStructuredItems) {
|
|
6589
|
+
this.syncUserProperties(userProperties);
|
|
6590
|
+
this.warn("当前 Java Bridge 不支持 Bundle[] items,支付事件已忽略。");
|
|
6591
|
+
return;
|
|
6592
|
+
}
|
|
6593
|
+
this.syncUserProperties(userProperties);
|
|
6594
|
+
const parameters = this.normalizeParameters(eventData);
|
|
6595
|
+
NativeHelper.call(this._config.bridgeClassName, "logEvent", eventName, JSON.stringify(parameters));
|
|
6596
|
+
});
|
|
6597
|
+
}
|
|
6598
|
+
mapParameters(eventName, eventData) {
|
|
6599
|
+
const data = Object.assign({}, eventData);
|
|
6600
|
+
if (eventName === AnalyticsBehavior.LEVEL_START ||
|
|
6601
|
+
eventName === AnalyticsBehavior.LEVEL_END) {
|
|
6602
|
+
if (data.levelId !== undefined) {
|
|
6603
|
+
data.level_name = data.levelId;
|
|
6604
|
+
delete data.levelId;
|
|
6605
|
+
}
|
|
6606
|
+
}
|
|
6607
|
+
if (eventName === AnalyticsBehavior.SOCIAL_SHARE) {
|
|
6608
|
+
if (data.contentType !== undefined) {
|
|
6609
|
+
data.content_type = data.contentType;
|
|
6610
|
+
delete data.contentType;
|
|
6611
|
+
}
|
|
6612
|
+
if (data.itemId !== undefined) {
|
|
6613
|
+
data.item_id = data.itemId;
|
|
6614
|
+
delete data.itemId;
|
|
6615
|
+
}
|
|
6616
|
+
}
|
|
6617
|
+
if (eventName === AnalyticsBehavior.PAY_BEGIN ||
|
|
6618
|
+
eventName === AnalyticsBehavior.PAY_PURCHASE) {
|
|
6619
|
+
if (data.transactionId !== undefined) {
|
|
6620
|
+
data.transaction_id = data.transactionId;
|
|
6621
|
+
delete data.transactionId;
|
|
6622
|
+
}
|
|
6623
|
+
if (Array.isArray(data.items)) {
|
|
6624
|
+
data.items = data.items.map((item) => {
|
|
6625
|
+
if (item.itemId === undefined) {
|
|
6626
|
+
return Object.assign({}, item);
|
|
6627
|
+
}
|
|
6628
|
+
const mapped = Object.assign(Object.assign({}, item), { item_id: item.itemId });
|
|
6629
|
+
delete mapped.itemId;
|
|
6630
|
+
if (item.itemName !== undefined) {
|
|
6631
|
+
mapped.item_name = item.itemName;
|
|
6632
|
+
delete mapped.itemName;
|
|
6633
|
+
}
|
|
6634
|
+
if (item.itemCategory !== undefined) {
|
|
6635
|
+
mapped.item_category = item.itemCategory;
|
|
6636
|
+
delete mapped.itemCategory;
|
|
6637
|
+
}
|
|
6638
|
+
return mapped;
|
|
6639
|
+
});
|
|
6640
|
+
}
|
|
6641
|
+
}
|
|
6642
|
+
return data;
|
|
6643
|
+
}
|
|
6644
|
+
syncUserProperties(properties) {
|
|
6645
|
+
const previous = this._lastUserProperties;
|
|
6646
|
+
Object.keys(previous).forEach((key) => {
|
|
6647
|
+
if (!Object.prototype.hasOwnProperty.call(properties, key)) {
|
|
6648
|
+
this.setUserProperty(key, null);
|
|
6649
|
+
}
|
|
6650
|
+
});
|
|
6651
|
+
Object.keys(properties).forEach((key) => {
|
|
6652
|
+
if (previous[key] !== properties[key]) {
|
|
6653
|
+
this.setUserProperty(key, properties[key]);
|
|
6654
|
+
}
|
|
6655
|
+
});
|
|
6656
|
+
this._lastUserProperties = Object.assign({}, properties);
|
|
6657
|
+
}
|
|
6658
|
+
setUserProperty(key, value) {
|
|
6659
|
+
if (!this.isValidName(key, 24) || RESERVED_USER_PROPERTIES.has(key)) {
|
|
6660
|
+
this.warn(`忽略无效 Firebase 用户属性: ${key}`);
|
|
6661
|
+
return;
|
|
6662
|
+
}
|
|
6663
|
+
if (value == null) {
|
|
6664
|
+
NativeHelper.call(this._config.bridgeClassName, "clearUserProperty", key);
|
|
6665
|
+
return;
|
|
6666
|
+
}
|
|
6667
|
+
const normalized = typeof value === "boolean"
|
|
6668
|
+
? (value ? "1" : "0")
|
|
6669
|
+
: String(value);
|
|
6670
|
+
NativeHelper.call(this._config.bridgeClassName, "setUserProperty", key, this.truncate(normalized, 36));
|
|
6671
|
+
}
|
|
6672
|
+
normalizeParameters(data) {
|
|
6673
|
+
const result = {};
|
|
6674
|
+
const keys = Object.keys(data || {});
|
|
6675
|
+
for (let i = 0; i < keys.length; i++) {
|
|
6676
|
+
if (Object.keys(result).length >= this._config.maxParameters) {
|
|
6677
|
+
this.warn(`Firebase 事件参数超过 ${this._config.maxParameters} 个,后续参数已忽略。`);
|
|
6678
|
+
break;
|
|
6679
|
+
}
|
|
6680
|
+
const key = keys[i];
|
|
6681
|
+
if (this._ignoredParameters.has(key) || !this.isValidName(key, 40)) {
|
|
6682
|
+
continue;
|
|
6683
|
+
}
|
|
6684
|
+
const value = data[key];
|
|
6685
|
+
if (key === "items" && Array.isArray(value)) {
|
|
6686
|
+
if (this._config.supportsStructuredItems) {
|
|
6687
|
+
result[key] = value.map((item) => (Object.assign({}, item)));
|
|
6688
|
+
}
|
|
6689
|
+
continue;
|
|
6690
|
+
}
|
|
6691
|
+
const normalized = this.normalizeValue(value);
|
|
6692
|
+
if (normalized !== undefined) {
|
|
6693
|
+
result[key] = normalized;
|
|
6694
|
+
}
|
|
6695
|
+
}
|
|
6696
|
+
return result;
|
|
6697
|
+
}
|
|
6698
|
+
normalizeValue(value) {
|
|
6699
|
+
if (value == null) {
|
|
6700
|
+
return undefined;
|
|
6701
|
+
}
|
|
6702
|
+
if (typeof value === "boolean") {
|
|
6703
|
+
return value ? 1 : 0;
|
|
6704
|
+
}
|
|
6705
|
+
if (typeof value === "number") {
|
|
6706
|
+
return Number.isFinite(value) ? value : undefined;
|
|
6707
|
+
}
|
|
6708
|
+
if (typeof value === "string") {
|
|
6709
|
+
return this.truncate(value, 100);
|
|
6710
|
+
}
|
|
6711
|
+
return undefined;
|
|
6712
|
+
}
|
|
6713
|
+
isValidName(name, maxLength) {
|
|
6714
|
+
if (!name || name.length > maxLength || !/^[A-Za-z][A-Za-z0-9_]*$/.test(name)) {
|
|
6715
|
+
return false;
|
|
6716
|
+
}
|
|
6717
|
+
return !RESERVED_PREFIXES.some((prefix) => name.startsWith(prefix));
|
|
6718
|
+
}
|
|
6719
|
+
truncate(value, maxLength) {
|
|
6720
|
+
return value.length > maxLength ? value.slice(0, maxLength) : value;
|
|
6721
|
+
}
|
|
6722
|
+
warn(message) {
|
|
6723
|
+
this._config.debug && console.warn(`[FirebaseAnalyticsSender] ${message}`);
|
|
6724
|
+
}
|
|
6725
|
+
}
|
|
6726
|
+
|
|
6241
6727
|
class AnalyticsManager {
|
|
6242
6728
|
constructor() {
|
|
6243
6729
|
this._base = null;
|
|
@@ -6246,6 +6732,9 @@ class AnalyticsManager {
|
|
|
6246
6732
|
this._session = null;
|
|
6247
6733
|
this._launch = null;
|
|
6248
6734
|
this._social = null;
|
|
6735
|
+
this._tutorial = null;
|
|
6736
|
+
this._pay = null;
|
|
6737
|
+
this._abilityMap = new Map();
|
|
6249
6738
|
this._assignmentSender = null;
|
|
6250
6739
|
}
|
|
6251
6740
|
hasRelayUrl(config) {
|
|
@@ -6333,6 +6822,46 @@ class AnalyticsManager {
|
|
|
6333
6822
|
}
|
|
6334
6823
|
return this._social;
|
|
6335
6824
|
}
|
|
6825
|
+
/**
|
|
6826
|
+
* 新手引导统计能力
|
|
6827
|
+
*/
|
|
6828
|
+
get tutorial() {
|
|
6829
|
+
if (!this.base.inited) {
|
|
6830
|
+
throw new Error("请先通过enable初始化基础统计能力");
|
|
6831
|
+
}
|
|
6832
|
+
if (!this._tutorial) {
|
|
6833
|
+
this._tutorial = new TutorialAnalyticsAble(this.base);
|
|
6834
|
+
}
|
|
6835
|
+
return this._tutorial;
|
|
6836
|
+
}
|
|
6837
|
+
/**
|
|
6838
|
+
* 支付漏斗统计能力
|
|
6839
|
+
*/
|
|
6840
|
+
get pay() {
|
|
6841
|
+
if (!this.base.inited) {
|
|
6842
|
+
throw new Error("请先通过enable初始化基础统计能力");
|
|
6843
|
+
}
|
|
6844
|
+
if (!this._pay) {
|
|
6845
|
+
this._pay = new PayAnalyticsAble(this.base);
|
|
6846
|
+
}
|
|
6847
|
+
return this._pay;
|
|
6848
|
+
}
|
|
6849
|
+
/**
|
|
6850
|
+
* 获取由 AnalyticsManager 代管的自定义统计能力。
|
|
6851
|
+
*
|
|
6852
|
+
* 同一个构造器只会创建一个实例;自定义能力应通过构造参数接收基础统计能力。
|
|
6853
|
+
*/
|
|
6854
|
+
getAbility(abilityClass) {
|
|
6855
|
+
if (!this.base.inited) {
|
|
6856
|
+
throw new Error("请先通过enable初始化基础统计能力");
|
|
6857
|
+
}
|
|
6858
|
+
let instance = this._abilityMap.get(abilityClass);
|
|
6859
|
+
if (!instance) {
|
|
6860
|
+
instance = new abilityClass(this.base);
|
|
6861
|
+
this._abilityMap.set(abilityClass, instance);
|
|
6862
|
+
}
|
|
6863
|
+
return instance;
|
|
6864
|
+
}
|
|
6336
6865
|
/**
|
|
6337
6866
|
* 启用统计(基础统计能力)
|
|
6338
6867
|
* @param debugMode 调试模式,是否打印日志信息,默认为false
|
|
@@ -6398,7 +6927,7 @@ class AnalyticsManager {
|
|
|
6398
6927
|
if (levelid !== undefined) {
|
|
6399
6928
|
payload.level_id = levelid;
|
|
6400
6929
|
}
|
|
6401
|
-
this.assignmentSender.send(eventName, payload);
|
|
6930
|
+
this.assignmentSender.send(eventName, payload, {});
|
|
6402
6931
|
});
|
|
6403
6932
|
}
|
|
6404
6933
|
}
|
|
@@ -6716,37 +7245,6 @@ Application.KEY = "Application";
|
|
|
6716
7245
|
*/
|
|
6717
7246
|
const App = new Application();
|
|
6718
7247
|
|
|
6719
|
-
/*
|
|
6720
|
-
@name: NativeHelper
|
|
6721
|
-
@desc: 原生函数调用代理
|
|
6722
|
-
@author: timoo
|
|
6723
|
-
@date: 2022/11/26
|
|
6724
|
-
*/
|
|
6725
|
-
class NativeHelper {
|
|
6726
|
-
static call(className, methodName, ...args) {
|
|
6727
|
-
NativeHelper.impl.call(className, methodName, ...args);
|
|
6728
|
-
}
|
|
6729
|
-
static callWithReturnType(className, methodName, returnType, ...args) {
|
|
6730
|
-
return NativeHelper.impl.callWithReturnType(className, methodName, returnType, ...args);
|
|
6731
|
-
}
|
|
6732
|
-
static registerCallback(caller, method, times, ...args) {
|
|
6733
|
-
return NativeHelper.impl.registerCallback(caller, method, times, ...args);
|
|
6734
|
-
}
|
|
6735
|
-
static registerCallbackOnce(caller, method, ...args) {
|
|
6736
|
-
return NativeHelper.impl.registerCallback(caller, method, 1, ...args);
|
|
6737
|
-
}
|
|
6738
|
-
static get impl() {
|
|
6739
|
-
if (this._impl == null) {
|
|
6740
|
-
this._impl = Injector.getInject(NativeHelper.KEY);
|
|
6741
|
-
}
|
|
6742
|
-
if (this._impl == null) {
|
|
6743
|
-
throw new Error(NativeHelper.KEY + " 未注入!");
|
|
6744
|
-
}
|
|
6745
|
-
return this._impl;
|
|
6746
|
-
}
|
|
6747
|
-
}
|
|
6748
|
-
NativeHelper.KEY = "NativeHelper";
|
|
6749
|
-
|
|
6750
7248
|
/*
|
|
6751
7249
|
@name: BusinessCenter
|
|
6752
7250
|
@desc: 事务中心,管理事务
|
|
@@ -9872,15 +10370,18 @@ class IShareAble {
|
|
|
9872
10370
|
let internalQuery = dataArr.join("&");
|
|
9873
10371
|
return query ? query + "&" + internalQuery : internalQuery;
|
|
9874
10372
|
}
|
|
9875
|
-
_report(analyticsName,
|
|
9876
|
-
let data = {
|
|
10373
|
+
_report(analyticsName, phase, method = "text_or_image") {
|
|
10374
|
+
let data = { phase, method };
|
|
9877
10375
|
if (typeof analyticsName === "string") {
|
|
9878
|
-
data.
|
|
10376
|
+
data.itemId = analyticsName;
|
|
9879
10377
|
}
|
|
9880
10378
|
else if (typeof analyticsName == "object") {
|
|
9881
10379
|
Object.assign(data, analyticsName);
|
|
10380
|
+
if (data.itemId === undefined && data.name !== undefined) {
|
|
10381
|
+
data.itemId = data.name;
|
|
10382
|
+
}
|
|
9882
10383
|
}
|
|
9883
|
-
analytics.social.
|
|
10384
|
+
analytics.social.share(data);
|
|
9884
10385
|
}
|
|
9885
10386
|
/**
|
|
9886
10387
|
* 分享图片或者文字
|
|
@@ -10619,9 +11120,12 @@ class NativeAnalyticsSender extends EmptyAnalyticsSender {
|
|
|
10619
11120
|
this._className = "sdk.Share";
|
|
10620
11121
|
this._className = className;
|
|
10621
11122
|
}
|
|
10622
|
-
|
|
11123
|
+
mapEvent(eventName, eventData) {
|
|
11124
|
+
return mapCanonicalEventToFlatName(eventName, eventData);
|
|
11125
|
+
}
|
|
11126
|
+
send(eventName, eventData, userProperties) {
|
|
10623
11127
|
return new Promise((success) => {
|
|
10624
|
-
NativeHelper.call(this._className, "report", eventName, JSON.stringify(
|
|
11128
|
+
NativeHelper.call(this._className, "report", eventName, JSON.stringify(Object.assign(Object.assign({}, userProperties), eventData)));
|
|
10625
11129
|
success();
|
|
10626
11130
|
});
|
|
10627
11131
|
}
|
|
@@ -10892,14 +11396,14 @@ class NativeShare extends IShareAble {
|
|
|
10892
11396
|
shareTextOrImage(analyticsName, data) {
|
|
10893
11397
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10894
11398
|
console.log("发起分享:", analyticsName, data);
|
|
10895
|
-
this._report(analyticsName, "
|
|
11399
|
+
this._report(analyticsName, "begin");
|
|
10896
11400
|
return this._share("textOrImage", analyticsName, data);
|
|
10897
11401
|
});
|
|
10898
11402
|
}
|
|
10899
11403
|
shareVideo(analyticsName, data) {
|
|
10900
11404
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10901
11405
|
console.log("发起视频分享:", analyticsName, data);
|
|
10902
|
-
this._report(analyticsName, "
|
|
11406
|
+
this._report(analyticsName, "begin", "video");
|
|
10903
11407
|
return this._share("video", analyticsName, data);
|
|
10904
11408
|
});
|
|
10905
11409
|
}
|
|
@@ -10908,12 +11412,12 @@ class NativeShare extends IShareAble {
|
|
|
10908
11412
|
let callbacks = [];
|
|
10909
11413
|
callbacks.push(NativeHelper.registerCallbackOnce(this, () => {
|
|
10910
11414
|
console.log("分享完成,分享是否成功:", true);
|
|
10911
|
-
this._report(analyticsName, "
|
|
11415
|
+
this._report(analyticsName, "success", action === "video" ? "video" : "text_or_image");
|
|
10912
11416
|
resolve(true);
|
|
10913
11417
|
}));
|
|
10914
11418
|
callbacks.push(NativeHelper.registerCallbackOnce(this, () => {
|
|
10915
11419
|
console.log("分享完成,分享是否成功:", false);
|
|
10916
|
-
this._report(analyticsName, "
|
|
11420
|
+
this._report(analyticsName, "fail", action === "video" ? "video" : "text_or_image");
|
|
10917
11421
|
resolve(false);
|
|
10918
11422
|
}));
|
|
10919
11423
|
if (typeof data == "string") {
|
|
@@ -11358,10 +11862,13 @@ class TKAd extends IADAble {
|
|
|
11358
11862
|
* TK事件上报器(window['tt'].reportAnalytics)
|
|
11359
11863
|
*/
|
|
11360
11864
|
class TKAnalyticsSender extends EmptyAnalyticsSender {
|
|
11361
|
-
|
|
11865
|
+
mapEvent(eventName, eventData) {
|
|
11866
|
+
return mapCanonicalEventToFlatName(eventName, eventData);
|
|
11867
|
+
}
|
|
11868
|
+
send(eventName, eventData, userProperties) {
|
|
11362
11869
|
var _a, _b;
|
|
11363
11870
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11364
|
-
(_b = (_a = window['TTMinis']) === null || _a === void 0 ? void 0 : _a.game) === null || _b === void 0 ? void 0 : _b.reportEvent(eventName,
|
|
11871
|
+
(_b = (_a = window['TTMinis']) === null || _a === void 0 ? void 0 : _a.game) === null || _b === void 0 ? void 0 : _b.reportEvent(eventName, Object.assign(Object.assign({}, userProperties), eventData));
|
|
11365
11872
|
});
|
|
11366
11873
|
}
|
|
11367
11874
|
}
|
|
@@ -11383,9 +11890,12 @@ class WXPay extends IPayAble {
|
|
|
11383
11890
|
* 微信事件上报器(window['wx'].reportEvent)
|
|
11384
11891
|
*/
|
|
11385
11892
|
class WXAnalyticsSender extends EmptyAnalyticsSender {
|
|
11386
|
-
|
|
11893
|
+
mapEvent(eventName, eventData) {
|
|
11894
|
+
return mapCanonicalEventToFlatName(eventName, eventData);
|
|
11895
|
+
}
|
|
11896
|
+
send(eventName, eventData, userProperties) {
|
|
11387
11897
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11388
|
-
window['wx'].reportEvent(eventName,
|
|
11898
|
+
window['wx'].reportEvent(eventName, Object.assign(Object.assign({}, userProperties), eventData));
|
|
11389
11899
|
});
|
|
11390
11900
|
}
|
|
11391
11901
|
}
|
|
@@ -11446,7 +11956,7 @@ class WXShare extends IShareAble {
|
|
|
11446
11956
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11447
11957
|
return new Promise((resolve) => {
|
|
11448
11958
|
console.log("发起分享:", analyticsName, data);
|
|
11449
|
-
this._report(analyticsName, "
|
|
11959
|
+
this._report(analyticsName, "begin");
|
|
11450
11960
|
if (!this._wx) {
|
|
11451
11961
|
console.error("wx接口不存在!");
|
|
11452
11962
|
resolve(false);
|
|
@@ -11462,14 +11972,14 @@ class WXShare extends IShareAble {
|
|
|
11462
11972
|
let duration = Math.floor((Date.now() - shareTime) / 1000);
|
|
11463
11973
|
let shareResult = duration <= tempData.durationMax && duration >= tempData.durationMin;
|
|
11464
11974
|
console.log("分享完成,分享是否成功:", shareResult);
|
|
11465
|
-
this._report(analyticsName, "
|
|
11975
|
+
this._report(analyticsName, shareResult ? "success" : "fail");
|
|
11466
11976
|
resolve(shareResult);
|
|
11467
11977
|
};
|
|
11468
11978
|
App.onShow(onShareBack);
|
|
11469
11979
|
}
|
|
11470
11980
|
else {
|
|
11471
11981
|
console.log("分享完成,分享是否成功:", false);
|
|
11472
|
-
this._report(analyticsName, "
|
|
11982
|
+
this._report(analyticsName, "fail");
|
|
11473
11983
|
resolve(true);
|
|
11474
11984
|
}
|
|
11475
11985
|
});
|
|
@@ -12203,7 +12713,7 @@ class KSShare extends IShareAble {
|
|
|
12203
12713
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12204
12714
|
return new Promise((resolve) => {
|
|
12205
12715
|
console.log("发起分享:", data);
|
|
12206
|
-
this._report(analyticsName, "
|
|
12716
|
+
this._report(analyticsName, "begin");
|
|
12207
12717
|
if (!this._ks) {
|
|
12208
12718
|
console.error("快手接口不存在!");
|
|
12209
12719
|
resolve(false);
|
|
@@ -12212,12 +12722,12 @@ class KSShare extends IShareAble {
|
|
|
12212
12722
|
params.query = this._getShareQuery(analyticsName, params.query);
|
|
12213
12723
|
params.success = () => {
|
|
12214
12724
|
console.log("分享完成,分享是否成功:", true);
|
|
12215
|
-
this._report(analyticsName, "
|
|
12725
|
+
this._report(analyticsName, "success");
|
|
12216
12726
|
resolve(true);
|
|
12217
12727
|
};
|
|
12218
12728
|
params.fail = (e) => {
|
|
12219
12729
|
console.log("分享完成,分享是否成功:", false, e);
|
|
12220
|
-
this._report(analyticsName, "
|
|
12730
|
+
this._report(analyticsName, "fail");
|
|
12221
12731
|
resolve(false);
|
|
12222
12732
|
};
|
|
12223
12733
|
this._ks.shareAppMessage(params);
|
|
@@ -12226,8 +12736,10 @@ class KSShare extends IShareAble {
|
|
|
12226
12736
|
}
|
|
12227
12737
|
shareVideo(analyticsName, data) {
|
|
12228
12738
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12229
|
-
|
|
12230
|
-
|
|
12739
|
+
this._report(analyticsName, "begin", "video");
|
|
12740
|
+
const success = yield publisher.recordT().publicVideo(this._getShareQuery(analyticsName, data.query), data.mouldId);
|
|
12741
|
+
this._report(analyticsName, success ? "success" : "fail", "video");
|
|
12742
|
+
return success;
|
|
12231
12743
|
});
|
|
12232
12744
|
}
|
|
12233
12745
|
}
|
|
@@ -12348,7 +12860,7 @@ class TTShare extends IShareAble {
|
|
|
12348
12860
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12349
12861
|
return new Promise((resolve) => {
|
|
12350
12862
|
console.log("发起分享:", data);
|
|
12351
|
-
this._report(analyticsName, "
|
|
12863
|
+
this._report(analyticsName, "begin");
|
|
12352
12864
|
if (!this._tt) {
|
|
12353
12865
|
console.error("tt接口不存在!");
|
|
12354
12866
|
resolve(false);
|
|
@@ -12357,12 +12869,12 @@ class TTShare extends IShareAble {
|
|
|
12357
12869
|
params.query = this._getShareQuery(analyticsName, params.query);
|
|
12358
12870
|
params.success = () => {
|
|
12359
12871
|
console.log("分享完成,分享是否成功:", true);
|
|
12360
|
-
this._report(analyticsName, "
|
|
12872
|
+
this._report(analyticsName, "success");
|
|
12361
12873
|
resolve(true);
|
|
12362
12874
|
};
|
|
12363
12875
|
params.fail = (e) => {
|
|
12364
12876
|
console.log("分享完成,分享是否成功:", false, e);
|
|
12365
|
-
this._report(analyticsName, "
|
|
12877
|
+
this._report(analyticsName, "fail");
|
|
12366
12878
|
resolve(false);
|
|
12367
12879
|
};
|
|
12368
12880
|
this._tt.shareAppMessage(params);
|
|
@@ -12373,7 +12885,7 @@ class TTShare extends IShareAble {
|
|
|
12373
12885
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12374
12886
|
return new Promise((resolve) => {
|
|
12375
12887
|
console.log("发起视频分享:", data);
|
|
12376
|
-
this._report(analyticsName, "
|
|
12888
|
+
this._report(analyticsName, "begin", "video");
|
|
12377
12889
|
if (!this._tt) {
|
|
12378
12890
|
console.error("tt接口不存在!");
|
|
12379
12891
|
resolve(false);
|
|
@@ -12390,12 +12902,12 @@ class TTShare extends IShareAble {
|
|
|
12390
12902
|
},
|
|
12391
12903
|
success: (res) => {
|
|
12392
12904
|
console.log("分享完成,分享是否成功:", true);
|
|
12393
|
-
this._report(analyticsName, "
|
|
12905
|
+
this._report(analyticsName, "success", "video");
|
|
12394
12906
|
resolve(true);
|
|
12395
12907
|
},
|
|
12396
12908
|
fail: (e) => {
|
|
12397
12909
|
console.log("分享完成,分享是否成功:", false, e);
|
|
12398
|
-
this._report(analyticsName, "
|
|
12910
|
+
this._report(analyticsName, "fail", "video");
|
|
12399
12911
|
resolve(false);
|
|
12400
12912
|
},
|
|
12401
12913
|
});
|
|
@@ -12761,9 +13273,12 @@ class TTAd extends IADAble {
|
|
|
12761
13273
|
* 字节事件上报器(window['tt'].reportAnalytics)
|
|
12762
13274
|
*/
|
|
12763
13275
|
class TTAnalyticsSender extends EmptyAnalyticsSender {
|
|
12764
|
-
|
|
13276
|
+
mapEvent(eventName, eventData) {
|
|
13277
|
+
return mapCanonicalEventToFlatName(eventName, eventData);
|
|
13278
|
+
}
|
|
13279
|
+
send(eventName, eventData, userProperties) {
|
|
12765
13280
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12766
|
-
window['tt'].reportAnalytics(eventName,
|
|
13281
|
+
window['tt'].reportAnalytics(eventName, Object.assign(Object.assign({}, userProperties), eventData));
|
|
12767
13282
|
});
|
|
12768
13283
|
}
|
|
12769
13284
|
}
|
|
@@ -15222,4 +15737,4 @@ TipsView = __decorate([
|
|
|
15222
15737
|
menu("基础视图/TipsView")
|
|
15223
15738
|
], TipsView);
|
|
15224
15739
|
|
|
15225
|
-
export { ADAnalyticsAble, ADBehaviorReporter, ADEvent, ADType, AD_METRIC_ORDER_V1, ALiAnalyticsSender, AdDimension, AnalyticsAble, App, Application, Async, AudioBusiness, BaseDimension, BaseOnlineConfig, BaseProtocolHelper, BusinessCenter, ByteView, CCPViewLoader, CCSceneLoader, CocosNativeHelper, CocosStorageUtils, CocosViewManager, Component, ConfigHelper, DEFAULT_GAME_FLAG, Dictionary, DimensionType, ECS, EffectAudioSourceProxy, EmptyAnalyticsSender, EmptyLink, EnterOptionParser, Event$2 as Event, EventDispatcher, Fsm, FsmBase, GameDimension, GameLeaveType, GeometryUtils, Handler, HttpNode, HttpRequest, IADAble, IDevice, IGameUpdateAble, ILoginAble, INTERNAL_METHODS, INativeHelper, IPayAble, IPublisher, IPublisherManager, IRecordAble, IShareAble, IViewLoader, Injector, Json, KKTServer, KSAd, KSDevice, KSLogin, KSPublisher, KSRecorder, KSShare, KeytopsAnalyticsSender, LEVEL_STATS_METRIC_ORDER_V1, LaunchAnalyticsAble, LevelAnalyticsAble, LevelBehaviorReporter, LevelOnlineConfig, LevelStatsDimension, Link, List, LogType, Logger, MYAd, MYDevice, MYLogin, MYPublisher, Mask, MathUtils, MemeryStorage, NativeAd, NativeAnalyticsSender, NativeDevice, NativeHelper, NativeLogin, NativePay, NativePublisher, NativeRecorder, NativeShare, NativeUtils, NetManager, NoRequestServer, PLAYER_ABILITY_METRIC_ORDER_V1, PlayerAbilityDimension, Pool, PromiseUtils, PropSupport, PublisherManager, RemoteConfigService, RemoteConfigStore, ResourceManager, RewardVideoMaskBusiness, RuntimeApplicationImpl, Scene, Server, SessionAnalyticsAble, SessionDimension, SocialAnalyticsAble, SocialDimension, Socket, SocketLogType, SocketNode, Storage, StorageImpl, StringUtils, System, SystemOnlineConfig, TKAd, TKAnalyticsSender, TKDevice, TKLogin, TKPublisher, TTAd, TTAnalyticsSender, TTDevice, TTGameUpdater, TTLogin, TTPay, TTPublisher, TTRecorder, TTShare, Task, TaskQueue, TaskSequence, Timer, TimerImpl, TipsType, TipsView, View, ViewControl, ViewLevel, ViewManager, WXAd, WXAnalyticsSender, WXDevice, WXGameUpdater, WXLogin, WXPay, WXPublisher, WXShare, ab, analytics, audio, bidding, businessCenter, cmd, component, eventCenter, fsmManager, manager, maskView, md5, net, publisher, remoteConfig, remoteConfigService, res, server, storage, system, timer, version, viewAnalytics, viewClass, viewManager };
|
|
15740
|
+
export { ADAnalyticsAble, ADBehaviorReporter, ADEvent, ADType, AD_METRIC_ORDER_V1, ALiAnalyticsSender, AdDimension, AnalyticsAble, AnalyticsBehavior, App, Application, Async, AudioBusiness, BaseDimension, BaseOnlineConfig, BaseProtocolHelper, BusinessCenter, ByteView, CCPViewLoader, CCSceneLoader, CocosNativeHelper, CocosStorageUtils, CocosViewManager, Component, ConfigHelper, DEFAULT_GAME_FLAG, Dictionary, DimensionType, ECS, EffectAudioSourceProxy, EmptyAnalyticsSender, EmptyLink, EnterOptionParser, Event$2 as Event, EventDispatcher, FirebaseAnalyticsSender, Fsm, FsmBase, GameDimension, GameLeaveType, GeometryUtils, Handler, HttpNode, HttpRequest, IADAble, IDevice, IGameUpdateAble, ILoginAble, INTERNAL_METHODS, INativeHelper, IPayAble, IPublisher, IPublisherManager, IRecordAble, IShareAble, IViewLoader, Injector, Json, KKTServer, KSAd, KSDevice, KSLogin, KSPublisher, KSRecorder, KSShare, KeytopsAnalyticsSender, LEVEL_STATS_METRIC_ORDER_V1, LaunchAnalyticsAble, LevelAnalyticsAble, LevelBehaviorReporter, LevelOnlineConfig, LevelStatsDimension, Link, List, LogType, Logger, MYAd, MYDevice, MYLogin, MYPublisher, Mask, MathUtils, MemeryStorage, NativeAd, NativeAnalyticsSender, NativeDevice, NativeHelper, NativeLogin, NativePay, NativePublisher, NativeRecorder, NativeShare, NativeUtils, NetManager, NoRequestServer, PLAYER_ABILITY_METRIC_ORDER_V1, PayAnalyticsAble, PlayerAbilityDimension, Pool, PromiseUtils, PropSupport, PublisherManager, RemoteConfigService, RemoteConfigStore, ResourceManager, RewardVideoMaskBusiness, RuntimeApplicationImpl, Scene, Server, SessionAnalyticsAble, SessionDimension, SocialAnalyticsAble, SocialDimension, Socket, SocketLogType, SocketNode, Storage, StorageImpl, StringUtils, System, SystemOnlineConfig, TKAd, TKAnalyticsSender, TKDevice, TKLogin, TKPublisher, TTAd, TTAnalyticsSender, TTDevice, TTGameUpdater, TTLogin, TTPay, TTPublisher, TTRecorder, TTShare, Task, TaskQueue, TaskSequence, Timer, TimerImpl, TipsType, TipsView, TutorialAnalyticsAble, View, ViewControl, ViewLevel, ViewManager, WXAd, WXAnalyticsSender, WXDevice, WXGameUpdater, WXLogin, WXPay, WXPublisher, WXShare, ab, analytics, audio, bidding, businessCenter, cmd, component, eventCenter, fsmManager, manager, mapCanonicalEventToFlatName, mapCanonicalEventToLegacy, maskView, md5, net, publisher, remoteConfig, remoteConfigService, res, server, storage, system, timer, version, viewAnalytics, viewClass, viewManager };
|