Background
I am trying to measure app launch time (TTFD) using the @amazon-devices/kepler-performance-api package.
The official documentation recommends using the useReportFullyDrawn() hook, but I have a use case where I need to emit the fully_drawn marker from outside a React component (i.e., a non-React context). For this reason, I am considering calling global.performance.reportFullyDrawn directly, which appears to be the underlying implementation used by the hook.
Questions
1. Is it safe to call global.performance.reportFullyDrawn directly?
Since useReportFullyDrawn is a React hook, it can only be called inside a React component. I would like to know whether calling global.performance.reportFullyDrawn(...) directly from a non-React context or a utility function is a supported usage, or whether it is considered an unsupported internal API that may break in future versions.
2. Is it safe to pass null or an empty value for the rootTag argument?
Looking at the internal implementation of the hook, I can see that it retrieves rootTag from RootTagContext and passes it to global.performance.reportFullyDrawn(rootTag). When calling the function directly outside of a React context, RootTagContext is not accessible, so rootTag would need to be passed as null or an empty value. Would this cause any issues with TTFD measurement?
3. Is it safe to call reportFullyDrawn multiple times during app launch?
I am considering an implementation that calls reportFullyDrawn at different points to handle both cold start and warm start scenarios. If the function is called multiple times within a single launch lifecycle, could this corrupt trace data or cause a crash?
Environment
-
Package:
@amazon-devices/kepler-performance-api v0.1.2 -
Related hook:
useReportFullyDrawn
Thank you in advance for your help.