Capture page context as early as possible if initialPageview = true#1009
Capture page context as early as possible if initialPageview = true#1009
initialPageview = true#1009Conversation
🦋 Changeset detectedLatest commit: 58310d6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
10e2fb9 to
cd3d1ca
Compare
initialPageview setting is true
initialPageview setting is trueinitialPageview = true
b4010c1 to
0649fdf
Compare
| export interface InitOptions { | ||
| updateCDNSettings?(cdnSettings: CDNSettings): CDNSettings | ||
| disable?: boolean | ((cdnSettings: CDNSettings) => boolean) | ||
| initialPageview?: boolean | ||
| } |
There was a problem hiding this comment.
why is this object completely detached from the interface of the options of the analytics client? shouldn't they be the same?
There was a problem hiding this comment.
Here's my original reasoning:
- Owning all our own interface forces us to be explicit about what features of the analytics client we are actually depending on, which helps with mocking / clarity (obviously you could use pick to grab fields -- but like that breaks down when you have say functions with callbacks that are typed. For example, we don't need all of the cdnSettings interface-- just a piece).
- We have both e2e and typedef tests to ensure that the real analytics types do not get out of sync with those defined here (that's why analytics-next is a dev dependency).
- avoiding a hard dependency on analytics-next means users who use the snippet but still build their application with npm don't get the large dependency tree. Also simplifies releasing via changeset (ie, ajs releases won't trigger a consent release by default), possible internal library compilation errors for those with skipLib check false etc. Just simplifies things generally 😄
e31b042 to
58310d6
Compare
|
|
||
| if (options.initialPageview) { | ||
| // capture the page context early, so it's always up-to-date | ||
| preInitBuffer.push(new PreInitMethodCall('page', [])) |
There was a problem hiding this comment.
This doesn't store all the page context like the snippet does...does it? My understanding is that this would queue a page call that will be invoked after some async work has been completed (which gives the address of the page time to change)
There was a problem hiding this comment.
Yes, it stores the page context at insertion!
There was a problem hiding this comment.
Ah right, forgot preInitBuffer isn't a regular array.
Uh oh!
There was an error while loading. Please reload this page.