From 70fb62d1d6bc9c6d8c6d9a37a13a701806bcf4cc Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Wed, 21 Apr 2021 15:51:17 +0800 Subject: [PATCH] 服务器数据打点 --- src/actions/ActivityAction.lua | 5 ++++- src/actions/AdvAction.lua | 2 ++ src/actions/DinerAction.lua | 10 +++++++--- src/actions/EmailAction.lua | 3 ++- src/actions/FriendAction.lua | 3 ++- src/actions/HangAction.lua | 20 +++++++++++++++++++- src/actions/HeroAction.lua | 8 +++++--- src/actions/RadioAction.lua | 3 ++- src/actions/RoleAction.lua | 9 ++++++++- src/actions/SeaportAction.lua | 2 ++ src/adv/Adv.lua | 2 +- src/models/HeroPlugin.lua | 1 + src/models/RoleBattle.lua | 1 + src/models/RolePlugin.lua | 28 +++++++++++++++++----------- src/models/Store.lua | 2 ++ 15 files changed, 75 insertions(+), 24 deletions(-) diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index 9d53c3b..3c14373 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -143,7 +143,8 @@ function _M.signRpc(agent, data) if monthData[curDay].daily_sign_email ~= "" then local emails = monthData[curDay].daily_sign_email:toArray(true,"=") for _, emailId in pairs(emails) do - redisproxy:insertEmail({roleId = role:getProperty("id"), emailId = emailId}) + --redisproxy:insertEmail({roleId = role:getProperty("id"), emailId = emailId}) + role:sendMail(emailId) end end @@ -312,6 +313,7 @@ function _M.actBattleCommandTaskRpc(agent, data) activity_type = role.activity.ActivityType.BattleCommandTask, -- 活动类型,见活动类型枚举表 activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} }) + role:mylog("act_action", {desc="bcTask", int1=taskId, int2=taskCfg.resetType}) role:checkTaskEnter("FinishSpeTask", {taskId = taskId, actId = actId}) @@ -1327,6 +1329,7 @@ function _M.buyBattleCommandLvlRpc(agent, data) role:costItems({[ItemId.Jade] = cost}, {log = {desc = "actBuyBpLevel", int1 = curLvl}}) actData["lvl"] = nextLvl role.activity:updateActData("BattleCommand", actData) + role:mylog("act_action", {desc="buyBcLvl", int1=count, int2=nextLvl}) SendPacket(actionCodes.Activity_buyBattleCommandLvlRpc, MsgPack.pack({})) return true diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index 47b1c3b..95b4e0e 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -183,6 +183,7 @@ function _M.startAdvRpc( agent, data ) cost = relayData.supply end role:checkTaskEnter("AdvCostPower", {count = cost}) + role:mylog("adv_action", {desc = "costPower", int1 = cost}) local support = {} -- 支援效果 if AdvCommon.isEndless(chapterId) then @@ -293,6 +294,7 @@ function _M.startHangRpc(agent, data) if not role:checkAdvCount(adv_idle_energy) then return 7 end -- 是否有体力 role:checkTaskEnter("AdvCostPower", {count = adv_idle_energy}) + role:mylog("adv_action", {desc = "costPower", int1 = adv_idle_energy}) if not checkFormat(role, format, role:getAdvData():isRunning()) then return 8 end --编队是否正确 diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index e71c814..3e80549 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -182,13 +182,17 @@ function _M.getSellRewardRpc( agent, data ) local sells = json.decode(role.dinerData:getProperty("sells")) local deltaTimes = {} - for slot, _ in pairs(sells) do + for slot, sell in pairs(sells) do + local oldCount = sell.count + local sellDish = sell.dish local temp = role.dinerData:updateSell(slot) or { deltaCount = 0, deltaTime = 0, lastCount = 0, } deltaTimes[slot] = temp.deltaTime + local sellCount = oldCount - temp.lastCount + role:mylog("diner_action", {desc = "sell", int1 = sellDish, int2 = sellCount}) end sells = json.decode(role.dinerData:getProperty("sells")) for slot, sell in pairs(sells) do @@ -238,7 +242,7 @@ function _M.getSellRewardRpc( agent, data ) role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) end - role:mylog("diner_action", {desc = "sell"}) + --role:mylog("diner_action", {desc = "sell"}) SendPacket(actionCodes.Diner_getSellRewardRpc, MsgPack.pack({reward = reward, change = change})) return true @@ -327,7 +331,7 @@ function _M.expediteSellRpc( agent, data ) end role:checkTaskEnter("FoodSellQuick") - role:mylog("diner_action", {desc = "sellQ"}) + role:mylog("diner_action", {desc = "sellQ", int1 = count + 1}) SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward, change = change, popular = popular})) return true diff --git a/src/actions/EmailAction.lua b/src/actions/EmailAction.lua index 262963e..57ce69c 100644 --- a/src/actions/EmailAction.lua +++ b/src/actions/EmailAction.lua @@ -133,6 +133,7 @@ function _M.drawAttachRpc(agent, data) local email = require("models.Email").new({key = string.format("%d", id), id = id}) + email.owner = role if not email:load() then return end local attachments = getEmailAttachments(email) @@ -142,7 +143,7 @@ function _M.drawAttachRpc(agent, data) email:setProperty("status", 2, true) email:log(role, 2) SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) - role:mylog("mail_action", {desc = "draw_attach", int1 = id, key1 = email:getProperty("title"), key2 = attachments}) + role:mylog("mail_action", {desc = "draw_attach", int1 = email:getProperty("emailId"), key1 = email:getProperty("title"), key2 = attachments}) return true end diff --git a/src/actions/FriendAction.lua b/src/actions/FriendAction.lua index deab659..5928a6e 100644 --- a/src/actions/FriendAction.lua +++ b/src/actions/FriendAction.lua @@ -171,7 +171,7 @@ function _M.applyRpc(agent, data) myInfo.online = true myInfo.hadApply = true - role:mylog("role_action", {desc = "addFriend", int1 = 1}) + role:mylog("role_action", {desc = "applyFriend", int1 = 1}) rpcRole(objectId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newApply = 1, info = {myInfo}})) -- 通知对方 end @@ -420,6 +420,7 @@ function _M.deleteRpc(agent, data) friend_roleid = objectId, -- 好友账户下的角色id friend_cnt = 0, -- 操作后好友数量 }) + role:mylog("role_action", {desc = "delFriend", int1 = 1}) SendPacket(actionCodes.Friend_deleteRpc, MsgPack.pack("")) return true end diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 3c6bacb..79e553f 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -16,6 +16,17 @@ local table_unpack = table.unpack local _M = {} +local function getHangTime(role) + local hangInfo = role:getProperty("hangInfo") + if not hangInfo.carbonId or not hangInfo.coinTime or not hangInfo.itemTime then + return 0 + end + local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] + local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) + + return nowCoinTime - hangInfo.coinTime +end + local function checkReward(role) local hangInfo = role:getProperty("hangInfo") if not hangInfo.carbonId or not hangInfo.coinTime or not hangInfo.itemTime then @@ -214,6 +225,7 @@ function _M.startBattleRpc(agent, data) end _BattleKey = tostring(math.random()) + role._StartBattleTs = skynet.timex() role:checkTaskEnter("HangBattle", {id = carbonId}) SendPacket(actionCodes.Hang_startBattleRpc, MsgPack.pack({key = _BattleKey})) @@ -323,7 +335,9 @@ function _M.endBattleRpc(agent, data) }) local team = role:getProperty("pvpTC") - role:mylog("hang_action", {desc = "hangBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = carbonId, int2 = role:getProperty("hangTBV"), cint1 = role:getHerosCamp(team.heros)}) + + local battleTime = skynet.timex() - role._StartBattleTs + role:mylog("hang_action", {desc = "hangBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = carbonId, int2 = role:getProperty("hangTBV"), cint1 = role:getHerosCamp(team.heros), cint2 = battleTime}) SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({ starNum = msg.starNum, @@ -394,6 +408,7 @@ end function _M.getRewardRpc(agent , data) local role = agent.role + local hangTime = getHangTime(role) checkReward(role) local items = role:getProperty("hangBag") if not next(items) then return end @@ -424,6 +439,7 @@ function _M.getRewardRpc(agent , data) residence_reward = reward, --获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} }) + role:mylog("hang_action", {desc = "hangReward", int1 = hangTime}) SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({ reward = reward, @@ -493,6 +509,8 @@ function _M.quickRpc(agent , data) residence_time = time, --挂机或排名时长 residence_reward = reward, --获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} }) + role:mylog("hang_action", {desc = "quick", short1 = curCount}) + SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({ reward = reward, change = change diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 635a3b9..e2309df 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -728,7 +728,7 @@ function _M.getResetRewardRpc(agent, data) equip = "", rune = "", }) - hero:mylog({desc = "resetHero"}) + hero:mylog({desc = "resetHero", int1=tmpLevel}) --local coef = globalCsv.unit_back_discount --coef = (pay or tmpLevel <= 60) and 1 or coef @@ -991,11 +991,11 @@ function _M.drawHeroRpc(agent, data) local fragId = itemData.id - ItemStartId.Hero local heroData = csvdb["unitCsv"][fragId] local count = globalCsv.draw_unit_tofragment[heroData.rare] - role:award({[fragId] = count}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) + role:award({[fragId] = count}, {log = {desc = "drawHero", int1 = btype, int2 = poolId, short1=isFloorBack and 1 or 0}}) logReward[fragId] = (logReward[fragId] or 0) + count table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1}) else - role:award({[itemId] = 1}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) + role:award({[itemId] = 1}, {log = {desc = "drawHero", int1 = btype, int2 = poolId, short1=isFloorBack and 1 or 0}}) logReward[itemId] = (logReward[itemId] or 0) + 1 table.insert(reward, {id = itemId, count = 1}) end @@ -1035,6 +1035,8 @@ function _M.drawHeroRpc(agent, data) gacha_cost = cost, -- 购买道具消耗的货币 gacha_cnt = floorHeroCount, }) + + role:mylog("hero_action", {desc = "drawHero", int1=poolId, int2=btype, short1 = drawCount[drawType]}) SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 local feedbackId = buildTypeData["can_feedback"] or 0 diff --git a/src/actions/RadioAction.lua b/src/actions/RadioAction.lua index b734feb..d19d401 100644 --- a/src/actions/RadioAction.lua +++ b/src/actions/RadioAction.lua @@ -199,7 +199,8 @@ function _M.finishQuestRpc(agent, data) mission_result = 1, -- 战斗结果(0-无效,1-胜利,2-失败) mission_roundtime = config.time, -- 完成耗时(秒) mission_cleartype = 2, -- 1-开始; 2-完成(领取奖励时) - }) + }) + role:mylog("role_action", {desc = "radioTask", int1 = id, short1 = bigSuccess and 1 or 0}) return true end diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 76d208b..4f72b8e 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -399,7 +399,8 @@ function _M.createRpc(agent, data) newRole:award(globalCsv.birthItem, {log = {desc = "birth"}, notNotify = true}) -- 欢迎邮件 - mysqlproxy:insertEmail({roleId = roleId, emailId = 1}) + --mysqlproxy:insertEmail({roleId = roleId, emailId = 1}) + newRole:sendMail(1) if msg.newuser then newRole:log("onCreateAccount") @@ -904,8 +905,10 @@ function _M.taskRpc(agent, data) -- 日常活动完成 if taskType == 1 then role:checkTaskEnter("DailyTask", {pre = (taskStatus["a"] or 0), cur = active}) + role:mylog("role_action", {desc="dayTask", int1=taskId, int2=active}) else role:checkTaskEnter("WeekTask", {pre = (taskStatus["a"] or 0), cur = active}) + role:mylog("role_action", {desc="weekTask", int1=taskId, int2=active}) end role:changeUpdates({ @@ -1000,6 +1003,8 @@ function _M.achiveRpc(agent, data) achievement_type = cfg.type, -- 成就类型,具体枚举表中成就类型枚举表 achievement_reward = award, -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} }) + + role:mylog("role_action", {desc="finishAchieve", int1=cfg.id}) end end end @@ -1034,6 +1039,7 @@ function _M.achiveRpc(agent, data) achievement_type = achiveTask.type, -- 成就类型,具体枚举表中成就类型枚举表 achievement_reward = reward, -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} }) + role:mylog("role_action", {desc="finishAchieve", int1=taskId}) SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack(role:packReward(reward, change))) end @@ -1057,6 +1063,7 @@ function _M.achiveRpc(agent, data) if preMaxCount < pData.request and overCount >= pData.request then role:sendMail(101, skynet.timex(), pData.reward, {pData.level}) flag = true + role:mylog("role_action", {desc="fux", int1=pdata.level}) end end if flag then diff --git a/src/actions/SeaportAction.lua b/src/actions/SeaportAction.lua index 1d5ab1e..c163b12 100644 --- a/src/actions/SeaportAction.lua +++ b/src/actions/SeaportAction.lua @@ -237,6 +237,8 @@ function _M.taskRpc(agent, data) reward, change = role:award(itemReward, {log = {desc = "seaportTask", int1 = taskId, int2 = level}}) seaport.collect[taskId] = nil + + role:mylog("role_action", {desc="seaportTask", int1=taskId, int2=level, short1=bigSuccess and 1 or 0}) else return 0 end diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index 845ab0e..39892c8 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -922,7 +922,7 @@ function Adv:over(success, rewardRatio, overType) end self:clearAdvUnlockCache() - self:mylog({desc = "over", short1 = success and 1 or 0, int1 = overType}) + self:mylog({desc = "over", short1 = success and 1 or 0, int1 = overType, int2 = self.chapterId, long1 = self.level}) local team = self.owner:getProperty("advTeam") diff --git a/src/models/HeroPlugin.lua b/src/models/HeroPlugin.lua index c811a36..6cf369d 100644 --- a/src/models/HeroPlugin.lua +++ b/src/models/HeroPlugin.lua @@ -381,6 +381,7 @@ function HeroPlugin.bind(Hero) end end self:setProperty("faith", faith) + self:mylog({desc = "addFaith", int1 = exp}) end end diff --git a/src/models/RoleBattle.lua b/src/models/RoleBattle.lua index 84ddcd3..629fdbe 100644 --- a/src/models/RoleBattle.lua +++ b/src/models/RoleBattle.lua @@ -197,6 +197,7 @@ function Role:checkBattle(battleType, params) local fixData = { hang = function() + dump(self:getProperty("hangTS")) for slot, hero in pairs(self:getProperty("hangTS").heros) do selflist[slot] = hero.type end diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index d180432..a535a43 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -252,7 +252,8 @@ function RolePlugin.bind(Role) local headData = csvdb["player_iconCsv"][itemId] -- pvp 跨服竞技场奖励 if headData and headData.path == 2 then - mysqlproxy:insertEmail({roleId = self:getProperty("id"), emailId = 19}) + --mysqlproxy:insertEmail({roleId = self:getProperty("id"), emailId = 19}) + self:sendMail(19) end end end @@ -1372,11 +1373,12 @@ function RolePlugin.bind(Role) end if done then update = true - redisproxy:insertEmail({ - roleId = self:getProperty("id"), - emailId = idx == 1 and 361 or 362, - attachments = set[1].phase_award, - }) + --redisproxy:insertEmail({ + -- roleId = self:getProperty("id"), + -- emailId = idx == 1 and 361 or 362, + -- attachments = set[1].phase_award, + --}) + self:sendMail(idx == 1 and 361 or 362, nil, set[1].phase_award) -- self:award(set[1].phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}}) donate[idx] = 1 end @@ -1469,11 +1471,12 @@ function RolePlugin.bind(Role) end rewardStr = rewardStr .. string.format("%s=%s",itemId,value) end - redisproxy:insertEmail({ - roleId = self:getProperty("id"), - emailId = 363, - attachments = rewardStr, - }) + --redisproxy:insertEmail({ + -- roleId = self:getProperty("id"), + -- emailId = 363, + -- attachments = rewardStr, + --}) + self:sendMail(363, nil, rewardStr) end end seaport.collect = {} @@ -1695,6 +1698,7 @@ function RolePlugin.bind(Role) if level > advL[1] then self:checkTaskEnter("AdvLevel", {level = level}) + self:mylog("adv_action", {desc = "adv_level", int1 = level}) end advL[1] = level advL[2] = newExp @@ -2341,6 +2345,8 @@ function RolePlugin.bind(Role) gift = gift .. k.."="..v.." " end mysqlproxy:insertEmail({roleId = self:getProperty("id"), emailId = mailId, createtime = createTime, attachments = gift, contentPms = contentPms}) + + self:mylog("role_action", {desc="sendMail", int1 = mailId}) self.sendMailFlag = true end diff --git a/src/models/Store.lua b/src/models/Store.lua index 68ac5f3..2a18ec9 100644 --- a/src/models/Store.lua +++ b/src/models/Store.lua @@ -301,7 +301,9 @@ function Store:onBuyCard(type, duration, id, actid) actData["unlock"] = 1 if actCfg.condition ~= 0 then actData["lvl"] = (actData["lvl"] or 0) + actCfg.condition + role:mylog("act_action", {desc="buyBcLvl", int1=actCfg.condition, int2=actData["lvl"]}) end + self.owner:mylog("act_action", {desc="buyBc", int1=id, int2=actData["lvl"] or 0}) self.owner.activity:updateActData("BattleCommand", actData) end end -- libgit2 0.21.2