Adjust.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. const attribution = require("AdjustAttribution");
  2. const Global = require("Global");
  3. const AdjustEvent = require("AdjustEvent");
  4. const BaseDefine = require("BaseDefine");
  5. function initAttribution() {
  6. cc.vv.reflection.getAdjustAttribution();
  7. }
  8. class Adjust {
  9. constructor() {
  10. this.attribution = attribution;
  11. // initAttribution();
  12. }
  13. getSpreadID() {
  14. let clickLabel = attribution.getClickLabel();
  15. let spreadID = "0";
  16. if (clickLabel) { // 使用后保存,保证安装后只使用一次
  17. spreadID = clickLabel.split("-")[0];
  18. }
  19. console.log("AdjustAttribution:: getSpreadID:" + spreadID);
  20. return spreadID;
  21. }
  22. getNetwork() {
  23. return attribution.getNetwork();
  24. }
  25. getChannelID() {
  26. let campaign = attribution.getCampaign();
  27. let clickLabel = attribution.getClickLabel();
  28. let channelID = cc.vv.config.Channel;
  29. if (campaign) {
  30. // 匹配 * 符号以后的数字,不包括 * 符号,且不包括被匹配数字后从非数字字符下标起的任意字符,包括数字
  31. channelID = campaign.match(/\*\d+/)[0].slice(1) || channelID;
  32. } else if (clickLabel) {
  33. channelID = clickLabel.split("-")[1] || channelID;
  34. }
  35. console.log("AdjustAttribution:: getChannelID:" + channelID);
  36. return channelID;
  37. }
  38. getCampaign() {
  39. return attribution.getCampaign();
  40. }
  41. getAdjustCam() {
  42. let campaign = attribution.getCampaign();
  43. let channelID = 0;
  44. if (campaign) {
  45. // 匹配 * 符号以后的数字,不包括 * 符号,且不包括被匹配数字后从非数字字符下标起的任意字符,包括数字
  46. let CA = campaign.match(/\*\d+/);
  47. if(CA && CA[0]) {
  48. channelID = CA[0].slice(1) || channelID;
  49. }
  50. // channelID = campaign.match(/\*\d+/)[0].slice(1) || channelID;
  51. }
  52. console.log("AdjustAttribution:: getAdjustCam:" + channelID);
  53. return channelID;
  54. }
  55. getAdID() {
  56. let adid = attribution.getAdid() || cc.vv.reflection.getDeviceUUID() || Global.getUUID();
  57. console.log("AdjustAttribution:: getAdID:" + adid);
  58. return adid;
  59. }
  60. getOnlyAdID() {
  61. return attribution.getAdid();
  62. }
  63. isEmpty() {
  64. if (BaseDefine.GAME_PLATFORM == BaseDefine.WEB_H5_PLATFORM) {
  65. return false;
  66. }
  67. return (cc.adjust) ? false : true;
  68. }
  69. static setTrackLinkID(packageID) {
  70. if (packageID == "com.teenpatti.queen") {
  71. cc.vv.config.Channel = 0;
  72. cc.vv.config.ChannelIdx = 0;
  73. BaseDefine.ADJUST_DATA.AGENT = "rp1867g";
  74. }
  75. else {
  76. cc.vv.config.Channel = 0;
  77. cc.vv.config.ChannelIdx = 0;
  78. BaseDefine.ADJUST_DATA.AGENT = "rp1867g";
  79. }
  80. Global.print("AppStart::initChannelInfo: " + BaseDefine.ADJUST_DATA.AGENT);
  81. }
  82. static setEventID(packageID) {
  83. if (packageID == "com.teempatti.championplayer") {
  84. AdjustEvent.config["Buy Gold Success"] = "nct9zd";
  85. AdjustEvent.config["Buy Gold Success Test"] = "fbhv45";
  86. AdjustEvent.config.Registration = "rj6t83";
  87. AdjustEvent.config.Registration_Test = "zdzryh";
  88. }
  89. else if (packageID == "com.teempatti.victory") {
  90. AdjustEvent.config["Buy Gold Success"] = "rp9epc";
  91. AdjustEvent.config.Registration = "ne97pz";
  92. }
  93. else {
  94. }
  95. Global.print("Adjust::setEventID: " + JSON.stringify(AdjustEvent.config));
  96. }
  97. }
  98. module.exports = Adjust;