From b76b55072fc8620fe9946789286a3c2e1eb1cdb6 Mon Sep 17 00:00:00 2001 From: Ben Gourley Date: Tue, 17 Dec 2019 15:23:39 +0000 Subject: [PATCH] refactor(session): Rename trackError -> _track and remove from public types --- packages/core/client.js | 2 +- packages/core/session.js | 2 +- packages/core/test/session.test.js | 12 ++++++------ packages/core/types/session.d.ts | 1 - 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/core/client.js b/packages/core/client.js index 67d6806e65..dc1bc0be8f 100644 --- a/packages/core/client.js +++ b/packages/core/client.js @@ -229,7 +229,7 @@ class BugsnagClient { event.breadcrumbs = this.breadcrumbs.slice(0) if (this._session) { - this._session.trackError(event) + this._session._track(event) event.session = this._session } diff --git a/packages/core/session.js b/packages/core/session.js index 909ffad994..f02eb1f5be 100644 --- a/packages/core/session.js +++ b/packages/core/session.js @@ -17,7 +17,7 @@ class Session { } } - trackError (event) { + _track (event) { this[event._handledState.unhandled ? '_unhandled' : '_handled'] += 1 } } diff --git a/packages/core/test/session.test.js b/packages/core/test/session.test.js index 4a567e204a..6c6989173a 100644 --- a/packages/core/test/session.test.js +++ b/packages/core/test/session.test.js @@ -11,14 +11,14 @@ describe('@bugsnag/core/session', () => { expect(s.events).toEqual({ handled: 0, unhandled: 0 }) }) }) - describe('trackError()', () => { + describe('track()', () => { it('returns the correct data structure', () => { const s = new Session() - s.trackError({ _handledState: { unhandled: true } }) - s.trackError({ _handledState: { unhandled: false } }) - s.trackError({ _handledState: { unhandled: true } }) - s.trackError({ _handledState: { unhandled: true } }) - s.trackError({ _handledState: { unhandled: false } }) + s._track({ _handledState: { unhandled: true } }) + s._track({ _handledState: { unhandled: false } }) + s._track({ _handledState: { unhandled: true } }) + s._track({ _handledState: { unhandled: true } }) + s._track({ _handledState: { unhandled: false } }) expect(s.toJSON().events).toEqual({ handled: 2, unhandled: 3 }) }) }) diff --git a/packages/core/types/session.d.ts b/packages/core/types/session.d.ts index 031a48f414..bdac18fab3 100644 --- a/packages/core/types/session.d.ts +++ b/packages/core/types/session.d.ts @@ -7,7 +7,6 @@ declare class Session { _handled: number; _unhandled: number; }; - public trackError: (event: Event) => void; } export default Session;