Skip to content

Commit

Permalink
Deprecate get_browser_timing_footer API (#999)
Browse files Browse the repository at this point in the history
* Add nonce to CSP in browser agent

* Adjust nonce position

* Add testing for browser timing nonces

* Deprecated browser timing footer APIs.

* Full rip out of browser timing footer

* Remove cross agent tests for RUM footer (per repo)

* Update cat_map tests

* Adjust browser header generation timing accuracy

* Fix browser tests

* Linting

* Apply suggestions from code review

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
TimPansino and mergify[bot] authored Jan 5, 2024
1 parent 1483f73 commit 27c874c
Show file tree
Hide file tree
Showing 25 changed files with 1,304 additions and 1,715 deletions.
13 changes: 3 additions & 10 deletions newrelic/api/asgi_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,9 @@ async def send_inject_browser_agent(self, message):

# if there's a valid body string, attempt to insert the HTML
if verify_body_exists(self.body):
header = self.transaction.browser_timing_header()
if not header:
# If there's no header, abort browser monitoring injection
await self.send_buffered()
return

footer = self.transaction.browser_timing_footer()
browser_agent_data = six.b(header) + six.b(footer)

body = insert_html_snippet(self.body, lambda: browser_agent_data, self.search_maximum)
body = insert_html_snippet(
self.body, lambda: six.b(self.transaction.browser_timing_header()), self.search_maximum
)

# If we have inserted the browser agent
if len(body) != len(self.body):
Expand Down
9 changes: 5 additions & 4 deletions newrelic/api/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def __init__(self, application, enabled=None, source=None):
self.synthetics_job_id = None
self.synthetics_monitor_id = None
self.synthetics_header = None

# Synthetics Info Header
self.synthetics_type = None
self.synthetics_initiator = None
Expand Down Expand Up @@ -1912,9 +1912,10 @@ def get_browser_timing_header(nonce=None):


def get_browser_timing_footer(nonce=None):
transaction = current_transaction()
if transaction and hasattr(transaction, "browser_timing_footer"):
return transaction.browser_timing_footer(nonce)
warnings.warn(
"The get_browser_timing_footer function is deprecated. Please migrate to only using the get_browser_timing_header API instead.",
DeprecationWarning,
)
return ""


Expand Down
Loading

0 comments on commit 27c874c

Please sign in to comment.