Skip to content

Commit 60b6e75

Browse files
committed
ref: Remove assign util in favor of Object.assign
1 parent 8578d50 commit 60b6e75

File tree

4 files changed

+8
-38
lines changed

4 files changed

+8
-38
lines changed

packages/core/src/dsn.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { DsnComponents, DsnLike, DsnProtocol } from '@sentry/types';
22
import { SentryError } from '@sentry/utils/error';
33
import { isNaN } from '@sentry/utils/is';
4-
import { assign } from '@sentry/utils/object';
54

65
/** Regular expression used to parse a Dsn. */
76
const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w\.-]+)(?::(\d+))?\/(.+)/;
@@ -67,7 +66,7 @@ export class Dsn implements DsnComponents {
6766
path = split.slice(0, -1).join('/');
6867
projectId = split.pop() as string;
6968
}
70-
assign(this, { host, pass, path, projectId, port, protocol, user });
69+
Object.assign(this, { host, pass, path, projectId, port, protocol, user });
7170
}
7271

7372
/** Maps Dsn components into this instance. */

packages/core/src/integrations/extraerrordata.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { isError, isPlainObject } from '@sentry/utils/is';
44
import { logger } from '@sentry/utils/logger';
55
import { safeNormalize } from '@sentry/utils/object';
66

7-
87
/** Patch toString calls to return proper name for wrapped functions */
98
export class ExtraErrorData implements Integration {
109
/**
@@ -44,13 +43,15 @@ export class ExtraErrorData implements Integration {
4443
let extra = {
4544
...event.extra,
4645
};
46+
4747
const normalizedErrorData = safeNormalize(errorData);
48-
if (!isString(normalizedErrorData)) {
48+
if (isPlainObject(normalizedErrorData)) {
4949
extra = {
5050
...event.extra,
5151
...normalizedErrorData,
5252
};
5353
}
54+
5455
return {
5556
...event,
5657
extra,

packages/hub/src/scope.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Breadcrumb, Event, EventHint, EventProcessor, Scope as ScopeInterface, Severity, User } from '@sentry/types';
22
import { isFunction, isThenable } from '@sentry/utils/is';
33
import { getGlobalObject } from '@sentry/utils/misc';
4-
import { assign, safeNormalize } from '@sentry/utils/object';
4+
import { safesafeNormalize } from '@sentry/utils/object';
55
import { SyncPromise } from '@sentry/utils/syncpromise';
66

77
/**
@@ -123,12 +123,12 @@ export class Scope implements ScopeInterface {
123123
*/
124124
public static clone(scope?: Scope): Scope {
125125
const newScope = new Scope();
126-
assign(newScope, scope, {
126+
Object.assign(newScope, scope, {
127127
scopeListeners: [],
128128
});
129129
if (scope) {
130-
newScope.extra = assign(scope.extra);
131-
newScope.tags = assign(scope.tags) as any;
130+
newScope.extra = { ...scope.extra };
131+
newScope.tags = { ...scope.tags };
132132
newScope.breadcrumbs = [...scope.breadcrumbs];
133133
newScope.eventProcessors = [...scope.eventProcessors];
134134
}

packages/utils/src/object.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -193,36 +193,6 @@ export function serializeKeysToEventMessage(keys: string[], maxLength: number =
193193
return '';
194194
}
195195

196-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill
197-
/** JSDoc */
198-
export function assign(target: any, ...args: any[]): object {
199-
if (target === null || target === undefined) {
200-
throw new TypeError('Cannot convert undefined or null to object');
201-
}
202-
203-
const to = Object(target) as {
204-
[key: string]: any;
205-
};
206-
207-
// tslint:disable-next-line:prefer-for-of
208-
for (let i = 0; i < args.length; i++) {
209-
const source = args[i];
210-
if (source !== null) {
211-
for (const nextKey in source as {
212-
[key: string]: any;
213-
}) {
214-
if (Object.prototype.hasOwnProperty.call(source, nextKey)) {
215-
to[nextKey] = (source as {
216-
[key: string]: any;
217-
})[nextKey];
218-
}
219-
}
220-
}
221-
}
222-
223-
return to;
224-
}
225-
226196
/**
227197
* Transforms Error object into an object literal with all it's attributes
228198
* attached to it.

0 commit comments

Comments
 (0)