Skip to content

Commit 27eb1c8

Browse files
authored
Clean up code in Crashtracker class (#5917)
Use private members and predefined private fields instead of prefixing with an underscore.
1 parent a408cd7 commit 27eb1c8

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

packages/dd-trace/src/crashtracking/crashtracker.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,29 @@ const { URL } = require('url')
99
const pkg = require('../../../../package.json')
1010

1111
class Crashtracker {
12-
constructor () {
13-
this._started = false
14-
}
12+
#started = false
1513

1614
configure (config) {
17-
if (!this._started) return
15+
if (!this.#started) return
1816

1917
try {
20-
binding.updateConfig(this._getConfig(config))
21-
binding.updateMetadata(this._getMetadata(config))
18+
binding.updateConfig(this.#getConfig(config))
19+
binding.updateMetadata(this.#getMetadata(config))
2220
} catch (e) {
2321
log.error('Error configuring crashtracker', e)
2422
}
2523
}
2624

2725
start (config) {
28-
if (this._started) return this.configure(config)
26+
if (this.#started) return this.configure(config)
2927

30-
this._started = true
28+
this.#started = true
3129

3230
try {
3331
binding.init(
34-
this._getConfig(config),
35-
this._getReceiverConfig(config),
36-
this._getMetadata(config)
32+
this.#getConfig(config),
33+
this.#getReceiverConfig(),
34+
this.#getMetadata(config)
3735
)
3836
} catch (e) {
3937
log.error('Error initialising crashtracker', e)
@@ -50,7 +48,7 @@ class Crashtracker {
5048
}
5149

5250
// TODO: Send only configured values when defaults are fixed.
53-
_getConfig (config) {
51+
#getConfig (config) {
5452
const { hostname = '127.0.0.1', port = 8126 } = config
5553
const url = config.url || new URL(`http://${hostname}:${port}`)
5654

@@ -75,7 +73,7 @@ class Crashtracker {
7573
}
7674
}
7775

78-
_getMetadata (config) {
76+
#getMetadata (config) {
7977
const tags = Object.keys(config.tags).map(key => `${key}:${config.tags[key]}`)
8078

8179
return {
@@ -94,7 +92,7 @@ class Crashtracker {
9492
}
9593
}
9694

97-
_getReceiverConfig () {
95+
#getReceiverConfig () {
9896
return {
9997
args: [],
10098
env: [],

0 commit comments

Comments
 (0)