8000 fix: Tests + Lint · phthhieu/sentry-javascript@0f642a0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f642a0

Browse files
committed
fix: Tests + Lint
1 parent 658a397 commit 0f642a0

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

packages/browser/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { API, BaseClient, DSN, SentryError } from '@sentry/core';
1+
import { API, BaseClient, SentryError } from '@sentry/core';
22
import { DSNLike } from '@sentry/types';
33
import { getGlobalObject } from '@sentry/utils/misc';
44
import { BrowserBackend, BrowserOptions } from './backend';

packages/core/src/api.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const SENTRY_API_VERSION = '7';
77
/** Helper class to provide urls to different Sentry endpoints. */
88
export class API {
99
/** The internally used DSN object. */
10-
private dsnObject: DSN;
10+
private readonly dsnObject: DSN;
1111
/** Create a new instance of API */
1212
public constructor(public dsn: DSNLike) {
1313
this.dsnObject = new DSN(dsn);
@@ -23,6 +23,7 @@ export class API {
2323
return `${this.getBaseUrl()}${this.getStoreEndpointPath()}`;
2424
}
2525

26+
/** Returns the store endpoint with auth added in url encoded. */
2627
public getStoreEndpointWithUrlEncodedAuth(): string {
2728
const dsn = this.dsnObject;
2829
const auth = {
@@ -62,23 +63,26 @@ export class API {
6263
}
6364

6465
/** Returns the url to the report dialog endpoint. */
65-
public getReportDialogEndpoint(dialogOptions: { [key: string]: any } = {}): string {
66+
public getReportDialogEndpoint(
67+
dialogOptions: {
68+
[key: string]: any;
69+
user?: { name?: string; email?: string };
70+
} = {},
71+
): string {
6672
const dsn = this.dsnObject;
6773
const endpoint = `${this.getBaseUrl()}${dsn.path ? `/${dsn.path}` : ''}/api/embed/error-page/`;
6874

6975
const encodedOptions = [];
7076
for (const key in dialogOptions) {
7177
if (key === 'user') {
72-
const user = dialogOptions.user;
73-
if (!user) {
78+
if (!dialogOptions.user) {
7479
continue;
7580
}
76-
77-
if (user.name) {
78-
encodedOptions.push(`name=${encodeURIComponent(user.name)}`);
81+
if (dialogOptions.user.name) {
82+
encodedOptions.push(`name=${encodeURIComponent(dialogOptions.user.name)}`);
7983
}
80-
if (user.email) {
81-
encodedOptions.push(`email=${encodeURIComponent(user.email)}`);
84+
if (dialogOptions.user.email) {
85+
encodedOptions.push(`email=${encodeURIComponent(dialogOptions.user.email)}`);
8286
}
8387
} else {
8488
encodedOptions.push(`${encodeURIComponent(key)}=${encodeURIComponent(dialogOptions[key] as string)}`);

packages/core/test/lib/api.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('API', () => {
4343
expect(
4444
new API(dsnPublic).getReportDialogEndpoint({
4545
eventId: 'abc',
46-
user: false,
46+
user: undefined,
4747
}),
4848
).toEqual('https://sentry.io:1234/subpath/api/embed/error-page/?eventId=abc');
4949
});

0 commit comments

Comments
 (0)
0