Skip to content

DEMRUM-2370: webview injection fix including legacy support #328

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

Draft
wants to merge 5 commits into
base: feature/next-gen
Choose a base branch
from

Conversation

carlosmcevilly
Copy link

@carlosmcevilly carlosmcevilly commented Jun 10, 2025

implement hybrid sync/async solution for partial legacy support

  • the word "partial" is due to legacy BRUM itself; we cannot do everything
    we want with BRUM but we can match the old agent.
  • provide legacy synchronous getNativeSessionId() for compatibility.
  • add modern async getNativeSessionIdAsync() for improved results.
  • update DevelApp demo to show both of the above scenarios in action.
  • introduce opt-in onNativeSessionIdChanged {} closure property to
    notify BRUM developers when the session ID updates.

More in the main commit message but I'll add it here for convenience:

DEMRUM-2370: Implement hybrid sync/async solution for partial legacy support

* provide legacy synchronous getNativeSessionId() for compatibility.
* add modern async getNativeSessionIdAsync() for improved results
  (see naming note).
* introduce opt-in onNativeSessionIdChanged {} closure property to
  notify BRUM developers when the session ID updates.
* update demo app to show both scenarios in action.

In the demo in DevelApp, we represent the BRUM agent with a timer
periodically calling the injected API to check for the native session
ID. But the injected code contains no timers.

Legacy agents will continue to work as they do now using
getNativeSessionId(). However, we recommend BRUM implementers
transition to the provided getNativeSessionIdAsync() for more
accurate and reliable behavior.

Caveats:

* In the legacy BRUM implementation, the session ID was retrieved
  synchronously via getNativeSessionId, and updates from native
  were not processed. This behavior in legacy BRUM limits what
  we can provide. We match the legacy behavior by providing the
  latest cached session ID and immediately queueing an update,
  but it is up to the legacy BRUM to read that update later. To
  benefit from reliable updates and proactive staleness handling,
  BRUM should adopt the modern async getNativeSessionIdAsync API
  in future updates.

Naming Note:

This is about private internal naming of interest to a BRUM
implementor.

Unfortunately, we can NOT follow these standard JavaScript naming
conventions:

  - getNativeSessionId()     <- (standard here would be async)
  - getNativeSessionIdSync()

Instead we have, not standard:

  - getNativeSessionId()     <- (ours is actually sync)
  - getNativeSessionIdAync()

The reason is that since getNativeSessionId() is already
established as synchronous in legacy BRUM implementations,
changing its behavior to async would be disruptive to deployed
devices in the field. To maintain backward compatibility, we
retain the existing semantics for getNativeSessionId() and must
use the Async postfix in the naming giving us
getNativeSessionIdAsync() for the async version.

Fortunately these are not customer-facing names -- only BRUM
developer facing.

…support

* provide legacy synchronous getNativeSessionId() for compatibility.
* add modern async getNativeSessionIdAsync() for improved results
  (see naming note).
* introduce opt-in onNativeSessionIdChanged {} closure property to
  notify BRUM developers when the session ID updates.
* update demo app to show both scenarios in action.

In the demo in DevelApp, we represent the BRUM agent with a timer
periodically calling the injected API to check for the native session
ID. But the injected code contains no timers.

Legacy agents will continue to work as they do now using
getNativeSessionId(). However, we recommend BRUM implementers
transition to the provided getNativeSessionIdAsync() for more
accurate and reliable behavior.

Caveats:

* In the legacy BRUM implementation, the session ID was retrieved
  synchronously via getNativeSessionId, and updates from native
  were not processed. This behavior in legacy BRUM limits what
  we can provide. We match the legacy behavior by providing the
  latest cached session ID and immediately queueing an update,
  but it is up to the legacy BRUM to read that update later. To
  benefit from reliable updates and proactive staleness handling,
  BRUM should adopt the modern async getNativeSessionIdAsync API
  in future updates.

Naming Note:

This is about private internal naming of interest to a BRUM
implementor.

Unfortunately, we can NOT follow these standard JavaScript naming
conventions:

  - getNativeSessionId()     <- (standard here would be async)
  - getNativeSessionIdSync()

Instead we have, not standard:

  - getNativeSessionId()     <- (ours is actually sync)
  - getNativeSessionIdAync()

The reason is that since getNativeSessionId() is already
established as synchronous in legacy BRUM implementations,
changing its behavior to async would be disruptive to deployed
devices in the field. To maintain backward compatibility, we
retain the existing semantics for getNativeSessionId() and must
use the Async postfix in the naming giving us
getNativeSessionIdAsync() for the async version.

Fortunately these are not customer-facing names -- only BRUM
developer facing.
@carlosmcevilly carlosmcevilly requested review from a team as code owners June 10, 2025 07:56
@jCharv jCharv requested a review from c0mtru1se June 10, 2025 13:45
@carlosmcevilly carlosmcevilly requested a review from SMickelsn June 10, 2025 14:52
@carlosmcevilly carlosmcevilly marked this pull request as draft June 11, 2025 06:41
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.

1 participant