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

🐛 [RUMF-1077] use cookies to get Synthetics context #1161

Merged
merged 4 commits into from
Nov 15, 2021

Conversation

BenoitZugmeyer
Copy link
Member

Motivation

More reliable way to get Synthetics context on Selenium-based browsers (Firefox, IE)

Changes

  • Remove the user agent check, since it shouldn't be needed anymore
  • Use synthetics context provided by cookies

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

Cookies + global variable should be enough/more reliable than the user
agent which can be edited by the customer.
By using both global variable and cookies, the Synthetics context
retrieval should be more reliable. We shouldn't need to check it every
time we assemble an event. It should allow us to get it once at init,
and keep the value locally so we don't need caching mechanism to access
cookies and ensure good performances.
@BenoitZugmeyer BenoitZugmeyer requested a review from a team as a code owner November 10, 2021 18:15
const resultId = (window as BrowserWindow)._DATADOG_SYNTHETICS_RESULT_ID
const testId = (window as BrowserWindow)._DATADOG_SYNTHETICS_PUBLIC_ID || getCookie(SYNTHETICS_TEST_ID_COOKIE_NAME)
const resultId =
(window as BrowserWindow)._DATADOG_SYNTHETICS_RESULT_ID || getCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME)

if (typeof testId === 'string' && typeof resultId === 'string') {
Copy link
Contributor

@amortemousque amortemousque Nov 12, 2021

Choose a reason for hiding this comment

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

if (typeof testId === 'string' && typeof resultId === 'string') {
Out of curiosity, what is this test for?
Is there any previous issue related to it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mmh this test is a bit too preventive, indeed. I don't recall any issue where values where truthy without being a string. But I guess it's fine nonetheless?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

@BenoitZugmeyer BenoitZugmeyer merged commit 07556ce into main Nov 15, 2021
@BenoitZugmeyer BenoitZugmeyer deleted the benoit/use-cookies-to-get-synthetics-context branch November 15, 2021 10:35
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.

3 participants