905 lines
37 KiB
C#
905 lines
37 KiB
C#
// ***********************************************************************
|
||
// Assembly : Game
|
||
// Author : Kimch
|
||
// Created : 2020-12-07
|
||
// Description :
|
||
// Last Modified By :
|
||
// Last Modified On :
|
||
// ***********************************************************************
|
||
// <copyright file= "KStatistics" company="Kunpo"></copyright>
|
||
// <summary></summary>
|
||
// ***********************************************************************
|
||
#if SDK_WECHAT_WASM
|
||
#define ENABLE_KTA
|
||
#endif
|
||
|
||
#if SDK_OHAYOO
|
||
#define ENABLE_PLATFORM
|
||
#endif
|
||
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
|
||
namespace G
|
||
{
|
||
/// <summary>
|
||
/// 数据统计管理类
|
||
/// </summary>
|
||
public class KStatistics : MonoBehaviour
|
||
{
|
||
#region Json
|
||
|
||
#if !ENABLE_KTA
|
||
|
||
static readonly System.Text.StringBuilder _Builder = new System.Text.StringBuilder();
|
||
|
||
static void Begin()
|
||
{
|
||
_Builder.Clear();
|
||
_Builder.Append('{');
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="key"></param>
|
||
/// <param name="value"></param>
|
||
static void Append(string key, string value)
|
||
{
|
||
_Builder.Append('"');
|
||
_Builder.Append(key);
|
||
_Builder.Append('"');
|
||
|
||
_Builder.Append(':');
|
||
|
||
_Builder.Append('"');
|
||
_Builder.Append(value);
|
||
_Builder.Append('"');
|
||
|
||
_Builder.Append(',');
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="key"></param>
|
||
/// <param name="value"></param>
|
||
static void Append(string key, int value)
|
||
{
|
||
_Builder.Append('"');
|
||
_Builder.Append(key);
|
||
_Builder.Append('"');
|
||
|
||
_Builder.Append(':');
|
||
|
||
_Builder.Append(value);
|
||
|
||
_Builder.Append(',');
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
static string End()
|
||
{
|
||
if (_Builder[_Builder.Length - 1] == ',')
|
||
_Builder[_Builder.Length - 1] = '}';
|
||
else
|
||
_Builder.Append('}');
|
||
return _Builder.ToString();
|
||
}
|
||
#endif
|
||
|
||
#endregion
|
||
|
||
#region Dict
|
||
|
||
#if ENABLE_KTA
|
||
static readonly Dictionary<string, object> _Builder = new Dictionary<string, object>();
|
||
|
||
static void Begin()
|
||
{
|
||
_Builder.Clear();
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="key"></param>
|
||
/// <param name="value"></param>
|
||
static void Append(string key, string value)
|
||
{
|
||
_Builder.Add(key, value);
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="key"></param>
|
||
/// <param name="value"></param>
|
||
static void Append(string key, int value)
|
||
{
|
||
_Builder.Add(key, value);
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
static Dictionary<string, object> End()
|
||
{
|
||
return _Builder;
|
||
}
|
||
|
||
#endif
|
||
|
||
#endregion
|
||
|
||
#region METHOD
|
||
|
||
public void Login(string account)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.Login(account);
|
||
#endif
|
||
}
|
||
|
||
public void Logout()
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.Logout();
|
||
#endif
|
||
}
|
||
|
||
public void Flush()
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.Flush();
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="jsonDict"></param>
|
||
public void SetCommon(Dictionary<string, object> jsonDict)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.SetSuperProperties(jsonDict);
|
||
#endif
|
||
}
|
||
|
||
public void SetUserData(Dictionary<string, object> jsonDict)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(jsonDict);
|
||
#endif
|
||
}
|
||
|
||
public void SetUserData(Dictionary<string, object> jsonDict, System.DateTime dateTime)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(jsonDict, dateTime);
|
||
#endif
|
||
}
|
||
|
||
public void SetUserDataOnce(Dictionary<string, object> jsonDict)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserSetOnce(jsonDict);
|
||
#endif
|
||
}
|
||
|
||
public void SetUserDataOnce(Dictionary<string, object> jsonDict, System.DateTime dateTime)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserSetOnce(jsonDict, dateTime);
|
||
#endif
|
||
}
|
||
|
||
public void UnsetUserData(string key)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserUnset(key);
|
||
#endif
|
||
}
|
||
|
||
public void UnsetUserData(List<string> keys)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserUnset(keys);
|
||
#endif
|
||
}
|
||
|
||
public void UnsetUserData(List<string> keys, System.DateTime dateTime)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserUnset(keys, dateTime);
|
||
#endif
|
||
}
|
||
|
||
public void AddUserData(Dictionary<string, object> jsonDict)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd(jsonDict);
|
||
#endif
|
||
}
|
||
|
||
public void AddUserData(Dictionary<string, object> jsonDict, System.DateTime dateTime)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd(jsonDict, dateTime);
|
||
#endif
|
||
}
|
||
|
||
public void AppendUserData(Dictionary<string, object> jsonDict)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserAppend(jsonDict);
|
||
#endif
|
||
}
|
||
|
||
public void AppendUserData(Dictionary<string, object> jsonDict, System.DateTime dateTime)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserAppend(jsonDict, dateTime);
|
||
#endif
|
||
}
|
||
|
||
public void DeleteUserData()
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserDelete();
|
||
#endif
|
||
}
|
||
|
||
public void DeleteUserData(System.DateTime dateTime)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.UserDelete(dateTime);
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="label"></param>
|
||
/// <param name="paramJson"></param>
|
||
public void ReportEvent(string label, string paramJson)
|
||
{
|
||
#if !UNITY_WEBGL
|
||
if (!GlobalVar.FirstInitGame)
|
||
{
|
||
if (PlayerProxy.Instance)
|
||
{
|
||
//KPlatform.Instance.SetEventCommonHeader("level", PlayerProxy.Instance.grade.ToString());
|
||
KPlatform.Instance.SetEventCommonHeader("total_battlepoint", PlayerProxy.Instance.combatValue.ToString());
|
||
}
|
||
|
||
if (VipProxy.Instance)
|
||
{
|
||
KPlatform.Instance.SetEventCommonHeader("yueli_level", VipProxy.Instance.curVip.ToString());
|
||
}
|
||
|
||
if (LevelProxy.Instance)
|
||
{
|
||
KPlatform.Instance.SetEventCommonHeader("mapid_max", LevelProxy.Instance.currentUnlockedLevel.ToString());
|
||
KPlatform.Instance.SetEventCommonHeader("mapchapter_max", LevelProxy.Instance.currentChapterId.ToString());
|
||
}
|
||
}
|
||
#endif
|
||
KPlatform.Instance.ReportEvent(label, paramJson);
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="label"></param>
|
||
/// <param name="jsonDict"></param>
|
||
public void ReportEvent(string label, Dictionary<string, object> jsonDict)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.Track(label, jsonDict);
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// 记录事件时长. 调用 TimeEvent 为某事件开始计时,当 track 传该事件时,SDK 会在在事件属性中加入 #duration 这一属性来表示事件时长,单位为秒.
|
||
/// </summary>
|
||
/// <param name="label">事件名称</param>
|
||
public void ReportTimeEvent(string label)
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.TimeEvent(label);
|
||
#endif
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
#region GAME DATA
|
||
|
||
//初始化 "ohayoo_game_init
|
||
//initid 初始化路径id 是 int 登录前,app初始化过程序列编号,必须有序
|
||
//initname 初始化路径中文描述 是 string 初始化过程路径转化中文描述,比如:资源加载、登录框调出等。研发根据产品监控设计自行输出
|
||
//initresult 初始化路径结果返回 否 int 参数枚举:0 成功 、1 失败
|
||
//initerror 初始化录路径错误返回 否 string 如果存在客户端自身的结果失败状况的话,可打失败的错误记录返回
|
||
//network 网络 是 string 玩家设备网络。如wifi、4g、5g等
|
||
//updatepkgid 更新包id 否 string 记录更新包的编号。当有更新行为发生时记录。没有更新行为记录为-1
|
||
//updatepkgsize 更新包大小 否 float 记录更新包的大小,单位M。当有更新行为发生时记录。没有更新行为记录为-1
|
||
/// <summary>
|
||
/// 初始化
|
||
/// ohayoo_game_init
|
||
/// </summary>
|
||
/// <param name="initid">初始化路径id 是 int 登录前,app初始化过程序列编号,必须有序</param>
|
||
/// <param name="initname">初始化路径中文描述 是 string 初始化过程路径转化中文描述,比如:资源加载、登录框调出等。研发根据产品监控设计自行输出</param>
|
||
/// <param name="initresult"> 初始化路径结果返回 否 int 参数枚举:0 成功 、1 失败</param>
|
||
/// <param name="initerror">初始化录路径错误返回 否 string 如果存在客户端自身的结果失败状况的话,可打失败的错误记录返回</param>
|
||
public void ReportEvent_GameInit(int initid, string initname, int initresult, int initerror)
|
||
{
|
||
Begin();
|
||
Append("initid", initid);
|
||
Append("initname", initname);
|
||
Append("initresult", initresult);
|
||
Append("initerror", initerror);
|
||
Append("network", Application.internetReachability.ToString());
|
||
Append("updatepkgid", "-1");
|
||
Append("updatepkgsize", "-1");
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_init", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// ohayoo_game_login
|
||
/// 1.正常登录并登陆成功、2.断线重连、3.杀进程重新登录、4.退后台5分钟后重新登录、5.切换账号。游戏产品端如有搭建自有服务器,该事件建议走服务端日志
|
||
/// 该事件必须上报,有接入登录系统的情况下,基于登录成功返回后出发;如没有登录系统,可在用户调起主界面或有主界面操作行为或开启关卡等情况下触发上报,上述5种上报建议均能准确触发
|
||
/// </summary>
|
||
/// <param name="username">用户name 否 string 提供用户设置name功能的情况下上报</param>
|
||
/// <param name="logintype">登录方式 否 string 参数枚举:微信、手机号、抖音授权....研发可自定义添加,打中文</param>
|
||
public void ReportEvent_GameLogin(string username, string logintype)
|
||
{
|
||
Begin();
|
||
Append(nameof(username), username);
|
||
Append("logintype", logintype);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_login", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// ohayoo_game_logout
|
||
/// </summary>
|
||
/// <param name="username"></param>
|
||
/// <param name="onlinetime">此次在线时长(秒)是 int 此次login到logout之间的游戏时长,打秒</param>
|
||
public void ReportEvent_GameLogout(string username, int onlinetime)
|
||
{
|
||
Begin();
|
||
Append("username", username);
|
||
Append("onlinetime", onlinetime);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_login", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// ohayoo_game_request
|
||
/// 向服务器请求广告时上报。游戏产品端如有搭建自有服务器,该事件建议走服务端日志。
|
||
/// 请求循环最多不能超过5次上报,不可循环不断的上报数据。
|
||
/// </summary>
|
||
/// <param name="ad_type">广告类型 是 string 广告类型:激励视频、插屏、banner等,使用汉字标识</param>
|
||
/// <param name="rit_id">广告代码位 是 string 广告代码位id</param>
|
||
public void ReportEvent_Ad_Request(string ad_type, string rit_id)
|
||
{
|
||
Begin();
|
||
Append("ad_type", ad_type);
|
||
//Append("rit_id", "946371133");
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_request", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// ohayoo_game_send
|
||
/// 向服务器请求广告有返回时。穿山甲广告有回调,可以直接获取。游戏产品端如有搭建自有服务器,该事件建议走服务端日志。
|
||
/// 返回成功的情况下上报,返回失败同样上报,返回结果需输出。
|
||
/// </summary>
|
||
/// <param name="ad_type">广告类型 是 string 广告类型:激励视频、插屏、banner等,使用汉字标识</param>
|
||
/// <param name="rit_id">广告代码位 是 string 广告代码位id</param>
|
||
/// <param name="ad_code">广告响应码 是 string SDK返回的响应码(包括错误码),如广告正常播放没有错误,返回值"2000"</param>
|
||
/// <param name="result">返回结果 是 string 广告返回结果:成功、失败,使用汉字进行标识</param>
|
||
public void ReportEvent_Ad_Send(string ad_type, string rit_id, string ad_code, string result)
|
||
{
|
||
Begin();
|
||
Append("ad_type", ad_type);
|
||
//Append("rit_id", "946371133");
|
||
Append("ad_code", ad_code);
|
||
Append("result", result);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_send", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 广告点击事件
|
||
/// ohayoo_game_button_click
|
||
/// 用户点击app内各广告位button时。游戏产品端如有搭建自有服务器,该事件建议走服务端日志。
|
||
/// </summary>
|
||
/// <param name="ad_type"></param>
|
||
/// <param name="ad_position_type"></param>
|
||
public void ReportEventClickAd(string ad_type, string ad_position, string ad_position_type)
|
||
{
|
||
Begin();
|
||
Append("ad_type", ad_type);
|
||
//Append("rit_id", "946371133");
|
||
Append("ad_position", ad_position);
|
||
Append("ad_position_type", ad_position_type);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_button_click", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 广告显示事件
|
||
/// ohayoo_game_show
|
||
/// 用户点击并观看广告时。穿山甲广告有回调,可以直接获取。游戏产品端如有搭建自有服务器,该事件建议走服务端日志。
|
||
/// </summary>
|
||
/// <param name="ad_type"></param>
|
||
/// <param name="ad_position_type"></param>
|
||
/// <param name="ad_position">ad_position 广告点位 是 string 自定义广告点位名称:ad_position_type加下划线加自定义广告点位格式上报,例:物品_关卡奖励多倍、道具_关卡复活</param>
|
||
/// <param name="stageId"></param>
|
||
public void ReportEventShowAd(string ad_type, string ad_position_type, string ad_position, string stageId)
|
||
{
|
||
Begin();
|
||
Append("ectype_name", stageId);
|
||
Append("ad_type", ad_type);
|
||
Append("rit_id", "946371133");
|
||
Append("ad_position_type", ad_position_type);
|
||
Append("ad_position", ad_position);
|
||
Append("rit_scene", "0");
|
||
Append("rit_scene_describe", ad_position);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_show", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 广告播放结束
|
||
/// ohayoo_game_show_end
|
||
/// 用户观看广告结束时,SDK会回调completed,即广告播放完成,收到这个回调后埋点上报。游戏产品端如有搭建自有服务器,该事件建议走服务端日志。
|
||
/// </summary>
|
||
/// <param name="ad_type"></param>
|
||
/// <param name="ad_position_type">广告点位类型 是 string 广告点位类型:物品、养成、道具等,基于ad_position汇总类型</param>
|
||
/// <param name="ad_position">ad_position 广告点位 是 string 自定义广告点位名称:ad_position_type加下划线加自定义广告点位格式上报,例:物品_关卡奖励多倍、道具_关卡复活</param>
|
||
/// <param name="result"></param>
|
||
/// <param name="stageId"></param>
|
||
public void ReportEventShowEndAd(string ad_type, string ad_position_type, string ad_position, string result, string stageId)
|
||
{
|
||
Begin();
|
||
Append("ectype_name", stageId);
|
||
Append("ad_type", ad_type);
|
||
//Append("rit_id", "946371133");
|
||
Append("ad_position_type", ad_position_type);
|
||
Append("ad_position", ad_position);
|
||
Append("result", result);
|
||
//Append("rit_scene", "0");
|
||
//Append("rit_scene_describe", ad_position);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_show_end", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// ohayoo_game_skilllevelup
|
||
/// 技能升级(武学打在这里
|
||
/// </summary>
|
||
/// <param name="wx_step"></param>
|
||
/// <param name="skilltype"></param>
|
||
/// <param name="skillname"></param>
|
||
/// <param name="bef"></param>
|
||
/// <param name="af"></param>
|
||
/// <param name="befbattlepoint"></param>
|
||
/// <param name="afbattlepoint"></param>
|
||
public void ReportEvent_SkillLevelUp(string wx_step, string skilltype, string skillname, int bef, int af, int befbattlepoint, int afbattlepoint)
|
||
{
|
||
Begin();
|
||
Append("wx_step", wx_step);
|
||
Append("skilltype", skilltype);
|
||
Append("skillname", skillname);
|
||
Append("bef", bef);
|
||
Append("af", af);
|
||
Append("befbattlepoint", befbattlepoint);
|
||
Append("afbattlepoint", afbattlepoint);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_skilllevelup", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// ohayoo_game_battlemap
|
||
/// 关卡/战斗
|
||
/// </summary>
|
||
/// <param name="battletype">关卡/战斗类型 是 string 枚举:普通/困难/pve/pvp等(参数不够不明同数分沟通),直接打中文</param>
|
||
/// <param name="mapchapter">章节 否 int 游戏的章节。比如:1=桃花镇、2=白帝山</param>
|
||
/// <param name="mapid">关卡id 否 int 含关卡id情况下上报,mapid必须有序,比如:1=林间小道、2=溪间道路</param>
|
||
/// <param name="submapid">子关卡id 否 int 如 林间小道 中细分的进度1,2,3等</param>
|
||
/// <param name="islastsubmapid"> 是否是关卡中最后的子关卡 否 int 默认值报0,是关卡中的最后地块时报1,否则报0;若不上报submapid,则islastsubmapid也不上报;若特殊玩法下无submapid上报,则submapid字段及islastsubmapid字段都报空值;</param>
|
||
/// <param name="battleresult">战斗状态 是 int 关卡状态枚举:0 开始、1 暂停、2 继续、3 成功、4 失败、5 复活、6 死亡(结算退出)。仅打枚举参数(如果用户非手动暂停情况下,杀进程退出必打暂停状态)</param>
|
||
/// <param name="deathtimes">死亡次数 否 int 关卡结束状态(成功、失败)存在死亡形态,有则打出此次局内总死亡次数</param>
|
||
/// <param name="skilltimes">技能释放详情 否 string 技能1名称+次数&技能2名称+次数+。。。</param>
|
||
/// <param name="costtime">关卡/战斗花费时间(秒) 否 int 关卡结束状态(成功、失败)后,打单局时长(秒)。开始时=0即可</param>
|
||
/// <param name="costtime_auto">自动战斗时间 否 int 关卡结束状态(成功、失败)后,打单局 自动战斗 时长(秒)。</param>
|
||
/// <param name="left_hp">剩余血量百分比 否 float 战斗结束后的剩余血量</param>
|
||
public void ReportEvent_Battle(string battletype, int mapchapter, int mapid, int submapid, int islastsubmapid, int battleresult, int deathtimes, string skilltimes, int costtime, int costtime_auto, int left_hp)
|
||
{
|
||
Begin();
|
||
Append("battletype", battletype);
|
||
Append("mapchapter", mapchapter);
|
||
Append("mapid", mapid);
|
||
Append("submapid", submapid);
|
||
Append("islastsubmapid", islastsubmapid);
|
||
Append("battleresult", battleresult);
|
||
Append("deathtimes", deathtimes);
|
||
Append("skilltimes", skilltimes);
|
||
Append("costtime", costtime);
|
||
Append("costtime_auto", costtime_auto);
|
||
Append("left_hp", left_hp);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_battlemap", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// ohayoo_game_battlechoose
|
||
/// 局内技能选择/奇遇获取
|
||
/// </summary>
|
||
/// <param name="battletype">战斗/关卡类型 是 string 枚举:普通/困难/pve/pvp等(参数不够不明同数分沟通),直接打中文</param>
|
||
/// <param name="mapchapter">章节 否 int 游戏的章节。比如:1=桃花镇、2=白帝山</param>
|
||
/// <param name="mapid">关卡id 否 int 含关卡id情况下上报,mapid必须有序,比如:1=林间小道、2=溪间道路</param>
|
||
/// <param name="submapid">子关卡id 否 int 如 林间小道 中细分的进度1,2,3等</param>
|
||
/// <param name="choosetype">选择类型 是 int 1=技能选择。2=奇遇</param>
|
||
/// <param name="chooseid1">可选择内容id1</param>
|
||
/// <param name="chooseid2"></param>
|
||
/// <param name="chooseid3"></param>
|
||
/// <param name="finalchoose">最终选择内容 是 int 用户获得的选择后/增益类buffid。当全部都要的时候=-1000,当全部都不要的时候=-2000</param>
|
||
public void ReportEvent_BattleChoose(string battletype, int mapchapter, int mapid, int submapid, int choosetype, int chooseid1, int chooseid2, int chooseid3, int finalchoose)
|
||
{
|
||
Begin();
|
||
Append("battletype", battletype);
|
||
Append("mapchapter", mapchapter);
|
||
Append("mapid", mapid);
|
||
Append("submapid", submapid);
|
||
Append("choosetype", choosetype);
|
||
Append("chooseid1", chooseid1);
|
||
Append("chooseid2", chooseid2);
|
||
Append("chooseid3", chooseid3);
|
||
Append("finalchoose", finalchoose);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_battlechoose", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// ohayoo_game_travel
|
||
/// </summary>
|
||
/// <param name="city"></param>
|
||
/// <param name="event_name"></param>
|
||
/// <param name="option"></param>
|
||
/// <param name="tier"></param>
|
||
public void ReportEvent_Travel(string city, int event_type, int option, int tier)
|
||
{
|
||
Begin();
|
||
Append("city", city);
|
||
Append("event_type", event_type);
|
||
Append("option", option);
|
||
Append("tier", tier);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_travel", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 等级升级
|
||
/// ohayoo_game_levelup
|
||
/// 1、有升级变化的情况下打 2、无等级体系,可按主玩法的id变化进行上报
|
||
/// </summary>
|
||
/// <param name="lev_type">等级类型 是 int 1=角色等级;2=阅历等级。。。后续有游戏内重要等级可以在这里增添。</param>
|
||
/// <param name="lev"></param>
|
||
/// <param name="aflev"></param>
|
||
public void ReportEventLevelUp(int lev_type, int lev, int aflev, string reason, int costtime)
|
||
{
|
||
Begin();
|
||
Append("lev_type", lev_type);
|
||
Append("beflevel", lev);
|
||
Append("aflev", aflev);
|
||
Append("reason", reason);
|
||
Append("costtime", costtime);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_levelup", data);
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="stageId"></param>
|
||
public void ReportEventStartStage(string stageId)
|
||
{
|
||
Begin();
|
||
Append("ectype_name", stageId);
|
||
var data = End();
|
||
|
||
ReportEvent("gt_start_stage", data);
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="stageId"></param>
|
||
/// <param name="died"></param>
|
||
public void ReportEventDied(string stageId, int died)
|
||
{
|
||
Begin();
|
||
Append("ectype_name", stageId);
|
||
Append("died", died);
|
||
var data = End();
|
||
|
||
ReportEvent("gt_stage_died", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 复活:gt_revive
|
||
/// </summary>
|
||
/// <param name="play_type">玩法类型:休闲模式、竞技模式</param>
|
||
/// <param name="play_id">play_type下对应的玩法id,例如章节等,如果是闯关性质的玩法,使用连续数字标识关卡的顺序</param>
|
||
/// <param name="play_lev">play_id下对应的关卡等级</param>
|
||
/// <param name="method">用户复活的途径:观看激励视频、使用金币等,使用汉字标识</param>
|
||
public void ReportRevive(string stageId, string result, string method = "play_ad")
|
||
{
|
||
Begin();
|
||
Append("ectype_name", stageId);
|
||
Append("play_type", "main");
|
||
Append("result", result);
|
||
Append("method", method);
|
||
var data = End();
|
||
|
||
ReportEvent("gt_revive", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 新手引导:ohayoo_game_guide
|
||
/// </summary>
|
||
/// <param name="guide_id">新手引导的步骤:例如新手引导的第2步,则用2标识,使用数字标识引导内容的顺序</param>
|
||
/// <param name="guide_name">新手引导内容:例如:“点击开始按钮”,“切换到首页”等,使用汉字标识</param>
|
||
public void ReportGuide(int guide_id, string guidedesc)
|
||
{
|
||
Begin();
|
||
Append("guide_id", guide_id);
|
||
Append("guidedesc", guidedesc);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_guide", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 活动参与及奖励:
|
||
/// ohayoo_game_activity
|
||
/// </summary>
|
||
/// <param name="activitytype">活动类型 否 string 参数:日常活动 、特殊活动 等,研发可根据需求自打</param>
|
||
/// <param name="actid">活动id 是 string 该活动唯一标识</param>
|
||
/// <param name="actname">活动中文名 是 string 该活动的中文名</param>
|
||
/// <param name="actdesc">活动描述 否 string 该活动如果有中文详细描述,可打</param>
|
||
/// <param name="actresult">活动结果 是 int 参数:0 参加、1 完成、2 未完成、3 曝光</param>
|
||
/// <param name="actreward">活动奖励内容 否 string 该活动如果存在奖励,可将奖励内容打在该参数内</param>
|
||
/// <param name="starttime">活动开始时间戳(10位) 否 bigint 节日、特殊等活动如果存在时间限制,可将活动开启10位时间戳打在该参数</param>
|
||
/// <param name="endtime">活动结束时间戳(10位) 否 bigint 将活动关闭10位时间戳打在该参数</param>
|
||
public void ReportEvent_Activity(string activitytype, int actid, int subid, string actname, string actdesc, int actresult, string actreward, int starttime, int endtime)
|
||
{
|
||
Begin();
|
||
Append("activitytype", activitytype);
|
||
Append("actid", actid);
|
||
Append("subid", subid);
|
||
Append("actname", actname);
|
||
Append("actdesc", actdesc);
|
||
Append("actresult", actresult);
|
||
Append("actreward", actreward);
|
||
Append("starttime", starttime);
|
||
Append("endtime", endtime);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_activity", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 任务
|
||
/// ohayoo_game_task
|
||
/// </summary>
|
||
/// <param name="tasktype"></param>
|
||
/// <param name="taskid"></param>
|
||
/// <param name="taskname"></param>
|
||
/// <param name="taskdesc"></param>
|
||
/// <param name="taskresult"></param>
|
||
/// <param name="taskreward"></param>
|
||
public void ReportEvent_Mission(string tasktype, int taskid, string taskname, string taskdesc, int taskresult, string taskreward)
|
||
{
|
||
Begin();
|
||
Append("tasktype", tasktype);
|
||
Append("taskid", taskid);
|
||
Append("taskname", taskname);
|
||
Append("taskdesc", taskdesc);
|
||
Append("taskresult", taskresult);
|
||
Append("taskreward", taskreward);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_task", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 解锁玩法/系统:
|
||
/// ohayoo_game_unlock
|
||
/// </summary>
|
||
/// <param name="unlocktype">解锁类型 否 string 任务解锁、关卡解锁等,研发可自定义打</param>
|
||
/// <param name="unlockid">解锁内容id 否 string 该解锁的唯一标识,有则打</param>
|
||
/// <param name="unlockname">解锁中文名 是 string 具体解锁内容的中文标识</param>
|
||
public void ReportEvent_UnlockSystem(string unlocktype, int unlockid, string unlockname)
|
||
{
|
||
Begin();
|
||
Append("unlocktype", unlocktype);
|
||
Append("unlockid", unlockid);
|
||
Append("unlockname", unlockname);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_unlock", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 个人排行
|
||
/// ohayoo_game_rank
|
||
/// </summary>
|
||
/// <param name="ranktype">排行榜类型 是 string 参数:个人排行榜、战力排行榜、财富排行榜等,研发可自定义打</param>
|
||
/// <param name="rank">个人排名 是 int 个人排名</param>
|
||
/// <param name="point">个人排名分值 是 int 个人排名分值</param>
|
||
public void ReportEvent_GameRank(string ranktype, int rank, int point)
|
||
{
|
||
Begin();
|
||
Append("ranktype", ranktype);
|
||
Append("rank", rank);
|
||
Append("point", point);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_rank", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 各类功能按钮的点击:
|
||
/// ohayoo_game_buttonclick
|
||
/// </summary>
|
||
/// <param name="buttontype">button类型 否 string 参数:主界面button、互动页button、底部button等,可自定义打中文</param>
|
||
/// <param name="button_name">button中文名称 是 string 参数:商城、关卡、公会等,button的中文名称必打,可自定义中文</param>
|
||
public void ReportButtonClick(string buttontype, string buttonname)
|
||
{
|
||
Begin();
|
||
Append("buttontype", buttontype);
|
||
Append("buttonname", buttonname);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_buttonclick", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 虚拟货币(体力也打在这里面)
|
||
/// ohayoo_game_moneyflow
|
||
/// </summary>
|
||
/// <param name="moneytype"></param>
|
||
/// <param name="moneyname"></param>
|
||
/// <param name="addorreduce"></param>
|
||
/// <param name="mchange"></param>
|
||
/// <param name="moneyleft"></param>
|
||
/// <param name="reason"></param>
|
||
public void ReportEvent_Money(int moneytype, string moneyname, int addorreduce, int mchange, int moneyleft, string reason)
|
||
{
|
||
Begin();
|
||
Append("moneytype", moneytype);
|
||
Append("moneyname", moneyname);
|
||
Append("addorreduce", addorreduce);
|
||
Append("mchange", mchange);
|
||
Append("moneyleft", moneyleft);
|
||
Append("reason", reason);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_moneyflow", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// ohayoo_game_itemflow
|
||
/// 虚拟道具
|
||
/// </summary>
|
||
/// <param name="itemtype">道具类型 是 int 枚举参数:0 消耗类、1 装备类,按参数打(参数不明不够可联系数分) </param>
|
||
/// <param name="itemid">道具id 是 int 道具的唯一标识</param>
|
||
/// <param name="itemname">道具中文含义 是 string 道具的中文名称(无码表工具支持的情况下,目前均需要打)</param>
|
||
/// <param name="addorreduce">增加或减少 是 int 枚举参数:0 减少、1 增加</param>
|
||
/// <param name="ichange">道具变化量 是 int 造成的道具数量变化,必须为整数型</param>
|
||
/// <param name="itemleft">剩余道具 是 int 该类道具变化后剩余数量,必须为整数型</param>
|
||
/// <param name="reason">变化原因 是 string 记录变化原因,该参数必打,记录道具流变化原因</param>
|
||
public void ReportEvent_Item(string itemtype, int itemid, string itemname, int addorreduce, int ichange, int itemleft, string reason)
|
||
{
|
||
Begin();
|
||
Append("itemtype", itemtype);
|
||
Append("itemid", itemid);
|
||
Append("itemname", itemname);
|
||
Append("addorreduce", addorreduce);
|
||
Append("ichange", ichange);
|
||
Append("itemleft", itemleft);
|
||
Append("reason", reason);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_itemflow", data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// ohayoo_game_fps
|
||
/// 帧率日志
|
||
/// </summary>
|
||
/// <param name="game_ui">game_ui 玩家游戏界面 是 string 日志上报时,玩家所处的游戏界面</param>
|
||
/// <param name="mapchapter">mapchapter 章节 否 int 游戏的章节。比如:1=桃花镇、2=白帝山。当局内战斗时上报</param>
|
||
/// <param name="mapid">mapid 关卡id 否 int 含关卡id情况下上报,mapid必须有序,比如:1=林间小道、2=溪间道路</param>
|
||
/// <param name="submapid">submapid 子关卡id 否 int 如 林间小道 中细分的进度1,2,3等</param>
|
||
/// <param name="fps">fps 帧率 是 int 玩家帧率</param>
|
||
/// <param name="game_set">game_set 游戏设置 是 json 玩家的游戏设置。如{ "画质": "高"},玩家帧率除硬件因素外,也和游戏设置的画质等高中低有关,泛记录一些影响帧率的设置。</param>
|
||
/// <param name="cpu">cpu 中央处理器 是 string 设备的cpu。如高通骁龙865</param>
|
||
/// <param name="gpu">gpu 图形处理器 是 string 设备的gpu。如Adreno 660</param>
|
||
/// <param name="resolution">resolution 分辨率 是 string 设备的显示分辨率。如1920*1080</param>
|
||
/// <param name="ram">ram 运行内存 是 int 设备的ram。如2048M</param>
|
||
/// <param name="cpu_usage">cpu_usage cpu使用率 是 float 记录日志上报时,设备cpu的使用率。如0.25</param>
|
||
/// <param name="ram_usage">ram_usage ram使用率 是 float 记录日志上报时,设备ram的使用率。如0.25</param>
|
||
public void ReportEvent_Fps(string game_ui, int mapchapter, int mapid, int submapid, int fps, string game_set, string cpu, string gpu, string resolution, int ram, int cpu_usage, int ram_usage)
|
||
{
|
||
Begin();
|
||
Append("game_ui", game_ui);
|
||
Append("mapchapter", mapchapter);
|
||
Append("mapid", mapid);
|
||
Append("submapid", submapid);
|
||
Append("fps", fps);
|
||
Append("cpu", cpu);
|
||
Append("gpu", gpu);
|
||
Append("ram", ram);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_fps", data);
|
||
}
|
||
|
||
public void ReportEvent_Pay(string payid, string platform, string result)
|
||
{
|
||
Begin();
|
||
Append("payid", payid);
|
||
Append("platform", platform);
|
||
Append("result", result);
|
||
var data = End();
|
||
|
||
ReportEvent("ohayoo_game_pay", data);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region UNITY & STATIC
|
||
|
||
private static KStatistics _Instance;
|
||
public static KStatistics Instance { get { return _Instance; } }
|
||
private void Awake()
|
||
{
|
||
_Instance = this;
|
||
}
|
||
|
||
private void Start()
|
||
{
|
||
#if ENABLE_KTA
|
||
ThinkingAnalytics.ThinkingAnalyticsAPI.EnableAutoTrack(ThinkingAnalytics.AUTO_TRACK_EVENTS.ALL);
|
||
#endif
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
}
|