Skip to content

Commit f452357

Browse files
Merge remote-tracking branch 'origin/develop' into kw/normalize-infinity
2 parents aa096bd + c24f6d0 commit f452357

File tree

10 files changed

+138
-46
lines changed

10 files changed

+138
-46
lines changed

.github/actions/install-dependencies/action.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ outputs:
99
runs:
1010
using: "composite"
1111
steps:
12-
# we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed,
13-
# so no need to reinstall them
1412
- name: Compute dependency cache key
1513
id: compute_lockfile_hash
16-
run: echo "hash=dependencies-${{ hashFiles('yarn.lock', 'packages/*/package.json', 'dev-packages/*/package.json') }}" >> "$GITHUB_OUTPUT"
14+
run: node ./scripts/dependency-hash-key.js >> "$GITHUB_OUTPUT"
1715
shell: bash
1816

1917
- name: Check dependency cache

.github/workflows/build.yml

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ jobs:
127127
runs-on: ubuntu-20.04
128128
timeout-minutes: 15
129129
if: |
130-
needs.job_get_metadata.outputs.changed_any_code == 'true' &&
130+
needs.job_get_metadata.outputs.changed_any_code == 'true' ||
131+
needs.job_get_metadata.outputs.is_develop == 'true' ||
132+
needs.job_get_metadata.outputs.is_release == 'true' ||
131133
(needs.job_get_metadata.outputs.is_gitflow_sync == 'false' && needs.job_get_metadata.outputs.has_gitflow_label == 'false')
132134
steps:
133135
- name: Check out base commit (${{ github.event.pull_request.base.sha }})
@@ -344,7 +346,7 @@ jobs:
344346
name: ${{ github.sha }}
345347
path: |
346348
${{ github.workspace }}/packages/browser/build/bundles/**
347-
${{ github.workspace }}/packages/replay/build/bundles/**
349+
${{ github.workspace }}/packages/replay-internal/build/bundles/**
348350
${{ github.workspace }}/packages/replay-canvas/build/bundles/**
349351
${{ github.workspace }}/packages/feedback/build/bundles/**
350352
${{ github.workspace }}/packages/**/*.tgz
@@ -1416,31 +1418,29 @@ jobs:
14161418
with:
14171419
ref: ${{ env.HEAD_COMMIT }}
14181420

1421+
- name: Setup Node
1422+
uses: actions/setup-node@v4
1423+
with:
1424+
node-version: ${{ matrix.node }}
1425+
14191426
- name: Restore dependency cache
14201427
uses: actions/cache/restore@v4
14211428
id: restore-dependencies
14221429
with:
14231430
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
14241431
key: ${{ needs.job_build.outputs.dependency_cache_key }}
14251432
enableCrossOsArchive: true
1426-
fail-on-cache-miss: true
14271433

1428-
- name: Restore build cache
1429-
uses: actions/cache/restore@v4
1430-
id: restore-build
1431-
with:
1432-
path: ${{ env.CACHED_BUILD_PATHS }}
1433-
key: ${{ needs.job_build.outputs.dependency_cache_key }}
1434-
enableCrossOsArchive: true
1435-
fail-on-cache-miss: true
1434+
- name: Install dependencies
1435+
env:
1436+
SKIP_PLAYWRIGHT_BROWSER_INSTALL: "1"
1437+
if: steps.restore-dependencies.outputs.cache-hit != 'true'
1438+
run: yarn install --ignore-engines --frozen-lockfile
14361439

14371440
- name: Configure safe directory
14381441
run: |
14391442
git config --global --add safe.directory "*"
14401443
1441-
- name: Install yarn
1442-
run: npm i -g [email protected] --force
1443-
14441444
- name: Increase yarn network timeout on Windows
14451445
if: contains(matrix.os, 'windows')
14461446
run: yarn config set network-timeout 600000 -g
@@ -1452,15 +1452,6 @@ jobs:
14521452
with:
14531453
python-version: '3.8.10'
14541454

1455-
- name: Setup Node
1456-
uses: actions/setup-node@v4
1457-
with:
1458-
node-version: ${{ matrix.node }}
1459-
1460-
- name: Install Dependencies
1461-
if: steps.restore-dependencies.outputs.cache-hit != 'true'
1462-
run: yarn install --frozen-lockfile --ignore-engines --ignore-scripts
1463-
14641455
- name: Setup (arm64| ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})
14651456
if: matrix.arch == 'arm64' && !contains(matrix.container, 'alpine') && matrix.target_platform != 'darwin'
14661457
run: |

dev-packages/browser-integration-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"private": true,
1010
"scripts": {
1111
"clean": "rimraf -g suites/**/dist loader-suites/**/dist tmp",
12-
"install-browsers": "npx playwright install --with-deps",
12+
"install-browsers": "[[ -z \"$SKIP_PLAYWRIGHT_BROWSER_INSTALL\" ]] && yarn install-browsers || echo 'Skipping browser installation'",
1313
"lint": "eslint . --format stylish",
1414
"fix": "eslint . --format stylish --fix",
1515
"type-check": "tsc",

dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/init.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,3 @@ Sentry.init({
1010
feedbackIntegration({ tags: { from: 'integration init' }, styleNonce: 'foo1234', scriptNonce: 'foo1234' }),
1111
],
1212
});
13-
14-
document.addEventListener('securitypolicyviolation', () => {
15-
const container = document.querySelector('#csp-violation');
16-
if (container) {
17-
container.innerText = 'CSP Violation';
18-
}
19-
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
window.__CSPVIOLATION__ = false;
2+
document.addEventListener('securitypolicyviolation', () => {
3+
window.__CSPVIOLATION__ = true;
4+
});

dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/template.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@
77
content="style-src 'nonce-foo1234'; script-src sentry-test.io 'nonce-foo1234';"
88
/>
99
</head>
10-
<body>
11-
<div id="csp-violation" />
12-
</body>
10+
<body></body>
1311
</html>

dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => {
7979
},
8080
platform: 'javascript',
8181
});
82-
const cspContainer = await page.locator('#csp-violation');
83-
expect(cspContainer).not.toContainText('CSP Violation');
82+
const cspViolation = await page.evaluate<boolean>('window.__CSPVIOLATION__');
83+
expect(cspViolation).toBe(false);
8484
});

dev-packages/e2e-tests/test-applications/tanstack-router/yarn.lock

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@
150150
"@nodelib/fs.scandir" "2.1.5"
151151
fastq "^1.6.0"
152152

153+
"@playwright/test@^1.44.1":
154+
version "1.46.1"
155+
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.46.1.tgz#a8dfdcd623c4c23bb1b7ea588058aad41055c188"
156+
integrity sha512-Fq6SwLujA/DOIvNC2EL/SojJnkKf/rAwJ//APpJJHRyMi1PdKrY3Az+4XNQ51N4RTbItbIByQ0jgd1tayq1aeA==
157+
dependencies:
158+
playwright "1.46.1"
159+
153160
154161
version "4.18.0"
155162
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.18.0.tgz#bbd0e616b2078cd2d68afc9824d1fadb2f2ffd27"
@@ -268,6 +275,9 @@
268275
"@sentry/types" "8.4.0"
269276
"@sentry/utils" "8.4.0"
270277

278+
"@sentry-internal/test-utils@link:../../../test-utils":
279+
version "8.26.0"
280+
271281
272282
version "8.4.0"
273283
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-8.4.0.tgz#f4aa381eab212432d71366884693a36c2e3a1675"
@@ -398,10 +408,10 @@
398408
resolved "https://registry.yarnpkg.com/@tanstack/history/-/history-1.31.16.tgz#6b4947e967af3173ce4929d54d9cb97234646e32"
399409
integrity sha512-rahAZXlR879P7dngDH7BZwGYiODA9D5Hqo6nUHn9GAURcqZU5IW0ZiT54dPtV5EPES7muZZmknReYueDHs7FFQ==
400410

401-
"@tanstack/[email protected].3":
402-
version "1.34.3"
403-
resolved "https://registry.yarnpkg.com/@tanstack/react-router/-/react-router-1.34.3.tgz#1152ca7deaaec93f519971911a816bc42011b6ba"
404-
integrity sha512-0pB+4qnp+5snHu5T93gvFmLcpXuIfSEhXZG7ipf3Rq8kmv4y0DGwcbvgFLiYKSZ/3x58faE8U0MD6F9vR9JUtg==
411+
"@tanstack/[email protected].5":
412+
version "1.34.5"
413+
resolved "https://registry.yarnpkg.com/@tanstack/react-router/-/react-router-1.34.5.tgz#2c5bc5cd6b246f830ce586c51a87f95352481957"
414+
integrity sha512-mOMbNHSJ1cAgRuJj9W35wteQL7zFiCNJYgg3QHkxj+obO9zQWiAwycFs0hQTRxqzGfC+jhVLJe1+cW93BhqKyA==
405415
dependencies:
406416
"@tanstack/history" "1.31.16"
407417
"@tanstack/react-store" "^0.2.1"
@@ -636,6 +646,11 @@ fill-range@^7.1.1:
636646
dependencies:
637647
to-regex-range "^5.0.1"
638648

649+
650+
version "2.3.2"
651+
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
652+
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
653+
639654
fsevents@~2.3.2, fsevents@~2.3.3:
640655
version "2.3.3"
641656
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
@@ -712,9 +727,9 @@ merge2@^1.3.0, merge2@^1.4.1:
712727
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
713728

714729
micromatch@^4.0.4:
715-
version "4.0.7"
716-
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.7.tgz#33e8190d9fe474a9895525f5618eee136d46c2e5"
717-
integrity sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==
730+
version "4.0.8"
731+
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202"
732+
integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==
718733
dependencies:
719734
braces "^3.0.3"
720735
picomatch "^2.3.1"
@@ -756,6 +771,20 @@ picomatch@^2.3.1:
756771
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
757772
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
758773

774+
775+
version "1.46.1"
776+
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.46.1.tgz#28f3ab35312135dda75b0c92a3e5c0e7edb9cc8b"
777+
integrity sha512-h9LqIQaAv+CYvWzsZ+h3RsrqCStkBHlgo6/TJlFst3cOTlLghBQlJwPOZKQJTKNaD3QIB7aAVQ+gfWbN3NXB7A==
778+
779+
780+
version "1.46.1"
781+
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.46.1.tgz#ea562bc48373648e10420a10c16842f0b227c218"
782+
integrity sha512-oPcr1yqoXLCkgKtD5eNUPLiN40rYEM39odNpIb6VE6S7/15gJmA1NzVv6zJYusV0e7tzvkU/utBFNa/Kpxmwng==
783+
dependencies:
784+
playwright-core "1.46.1"
785+
optionalDependencies:
786+
fsevents "2.3.2"
787+
759788
postcss@^8.4.38:
760789
version "8.4.38"
761790
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.38.tgz#b387d533baf2054288e337066d81c6bee9db9e0e"

packages/feedback/src/core/sendFeedback.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ export const sendFeedback: SendFeedback = (
6464
);
6565
}
6666

67+
if (response && typeof response.statusCode === 'number' && response.statusCode === 403) {
68+
return reject(
69+
'Unable to send Feedback. This could be because this domain is not in your list of allowed domains.',
70+
);
71+
}
72+
6773
return reject(
6874
'Unable to send Feedback. This could be because of network issues, or because you are using an ad-blocker',
6975
);

scripts/dependency-hash-key.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
const crypto = require('crypto');
2+
const fs = require('fs');
3+
const path = require('path');
4+
5+
/**
6+
* Build a cache key for the dependencies of the monorepo.
7+
* In addition to the content of the yarn.lock file, we also include
8+
* dependencies of all workspace packages in the cache key.
9+
* This ensures that we get a consistent cache key even if a dependency change does not affect
10+
* the yarn.lock file.
11+
*/
12+
function outputDependencyCacheKey() {
13+
const lockfileContent = fs.readFileSync(path.join(process.cwd(), 'yarn.lock'), 'utf8');
14+
15+
const hashParts = [lockfileContent];
16+
17+
const packageJson = require(path.join(process.cwd(), 'package.json'));
18+
19+
const workspacePackages = packageJson.workspaces || [];
20+
21+
// Get the package name (e.g. @sentry/browser) of all workspace packages
22+
// we want to ignore their version numbers later
23+
const workspacePackageNames = getWorkspacePackageNames(workspacePackages);
24+
25+
// Add the dependencies of the workspace itself
26+
hashParts.push(getNormalizedDependencies(packageJson, workspacePackageNames));
27+
28+
// Now for each workspace package, add the dependencies
29+
workspacePackages.forEach(workspace => {
30+
const packageJsonPath = path.join(process.cwd(), workspace, 'package.json');
31+
const packageJson = require(packageJsonPath);
32+
hashParts.push(getNormalizedDependencies(packageJson, workspacePackageNames));
33+
});
34+
35+
const hash = crypto.createHash('md5').update(hashParts.join('\n')).digest('hex');
36+
// We log the output in a way that the GitHub Actions can append it to the output
37+
// We prefix it with `dependencies-` so it is easier to identify in the logs
38+
// eslint-disable-next-line no-console
39+
console.log(`hash=dependencies-${hash}`);
40+
}
41+
42+
function getNormalizedDependencies(packageJson, workspacePackageNames) {
43+
const { dependencies, devDependencies } = packageJson;
44+
45+
const mergedDependencies = {
46+
...devDependencies,
47+
...dependencies,
48+
};
49+
50+
const normalizedDependencies = {};
51+
52+
// Sort the keys to ensure a consistent order
53+
Object.keys(mergedDependencies)
54+
.sort()
55+
.forEach(key => {
56+
// If the dependency is a workspace package, ignore the version
57+
// No need to invalidate a cache after every release
58+
const version = workspacePackageNames.includes(key) ? '**workspace**' : mergedDependencies[key];
59+
normalizedDependencies[key] = version;
60+
});
61+
62+
return JSON.stringify(normalizedDependencies);
63+
}
64+
65+
function getWorkspacePackageNames(workspacePackages) {
66+
return workspacePackages.map(workspace => {
67+
const packageJsonPath = path.join(process.cwd(), workspace, 'package.json');
68+
const packageJson = require(packageJsonPath);
69+
return packageJson.name;
70+
});
71+
}
72+
73+
outputDependencyCacheKey();

0 commit comments

Comments
 (0)