Skip to content

Commit

Permalink
fix: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasBa committed Jun 23, 2023
1 parent c7078fb commit 5c29fa2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
15 changes: 8 additions & 7 deletions packages/browser/src/profiling/hubextensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ import type { Transaction } from '@sentry/types';
import { logger, uuid4 } from '@sentry/utils';

import { WINDOW } from '../helpers';
import type {
JSSelfProfile,
JSSelfProfiler,
JSSelfProfilerConstructor,
} from './jsSelfProfiling';
import { addProfileToMap,isValidSampleRate } from './utils';
import type { JSSelfProfile, JSSelfProfiler, JSSelfProfilerConstructor } from './jsSelfProfiling';
import { addProfileToMap, isValidSampleRate } from './utils';

export const MAX_PROFILE_DURATION_MS = 30_000;
// Keep a flag value to avoid re-initializing the profiler constructor. If it fails
Expand Down Expand Up @@ -82,7 +78,12 @@ export function wrapTransactionWithProfiling(transaction: Transaction): Transact

// Prefer sampler to sample rate if both are provided.
if (typeof profilesSampler === 'function') {
profilesSampleRate = profilesSampler({ transactionContext: transaction.toContext() });
const transactionContext = transaction.toContext();
profilesSampleRate = profilesSampler({
parentSampled: transactionContext.parentSampled,
transactionContext: transactionContext,
...transaction.getDynamicSamplingContext(),
});
}

// Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The
Expand Down
12 changes: 5 additions & 7 deletions packages/browser/src/profiling/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class BrowserProfilingIntegration implements Integration {

client.on('beforeEnvelope', (envelope): void => {
// if not profiles are in queue, there is nothing to add to the envelope.
if (!PROFILE_MAP.size) {
if (!PROFILE_MAP['size']) {
return;
}

Expand All @@ -51,14 +51,12 @@ export class BrowserProfilingIntegration implements Integration {
const profilesToAddToEnvelope: Profile[] = [];

for (const profiledTransaction of profiledTransactionEvents) {
const profile_id =
profiledTransaction &&
profiledTransaction.contexts &&
profiledTransaction.contexts['profile'] &&
profiledTransaction.contexts['profile']['profile_id'] as string
const context = profiledTransaction && profiledTransaction.contexts;
const profile_id = context && context['profile'] && (context['profile']['profile_id'] as string);

if (!profile_id) {
__DEBUG_BUILD__ && logger.log('[Profiling] cannot find profile for a transaction without a profile context');
__DEBUG_BUILD__ &&
logger.log('[Profiling] cannot find profile for a transaction without a profile context');
continue;
}

Expand Down
1 change: 0 additions & 1 deletion packages/browser/src/profiling/jsSelfProfiling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ declare global {
Profiler: typeof JSSelfProfilerConstructor | undefined;
}
}

2 changes: 1 addition & 1 deletion packages/browser/src/profiling/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ function isValidProfile(profile: JSSelfProfile): profile is JSSelfProfile & { pr
}

if (!profile.frames.length) {
if(__DEBUG_BUILD__) {
if (__DEBUG_BUILD__) {
logger.log('[Profiling] Discarding profile because it contains no frames');
}
return false;
Expand Down

0 comments on commit 5c29fa2

Please sign in to comment.