Verify Python SDK events
An event moves through four stages between your track() call and Amplitude's servers. Verify each stage in order. The first stage where the event looks wrong is where the problem is.
| Stage | Question | Where to look |
|---|---|---|
| Captured | Did the SDK accept the call? | amplitude log lines, and the event object |
| Transformed | What did plugins add, change, or drop? | An inspection plugin |
| Sent | Which URL did the SDK call, and with what payload? | client.configuration.server_url, the event body |
| Received | Did Amplitude accept and store the event? | The callback result, then User Lookup in Amplitude |
For problems common to every Amplitude SDK, go to SDK troubleshooting and debugging. If behavior changed after an SDK upgrade, check the Amplitude-Python changelog.
Turn on debug logging
The SDK logs through Python's logging module on the logger named amplitude. Validation errors log at ERROR, and the result of each upload logs at INFO, one line per event. Python hides INFO by default, so set the level while you verify:
import logging
from amplitude import Amplitude, BaseEvent
logging.basicConfig(level=logging.INFO)
logging.getLogger("amplitude").setLevel(logging.DEBUG)
client = Amplitude("AMPLITUDE_API_KEY")
client.track(BaseEvent("Report Exported", user_id="user-12345"))
# INFO:amplitude:Event sent successfully.
Each per-event log record stores the event and the response code in the event and code attributes of the LogRecord. A custom handler or filter can read these attributes. To move the per-event lines to DEBUG, or turn them off, set event_log_level. event_log_level requires 1.3.0 or later.
Check what the SDK captured
track(), identify(), group_identify(), and revenue() validate their input in your thread, before the SDK queues anything. A rejected call logs one of these lines and sends nothing:
| Log line | Cause |
|---|---|
Invalid event body {...}, followed by an InvalidEventError traceback | The event has neither user_id nor device_id, or its event_type is empty. |
Skipped event for opt out config | client.configuration.opt_out is True, or the client has shut down. |
Empty identify properties or Empty group identify properties | The Identify object has no operations. |
Key or clear all operation already set. | The Identify object already has an operation for that property, or clear_all() ran. |
Invalid price for revenue event | Revenue.price isn't a float (an int such as 4 fails), or quantity isn't a positive int. |
Event property <name> expected <type> but received <type>. | An event field has the wrong type, for example time as a float. The SDK drops the field. |
Too many properties. 1024 maximum. | A property dictionary has more than 1,024 keys. The SDK sends it empty. |
One failure produces no log line: when a property dictionary contains a value of an unsupported type, such as a datetime or a custom object, the SDK discards the whole dictionary. Check the event object before you track it:
from datetime import datetime
from amplitude import BaseEvent
event = BaseEvent(
"Report Exported",
user_id="user-12345",
event_properties={"exported_at": datetime.now()},
)
print(event.event_properties)
# None: datetime isn't a supported value type, so the SDK discarded the dictionary
Supported property values are strings, numbers, booleans, Enum members (sent as their .value), None (dropped from the payload), lists of those, and nested dictionaries. Convert anything else, for example datetime.now().isoformat().
Check how plugins transformed the event
After validation, each event passes through the plugin pipeline in a fixed order, in the thread that called track():
- Before plugins (
PluginType.BEFORE): The built-in context plugin setstimeandinsert_idif they're empty, adds the configuredplanandingestion_metadata, and setslibrarytoamplitude-python/<version>. - Enrichment plugins (
PluginType.ENRICHMENT): Your enrichment plugins run here, in the order you added them. A plugin that returnsNonedrops the event. - Destination plugins (
PluginType.DESTINATION): The built-in Amplitude destination checks that the event has an ID, then queues it. Each destination receives its own copy of the event.
To see the event exactly as the destinations receive it, add an enrichment plugin after your own plugins. The following plugin prints each event and returns the event unchanged:
from amplitude import Amplitude, BaseEvent, EventPlugin, PluginType
class InspectEvents(EventPlugin):
def __init__(self):
super().__init__(PluginType.ENRICHMENT)
def execute(self, event):
print("final event:", event)
return event
client = Amplitude("AMPLITUDE_API_KEY")
client.add(InspectEvents())
client.track(BaseEvent("Report Exported", user_id="user-12345"))
print(event) writes the event as the JSON object the SDK uploads. Remove the plugin with client.remove(plugin) when you're done. Exceptions inside a plugin don't reach your code. The SDK logs each exception as Error for apply ENRICHMENT plugin for event ... with a traceback. The SDK then continues with the event as it was before that plugin ran.
Check what the SDK sent
The SDK uploads with an HTTPS POST from a background thread. The SDK has no request log, so check the URL and the event body directly.
| Configuration | Request URL |
|---|---|
| Default (US) | https://api2.amplitude.com/2/httpapi |
server_zone="EU" | https://api.eu.amplitude.com/2/httpapi |
use_batch=True (US) | https://api2.amplitude.com/batch |
use_batch=True (EU) | https://api.eu.amplitude.com/batch |
server_url set | The URL you set |
client.configuration.server_url returns the URL the client uses. The SDK uploads queued events every flush_interval_millis (10 seconds by default), or sooner when flush_queue_size (200 by default) events are ready. Each request carries up to flush_queue_size events. Request bodies are uncompressed JSON, so a proxy or packet capture shows them as sent.
The request body has this shape:
from amplitude import Amplitude, BaseEvent
client = Amplitude("AMPLITUDE_API_KEY")
client.track(
BaseEvent(
"Sign Up Completed",
user_id="user-12345",
event_properties={"plan": "starter"},
)
)
{
"api_key": "AMPLITUDE_API_KEY",
"events": [
{
"event_type": "Sign Up Completed",
"user_id": "user-12345",
"event_properties": { "plan": "starter" },
"time": 1762780800000,
"insert_id": "5f1c8e2a-9b0d-4c6e-8f3a-2d7b1e4c9a60",
"library": "amplitude-python/1.3.0"
}
]
}
The SDK sets only the fields you pass plus time, insert_id, and library. The SDK doesn't add device, platform, IP, or location fields. To attribute an event to your end user's location rather than your server's, set ip or the location fields on the event. When you set min_id_length, the body also carries "options": {"min_id_length": <n>}.
Check what Amplitude received
Read the upload result
The client-level callback in Config and the callback argument of an individual event run when the event reaches a final upload result: success or final failure. Both callbacks receive (event, code, message):
from amplitude import Amplitude, BaseEvent
def on_result(event, code, message):
print(event.event_type, code, message)
client = Amplitude("AMPLITUDE_API_KEY")
client.track(BaseEvent("Report Exported", user_id="user-12345", callback=on_result))
# Report Exported 200 Event sent successfully.
code | message | Meaning | What the SDK does |
|---|---|---|---|
200 | Event sent successfully. | Amplitude accepted the event. | Removes the event from the queue. |
400 | Server error text, for example Invalid id length for user_id or device_id | Amplitude rejected this event. | Drops the events the server marked invalid or silenced, and retries the rest of the batch. |
400 | Request missing required field <field> | The request lacked a required field. | Drops every event in the batch. |
413 | Server error text | A single event was too large. | Drops the event. For a batch, the SDK lowers its batch size and retries. |
429 | Exceeded daily quota | The user or device exceeded its daily event quota. | Drops the event. Throttled events under the quota retry after 30 seconds without a callback. |
Last status, or -1 | Event reached max retry times 12. | Every attempt failed with a timeout, a 5xx status, or a network error (-1). | Drops the event after flush_max_retries failed attempts. |
| Any | Destination buffer full. Retry temporarily disabled | 20,000 or more events were waiting when a failed event came back for retry. | Drops that event. |
A rejected API key (400 with Invalid API key: ... from the server) doesn't reach the callback. The SDK logs Invalid API Key at ERROR and drops the batch.
A 200 response means Amplitude's ingestion API accepted the event. Amplitude can still exclude an accepted event from analysis later, for example when a block filter matches it.
Find the event in Amplitude
- Open User Lookup and search for the event's
user_id, or itsdevice_idif you sent only that. - Select the Activity tab and turn on Live event updates.
- Open the event and compare its properties with the
final eventoutput from your inspection plugin.
For events from many users, use the Ingestion Debugger to review accepted and rejected requests for the project. Charts can take a few minutes longer to include new events than User Lookup does.
Was this helpful?
For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.