Athana SDK

For Games

事件服务

配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Examples
// EventFactory 包含常用的事件构建

// 自定义事件
// [key] 事件Key
// [type] 事件类别,game - 游戏类事件;ad - 广告类事件
// [params] 事件参数
val event = EventFactory.buildEvent(key, type, params)

// 登出事件
val event = EventFactory.logout(params)

// 游戏任务事件
// - [taskId] 任务ID
// - [taskType] 任务类型
// - 1 - 一次性任务
// - 2 - 重复任务
// - [repeatCycle] 重复周期,是重复任务的前提下可传秒钟为单位,传int数字,每日重复,则传 86400* - [repeatCycleTimes] 期望数量
val event = EventFactory.logGamesTask(
taskId: Int,
taskType: Int,
repeatCycle: Int?,
repeatCycleTimes: Int?,
params: Map<String, Any>?,
)

// 游戏通关成功事件
// - [clearCostTime] 通关消耗时长,精确到毫秒
// - [level] 通关关卡,字符串,需要区分小关的话,可以用 "1-10"、"1-11"等
// - [score] 通过分数
// - [clearTimes] 累计通关关卡次数
// - [isRecharge] 是否在关卡中充值,1-是;2-否
// - [rechargeAmount] 充值金额,如果有充值,可传,最好以 美元/美分为单位
// - [currency] 如果广告商返回非 美元/美分 的预估收益,需要将 货币单位 返回来
// - [paid] 是否收费关卡,1-是;2-否
val event = EventFactory.logGamesStageFinished(
clearCostTime: Int,
level: String,
score: Int?,
clearTimes: Int?,
isRecharge: Int?,
rechargeAmount: Double?,
currency: String?,
paid: Int?,
params: Map<String, Any>?,
)

// 游戏通关失败事件
// - [clearCostTime] 通关消耗时长,精确到毫秒
// - [level] 当前关卡,字符串,需要区分小关的话,可以用 "1-10"、"1-11"等
// - [levelType] 关卡类型
// - 0 - 普通关卡
// - 1 - 副本关卡
// - 2 - 日常关卡
// - [reason] 失败原因
// - 1 - 超过限制时间
// - 2 - 没有可移动的步骤
// - [paid] 是否收费关卡,1-是;2-否
val event = EventFactory.logGamesStageNotFinish(
clearCostTime: Int,
level: String,
levelType: Int?,
reason: Int?,
paid: Int?,
params: Map<String, Any>?,
)

// 新手教程完成事件
// - [costTime] 消耗时长,精确到毫秒
// - [startTrialId] 新手教程id
// - [startTrialName] 新手教程名称
val event = EventFactory.logGamesStartTrialFinished(
costTime: Long,
startTrialId: Int,
startTrialName: String?,
params: Map<String, Any>?,
)

// 新手教程未完成(跳过)事件
// - [costTime] 消耗时长,精确到毫秒
// - [startTrialId] 新手教程id
// - [startTrialName] 新手教程名称
val event = EventFactory.logGamesStartTrialNotFinish(
costTime: Long,
startTrialId: Int,
startTrialName: String?,
params: Map<String, Any>?,
)

// 游戏角色升级/关卡通过事件
// - [oldLevel] 旧等级 / 关卡
// - [newLevel] 新等级 / 关卡
// - [scene] 发生场景
// - 1 - 通关关卡(副本)
// - 2 - 做任务
// - 3 - 击杀小怪
// - [sceneExt] 场景额外参数,例如:第几关卡、任务ID
// - [roleId] 游戏角色Id,适用于多角色类游戏
val event = EventFactory.logGamesLevelUp(
oldLevel: Int,
newLevel: Int,
scene: Int?,
sceneExt: String?,
roleId: Int?,
params: Map<String, Any>?,
)

// 分享事件
val event = EventFactory.logShare(params: Map<String, Any>?)

// 邀请事件
val event = EventFactory.logInvite(params: Map<String, Any>?)

// 发送事件
Athana.getInstance().eventService.logEvent(event)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Examples

// EventFactory 包含常用的事件构建

// 有额外参数需要传递,则创建
Map<String, Object> params = new HashMap<>();
params.put("params1", "value1");
// 没有额外参数传递,则不需要 params 参数
Map<String, Object> params = null;

// 自定义事件
// [key] 事件Key
// [type] 事件类别,game - 游戏类事件;ad - 广告类事件
// [params] 事件参数
GamesEvent event = EventFactory.buildEvent(key, type, params);

// 登出事件
GamesEvent event = EventFactory.logout(params);

// 游戏任务事件
// - [taskId] 任务ID
// - [taskType] 任务类型
// - 1 - 一次性任务
// - 2 - 重复任务
// - [repeatCycle] 重复周期,是重复任务的前提下可传秒钟为单位,传int数字,每日重复,则传 86400* - [repeatCycleTimes] 期望数量
GamesEvent event = EventFactory.logGamesTask(
taskId,
taskType,
repeatCycle,
repeatCycleTimes,
params
);

// 游戏通关成功事件
// - [clearCostTime] 通关消耗时长,精确到毫秒
// - [level] 通关关卡,字符串,需要区分小关的话,可以用 "1-10"、"1-11"等
// - [score] 通过分数
// - [clearTimes] 累计通关关卡次数
// - [isRecharge] 是否在关卡中充值,1-是;2-否
// - [rechargeAmount] 充值金额,如果有充值,可传,最好以 美元/美分为单位
// - [currency] 如果广告商返回非 美元/美分 的预估收益,需要将 货币单位 返回来
// - [paid] 是否收费关卡,1-是;2-否
GamesEvent event = EventFactory.logGamesStageFinished(
clearCostTime,
level,
score,
clearTimes,
isRecharge,
rechargeAmount,
currency,
paid,
params
);

// 游戏通关失败事件
// - [clearCostTime] 通关消耗时长,精确到毫秒
// - [level] 当前关卡,字符串,需要区分小关的话,可以用 "1-10"、"1-11"等
// - [levelType] 关卡类型
// - 0 - 普通关卡
// - 1 - 副本关卡
// - 2 - 日常关卡
// - [reason] 失败原因
// - 1 - 超过限制时间
// - 2 - 没有可移动的步骤
// - [paid] 是否收费关卡,1-是;2-否
GamesEvent event = EventFactory.logGamesStageNotFinish(
clearCostTime,
level,
levelType,
reason,
paid,
params
);

// 新手教程完成事件
// - [costTime] 消耗时长,精确到毫秒
// - [startTrialId] 新手教程id
// - [startTrialName] 新手教程名称
GamesEvent event = EventFactory.logGamesStartTrialFinished(
costTime,
startTrialId,
startTrialName,
params
);

// 新手教程未完成(跳过)事件
// - [costTime] 消耗时长,精确到毫秒
// - [startTrialId] 新手教程id
// - [startTrialName] 新手教程名称
GamesEvent event = EventFactory.logGamesStartTrialNotFinish(
costTime,
startTrialId,
startTrialName,
params
);

// 游戏角色升级/关卡通过事件
// - [oldLevel] 旧等级 / 关卡
// - [newLevel] 新等级 / 关卡
// - [scene] 发生场景
// - 1 - 通关关卡(副本)
// - 2 - 做任务
// - 3 - 击杀小怪
// - [sceneExt] 场景额外参数,例如:第几关卡、任务ID
// - [roleId] 游戏角色Id,适用于多角色类游戏
GamesEvent event = EventFactory.logGamesLevelUp(
oldLevel,
newLevel,
scene,
sceneExt,
roleId,
params
);

// 分享事件
GamesEvent event = EventFactory.logShare(params);

// 邀请事件
GamesEvent event = EventFactory.logInvite(params);

// 发送事件
Athana.getInstance().getEventService().logEvent(event);
0%