[Execution Context] Update on URL change#200785
Conversation
|
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
|
/ci |
💔 Build Failed
Failed CI StepsHistory
cc @afharo |
|
@afharo, thank for looking into it! Not sure I understand how this helps, I might be missing something here I thought that we already reported the correct The problem with #195778 is that we don't report so, for example, in the |
You are correct! The URL is correctly updated there, but the However, when the URL changes, we don't update it.
That's a great point! My PR would only update the path on URL changes providing the full path ( I wonder if this is a good fallback, but it still requires the ReactRouter to override this when necessary. WDYT? |
Aha, so is not called on every sent event? instead it is called only when |
Sorry, what do you mean with "always"? |
Dosant
left a comment
There was a problem hiding this comment.
Discussed offline. Forget previous questions, history.listen makes sense considering how the system is set up
| // Track URL changes to make sure that we reflect the new path name | ||
| this.subscription.add( | ||
| history.listen((location) => { | ||
| start.set({ url: location.pathname }); |
There was a problem hiding this comment.
it might be that location.pathname didn't change, right? Maybe worth calling only when has changed?
|
Closing for now with fears that it causes race conditions with app-driven updates: Refer to #201118 (comment) for more info. Happy to reopen anytime if this is still a valid approach. |
Summary
Resolves #195778
This PR attempts to fix #195778 and https://github.com/elastic/observability-dev/issues/3776 by calling
executionContext.set({ url })whenever we identify the pathname has changed (using thehistorymodule for that).Hopefully, this will remove the need of plugins explicitly calling the execution context to update the path when their internal
Routerapplies any changes.Checklist
Identify risks
executionContext.setinstead ofexecutionContext.clear. The difference is that any previous contextual information will be kept. When switching apps, we clear every previous context. However, when inside the same app, it didn't feel right to clear everything. Should it?