我正在尝试使Mixpanel人员跟踪工作,但没有成功。我在日志中看到发送了create alias event
,但在Mixpanel控制台中未创建用户配置文件。
这也是演示应用程序中的代码,我设法在其中复制了该问题,由于机密性原因,我无法共享原始应用程序中的代码。
class MainActivity : AppCompatActivity() {
lateinit var mixpanel: MixpanelAPI
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mixpanel = MixpanelAPI.getInstance(this, "mytoken")
mixpanel.people.set("open date", Date())
mixpanel.identify(mixpanel.distinctId)
setContentView(R.layout.activity_main)
initCustomer()
postToMixpanel("TEST EVENT")
MPLog.setLevel(MPLog.VERBOSE)
}
fun initCustomer() {
mixpanel.alias("1", mixpanel.distinctId)
val map = listOfNotNull(
"\$name" to "Nikola",
"Gender" to "Male",
"Attraction" to "Girls",
"Account type" to "WTF",
"\$email" to "mail@mail.com"
).toMap()
mixpanel.people.setMap(map)
mixpanel.flush()
}
fun postToMixpanel(eventId: String, additionalProps: Map<String, Any>? = null) {
val props = JSONObject()
additionalProps?.let {
for ((key, value) in it) {
props.put(key, value)
}
}
mixpanel.track(eventId, props)
}
}
这些是创建别名事件的混合面板日志,我看不到其中的任何特殊属性,例如$name
和$email
。
[{ "event": "$create_alias", "properties": { "mp_lib": "android", "$lib_version": "5.4.1", "$os": "Android", "$os_version": "8.1.0", "$manufacturer": "UMIDIGI", "$brand": "UMIDIGI", "$model": "A1_PRO", "$google_play_services": "available", "$screen_dpi": 320, "$screen_height": 1344, "$screen_width": 720, "$app_version": "1.007-staging", "$app_version_string": "1.007-staging", "$app_release": 15, "$app_build_number": 15, "$has_nfc": false, "$has_telephone": true, "$carrier": "m:tel", "$wifi": true, "$bluetooth_enabled": false, "$bluetooth_version": "ble", "token": "", "Has Credit": "False", "Amount of Credits": "0", "time": 1530099794, "distinct_id": "b8769eeb-6a3b-4692-8973-261f9933537e", "alias": "260", "original": "b8769eeb-6a3b-4692-8973-261f9933537e" }, "$mp_metadata": { "$mp_event_id": "43f9c3402ffa6f4c", "$mp_session_id": "c35a49a17d3b9de6", "$mp_session_seq_id": 0, "$mp_session_start_sec": 1530099793 } }]
答案 0 :(得分:1)
尝试在people对象上调用 identify()方法。它应该在Mixpanel中创建一个用户。
mixpanel.people.identify(mixpanel.getDistinctId());
之后
mixpanel.alias("1", mixpanel.distinctId)
通过您有趣的initCustomer()
方法。
示例:
fun initCustomer() {
mixpanel.alias("1", mixpanel.distinctId)
mixpanel.people.identify(mixpanel.getDistinctId());
val map = listOfNotNull(
"\$name" to "Nikola",
"Gender" to "Male",
"Attraction" to "Girls",
"Account type" to "WTF",
"\$email" to "mail@mail.com"
).toMap()
mixpanel.people.setMap(map)
mixpanel.flush()
}
Android文档中“部分:管理用户身份”中的更多信息