Skip to content

Commit c91e1fd

Browse files
authored
Merge pull request #6996 from getsentry/master
[Gitflow] MANUALLY merge master into develop
2 parents 0c641cf + a6c6b2a commit c91e1fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1449
-162
lines changed

.github/workflows/build.yml

+9-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 'Build & Test'
22
on:
33
push:
44
branches:
5-
- master
5+
- develop
66
- release/**
77
pull_request:
88
workflow_dispatch:
@@ -42,11 +42,11 @@ env:
4242

4343
# GH will use the first restore-key it finds that matches
4444
# So it will start by looking for one from the same branch, else take the newest one it can find elsewhere
45-
# We want to prefer the cache from the current master branch, if we don't find any on the current branch
45+
# We want to prefer the cache from the current develop branch, if we don't find any on the current branch
4646
NX_CACHE_RESTORE_KEYS: |
4747
nx-Linux-${{ github.ref }}-${{ github.event.inputs.commit || github.sha }}
4848
nx-Linux-${{ github.ref }}
49-
nx-Linux-refs/heads/master
49+
nx-Linux-refs/heads/develop
5050
nx-Linux
5151
5252
jobs:
@@ -134,7 +134,7 @@ jobs:
134134
changed_browser_integration: ${{ steps.changed.outputs.browser_integration }}
135135
changed_any_code: ${{ steps.changed.outputs.any_code }}
136136
# Note: These next three have to be checked as strings ('true'/'false')!
137-
is_master: ${{ github.ref == 'refs/heads/master' }}
137+
is_develop: ${{ github.ref == 'refs/heads/develop' }}
138138
is_release: ${{ startsWith(github.ref, 'refs/heads/release/') }}
139139
force_skip_cache:
140140
${{ github.event_name == 'pull_request' && contains(steps.pr-labels.outputs.labels, ' ci-skip-cache ') }}
@@ -202,7 +202,7 @@ jobs:
202202
- name: NX cache
203203
uses: actions/cache@v3
204204
# Disable cache when:
205-
# - on master
205+
# - on develop
206206
# - on release branches
207207
# - when PR has `ci-skip-cache` label
208208
if: |
@@ -211,9 +211,9 @@ jobs:
211211
with:
212212
path: node_modules/.cache/nx
213213
key: nx-Linux-${{ github.ref }}-${{ env.HEAD_COMMIT }}
214-
# On master branch, we want to _store_ the cache (so it can be used by other branches), but never _restore_ from it
214+
# On develop branch, we want to _store_ the cache (so it can be used by other branches), but never _restore_ from it
215215
restore-keys:
216-
${{needs.job_get_metadata.outputs.is_master == 'false' && env.NX_CACHE_RESTORE_KEYS || 'nx-never-restore'}}
216+
${{needs.job_get_metadata.outputs.is_develop == 'false' && env.NX_CACHE_RESTORE_KEYS || 'nx-never-restore'}}
217217

218218
- name: Build packages
219219
# Under normal circumstances, using the git SHA as a cache key, there shouldn't ever be a cache hit on the built
@@ -272,8 +272,7 @@ jobs:
272272
needs: [job_get_metadata, job_build]
273273
timeout-minutes: 15
274274
runs-on: ubuntu-20.04
275-
# Size Check will error out outside of the context of a PR or master branch
276-
if: github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_master == 'true'
275+
if: github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_develop == 'true'
277276
steps:
278277
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
279278
uses: actions/checkout@v3
@@ -283,7 +282,6 @@ jobs:
283282
uses: actions/setup-node@v3
284283
with:
285284
# The size limit action runs `yarn` and `yarn build` when this job is executed on
286-
# `master`. We can't change this without making changes to the action, so we'll
287285
# use Node 14 for now.
288286
node-version: '14'
289287
- name: Check dependency cache
@@ -301,6 +299,7 @@ jobs:
301299
with:
302300
github_token: ${{ secrets.GITHUB_TOKEN }}
303301
skip_step: build
302+
main_branch: develop
304303

305304
job_lint:
306305
name: Lint

.github/workflows/codeql-analysis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ name: 'CodeQL'
1313

1414
on:
1515
push:
16-
branches: [master]
16+
branches: [develop]
1717
pull_request:
1818
# The branches below must be a subset of the branches above
19-
branches: [master]
19+
branches: [develop]
2020
paths-ignore:
2121
# When _only_ changing .md files, no need to run CodeQL analysis
2222
- '**/*.md'

.github/workflows/enforce-license-compliance.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Enforce License Compliance
22

33
on:
44
push:
5-
branches: [master, main, release/*]
5+
branches: [master, develop, release/*]
66
pull_request:
7-
branches: [master, main]
7+
branches: [master, develop]
88

99
jobs:
1010
enforce-license-compliance:
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Gitflow - Sync master into develop
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths:
7+
# When the version is updated on master (but nothing else)
8+
- 'lerna.json'
9+
- '!**/*.js'
10+
- '!**/*.ts'
11+
workflow_dispatch:
12+
13+
env:
14+
DEV_BRANCH: develop
15+
16+
jobs:
17+
main:
18+
name: Create PR master->develop
19+
runs-on: ubuntu-20.04
20+
permissions:
21+
pull-requests: write
22+
contents: write
23+
steps:
24+
- name: git checkout
25+
uses: actions/checkout@v3
26+
27+
# https://github.com/marketplace/actions/github-pull-request-action
28+
- name: Create Pull Request
29+
id: open-pr
30+
uses: repo-sync/pull-request@v2
31+
with:
32+
destination_branch: ${{ env.DEV_BRANCH }}
33+
pr_title: '[Gitflow] Merge ${{ github.ref_name }} into ${{ env.DEV_BRANCH }}'
34+
pr_body: 'Merge ${{ github.ref_name }} branch into ${{ env.DEV_BRANCH }}'
35+
36+
# https://github.com/marketplace/actions/enable-pull-request-automerge
37+
- name: Enable automerge for PR
38+
if: steps.open-pr.outputs.pr_number != ''
39+
uses: peter-evans/enable-pull-request-automerge@v2
40+
with:
41+
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
42+
merge-method: merge
43+
44+
# https://github.com/marketplace/actions/auto-approve
45+
- name: Auto approve PR
46+
uses: hmarr/auto-approve-action@v3
47+
with:
48+
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
49+
review-message: 'Auto approved automated PR'
50+
# TODO: Use the token of some user here??
51+
# github-token: ${{ secrets.SOME_USERS_PAT }}
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Gitflow - Sync develop into master
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
paths:
7+
# We want to trigger this when ONLY the changlog is changed on develop, but nothing else
8+
- 'CHANGELOG.md'
9+
- '!packages'
10+
- '!**/*.js'
11+
- '!**/*.json'
12+
- '!**/*.ts'
13+
workflow_dispatch:
14+
15+
env:
16+
MAIN_BRANCH: master
17+
18+
jobs:
19+
main:
20+
name: Create PR develop->master
21+
runs-on: ubuntu-20.04
22+
permissions:
23+
pull-requests: write
24+
contents: write
25+
steps:
26+
- name: git checkout
27+
uses: actions/checkout@v3
28+
29+
# https://github.com/marketplace/actions/github-pull-request-action
30+
- name: Create Pull Request
31+
id: open-pr
32+
uses: repo-sync/pull-request@v2
33+
with:
34+
destination_branch: ${{ env.MAIN_BRANCH }}
35+
pr_title: '[Gitflow] Merge ${{ github.ref_name }} into ${{ env.MAIN_BRANCH }}'
36+
pr_body: 'Merge ${{ github.ref_name }} branch into ${{ env.MAIN_BRANCH }}'
37+
38+
# https://github.com/marketplace/actions/enable-pull-request-automerge
39+
- name: Enable automerge for PR
40+
if: steps.open-pr.outputs.pr_number != ''
41+
uses: peter-evans/enable-pull-request-automerge@v2
42+
with:
43+
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
44+
merge-method: merge
45+
46+
# https://github.com/marketplace/actions/auto-approve
47+
- name: Auto approve PR
48+
uses: hmarr/auto-approve-action@v3
49+
with:
50+
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
51+
review-message: 'Auto approved automated PR'
52+
# TODO: Use the token of some user here??
53+
# github-token: ${{ secrets.SOME_USERS_PAT }}

.github/workflows/release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
merge_target:
1212
description: Target branch to merge into. Uses the default branch as a fallback (optional)
1313
required: false
14+
default: master
1415
jobs:
1516
release:
1617
runs-on: ubuntu-20.04

CONTRIBUTING.md

+6-17
Original file line numberDiff line numberDiff line change
@@ -130,25 +130,14 @@ This means that all commits on the branch will be squashed into a single commit,
130130
* Make sure to rebase the branch on `master` before squashing it
131131
* Make sure to update the commit message of the squashed branch to follow the commit guidelines - including the PR number
132132
133-
## Publishing a Release
133+
### Gitflow
134134
135-
_These steps are only relevant to Sentry employees when preparing and publishing a new SDK release._
135+
We use [Gitflow](https://docs.github.com/en/get-started/quickstart/github-flow) as a branching model.
136136
137-
**If you want to release a new SDK for the first time, be sure to follow the [New SDK Release Checklist](./docs/new-sdk-release-checklist.md)**
137+
For more details, [see our Gitflow docs](./docs/gitflow.md).
138138
139-
1. Determine what version will be released (we use [semver](https://semver.org)).
140-
2. Update [`CHANGELOG.md`](https://github.com/getsentry/sentry-javascript/edit/master/CHANGELOG.md) to add an entry for the next release number and a list of changes since the last release. (See details below.)
141-
3. Run the [Prepare Release](https://github.com/getsentry/sentry-javascript/actions/workflows/release.yml) workflow.
142-
4. A new issue should appear in https://github.com/getsentry/publish/issues.
143-
5. Ask a member of the [@getsentry/releases team](https://github.com/orgs/getsentry/teams/releases/members) to approve the release.
139+
## Publishing a Release
144140
145-
### Updating the Changelog
141+
_These steps are only relevant to Sentry employees when preparing and publishing a new SDK release._
146142
147-
1. Create a new branch.
148-
2. Run `git log --format="- %s"` and copy everything since the last release.
149-
3. Create a new section in the changelog, deciding based on the changes whether it should be a minor bump or a patch release.
150-
4. Paste in the logs you copied earlier.
151-
5. Delete any which aren't user-facing changes.
152-
6. Alphabetize the rest.
153-
7. If any of the PRs are from external contributors, include underneath the commits `Work in this release contributed by <list of external contributors' GitHub usernames>. Thank you for your contributions!`. If there's only one external PR, don't forget to remove the final `s`. If there are three or more, use an Oxford comma. (It's in the Sentry styleguide!)
154-
8. Commit, push, and open a PR with the title `meta: Update changelog for <fill in relevant version here>`.
143+
[See the docs for publishing a release](./docs/publishing-a-release.md)

docs/assets/gitflow-chart.png

36.6 KB
Loading

docs/gitflow.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Gitflow
2+
3+
We use [Gitflow](https://docs.github.com/en/get-started/quickstart/github-flow) as a branching model.
4+
5+
## Summary
6+
7+
* Ongoing work happens on the `develop` branch
8+
* Any PRs (features, ...) are implemented as PRs against `develop`
9+
* When we are ready to release, we merge develop into master, create a release there, then merge master back into develop
10+
* Whatever is currently on `master` can be considered the last released state of the SDK
11+
* Never merge directly into `master` (unless we want e.g. an emergency bugfix release)
12+
13+
![gitflow-chart](./assets/gitflow-chart.png)

docs/publishing-a-release.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
# Publishing a Release
3+
4+
_These steps are only relevant to Sentry employees when preparing and publishing a new SDK release._
5+
6+
**If you want to release a new SDK for the first time, be sure to follow the [New SDK Release Checklist](./new-sdk-release-checklist.md)**
7+
8+
1. Determine what version will be released (we use [semver](https://semver.org)).
9+
2. Update [`CHANGELOG.md`](https://github.com/getsentry/sentry-javascript/edit/master/CHANGELOG.md) to add an entry for the next release number and a list of changes since the last release. (See details below.)
10+
a. Merging the Changelog PR will automatically trigger a sync from `develop` -> `master`
11+
3. Run the [Prepare Release](https://github.com/getsentry/sentry-javascript/actions/workflows/release.yml) workflow.
12+
a. Wait for this until the sync to `master` is completed.
13+
4. A new issue should appear in https://github.com/getsentry/publish/issues.
14+
5. Ask a member of the [@getsentry/releases team](https://github.com/orgs/getsentry/teams/releases/members) to approve the release.
15+
a. Once the release is completed, a sync from `master` ->` develop` will be automatically triggered
16+
17+
## Updating the Changelog
18+
19+
1. Create a new branch.
20+
2. Run `git log --format="- %s"` and copy everything since the last release.
21+
3. Create a new section in the changelog, deciding based on the changes whether it should be a minor bump or a patch release.
22+
4. Paste in the logs you copied earlier.
23+
5. Delete any which aren't user-facing changes.
24+
6. Alphabetize the rest.
25+
7. If any of the PRs are from external contributors, include underneath the commits `Work in this release contributed by <list of external contributors' GitHub usernames>. Thank you for your contributions!`. If there's only one external PR, don't forget to remove the final `s`. If there are three or more, use an Oxford comma. (It's in the Sentry styleguide!)
26+
8. Commit, push, and open a PR with the title `meta: Update changelog for <fill in relevant version here>` against `develop` branch.

packages/browser/src/client.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import type {
99
Severity,
1010
SeverityLevel,
1111
} from '@sentry/types';
12-
import { createClientReportEnvelope, dsnToString, logger, serializeEnvelope } from '@sentry/utils';
12+
import { createClientReportEnvelope, dsnToString, getSDKSource, logger, serializeEnvelope } from '@sentry/utils';
1313

1414
import { eventFromException, eventFromMessage } from './eventbuilder';
1515
import { WINDOW } from './helpers';
1616
import type { Breadcrumbs } from './integrations';
1717
import { BREADCRUMB_INTEGRATION_ID } from './integrations/breadcrumbs';
1818
import type { BrowserTransportOptions } from './transports/types';
19+
1920
/**
2021
* Configuration options for the Sentry Browser SDK.
2122
* @see @sentry/types Options for more information.
@@ -41,12 +42,14 @@ export class BrowserClient extends BaseClient<BrowserClientOptions> {
4142
* @param options Configuration options for this SDK.
4243
*/
4344
public constructor(options: BrowserClientOptions) {
45+
const sdkSource = WINDOW.SENTRY_SDK_SOURCE || getSDKSource();
46+
4447
options._metadata = options._metadata || {};
4548
options._metadata.sdk = options._metadata.sdk || {
4649
name: 'sentry.javascript.browser',
4750
packages: [
4851
{
49-
name: 'npm:@sentry/browser',
52+
name: `${sdkSource}:@sentry/browser`,
5053
version: SDK_VERSION,
5154
},
5255
],

packages/browser/src/loader.js

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
_window[_onerror] = _oldOnerror;
7171
_window[_onunhandledrejection] = _oldOnunhandledrejection;
7272

73+
// Add loader as SDK source
74+
_window.SENTRY_SDK_SOURCE = 'loader';
75+
7376
var SDK = _window[_namespace];
7477

7578
var oldInit = SDK.init;

packages/browser/test/integration/suites/loader.js

+14
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,19 @@ if (IS_LOADER) {
4949
assert.equal(summary.events[0].breadcrumbs[0].message, 'testing loader');
5050
});
5151
});
52+
53+
it('should set SENTRY_SDK_SOURCE value', () => {
54+
return runInSandbox(sandbox, function () {
55+
Sentry.onLoad(function () {
56+
Sentry.init({ debug: true });
57+
});
58+
setTimeout(function () {
59+
Sentry.captureMessage('test');
60+
});
61+
undefinedMethod(); // trigger error
62+
}).then(function (summary) {
63+
assert.equal(summary.events[0].sdk.packages[0].name, 'loader:@sentry/browser');
64+
});
65+
});
5266
});
5367
}

packages/browser/test/unit/index.test.ts

+22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getReportDialogEndpoint, SDK_VERSION } from '@sentry/core';
2+
import * as utils from '@sentry/utils';
23

34
import type { Event } from '../../src';
45
import {
@@ -277,6 +278,27 @@ describe('SentryBrowser initialization', () => {
277278
expect(sdkData?.version).toBe(SDK_VERSION);
278279
});
279280

281+
it('uses SDK source from window for package name', () => {
282+
global.SENTRY_SDK_SOURCE = 'loader';
283+
init({ dsn });
284+
285+
const sdkData = (getCurrentHub().getClient() as any).getOptions()._metadata.sdk;
286+
287+
expect(sdkData?.packages[0].name).toBe('loader:@sentry/browser');
288+
delete global.SENTRY_SDK_SOURCE;
289+
});
290+
291+
it('uses SDK source from global for package name', () => {
292+
const spy = jest.spyOn(utils, 'getSDKSource').mockReturnValue('cdn');
293+
init({ dsn });
294+
295+
const sdkData = (getCurrentHub().getClient() as any).getOptions()._metadata.sdk;
296+
297+
expect(sdkData?.packages[0].name).toBe('cdn:@sentry/browser');
298+
expect(utils.getSDKSource).toBeCalledTimes(1);
299+
spy.mockRestore();
300+
});
301+
280302
it('should set SDK data when instantiating a client directly', () => {
281303
const options = getDefaultBrowserClientOptions({ dsn });
282304
const client = new BrowserClient(options);

0 commit comments

Comments
 (0)