Skip to content

Commit

Permalink
Added a popstate listener & updated the changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Olwiba committed Dec 10, 2023
1 parent 3a9a53e commit 2d14e13
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Unused normalize.css file
-->
## [3.0.0]

### Added

- Adds Browserify support to build pipeline
- Added new browser mocks for unit tests
- Added new popstate event listener, to trigger
- unloadHandler replacement: Added popstate event listener network logic to [better support mobile devices](https://developer.chrome.com/docs/web-platform/page-lifecycle-api#advice-hidden)
- unloadHandler replacement: Added hidden visibilityState change network logic to [better support mobile devices](https://developer.chrome.com/docs/web-platform/page-lifecycle-api#advice-hidden)

### Changed

- Changed the way the web-vitals library is imported into the project
- Moved to using the official web vital callback triggers
- Updated the sendCoreWebVitalTimings method to fire web vital payloads using beacon if available
- Upgrade chromedriver dependency to 119.0.1

### Removed

- unloadHandler replacement: Removed the unload event listener network logic in favour of other approaches

## [2.28.0]

### Changed
Expand Down Expand Up @@ -785,4 +806,4 @@ NPM and nuget packages (2.25.4 and older) were marked deprecated on NPM and Nuge

## v1.0.1

- Initial Release
- Initial Release
21 changes: 14 additions & 7 deletions src/raygun.rum/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ var raygunRumFactory = function (window, $, Raygun) {
Raygun.CoreWebVitals.attach(sendCoreWebVitalTimings, self.parentResource);
}

var sendAllQueuedPayloadsWithBeacon = function () {
self.sendUsingNavigatorBeacon = true;
sendChildAssets(true);
sendQueuedItems();
}.bind(_private);

var clickHandler = function () {
this.updateStorageTimestamp();
}.bind(_private);
Expand All @@ -127,22 +133,23 @@ var raygunRumFactory = function (window, $, Raygun) {
}

if (document.visibilityState === 'hidden') {
self.sendUsingNavigatorBeacon = true;
sendChildAssets(true);
sendQueuedItems();
sendAllQueuedPayloadsWithBeacon();
}
}.bind(_private);

var urlChangeHandler = function () {
sendAllQueuedPayloadsWithBeacon();
}.bind(_private);

var pageHideHandler = function () {
self.sendUsingNavigatorBeacon = true;
sendChildAssets(true);
sendQueuedItems();
sendAllQueuedPayloadsWithBeacon();
self.stopCollectingMetrics = true;
}.bind(_private);

if (window.addEventListener) {
window.addEventListener('click', clickHandler);
document.addEventListener('visibilitychange', visibilityChangeHandler);
window.addEventListener('popstate', urlChangeHandler);
window.addEventListener('pagehide', pageHideHandler);
} else if (window.attachEvent) {
document.attachEvent('onclick', clickHandler);
Expand Down Expand Up @@ -499,8 +506,8 @@ var raygunRumFactory = function (window, $, Raygun) {

function sendCoreWebVitalTimings(performanceData) {
var payload = createTimingPayload([performanceData]);
// send the payload immediately if beacon is not supported
if (!navigator.sendBeacon) {
// send the payload immediately if beacon is not supported
sendItemsImmediately([payload]);
} else {
// send the payload using beacon, if there is data
Expand Down

0 comments on commit 2d14e13

Please sign in to comment.