4

I am trying to measure how long does it take for images to load in a react native app on my users' devices in different countries.

In debug mode there is performance.now() that creates timestamp that I then send as a property of the event to Amplitude.

But performance.now() is a JS method and is not available in Release builds for users. There is an undocumented global.nativePerformanceNow method

 const loadStartAmplitudeEvent = () => {
    if (R.not(__DEV__)) {
      const timeStamp = global.nativePerformanceNow();
      amplitude.logEvent('Photo On Load Start', {
        uri, timeStamp,
      });
    }
  };

For example, that's how I create an event with a timestamp to send to amplitude, but I get an error, what am I doing wrong? Thanks a lot! Should i use some other method? Is the global.nativePerformanceNow → g.nativePerformanceNow transformation messing it up?

2019-08-06 03:10:45.134 [error][tid:com.facebook.react.JavaScript]
g.nativePerformanceNow is not a function. 
(In 'g.nativePerformanceNow()', 'g.nativePerformanceNow' is undefined)

1 Answers1

0

Seems like the feature was removed from RN in mid October 2018...

This crashes on device (works on Chrome tools which is a bit meh): https://github.com/facebook/react-native/issues/27274#issuecomment-557586801

But also seems it's been brought back from the dead recently. So maybe next React Native release will include performance, performanceNow(), performance.now() https://github.com/facebook/react-native/commit/232517a5740f5b82cfe8779b3832e9a7a47a8d3d

wolffan
  • 1,084
  • 10
  • 15