小编Ale*_*sky的帖子

如何在本机生产构建中访问 global.nativePerformanceNow() ?或者任何其他测量时间戳的方法

我正在尝试测量在不同国家/地区的用户设备上的反应本机应用程序中加载图像需要多长时间。

\n\n

在调试模式下, Performance.now() 创建时间戳,然后将其作为事件的属性发送到 Amplitude。

\n\n

但 Performance.now() 是一个 JS 方法,在 Release 版本中不提供给用户。有一个未记录的 global.nativePerformanceNow 方法

\n\n
 const loadStartAmplitudeEvent = () => {\n    if (R.not(__DEV__)) {\n      const timeStamp = global.nativePerformanceNow();\n      amplitude.logEvent(\'Photo On Load Start\', {\n        uri, timeStamp,\n      });\n    }\n  };\n
Run Code Online (Sandbox Code Playgroud)\n\n

例如,这就是我创建一个带有时间戳的事件以发送到幅度的方法,但我收到错误,我做错了什么?多谢!我应该使用其他方法吗?global.nativePerformanceNow \xe2\x86\x92 g.nativePerformanceNow 转换是否搞砸了?

\n\n
2019-08-06 03:10:45.134 [error][tid:com.facebook.react.JavaScript]\ng.nativePerformanceNow is not a function. \n(In \'g.nativePerformanceNow()\', \'g.nativePerformanceNow\' is undefined)\n
Run Code Online (Sandbox Code Playgroud)\n

performance timestamp react-native

5
推荐指数
1
解决办法
2437
查看次数

标签 统计

performance ×1

react-native ×1

timestamp ×1