In the Statsig React SDK, you can use the initCompletionCallback
option during the SDK initialization to verify if the initialization was successful within a specified timeframe. This callback is invoked when the initialization process is completed, but before the provider re-renders the app. Therefore, it is useful for metadata collection on timing and success rates, but it is not a hook for triggering checks to gates or other entities. The initCompletionCallback
provides three parameters: initDurationMs
, success
, and message
.
If the initialization was not successful within the specified timeframe, the success
parameter would be false
and the message
parameter would provide additional information.
Here's an example of how to use it:
statsig.initialize('<CLIENT_SDK_KEY>', user, {
initCompletionCallback: (initDurationMs, success, message) => {
if (success) {
console.log('Statsig has been initialized successfully.');
} else {
console.log('Statsig initialization failed:', message);
}
},
});
Please note that this option is supported in v4.13.0+ of the JavaScript SDK. For more information, you can refer to the Statsig JavaScript SDK documentation under Options.