Skip to content

Sessions are not sent to the dashboard until after end_session #4

@areibman

Description

@areibman

🐛 Bug Report

🔎 Describe the Bug
When a session begins, events are POST'ed to the database, but sessions are only saved after end_session is called.

🔄 Reproduction Steps
Create a session, send events, but don't end the session.

🙁 Expected Behavior
Post the session as soon as it is created. After end_session, update the session.

📸 Screenshots
Proposed fix, add start_session to the Worker:

    def start_session(self, session: Session) -> None:
        with self.lock:
            payload = {
                "session": session.__dict__
            }

            HttpClient.post(f'{self.config.endpoint}/sessions',
                            json.dumps(payload).encode("utf-8"),
                            self.config.api_key) 

Current end session should remain the same:

    def end_session(self, session: Session) -> None:
        self.stop_flag.set()
        self.thread.join()
        self.flush_queue()

        with self.lock:
            payload = {
                "session": session.__dict__
            }

            HttpClient.post(f'{self.config.endpoint}/sessions',
                            json.dumps(payload).encode("utf-8"),
                            self.config.api_key)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions