DataSystem.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import JsbSystem from "./JsbSystem";
  2. /**
  3. * @description 数据管理类
  4. * @author 邹勇
  5. */
  6. export default class DataSystem {
  7. constructor() {
  8. }
  9. /**
  10. * 数数注册事件
  11. */
  12. public setTAEventRegister() {
  13. JsbSystem.setTAEventRegister();
  14. }
  15. /**
  16. * 数数打点
  17. * @param eventId 事件Id
  18. * @param des 事件内容
  19. */
  20. public sendDataEvent(eventId: string, des: string) {
  21. console.log("===[DataSystem", eventId, des);
  22. if (eventId && des) {
  23. JsbSystem.sendEvent(eventId, des);
  24. this.sendXYTrack(eventId, 'des', des);
  25. }
  26. }
  27. /**
  28. * 数数打点
  29. * @param eventId 事件Id
  30. * @param des 事件内容
  31. */
  32. public sendDataEventValue(eventId: string, des: string, value: number) {
  33. console.log("===[DataSystem", eventId, des, value);
  34. if (eventId && des) {
  35. JsbSystem.sendEventValue(eventId, des, value);
  36. this.sendXYTrack(eventId, des, value);
  37. }
  38. }
  39. /**
  40. * 设置人物属性
  41. * @param type 0 set 1 add
  42. * @param property 属性名
  43. * @param value 浮点数值
  44. */
  45. public setTAEventUser(type: number, property: string, value: number) {
  46. JsbSystem.setTAEventUser(type, property, value);
  47. }
  48. /**
  49. * 设置人物属性
  50. * @param type 0 set 1 add
  51. * @param property 属性名
  52. * @param value 字符串数值
  53. */
  54. public setTAEventUserStr(type: number, property: string, value: string) {
  55. JsbSystem.setTAEventUserStr(type, property, value);
  56. }
  57. /**
  58. * 设置人物uin
  59. */
  60. public setTAUserID(id: string) {
  61. JsbSystem.setTAUserID(id);
  62. }
  63. /**
  64. * 星云打点
  65. */
  66. public sendXYEvent(eventId: string, des: string) {
  67. if (eventId && des) {
  68. let data = {
  69. "uin": gData.loginData.uin,
  70. "isFirstDay": gData.gameData.playerProp.loginDays == 1 ? 1 : 0,
  71. "umengChannel": gData.appData.umengChannel,
  72. "deviceType": gData.appData.deviceType,
  73. "androidVerison": gData.appData.androidVersion,
  74. "version": gData.appData.appVersion,
  75. "point": eventId,
  76. "description": des,
  77. "tfChannel": gData.appData.tfChannel
  78. }
  79. mk.http.sendData('cp', data);
  80. }
  81. }
  82. private xyTrackUrl = 'https://hyperion-track-app.mokamrp.com/';
  83. /**
  84. * 星云打点 Track
  85. */
  86. public sendXYTrack(eventId: string, des: string, value: number | string) {
  87. if (CC_DEBUG) {
  88. return;
  89. }
  90. const event_value = {}
  91. event_value[des] = value
  92. let data = {
  93. app_id: '30WAK1lNDc0b99LzSOJqv3TXa',
  94. app_type: 1,
  95. app_ver: gData.appData.appVersion,
  96. app_channel: gData.appData.tfChannel,
  97. report_time: Date.now(),
  98. user_id: gData.loginData.uin,
  99. device_id: "",
  100. os_type: 1,
  101. user_agent: gData.appData.machineInfo.UA,
  102. imei: gData.appData.machineInfo.imei,
  103. ifda: gData.appData.machineInfo.idfa,
  104. oaid: gData.appData.machineInfo.oaid,
  105. event_id: eventId,
  106. event_value: JSON.stringify(event_value)
  107. }
  108. let url = this.xyTrackUrl + 'track';
  109. mk.http.sendRequestNormal(url, 'POST', JSON.stringify(data));
  110. }
  111. }