Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ jobs:
bundle:
name: Bundle and script tests
runs-on: ubuntu-latest
env:
BUILD_MODE: release
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -106,6 +104,9 @@ jobs:

- name: Build release bundles
run: yarn build:bundle
env:
# scoped to this step only: script tests must run with the default (dev) build mode
BUILD_MODE: release

- name: Run script tests
run: yarn test:script
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/browser/pageActivationObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export function createPageActivationObservable(configuration: Configuration): Ob
window,
[DOM_EVENT.BLUR, DOM_EVENT.FOCUS, DOM_EVENT.VISIBILITY_CHANGE, DOM_EVENT.PAGE_SHOW],
(event) => {
// With capture on window, focus/blur of descendant elements are also received (they don't
// bubble but are captured). Only window-level focus/blur indicate page (de)activation.
if ((event.type === DOM_EVENT.BLUR || event.type === DOM_EVENT.FOCUS) && event.target !== window) {
return
}
if (event.type === DOM_EVENT.BLUR) {
isInactive = true
} else if (event.type === DOM_EVENT.VISIBILITY_CHANGE) {
Expand Down
3 changes: 2 additions & 1 deletion scripts/cli
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

set -euo pipefail

PATH="$PATH:node_modules/.bin"
# prepend so the repo-pinned binaries (tsc, eslint, ...) win over any globally installed ones
PATH="node_modules/.bin:$PATH"

main () {
if [[ $# -lt 1 ]]; then
Expand Down
14 changes: 11 additions & 3 deletions test/e2e/scenario/rum/init.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,22 @@ test.describe('API calls and events around init', () => {
.run(async ({ intakeRegistry, flushEvents }) => {
await flushEvents()

const initialView = intakeRegistry.rumViewEvents[0]
// a view can emit several update events; pick the latest one per view as it carries the
// cumulative state (e.g. custom_timings added after the first update)
const latestViewUpdate = (viewId: string) =>
intakeRegistry.rumViewEvents
.filter((event) => event.view.id === viewId)
.sort((a, b) => a._dd.document_version - b._dd.document_version)
.at(-1)!

const initialView = latestViewUpdate(intakeRegistry.rumViewEvents[0].view.id)
expect(initialView.view.name).toBeUndefined()
expect(initialView.view.custom_timings).toEqual({
before_manual_view: expect.any(Number),
})

const manualView = intakeRegistry.rumViewEvents[1]
expect(manualView.view.name).toBe('manual view')
const manualViewId = intakeRegistry.rumViewEvents.find((event) => event.view.name === 'manual view')!.view.id
const manualView = latestViewUpdate(manualViewId)
expect(manualView.view.custom_timings).toEqual({
after_manual_view: expect.any(Number),
})
Expand Down
Loading