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

chore: "Soft Nav" POC #626

Closed
wants to merge 41 commits into from
Closed

chore: "Soft Nav" POC #626

wants to merge 41 commits into from

Conversation

metal-messiah
Copy link
Member

Please add a one-paragraph summary here, suitable for a release notes description. This will help with documentation.

Overview

Related Issue(s)

Testing

@metal-messiah metal-messiah added the POC A proof of concept label Jul 25, 2023
@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

Merging #626 (45f8401) into main (51bfee8) will decrease coverage by 0.30%.
Report is 1 commits behind head on main.
The diff coverage is 39.28%.

@@            Coverage Diff             @@
##             main     #626      +/-   ##
==========================================
- Coverage   86.74%   86.45%   -0.30%     
==========================================
  Files         136      137       +1     
  Lines        5273     5278       +5     
  Branches      724      734      +10     
==========================================
- Hits         4574     4563      -11     
- Misses        636      645       +9     
- Partials       63       70       +7     
Flag Coverage Δ
unit-tests 78.62% <39.28%> (-0.43%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
src/cdn/experimental.js 100.00% <ø> (ø)
src/cdn/spa.js 100.00% <ø> (ø)
src/common/serialize/bel-serializer.js 48.48% <0.00%> (-1.52%) ⬇️
src/common/util/feature-flags.js 96.42% <ø> (ø)
src/common/vitals/constants.js 100.00% <ø> (ø)
src/features/ajax/aggregate/index.js 91.39% <ø> (-1.06%) ⬇️
src/features/page_view_event/aggregate/index.js 87.75% <ø> (ø)
src/features/spa/aggregate/index.js 78.44% <ø> (ø)
src/loaders/features/features.js 100.00% <ø> (ø)
src/common/util/feature-state.js 16.66% <16.66%> (ø)
... and 4 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link

github-actions bot commented Jul 25, 2023

Asset Size Report

Merging this pull request will result in the following asset size changes:

Agent Asset Previous Size New Size Diff
lite loader 28.54 kB / 9.89 kB (gzip) 29.26 kB / 10.18 kB (gzip) 2.5% / 2.85% (gzip)
lite async-chunk 45.53 kB / 15.1 kB (gzip) 45.78 kB / 15.14 kB (gzip) 0.55% / 0.3% (gzip)
pro loader 45.95 kB / 15.38 kB (gzip) 46.72 kB / 15.68 kB (gzip) 1.69% / 1.93% (gzip)
pro async-chunk 166.12 kB / 52.32 kB (gzip) 166.12 kB / 52.32 kB (gzip) 0% / 0% (gzip)
spa loader 52.36 kB / 17.35 kB (gzip) 48.69 kB / 16.25 kB (gzip) -7.02% / -6.34% (gzip)
spa async-chunk 166.12 kB / 52.32 kB (gzip) 166.12 kB / 52.32 kB (gzip) 0% / 0% (gzip)
lite-polyfills loader 99.04 kB / 31.55 kB (gzip) 99.95 kB / 31.9 kB (gzip) 0.92% / 1.11% (gzip)
lite-polyfills async-chunk 57.95 kB / 17.32 kB (gzip) 58.23 kB / 17.36 kB (gzip) 0.48% / 0.27% (gzip)
pro-polyfills loader 119.02 kB / 37.53 kB (gzip) 120.06 kB / 37.89 kB (gzip) 0.88% / 0.96% (gzip)
pro-polyfills async-chunk 99.08 kB / 26.77 kB (gzip) 103.4 kB / 27.7 kB (gzip) 4.36% / 3.47% (gzip)
spa-polyfills loader 126.99 kB / 39.67 kB (gzip) 122.84 kB / 38.66 kB (gzip) -3.26% / -2.56% (gzip)
spa-polyfills async-chunk 113.96 kB / 31.16 kB (gzip) 129.28 kB / 34.14 kB (gzip) 13.44% / 9.57% (gzip)
worker loader 40.65 kB / 13.78 kB (gzip) 41.41 kB / 14.08 kB (gzip) 1.89% / 2.16% (gzip)
worker async-chunk 45.51 kB / 15.44 kB (gzip) 47.56 kB / 16.1 kB (gzip) 4.51% / 4.26% (gzip)

@metal-messiah metal-messiah changed the title [WIP] Basic spa poc chore: Basic spa POC Aug 1, 2023
@metal-messiah metal-messiah changed the title chore: Basic spa POC chore: "Soft Nav" POC Sep 6, 2023
toArray (type, obj) {
if (typeof obj !== 'object') return []

return mapOwn(obj, (key, value) => this.getValue(key, value, type))
Copy link
Contributor

Choose a reason for hiding this comment

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

The key parameter is never used and I would like to continue removing uses of mapOwn

Suggested change
return mapOwn(obj, (key, value) => this.getValue(key, value, type))
return Object.values(obj).map(value => this.getValue(value, type))

return mapOwn(obj, (key, value) => this.getValue(key, value, type))
}

getValue (key, value, type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
getValue (key, value, type) {
getValue (value, type) {


windowAddEventListener('hashchange', trackURLChange, true, this.removeOnAbort?.signal)
windowAddEventListener('load', trackURLChange, true, this.removeOnAbort?.signal)
windowAddEventListener('popstate', trackURLChange, true, this.removeOnAbort?.signal)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need both the history wrappers on lined 25-26 and this event listener?

Copy link
Member Author

Choose a reason for hiding this comment

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

These are ports over from the original spa feature, needs eval as to what is actually needed there

Copy link
Contributor

@cwli24 cwli24 left a comment

Choose a reason for hiding this comment

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

So while this is less problem prone than the existing spa, it could use a big sweeping.

Overall, a lack of jsdoc, documentation behind the process, and unclear semantics make this hard to trace through. For example, on one line, I'm reading about "interactions" -> "ixn" to have it suddenly use a function that's within the BelNode class -- is an interaction simply a bel-serializer node or is it made up of nodes? It's confusing and unclear.
The way things are passed around is also reminiscent of a top issue with writing/reading/debugging javascript code with dynamic types: I'm getting lost on what a function should pass back and both the type and available properties of objects.

The other part of the confusion-complication is the way things are structured. For example, the belnode is responsible for cancel()-ing itself. Something that should be a simple data structure is sharing the logic/responsibility of its handler.

Comment on lines +104 to +116
const shouldHold = this.checkInteractions(value) // add an interaction ID if exists
if (shouldHold) return
return value
}

checkInteractions (value) {
const spaFeature = getFeatureState({ agentIdentifier: this.sharedContext.agentIdentifier, featureName: FEATURE_NAMES.basicSpa })
const { shouldHold, interactions } = spaFeature?.hasInteraction?.({ timestamp: value?.metrics?.time?.t }) || {}
if (shouldHold) return true
let browserInteractionId = interactions?.[0]?.id.replace('\'', '')
if (browserInteractionId) value.params.browserInteractionId = browserInteractionId
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

A styling remark but there's something--or a combination of things--that makes this not obvious as to what's happening.

src/common/timing/now.js Show resolved Hide resolved
src/common/util/feature-flags.js Show resolved Hide resolved
#setLtTimer () {
clearTimeout(this.#ltTimer)
this.#ltTimer = setTimeout(() => {
this.#resolver({ value: Math.round(Math.max(this.#startTimestamp, this.#latestLT)), attrs: { startTimestamp: this.#startTimestamp, longTasks: this.#longTasks } })
Copy link
Contributor

Choose a reason for hiding this comment

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

What exactly is #startTimestamp (passed in as) and why is it some external value?

Copy link
Contributor

Choose a reason for hiding this comment

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

--Actually see related notes in initial page load class.

Copy link
Member Author

Choose a reason for hiding this comment

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

essentially to accommodate for either being started on the fly, or representing a past time, ie from the page load origin time

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you put comments in here about how this is being calculated, e.g. citing whatever source?

Also, assuming this is following webdev, it's missing both the max 2 in-flight network GET factor and the FCP should be gotten within this module so that this is a self-contained metric.

@@ -720,6 +720,8 @@ export class Aggregate extends AggregateBase {
}
baseEE.emit('interactionSaved', [interaction])
state.interactionsToHarvest.push(interaction)

Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder to delete

@@ -109,6 +109,7 @@ export class Aggregate extends AggregateBase {
activateFeatures(JSON.parse(responseText), this.agentIdentifier)
this.drain()
} catch (err) {
console.error(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder to delete

@@ -32,6 +32,8 @@ export function lazyFeatureLoader (featureName, featurePart) {
return import(/* webpackChunkName: "session_trace-aggregate" */ '../session_trace/aggregate')
case FEATURE_NAMES.spa:
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise can take old spa out

}

hasInteraction ({ timestamp }) {
if (!timestamp) return { interaction: undefined }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is meant to return interactions? Can you align function name & property singular or plural?

} = spaFeature?.hasInteraction?.({ timestamp: event.startTime }) || {}

// if the ajax happened inside an ixn window (found a match), add it to the ixn
if (interactions?.length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if there is more than 1 interaction that's returned? How can it make sense that there's more than 1 interaction at a time and that this ajax is a child of every one (multiple)?

Copy link
Member Author

Choose a reason for hiding this comment

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

it could be a child of both a page load interaction and a click interaction if both are happening simultaneously while the ajax occurs under this model, since its timestamp-based alone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
POC A proof of concept
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants