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

Update current state in page load and navigation plugins #553

Open
wants to merge 20 commits into
base: integration/component-rendering
Choose a base branch
from

Conversation

AnastasiiaSvietlova
Copy link

@AnastasiiaSvietlova AnastasiiaSvietlova commented Dec 19, 2024

Goal

Automated component instrumentation

Changeset

Update page load plugins to set appState to ready after ending the app start span.

Update navigation plugins to set appState to navigating when the route changes and ready when the navigation is complete.

Testing

Update unit test to check if setAppState was called and changed

@AnastasiiaSvietlova AnastasiiaSvietlova changed the title update current state in page load and navigation Update current state in page load and navigation plugins Dec 19, 2024
@AnastasiiaSvietlova AnastasiiaSvietlova marked this pull request as ready for review January 14, 2025 11:20
@@ -4,6 +4,7 @@ import type { BrowserConfiguration } from '../config'
import type { RouteChangeSpanEndOptions, RouteChangeSpanOptions } from '../routing-provider'
import { getPermittedAttributes } from '../send-page-attributes'
import { defaultRouteResolver } from '../default-routing-provider'
import type { AppState } from '../../../../core/lib/core'
Copy link
Member

@gingerbenw gingerbenw Jan 14, 2025

Choose a reason for hiding this comment

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

This should be an import from @bugsnag/core-performance and not a relative import

Copy link
Author

@AnastasiiaSvietlova AnastasiiaSvietlova Jan 14, 2025

Choose a reason for hiding this comment

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

So this import needs to be fixed in all plugins?

Copy link
Member

Choose a reason for hiding this comment

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

yep, if we need to use code from another library, it should be exported and imported appropriately.

@@ -10,6 +10,7 @@ import type { BrowserConfiguration, BrowserSchema } from '../../lib/config'
import { createDefaultRoutingProvider } from '../../lib/default-routing-provider'
import type { OnSettle } from '../../lib/on-settle'
import type { StartRouteChangeCallback } from '../../lib/routing-provider'
import type { AppState } from '../../../../core/lib/core'
Copy link
Member

@gingerbenw gingerbenw Jan 14, 2025

Choose a reason for hiding this comment

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

same as above, though not such a big deal in the tests

Comment on lines 43 to 46
let appState: AppState = 'starting'
const setAppState = jest.fn((state: AppState) => {
appState = state
})
Copy link
Member

@gingerbenw gingerbenw Jan 14, 2025

Choose a reason for hiding this comment

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

are you not able to get these from the plugins: (spanFactory) => [] parameter of the test client on line 57? they should be part of the base client so no need to mock them here

Copy link

github-actions bot commented Jan 14, 2025

Browser bundle size

NPM build

Package
Before 211.17 kB
After 212.25 kB
± +1,074 bytes ⚠️

CDN build

Unminified Minfied Minified + gzipped
Before 107.77 kB 40.65 kB 11.92 kB
After 108.20 kB 40.83 kB 11.97 kB
± +438 bytes ⚠️ +187 bytes ⚠️ +53 bytes ⚠️

Code coverage

Ok File (✨=New File) Lines Branches Functions Statements
🔴 /home/runner/work/bugsnag-js-performance/bugsnag-js-performance/packages/platforms/browser/lib/auto-instrumentation/route-change-plugin.ts 89.47%
(+0.59%)
75%
(+0%)
53.84%
(+0%)
89.83%
(+0.55%)

Total:

Lines Branches Functions Statements
87.53%(-0.31%) 78.02%(-0.74%) 86.75%(+0%) 85.52%(-0.43%)

Generated against 7f23a1c on 16 January 2025 at 13:09:15 UTC

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.

2 participants