Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyfills Bailout: Part 1 #2243

Merged
merged 3 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/browser/src/integrations/breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class Breadcrumbs implements Integration {
const filterUrl = new API(dsn).getStoreEndpoint();
// if Sentry key appears in URL, don't capture it as a request
// but rather as our own 'sentry' type breadcrumb
if (filterUrl && url.includes(filterUrl)) {
if (filterUrl && url.indexOf(filterUrl) !== -1) {
if (method === 'POST' && args[1] && args[1].body) {
addSentryBreadcrumb(args[1].body);
}
Expand Down Expand Up @@ -407,7 +407,7 @@ export class Breadcrumbs implements Integration {
const filterUrl = new API(dsn).getStoreEndpoint();
// if Sentry key appears in URL, don't capture it as a request
// but rather as our own 'sentry' type breadcrumb
if (isString(url) && (filterUrl && url.includes(filterUrl))) {
if (isString(url) && (filterUrl && url.indexOf(filterUrl) !== -1)) {
this.__sentry_own_request__ = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ export function prepareFramesForEvent(stack: TraceKitStackFrame[]): StackFrame[]
const lastFrameFunction = localStack[localStack.length - 1].func || '';

// If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
if (firstFrameFunction.includes('captureMessage') || firstFrameFunction.includes('captureException')) {
if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
localStack = localStack.slice(1);
}

// If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call)
if (lastFrameFunction.includes('sentryWrapped')) {
if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
localStack = localStack.slice(0, -1);
}

Expand Down
4 changes: 0 additions & 4 deletions packages/browser/src/tracekit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,10 +918,6 @@ TraceKit._computeStackTrace = (function _computeStackTraceWrapper() {
}

function popFrames(stacktrace: any, popSize: number): any {
if (Number.isNaN(popSize)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done on purpose. It's safe to remove.

return stacktrace;
}

try {
return {
...stacktrace,
Expand Down
39 changes: 0 additions & 39 deletions packages/browser/test/integration/polyfills/assign.js

This file was deleted.

23 changes: 0 additions & 23 deletions packages/browser/test/integration/polyfills/includes.js

This file was deleted.

14 changes: 0 additions & 14 deletions packages/browser/test/integration/polyfills/nan.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/browser/test/integration/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ function build() {
"polyfills/fetch.js",
"polyfills/raf.js",
"polyfills/events.js",
"polyfills/assign.js",
"polyfills/nan.js",
"polyfills/includes.js",
]);

writeFile(
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/dsn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,22 @@ export class Dsn implements DsnComponents {
/** Parses a string into this Dsn. */
private _fromString(str: string): void {
const match = DSN_REGEX.exec(str);

if (!match) {
throw new SentryError(ERROR_MESSAGE);
}

const [protocol, user, pass = '', host, port = '', lastPath] = match.slice(1);
let path = '';
let projectId = lastPath;

const split = projectId.split('/');
if (split.length > 1) {
path = split.slice(0, -1).join('/');
projectId = split.pop() as string;
}
Object.assign(this, { host, pass, path, projectId, port, protocol, user });

this._fromComponents({ host, pass, path, projectId, port, protocol: protocol as DsnProtocol, user });
}

/** Maps Dsn components into this instance. */
Expand All @@ -94,7 +97,7 @@ export class Dsn implements DsnComponents {
throw new SentryError(ERROR_MESSAGE);
}

if (this.port && Number.isNaN(parseInt(this.port, 10))) {
if (this.port && isNaN(parseInt(this.port, 10))) {
throw new SentryError(ERROR_MESSAGE);
}
}
Expand Down
3 changes: 0 additions & 3 deletions packages/hub/src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,6 @@ export class Scope implements ScopeInterface {
*/
public static clone(scope?: Scope): Scope {
const newScope = new Scope();
Object.assign(newScope, scope, {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no clue why we had it here if we manually assign all the properties below anyway.
Same goes for _scopeListeners, which is initialized in the constructor and we don't have to override it if we skip Object.assign.

_scopeListeners: [],
});
if (scope) {
newScope._breadcrumbs = [...scope._breadcrumbs];
newScope._tags = { ...scope._tags };
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function emitWrapper(origEmit: EventListener): (event: string, response: http.Se
const dsn = client.getDsn();

const isInterestingEvent = event === 'response' || event === 'error';
const isNotSentryRequest = dsn && this.__ravenBreadcrumbUrl && !this.__ravenBreadcrumbUrl.includes(dsn.host);
const isNotSentryRequest = dsn && this.__ravenBreadcrumbUrl && this.__ravenBreadcrumbUrl.indexOf(dsn.host) === -1;

if (isInterestingEvent && isNotSentryRequest && getCurrentHub().getIntegration(Http)) {
getCurrentHub().addBreadcrumb(
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function parseStack(stack: stacktrace.StackFrame[], options?: NodeOptions
// note that isNative appears to return true even for node core libraries
// see https://github.com/getsentry/raven-node/issues/176
parsedFrame.in_app =
!isInternal && parsedFrame.filename !== undefined && !parsedFrame.filename.includes('node_modules/');
!isInternal && parsedFrame.filename !== undefined && parsedFrame.filename.indexOf('node_modules/') === -1;

// Extract a module name based on the filename
if (parsedFrame.filename) {
Expand Down Expand Up @@ -271,7 +271,7 @@ export function prepareFramesForEvent(stack: StackFrame[]): StackFrame[] {
let localStack = stack;
const firstFrameFunction = localStack[0].function || '';

if (firstFrameFunction.includes('captureMessage') || firstFrameFunction.includes('captureException')) {
if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
localStack = localStack.slice(1);
}

Expand Down
3 changes: 2 additions & 1 deletion packages/utils/src/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ function normalizeValue<T>(value: T, key?: any): T | string {
return '[SyntheticEvent]';
}

if (Number.isNaN((value as unknown) as number)) {
// tslint:disable-next-line:no-tautology-expression
if (typeof value === 'number' && value !== value) {
return '[NaN]';
}

Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function isMatchingPattern(value: string, pattern: RegExp | string): bool
return (pattern as RegExp).test(value);
}
if (typeof pattern === 'string') {
return value.includes(pattern);
return value.indexOf(pattern) !== -1;
}
return false;
}