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

[EBT] Add page url to browser-side context #159916

Merged
merged 9 commits into from
Jun 20, 2023

Conversation

pgayvallet
Copy link
Contributor

@pgayvallet pgayvallet commented Jun 19, 2023

Summary

Part of #149249

Add a new EBT context providing the page_url field to events.

page_url is based on the current url's pathname and hash exclusively (no domain, port, query param...)

@pgayvallet pgayvallet added Feature:Telemetry release_note:skip Skip the PR/issue when compiling release notes v8.9.0 labels Jun 19, 2023
@pgayvallet pgayvallet changed the title add page url and title to browser EBT context Add page url to browser-side EBT context Jun 19, 2023
@pgayvallet pgayvallet changed the title Add page url to browser-side EBT context [EBT] Add page url to browser-side context Jun 19, 2023
Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for doing this!

I just added 1 question since I'm not familiar of how internal route-navigation is performed

Comment on lines 118 to 122
await navigate('/app/app1/bar?hello=dolly');
await flushPromises();
await navigate('/app/app2#/foo');
await flushPromises();

Copy link
Member

Choose a reason for hiding this comment

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

Q: would it work when navigating inside the same app?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it does, but I can add a test to ensure that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 06452c6

@pgayvallet pgayvallet marked this pull request as ready for review June 19, 2023 17:25
@pgayvallet pgayvallet requested a review from a team as a code owner June 19, 2023 17:25
Copy link
Contributor Author

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

self-review

Comment on lines +139 to +143
const location$ = getLocationObservable(window.location, this.history);
registerAnalyticsContextProvider({
analytics,
location$,
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The actual registration

Comment on lines +33 to +35
const locationToUrl = (location: Location) => {
return `${location.pathname}${location.hash}`;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Converting Location to our actual url: using pathname + hash

Comment on lines +23 to +30
history.listen((location) => {
subject.next(locationToUrl(location));
});
return subject.pipe(
startWith(locationToUrl(initialLocation)),
distinctUntilChanged(),
shareReplay(1)
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Emit with initial page's location + on each history change. Using distinctUntilChanged to avoid emitting multiple time for the exact same url

@pgayvallet
Copy link
Contributor Author

@elasticmachine merge upstream

@pgayvallet pgayvallet enabled auto-merge (squash) June 20, 2023 09:09
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
core 426 428 +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
core 352.3KB 352.8KB +486.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 13 15 +2
securitySolution 411 415 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 14 16 +2
securitySolution 494 498 +4
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@pgayvallet pgayvallet merged commit 97dc2ec into elastic:main Jun 20, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Telemetry release_note:skip Skip the PR/issue when compiling release notes v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants