DataSystem.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. /**
  83. * 星云打点 Track
  84. */
  85. public sendXYTrack(eventId: string, des: string, value: number | string) {
  86. let data = {
  87. app_id: '30WAK1lNDc0b99LzSOJqv3TXa',
  88. app_type: 1,
  89. app_ver: gData.appData.androidVersion,
  90. app_channel: gData.appData.tfChannel,
  91. report_time: Date.now(),
  92. user_id: gData.loginData.uin,
  93. device_id: gData.appData.deviceType,
  94. os_type: 1,
  95. user_agent: gData.appData.UA,
  96. imei: gData.appData.machineInfo.imei,
  97. ifda: gData.appData.machineInfo.idfa,
  98. oaid: gData.appData.machineInfo.oaid,
  99. event_id: eventId,
  100. event_value: `{"${des}":${value}}`
  101. }
  102. mk.http.sendData('track', data);
  103. }
  104. }