Skip to main content
def tell_amplitude_account_created(user_id:int, account_id:int):
"""
server_side API to Amplitude about account_created
"""

client = Amplitude(AMPLITUDE_API_KEY)

# see
# One of user_id and device_id is required

# Track events with optional properties
# identify_obj=Identify()
# identify_obj.set("account_id", str(account_id))
# client.identify(identify_obj, EventOptions(user_id=str(user_id)))
client.track(
BaseEvent(
event_type = "account_created",
user_id = str(user_id),
event_properties = {
"signup_via": "github",
}
)
)

Under data

Nothing shows up. HOw do i troubleshoot this?

Please make it easy for me to troubleshoot. I’m seriously considering to move to mixpanel if this is too difficult

Hello @kimsia to my understanding, you are having some trouble sending in events via the Python SDK.

Have you installed and imported the Python SDK into the code? For example, I installed the Python SDK to my mac using PIP.

pip install amplitude-analytics
"""A very simple example of using Amplitude Python SDK to track  events"""

from amplitude import Amplitude,BaseEvent


def callback_fun(e, code, message):
"""A callback function"""
print(e)
print(code, message)


# Initialize a Amplitude client instance
amp_client = Amplitude(api_key="API_Key")
# Config a callback function
amp_client.configuration.callback = callback_fun

# Create a BaseEvent instance
event = BaseEvent(event_type="Test python SDK", user_id="test_user_id", device_id="test_devece_id")
# Set event properties
eventt"event_properties"] = {
"keywords": "amplitude", "python"],
"likes": True
}
amp_client.track(event)

# Flush the event buffer
amp_client.flush()

# Shutdown the client
amp_client.shutdown()

Then I ran python3 trackevent.py and got a successful response and I can see the event got ingested into my project.

Could you try using the code I provided above into a python file and try to run it that way? Also, if it’s helpful the engineering team has great examples on the Python SDK in GitHub: https://github.com/amplitude/Amplitude-Python/tree/main/examples

 

Hope this helps!


Is the callback necessary?


I found out the issue. it’s because of your gotcha about invalid user_id.

 

That’s an extremely bad design in your documentation. This is such a simple thing to do. First, i disagree with the min length. Even if this is the least of all evils, please make it clear THROUGHOUT your ENTIRE documentation. Constantly and frequently.

Because it’s just a surprising behavior.

I’m a fan of John Cutle but i cannot believe he works in an organization that makes this kind of extreme unexpected behavior.

Very disappointing.

I posted my experience searching for an answer in a separate post. Make it upfront throughout ALL your documentation abt the char limit for ur user_id | Community (amplitude.com)


Hi @eddie.gaona,

I’ve also been having trouble seeing any events in my dashboard and having run your script locally (with my API key), I get the following message from the print(code, message).

-1 1SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)

Any advice on how to tackle this? I can’t see any articles about this in particular…

Thanks in advance,

Chris


Ok looks like this might be a Python version issue. Getting the error locally, on 3.12, but my deployed version uses 3.11 and that’s working ok 🤷‍♂️


Reply