Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Successive track calls don't get logged to app.segment.com sources (Debugger) #276

Closed
EricSchuMa opened this issue Jul 19, 2023 · 0 comments

Comments

@EricSchuMa
Copy link

EricSchuMa commented Jul 19, 2023

I am using segment-analytics-python 2.2.3 in my FastAPI project.
When doing two successive track calls, only the first one is saved to my sources on app.segment.com

To reproduce run something like

import segment.analytics as segment_analytics

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()
segment_analytics.write_key = "YOURKEY"


@app.post("/index")
async def index(payload: BaseModel, uid):
    segment_analytics.track(uid, "Opened index")
    segment_analytics.track("anonymous", "Data for opened index", payload.dict())

Side note: My goal is to associate user actions with users and also track payloads (not associated to users).

Hack that does not suffice:
The second call is only tracked if I do something in between calls, e.g.
this works perfectly fine:

import time

segment_analytics.track(uid, "Opened index")
time.sleep(2)
segment_analytics.track("anonymous", "Data for opened index", payload.dict())

Things I have tried (didn't work):

  • Waiting for the next batch to arrive in my dashboard
  • Flushing the queue of the client
  • Create two clients (one for each call)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant