0

我们在拥有数千名用户的流程中使用 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 方面控制更多。那是对的吗?我们还能看到什么?

4

1 回答 1

0

我们在使用 REST API 时遇到了类似的问题。

在这里,您可以看到与 Jordi 的情况不谋而合的情况:

  • 我们也来自西班牙(以及我们的用户),尽管我们在西班牙和美国使用服务器
  • 对于某些用户,我们获得与 google fit 应用程序相同的每日步数值,但对于其他用户则不然
  • 当天步数增加,但隔天我们提出请求,有时每日步数会减少
  • 从一天的开始到一天的结束,我们发出相同的请求,桶时间为 86400000,数据类型和数据源 ID 相同

我们正处于最后的开发阶段,所以我们只对少数用户进行测试。我们的用户拥有小米手环设备。

我们认为问题可能是我们正在访问的服务器不同步,因为如果我们使用类似这样的其他应用程序进行测试,它们会显示正确的值。我们创建了另一个谷歌云控制台 oauth 客户端凭据和新的电子邮件帐户,以使用全新的用户和 oauth 客户端进行测试,但结果是相同的。

这是获取每日步骤的推荐方法,我们使用完全相同的请求 https://developers.google.com/fit/scenarios/read-daily-step-total 甚至使用文档中的“尝试”选项结果是错误的。

我们还能做些什么来帮助您解决问题?非常感谢!

于 2021-03-25T12:17:13.287 回答