android - Mixpanel 人员跟踪不起作用
问题描述
我试图让 Mixpanel 的人跟踪工作但没有成功。我在日志中看到 acreate 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
and $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 } }]
解决方案
尝试在 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 文档中的更多信息部分:管理用户身份
推荐阅读
- javascript - 如何修复 jQuery 中的 ReferenceError
- macos - .zshrc 上的 PS1 输出字符串而不是所需的输出
- javascript - 如何让我的机器人可以容纳 2 个参数命令 DiscordJS
- r - 通过括号 [] 将字符串应用到子集
- javascript - 如何在 Visual Studio Code 上的 Vue 文件中启用 JavaScript 类型检查?
- javascript - 如何将自定义道具传递给反应登录按钮
- python - 将索引和值作为字典返回
- r - 有没有办法将 chemarr 的乳胶表达式用于 bookdown 包的 `gitbook` 格式?
- python - 方法内的递归
- python - 如何仅计算连续天数的百分比变化?