-
Notifications
You must be signed in to change notification settings - Fork 49
feat(analytics-browser): add page-url-previous-page plugin #1110
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
base: main
Are you sure you want to change the base?
Conversation
c2223a5
to
d8e6eba
Compare
d5d2b40
to
c3dbbce
Compare
this is fine since |
packages/analytics-browser/src/plugins/page-url-previous-page.ts
Outdated
Show resolved
Hide resolved
packages/analytics-browser/src/plugins/page-url-previous-page.ts
Outdated
Show resolved
Hide resolved
packages/analytics-browser/src/plugins/page-url-previous-page.ts
Outdated
Show resolved
Hide resolved
packages/analytics-browser/src/plugins/page-url-previous-page.ts
Outdated
Show resolved
Hide resolved
Thanks @cyhk ! Generally looks, had some comments. General question though: was there a formal process for deciding the namings of the config and events? For the config ( I'm asking just because API changes (in this case the config definition) and event properties can't be reverted once they've been released. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ BugBot reviewed your changes and found no bugs!
Was this report helpful? Give feedback by reacting with 👍 or 👎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @cyhk for making this PR. I have two major concerns.
- Is it necessary to add more event properties to all events? Potential COGS. Or at least we should have a filter to decide which events to add.
- The definition of previous page url is the same as the event property referrer of page view. I read the proposal but didn't find the case where referrer cannot help.
packages/analytics-browser/src/plugins/page-url-previous-page.ts
Outdated
Show resolved
Hide resolved
packages/analytics-browser/src/plugins/page-url-previous-page.ts
Outdated
Show resolved
Hide resolved
let previousPage = ''; | ||
if (sessionStorage && isStorageEnabled) { | ||
const URLInfo = await sessionStorage.get(URL_INFO_STORAGE_KEY); | ||
previousPage = URLInfo?.[PREVIOUS_PAGE_STORAGE_KEY] || document.referrer || ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May result in different previous page location and referrer event properties and thus cause confusion.
event.event_properties = { | ||
...(event.event_properties || {}), | ||
'[Amplitude] Page Domain': | ||
/* istanbul ignore next */ (typeof location !== 'undefined' && location.hostname) || '', | ||
'[Amplitude] Page Location': locationHREF, | ||
'[Amplitude] Page Path': | ||
/* istanbul ignore next */ (typeof location !== 'undefined' && getDecodeURI(location.pathname)) || '', | ||
'[Amplitude] Page Title': | ||
/* istanbul ignore next */ (typeof document !== 'undefined' && document.title) || '', | ||
'[Amplitude] Page URL': locationHREF.split('?')[0], | ||
'[Amplitude] Previous Page Location': previousPage, | ||
'[Amplitude] Previous Page Type': getPrevPageType(previousPage), | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any COGS concern @izaaz if we add extra event properties to all events?
Any plan to add a filter to apply to specific events? I'm thinking about config.autocapture.pageUrlPreviousPage.trackOn
, a function returning boolean.
packages/analytics-browser/src/plugins/page-url-previous-page.ts
Outdated
Show resolved
Hide resolved
6bf3702
to
af0aa65
Compare
Summary
This adds a
page-url-previous-page
plugin to the analytics browser, enriching events with a set of page url and previous page related properties.The PRD is here.
Note that the plugin is default off right now, but there are plans to make this default on in the future.
Checklist