Skip to content

Commit

Permalink
Merge branch 'main' into rum-js-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
kptdobe authored Jun 20, 2024
2 parents 96fbd9f + 4ef4465 commit ca30120
Show file tree
Hide file tree
Showing 9 changed files with 1,630 additions and 1,421 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Release
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next'
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -29,6 +29,10 @@ jobs:
with:
node-version: 20
- run: npm ci
- name: Sync next branch
run: sh sync.sh
env:
GITHUB_TOKEN: ${{ secrets.ADOBE_BOT_GITHUB_TOKEN }}
- run: npm run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.ADOBE_BOT_GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .releaserc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ module.exports = {
"publishCmd": "./publish.sh ${nextRelease.version} ${nextRelease.type}"
}],
],
branches: ['main'],
branches: ["main", "next"],
};
9 changes: 8 additions & 1 deletion .renovaterc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
"extends": [
"github>adobe/helix-shared"
],
"baseBranches": [
"main",
"2.x"
],
"packageRules": [
{
"matchPackageNames": [
"helix-rum-js"
],
"allowedVersions": ">=1.0.0 <2.0.0"
"matchBaseBranches": [
"main"
],
"allowedVersions": "<2.0.0"
}
]
}
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
## [2.1.2](https://github.com/adobe/aem-lib/compare/v2.1.1...v2.1.2) (2024-06-12)


### Bug Fixes

* **deps:** update dependency @adobe/helix-rum-js to v1.9.0 ([#75](https://github.com/adobe/aem-lib/issues/75)) ([92af474](https://github.com/adobe/aem-lib/commit/92af4743ce2e1f4d22e2da910f743861770eba1d))

## [2.1.1](https://github.com/adobe/aem-lib/compare/v2.1.0...v2.1.1) (2024-06-07)


### Bug Fixes

* **deps:** update dependency @adobe/helix-rum-js to v1.8.1 ([2c64eb0](https://github.com/adobe/aem-lib/commit/2c64eb0553bff19f269faaf4ba7b44b08232cfa1))

# [2.1.0](https://github.com/adobe/aem-lib/compare/v2.0.0...v2.1.0) (2024-04-19)


### Features

* **setup:** better RUM error logging ([3908f1e](https://github.com/adobe/aem-lib/commit/3908f1ed1bcab7005891c17294d12f1bf9559838))

# [2.0.0](https://github.com/adobe/aem-lib/compare/v1.5.4...v2.0.0) (2024-04-17)


### chore

* **deps:** use helix-rum-js@v2 ([5ebd74d](https://github.com/adobe/aem-lib/commit/5ebd74dbea0fca6d125c3002f5cbbbe547c543fe))


### BREAKING CHANGES

* **deps:** this requires a helix5 origin, on aem.live

## [1.5.4](https://github.com/adobe/aem-lib/compare/v1.5.3...v1.5.4) (2024-04-17)


### Bug Fixes

* **release:** allow releases from 2.x ([80356f5](https://github.com/adobe/aem-lib/commit/80356f5f4c2706bf354bc258e05ee18be95676ac))

## [1.5.3](https://github.com/adobe/aem-lib/compare/v1.5.2...v1.5.3) (2024-04-17)


### Bug Fixes

* **package): Revert "fix(deps:** update dependency @adobe/helix-rum-js to v2" ([a0a54a9](https://github.com/adobe/aem-lib/commit/a0a54a93e6c4fb2ba9e2405e51f9535967121dc5))

## [1.5.2](https://github.com/adobe/aem-lib/compare/v1.5.1...v1.5.2) (2024-04-17)


### Bug Fixes

* **deps:** update dependency @adobe/helix-rum-js to v2 ([ea35ac5](https://github.com/adobe/aem-lib/commit/ea35ac5116e89d5b8b6282847a9ffdb31f2c6ee0))

## [1.5.1](https://github.com/adobe/aem-lib/compare/v1.5.0...v1.5.1) (2024-01-22)


Expand Down
33 changes: 11 additions & 22 deletions dist/aem.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* for instance the href of a link, or a search term
*/
function sampleRUM(checkpoint, data = {}) {
const SESSION_STORAGE_KEY = 'aem-rum';
sampleRUM.baseURL = sampleRUM.baseURL
|| new URL(window.RUM_BASE == null ? 'https://rum.hlx.page' : window.RUM_BASE, window.location);
sampleRUM.defer = sampleRUM.defer || [];
Expand Down Expand Up @@ -50,10 +49,7 @@ function sampleRUM(checkpoint, data = {}) {
if (!window.hlx.rum) {
const usp = new URLSearchParams(window.location.search);
const weight = usp.get('rum') === 'on' ? 1 : 100; // with parameter, weight is 1. Defaults to 100.
const id = Array.from({ length: 75 }, (_, i) => String.fromCharCode(48 + i))
.filter((a) => /\d|[A-Z]/i.test(a))
.filter(() => Math.random() * 75 > 70)
.join('');
const id = Math.random().toString(36).slice(-4);
const random = Math.random();
const isSelected = random * weight < 1;
const firstReadTime = window.performance ? window.performance.timeOrigin : Date.now();
Expand All @@ -62,15 +58,6 @@ function sampleRUM(checkpoint, data = {}) {
origin: () => window.location.origin,
path: () => window.location.href.replace(/\?.*$/, ''),
};
// eslint-disable-next-line max-len
const rumSessionStorage = sessionStorage.getItem(SESSION_STORAGE_KEY)
? JSON.parse(sessionStorage.getItem(SESSION_STORAGE_KEY))
: {};
// eslint-disable-next-line max-len
rumSessionStorage.pages = (rumSessionStorage.pages ? rumSessionStorage.pages : 0)
+ 1
/* noise */ + (Math.floor(Math.random() * 20) - 10);
sessionStorage.setItem(SESSION_STORAGE_KEY, JSON.stringify(rumSessionStorage));
// eslint-disable-next-line object-curly-newline, max-len
window.hlx.rum = {
weight,
Expand All @@ -80,7 +67,6 @@ function sampleRUM(checkpoint, data = {}) {
firstReadTime,
sampleRUM,
sanitizeURL: urlSanitizers[window.hlx.RUM_MASK_URL || 'path'],
rumSessionStorage,
};
}

Expand Down Expand Up @@ -119,7 +105,6 @@ function sampleRUM(checkpoint, data = {}) {
console.debug(`ping:${checkpoint}`, pdata);
};
sampleRUM.cases = sampleRUM.cases || {
load: () => sampleRUM('pagesviewed', { source: window.hlx.rum.rumSessionStorage.pages }) || true,
cwv: () => sampleRUM.cwv(data) || true,
lazy: () => {
// use classic script to avoid CORS issues
Expand Down Expand Up @@ -175,12 +160,16 @@ function init() {

window.addEventListener('load', () => sampleRUM('load'));

window.addEventListener('unhandledrejection', (event) => {
sampleRUM('error', { source: event.reason.sourceURL, target: event.reason.line });
});

window.addEventListener('error', (event) => {
sampleRUM('error', { source: event.filename, target: event.lineno });
['error', 'unhandledrejection'].forEach((event) => {
window.addEventListener(event, ({ reason, error }) => {
const source = (reason || error).stack
.split('\n')
.filter((line) => line.match(/https?:\/\//))
.shift()
.replace(/at ([^ ]+) \((.+)\)/, '$1@$2');
const target = (reason || error).toString();
sampleRUM('error', { source, target });
});
});
}

Expand Down
Loading

0 comments on commit ca30120

Please sign in to comment.