You can indeed send the environment information using the HTTP API in Statsig. The process involves logging an event with a custom environment. Here's an example of how to do this:
bash curl \ --header "statsig-api-key: <YOUR-SDK-KEY>" \ --header "Content-Type: application/json" \ --request POST \ --data '{"events": [{"user": { "userID": "42", "statsigEnvironment": {"tier": "staging"} }, "time": 1616826986211, "eventName": "test_api_event"}]}' \ "https://events.statsigapi.net/v1/log_event>"
In this example, the statsigEnvironment
field is included in the user object, and it contains a tier
field which is set to "staging". You can replace "staging" with your desired environment.For more information, you can refer to the Statsig HTTP API documentation.
When you encounter the error statsigSDK> Event metadata is too large (max 4096). Some attributes may be stripped.
in your logs, it indicates that the size of the metadata for a particular event has exceeded the maximum limit of 4096 characters when stringified. This limit is set by Statsig to ensure efficient data handling.
To resolve this issue, you should review the events you're logging and the associated metadata. You might be logging more information than necessary or there could be large data structures being included unintentionally. If you're unsure about what metadata is being sent, you can add debugging statements in your code to print out the metadata before it's sent to Statsig. This will help you identify any unusually large pieces of data. Once you've identified the cause, you can then modify your logging to reduce the size of the metadata. The goal is to log only the information that is necessary for your metrics and analyses.
Event metadata is usually included to filter your Metrics during analysis and define more contextual metrics. The topic of event-metadata and this limit are covered in the Statsig documentation.
This error is likely to be thrown when we log internal used performance logging events. It's not related to events your service logged with log_event. A patch will be released to fix this issue.
In the event of encountering unexpected diagnostic results when evaluating a gate on React Native, despite the gate being set to 100% pass and Statsig being initialized, there are several potential causes to consider.
The "Uninitialized" status in evaluationDetails.reason
can occur even after calling .initialize()
and awaiting the result. This issue can be due to several reasons:
1. **Ad Blockers**: Ad blockers can interfere with the initialization network request, causing it to fail.
2. **Network Failures**: Any network issues that prevent the initialization network request from completing successfully can result in an "Uninitialized" status.
3. **Timeouts**: The statsig-js SDK applies a default 3-second timeout on the initialize request. This can lead to more frequent initialization timeouts on mobile clients where users may have slower connections.
If you encounter this issue, it's recommended to investigate the potential causes listed above. Check for the presence of ad blockers, network issues, and timeouts. This will help you identify the root cause and implement the appropriate solution.
It's worth noting that the initCalled: true
value doesn't necessarily mean the initialization succeeded. It's important to check for any errors thrown from the initialization method.
If you're still experiencing issues, it might be helpful to use the debugging tools provided by Statsig. These tools can help you understand why a certain user got a certain value. For instance, you can check the diagnostics tab for higher-level pass/fail/bucketing population sizes over time, and for debugging specific checks, the logstream at the bottom is useful and shows both production and non-production exposures in near real-time.
One potential solution to this issue is to use the waitForInitialization
option. When you don’t use this option, any of your components will be called immediately, regardless of if Statsig has initialized. This can result in 'Uninitialized' exposures. By setting waitForInitialization=true
, you can defer the rendering of those components until after statsig has already initialized. This will guarantee the components aren’t called until initialize has completed, and you won’t see any of those ‘Uninitialized’ exposures being logged. You can find more details in the Statsig documentation.
However, if you can't use waitForInitialization
due to it remounting the navigation stack resulting in a changed navigation state, you can check for initialization through initCompletionCallback
.
You can also verify the initialization by checking the value of isLoading
from useGate
and useConfig
and also initialized
and initStarted
from StatsigContext
.If the issue persists, please reach out to the Statsig team for further assistance.
If you're not seeing any exposure/checks data in the Diagnostics/Pulse Results tabs of the feature gate after launching, there are a few things you might want to check:
1. Ensure that your Server Secret Key is correct. You can find this in the Statsig console under Project Settings > API Keys. 2. Make sure that the name of the feature gate in your function matches exactly with the name of the feature gate you've created in the Statsig console. 3. Verify that the user ID is being correctly set and passed to the StatsigUser object. 4. Check if your environment tier matches the one you've set in the Statsig console.If all these are correct and you're still not seeing any data in the Diagnostics/Pulse Results tabs, it might be a technical issue on our end.
The Statsig SDK batches events and flushes them periodically as well as on shutdown
or flush
. If you are using the SDK in your middleware, it's recommended to call flush
to guarantee events are flushed. For more information, refer to the Statsig documentation.
If you're still not seeing any data, it's possible that there's an issue with event compression. In some cases, disabling event compression can resolve the issue. However, this should be done with caution and only as a last resort, as it may impact performance.
If you're using a specific version of the SDK, you might want to consider downgrading to a previous version, such as v5.13.2, which may resolve the issue.
Remember, if you're still experiencing issues, don't hesitate to reach out to the Statsig team for further assistance.