我们在拥有数千名用户的流程中使用 Googlefit REST API 来获取每日步数。对于大多数用户来说,过程是可以的,尽管我们发现一些用户具有这种特定行为:用户在白天步数增加,但在某些时候,他们会显着减少。
我们发现一些与此相关的问题主要与华为健康应用程序(以及一些小米健康应用程序)有关。
我们使用这个 dataSourceId 来获取每日步数:derived:com.google.step_count.delta:com.google.android.gms:estimated_steps
我们请求获取 3 月 15 日(西班牙时报)数据的示例之一:
POST https://www.googleapis.com/fitness/v1/users/me/dataSources
Accept: application/json
Content-Type: application/json;encoding=utf-8
Authorization: Bearer XXXXXXX
{
"aggregateBy": [{
"dataTypeName": "com.google.step_count.delta",
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
}],
"bucketByTime": { "durationMillis": 86400000 },
"startTimeMillis": 1615244400000,
"endTimeMillis": 1615330800000
}
对于大多数用户来说,这很顺利(它获得的数据与在 googlefit 应用程序中显示给用户的数据相同),但对于一些用户来说,一天中的数字首先增加,然后减少。googlefit 应用中的一些用户数据比通过 REST API 找到的数据要大得多(或显着多)。
我们甚至在白天对特定用户进行了跟踪。使用 'durationMillis': 3600000 的桶,我们绘制了一天内每小时步数的直方图(使用定制流程)。
在同一天,在不同的时间点(在这种情况下相差几个小时),我们为完全相同的用户得到了这个:
20210315-07 | ########################################################## | 1568
20210315-08 | ############################################################ | 1628
20210315-09 | ########################################################## | 1574
20210315-10 | ####################### | 636
20210315-11 | ################################################### | 1383
20210315-12 | ###################################################### | 1477
20210315-13 | ############################################### | 1284
20210315-14 | #################### | 552
与这个相比,它在几个小时后被检索到:
20210315-08 | ################# | 430
20210315-09 | ######### | 229
20210315-10 | ################# | 410
20210315-11 | ###################################################### | 1337
20210315-12 | ############################################################ | 1477
20210315-13 | #################################################### | 1284
20210315-14 | ###################### | 552
(“20210315-14”是指 2021 年 3 月 15 日 14 点)
这是第一种情况下返回的 JSON:
[{"startTimeNanos":"1615763400000000000","endTimeNanos":"1615763460000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":6,"mapVal":[]}]},
{"startTimeNanos":"1615788060000000000","endTimeNanos":"1615791600000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":1568,"mapVal":[]}]},
{"startTimeNanos":"1615791600000000000","endTimeNanos":"1615795080000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":1628,"mapVal":[]}]},
{"startTimeNanos":"1615795200000000000","endTimeNanos":"1615798500000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":1574,"mapVal":[]}]},
{"startTimeNanos":"1615798860000000000","endTimeNanos":"1615802400000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":636,"mapVal":[]}]},
{"startTimeNanos":"1615802400000000000","endTimeNanos":"1615806000000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":1383,"mapVal":[]}]},
{"startTimeNanos":"1615806000000000000","endTimeNanos":"1615809480000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":1477,"mapVal":[]}]},
{"startTimeNanos":"1615809660000000000","endTimeNanos":"1615813200000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":1284,"mapVal":[]}]},
{"startTimeNanos":"1615813380000000000","endTimeNanos":"1615815420000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":552,"mapVal":[]}]}]
这是后一种情况下返回的 JSON:
[{"startTimeNanos":"1615788300000000000","endTimeNanos":"1615791600000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":517,"mapVal":[]}]},
{"startTimeNanos":"1615791600000000000","endTimeNanos":"1615794540000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":430,"mapVal":[]}]},
{"startTimeNanos":"1615796400000000000","endTimeNanos":"1615798200000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":229,"mapVal":[]}]},
{"startTimeNanos":"1615798980000000000","endTimeNanos":"1615802400000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":410,"mapVal":[]}]},
{"startTimeNanos":"1615802400000000000","endTimeNanos":"1615806000000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":1337,"mapVal":[]}]},
{"startTimeNanos":"1615806000000000000","endTimeNanos":"1615809480000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":1477,"mapVal":[]}]},
{"startTimeNanos":"1615809660000000000","endTimeNanos":"1615813200000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":1284,"mapVal":[]}]},
{"startTimeNanos":"1615813380000000000","endTimeNanos":"1615815420000000000","dataTypeName":"com.google.step_count.delta","originDataSourceId":"raw:com.google.step_count.delta:com.huawei.health:","value":[{"intVal":552,"mapVal":[]}]}]
如您所见,所有点始终来自 originDataSourceId: "raw:com.google.step_count.delta:com.huawei.health"
看起来 Googlefit 的一个过程正在做某种调整,删除一些步骤或数据点,尽管我们无法找到检测什么和原因的方法,我们无法向用户解释正在发生的事情或他或我们可以做什么使他的应用数据与我们的完全一样(或相反)。他的 googlefit 应用程序显示的数字与 REST API 显示的数字不同。
用户已禁用“googlefit 应用跟踪活动”选项。
我很想知道,或尝试获得一些提示以了解:
- 我能做些什么来调试更多?
- 关于为什么会发生这种情况的任何提示?
- 无论如何,从配置的角度(对于用户)来说,可以防止这种情况发生吗?
- 无论如何,从发展的角度来看,是否可以防止这种情况发生?
谢谢并恭祝安康。
在安迪·特纳的问题之后更新(感谢您的评论!)。
我们能够在几个小时内“捕捉”到这一点:18.58(大约 6K 步)、21.58(大约 25K 步)、22.58(大约 17K 步)、23.58(大约 26K 步)。我们为这些导出了数据集,这是结果。
另一个重要信息:数据仅来自“raw:com.google.step_count.delta:com.huawei.health”。我们检查了其他可能看起来可疑的数据集,所有数据集都是空的(除了派生的等等)。
如果我们正确地解释这一点,可能是华为有时发送一个值,而下一次发送另一个东西;所以这可能是华为部分的一些错误配置。
以下是导出的数据集: https ://gist.github.com/jmarti-theinit/8d98996873a9c499a14899a9b62162f3
GIST的结果是:
Length of 18.58 points 165
Length of 21.58 points 503
Length of 22.58 points 294
Length of 23.58 points 537
How many points in 21.58 that exist in 18.58 => 165
How many points in 22.58 that exist in 18.58 => 57
How many points in 22.58 that exist in 21.58 => 294
How many points in 23.58 that exist in 18.58 => 165
How many points in 23.58 that exist in 21.58 => 503
How many points in 23.58 that exist in 22.58 => 294
所以我们的赌注是华为背后的设备会删除和添加积分(例如,在 18.58 - 22.58 中只有 57 是常见的),我们无法从 googlefit 方面控制更多。那是对的吗?我们还能看到什么?