Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0c75dce

Browse files
refactor: Revert top-level metadata feature
Revert "refactor(types): Allow null section in event metadata" This reverts commit 23e3a02. Revert "refactor(types): Allow null metadata in types too" This reverts commit 1e2d8d2. Revert "docs: Update upgrading guide with top-level metadata" This reverts commit d0f3bb8. Revert "feat(core): Support adding top-level metadata" This reverts commit 526c897.
1 parent 0129864 commit 0c75dce

File tree

5 files changed

+10
-34
lines changed

5 files changed

+10
-34
lines changed

‎UPGRADING.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,6 @@ It remains possible to supply initial metadata in configuration:
237237
})
238238
```
239239

240-
All metadata is now required to have a section. If you were previously supplying metadata without a section name (this would display on your dashboard under the "Custom" tab), we have enabled passing `null` as the section name for continuity:
241-
242-
```js
243-
- bugsnagClient.metaData.assetUrl = config.assetUrl
244-
+ Bugsnag.addMetadata(null, 'assetUrl', config.assetUrl)
245-
```
246-
247-
You should only use this method if you have a custom filter based on some top-level metadata, otherwise you should supply a section name for your metadata.
248-
249240
#### Context
250241

251242
On the client, context is now managed via `get/setContext()`:

‎packages/core/lib/metadata-delegate.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const assign = require('./es-utils/assign')
22

33
const add = (state, section, keyOrObj, maybeVal) => {
4-
if (!section&&section!==null) return
4+
if (!section) return
55
let updates
66

77
// addMetadata("section", null) -> clears section
@@ -14,14 +14,11 @@ const add = (state, section, keyOrObj, maybeVal) => {
1414
// exit if we don't have an updates object at this point
1515
if (!updates) return
1616

17-
if (section !== null) {
18-
// ensure a section with this name exists
19-
if (!state[section] || typeof state[section] !== 'object') state[section] = {}
20-
// merge the updates with the existing section
21-
state[section] = assign({}, state[section], updates)
22-
} else {
23-
assign(state, updates)
24-
}
17+
// ensure a section with this name exists
18+
if (!state[section]) state[section] = {}
19+
20+
// merge the updates with the existing section
21+
state[section] = assign({}, state[section], updates)
2522
}
2623

2724
const get = (state, section, key) => {

‎packages/core/test/client.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -654,18 +654,6 @@ describe('@bugsnag/core/client', () => {
654654
expect(client.getMetadata('a', 'b')).toBe(undefined)
655655
client.clearMetadata('a')
656656
expect(client.getMetadata('a')).toBe(undefined)
657-
658-
// check that top-level metadata can be added with section=null
659-
client.addMetadata(null, 'top', 'val')
660-
expect(client._metadata).toEqual({ top: 'val' })
661-
client.addMetadata('top', 'key', 'val')
662-
expect(client._metadata).toEqual({ top: { key: 'val' } })
663-
664-
client._metadata = {}
665-
666-
client.addMetadata('replace', 'key', 'origval')
667-
client.addMetadata(null, 'replace', { diffkey: 'replaceval' })
668-
expect(client._metadata).toEqual({ replace: { diffkey: 'replaceval' } })
669657
})
670658

671659
it('can be set in config', () => {

‎packages/core/types/client.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ declare class Client {
3434
): void;
3535

3636
// metadata
37-
public addMetadata(section: string|null, values: { [key: string]: any }): void;
38-
public addMetadata(section: string|null, key: string, value: any): void;
37+
public addMetadata(section: string, values: { [key: string]: any }): void;
38+
public addMetadata(section: string, key: string, value: any): void;
3939
public getMetadata(section: string, key?: string): any;
4040
public clearMetadata(section: string, key?: string): void;
4141

‎packages/core/types/event.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ declare class Event {
3838
public setUser(id?: string, email?: string, name?: string): void;
3939

4040
// metadata
41-
public addMetadata(section: string|null, values: { [key: string]: any }): void;
42-
public addMetadata(section: string|null, key: string, value: any): void;
41+
public addMetadata(section: string, values: { [key: string]: any }): void;
42+
public addMetadata(section: string, key: string, value: any): void;
4343
public getMetadata(section: string, key?: string): any;
4444
public clearMetadata(section: string, key?: string): void;
4545
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /