-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
124 lines (110 loc) · 2.66 KB
/
index.js
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
123
124
'use strict';
import React, {Component, PropTypes} from 'react';
import {
StyleSheet,
View,
Text,
Animated,
Platform,
Dimensions,
PickerIOS,
NativeModules
} from 'react-native';
const RNMTA = NativeModules.MTA;
class MTA {
startWithAppkey(appkey){
// appkey = typeof appkey === "string" ? appkey : "";
RNMTA.startWithAppkey(appkey);
this.kvs = {};
}
startWithAppkeyVersion(appkey){
// appkey = typeof appkey === "string" ? appkey : "";
return new Promise((resolve, reject)=>{
RNMTA.startWithAppkeyVersion(appkey, (error, res)=>{
if(!error)
return resolve(res);
else
return reject(error);
});
})
}
/**
* 设置MTA全局kvs,用户注入用户user_id等操作
* @Author kiddxu
* @DateTime 2016-11-17T14:50:08+0800
* @param {object} kvs 对象
*/
setGlobalKvs(kvs){
kvs = typeof kvs === "object" && !Array.isArray(kvs) ? kvs : {};
this.globalKvs = kvs;
}
changeToDebugMode(){
RNMTA.changeToDebugMode();
}
trackPageViewBegin(page){
RNMTA.trackPageViewBegin(page);
}
trackPageViewEnd(page){
RNMTA.trackPageViewEnd(page);
}
trackError(error){
RNMTA.trackError(error);
}
trackException(exception){
RNMTA.trackException(exception);
}
trackCustomEvent(event_id, array){
RNMTA.trackCustomEvent(event_id, array);
}
trackCustomEventBegin(event_id, array){
RNMTA.trackCustomEventBegin(event_id, array);
}
trackCustomEventEnd(event_id, array){
RNMTA.trackCustomEventEnd(event_id, array);
}
trackCustomKeyValueEvent(event_id, kvs={}){
console.debug("trackCustomKeyValueEvent: ", event_id);
RNMTA.trackCustomKeyValueEvent(event_id, {...kvs, ...this.globalKvs});
}
trackCustomKeyValueEventBegin(event_id, kvs={}){
RNMTA.trackCustomKeyValueEventBegin(event_id, {...kvs, ...this.globalKvs});
}
trackCustomKeyValueEventEnd(event_id, kvs={}){
RNMTA.trackCustomKeyValueEventEnd(event_id,{...kvs, ...this.globalKvs})
}
trackCustomKeyValueEventDuration(seconds,event_id, kvs={}){
RNMTA.trackCustomKeyValueEventDuration(seconds, event_id, {...kvs, ...this.globalKvs});
}
commitCachedStats(maxStatCount){
RNMTA.commitCachedStats(maxStatCount);
}
startNewSession(){
RNMTA.startNewSession();
}
stopSession(){
RNMTA.stopSession();
}
trackActiveBegin(){
RNMTA.trackActiveBegin();
}
trackActiveEnd(){
RNMTA.trackActiveEnd();
}
reportQQ(qq){
RNMTA.reportQQ(qq);
}
reportAccount(account,type,ext){
RNMTA.reportAccount(account, type, ext);
}
trackGameUser(uid,world,level){
RNMTA.trackGameUser(uid, world, level);
}
getMtaUDID(){
return new Promise((resolve, reject)=>{
const id = RNMTA.getMtaUDID();
resolve(id);
})
}
}
const mta = new MTA();
export default mta;