Skip to content

Conversation

@dmashuda
Copy link
Contributor

@dmashuda dmashuda commented Aug 4, 2025

Add SDK Event to Ldcli:

1.) Adds a new navigation so that uses can switch between multiple pages
2.) Adds new local event debugger:

When a user is viewing the "Events" Page:

  • A new "Debug Session" is created
  • SDK events are streamed via SSE to the frontend and displayed
  • SDK events are stored on the "Debug Session
Screenshot 2025-08-19 at 3 12 25 PM

A User can View/Delete Debug Sessions:
Screenshot 2025-08-19 at 3 10 35 PM

When A user is viewing a past "Debug Session", they can search for events:
Screenshot 2025-08-19 at 3 12 03 PM

router.HandleFunc("/bulk", DevNull)
router.HandleFunc("/bulk", SdkEventsReceiveHandler)
router.HandleFunc("/diagnostic", DevNull)
router.HandleFunc("/events/tee", SdkEventsTeeHandler)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

router.HandleFunc("/bulk", SdkEventsReceiveHandler)
router.HandleFunc("/diagnostic", DevNull)
router.HandleFunc("/events/tee", SdkEventsTeeHandler)
router.Handle("/events/bulk/{envId}", EventsCorsHeaders(DevNull))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is for js sdk events

Comment on lines 18 to 19
router.HandleFunc("/mobile", DevNull)
router.HandleFunc("/mobile/events", DevNull)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are for old mobile SDKs


const newEvent: EventData = {
id: Math.random().toString(36).slice(2, 11),
timestamp: Date.now(),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😕 what is this doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moribellamy setting an initial fake event like this necessary still or was this just during prototyping?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a real event to me, as collected by the server on line 25. id is so dom elements can have something unique to help react caching.

am i missing something?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, so the id is just for the DOM. Why is the timestamp being set like this though? The events should have a timestamp in there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated it to try and use the timestamp from the event in 252a933

Version int `json:"version"`
Value ldvalue.Value `json:"value"`
Version int `json:"version"`
TrackEvents bool `json:"trackEvents"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What behavior do we want? This will send an event for every flag eval which is not what will happen in real LD.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our thought was any flag with an override, we can set trackEvents to be true to mimics like the flag is under an experiment/guarded rollout

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I guess that kinda makes sense, but the behavior needs to be documented somewhere. Maybe a new events section in the reference guide?


// Get total count for pagination info
var totalCount int64
countQuery := `SELECT count(DISTINCT(debug_session_key)) FROM debug_events`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query the other table

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is possible for a debug_session to end up with 0 events, and we did not want to show show those.

The main list query for events also excludes debug_sessions with 0 events

And we purge the orphaned debug_sessions at startup: http://github.com/launchdarkly/ldcli/pull/596/files#diff-bb1801aac503b2e2234ecb22f46b77b6d090c9274966475e2a2873f76166d20dR179

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhhhh got it. Makes sense

writer.WriteHeader(http.StatusAccepted)
}

func SdkEventsTeeHandler(writer http.ResponseWriter, request *http.Request) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhhh. I get what this is for now. I think we should move this to not be in the SDK package. Similarly for this observer.


var observers *model.Observers = model.NewObservers()

func SdkEventsReceiveHandler(writer http.ResponseWriter, request *http.Request) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kinda busting the testable MVC-like pattern elsewhere in the dev server. I'd like to see this factored into the model so that we can have a test for the behavior independent of http.

<div>
<h3>Events Stream</h3>
{onToggleStreaming && (
<button

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't launchpad components being used?

@tvarney13
Copy link
Member

Picking this back up, doccing the local dev loop:

  • run Okteto services
  • kill your dev server in Okteto
  • run local Gonfalon
  • run local Dev Server via make - make sure the base URL is catamorphic (docker-compose.yml for dev-server)

</Text>
</Box>

{debugSessions.length === 0 ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting a crash instead of showing zero-state page here

Uncaught TypeError: can't access property "length", debugSessions is null

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in eb221a6

@brianvans brianvans force-pushed the moonshot-xxii-debugger branch from 618cb61 to d77388b Compare September 26, 2025 00:01
Copy link
Contributor

@moribellamy moribellamy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brianvans brianvans merged commit cffa7ec into main Sep 30, 2025
11 checks passed
@brianvans brianvans deleted the moonshot-xxii-debugger branch September 30, 2025 15:57
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

Successfully merging this pull request may close these issues.

6 participants