Skip to content

Commit ea9b9d3

Browse files
committed
Rename matchBacktracePaths option
Rename the `matchPath` config option to a more explicit `matchBacktracePaths`.
1 parent d527ce3 commit ea9b9d3

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

packages/javascript/.changesets/custom-backtrace-sanitization.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ type: add
55

66
Allow custom backtrace sanitization.
77

8-
> **Warning:** This is an advanced feature meant for specific use cases. For most use cases, you should not need this functionality. If in doubt, leave `matchPath` unset.
8+
> **Warning:** This is an advanced feature meant for specific use cases. For most use cases, you should not need this functionality. If in doubt, leave `matchBacktracePaths` unset.
99
>
10-
> **Using `matchPath` will cause public sourcemap detection to fail.** If using `matchPath`, use our private sourcemap API to upload sourcemaps to AppSignal.
10+
> **Using `matchBacktracePaths` will cause public sourcemap detection to fail.** If using `matchBacktracePaths`, use our private sourcemap API to upload sourcemaps to AppSignal.
1111
1212
Some applications, such as those running on Electron or React Native environments, emit backtrace lines containing paths relative to the device in which the application is running.
1313

1414
The unpredictability of these backtrace line paths interferes with the correct functioning of backtrace error grouping, and makes it impossible to upload sourcemaps for these files using our private sourcemap API, as it is not possible to know the expected path beforehand.
1515

16-
You can set the `matchPath` configuration to a list of one or more regexes, which will be used to attempt to match the relevant section of the backtrace line path.
16+
You can set the `matchBacktracePaths` configuration to a list of one or more regexes, which will be used to attempt to match the relevant section of the backtrace line path.
1717

1818
For example, suppose you have an Electron application, which your users install at unpredictable locations. Your backtrace line paths may look something like this, with the username changing for each installation:
1919

@@ -25,13 +25,13 @@ To ignore these parts of the path that are not predictable, you can configure Ap
2525

2626
```js
2727
const appsignal = new AppSignal({
28-
matchPath: [
28+
matchBacktracePaths: [
2929
new RegExp("CoolBeans\\.app/Contents/Resources/(.*)$")
3030
]
3131
})
3232
```
3333

34-
If set, the `matchPath` configuration option must contain a regular expression, or an array of one or more regular expressions, which attempt to match the whole backtrace line path. These regular expressions must have one or more match groups, such as `(.*)` in the example above, which attempt to match against the relevant segments of the backtrace line path.
34+
If set, the `matchBacktracePaths` configuration option must contain a regular expression, or an array of one or more regular expressions, which attempt to match the whole backtrace line path. These regular expressions must have one or more match groups, such as `(.*)` in the example above, which attempt to match against the relevant segments of the backtrace line path.
3535

3636
AppSignal will attempt to match the whole backtrace line path against these regular expressions in order. If any of the regular expression matches and produces a match group, AppSignal will replace the path in the backtrace line with the matched segment.
3737

packages/javascript/src/__tests__/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ describe("Appsignal", () => {
7979
console.warn = original
8080
})
8181

82-
it("cleans the backtrace path if `matchPath` is set", () => {
82+
it("cleans the backtrace path if `matchBacktracePaths` is set", () => {
8383
appsignal = new Appsignal({
8484
key: "TESTKEY",
8585
namespace: "test",
86-
matchPath: [/here(.*)/]
86+
matchBacktracePaths: [/here(.*)/]
8787
})
8888

8989
const error = new Error("test error")

packages/javascript/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ export default class Appsignal implements JSClient {
207207
compose(...this._hooks.overrides)(span)
208208
}
209209

210-
if (this._options.matchPath) {
211-
span.cleanBacktracePath(this._options.matchPath)
210+
if (this._options.matchBacktracePaths) {
211+
span.cleanBacktracePath(this._options.matchBacktracePaths)
212212
}
213213

214214
if (Environment.supportsPromises()) {

packages/javascript/src/interfaces/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface AppsignalOptions extends BaseOptions {
77
namespace?: string
88
revision?: string
99
ignoreErrors?: RegExp[]
10-
matchPath?: RegExp | RegExp[]
10+
matchBacktracePaths?: RegExp | RegExp[]
1111
}
1212

1313
export interface PushApiOptions extends BaseOptions {

packages/javascript/src/span.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ export class Span extends Serializable<JSSpanData> {
7171
}
7272

7373
// @private
74-
// Do not use this function directly. Instead, set the `matchPath`
74+
// Do not use this function directly. Instead, set the `matchBacktracePaths`
7575
// configuration option when initializing AppSignal.
76-
public cleanBacktracePath(matchPath: RegExp | RegExp[]): this {
77-
if (matchPath instanceof RegExp) {
78-
matchPath = [matchPath]
76+
public cleanBacktracePath(matchBacktracePaths: RegExp | RegExp[]): this {
77+
if (matchBacktracePaths instanceof RegExp) {
78+
matchBacktracePaths = [matchBacktracePaths]
7979
}
8080

81-
if (!Array.isArray(matchPath)) {
81+
if (!Array.isArray(matchBacktracePaths)) {
8282
return this
8383
}
8484

@@ -92,7 +92,7 @@ export class Span extends Serializable<JSSpanData> {
9292
return line
9393
}
9494

95-
for (const matcher of matchPath as RegExp[]) {
95+
for (const matcher of matchBacktracePaths as RegExp[]) {
9696
if (!(matcher instanceof RegExp)) {
9797
continue
9898
}

0 commit comments

Comments
 (0)