Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

## Unreleased

### Fixes

- Fix app start transaction profile offset by using the actual profiling start timestamp instead of the adjusted app start time ([#4511](https://github.com/getsentry/sentry-react-native/issues/4511))

### Features

- Enable "Open Sentry" button in Playground for Expo apps ([#5947](https://github.com/getsentry/sentry-react-native/pull/5947))
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/js/profiling/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,13 @@ export function stopProfiling(
return null;
}

hermesProfileEvent.profilingStartTimestampNs = profileStartTimestampNs;

if (collectedProfiles.androidProfile) {
const durationNs = profileEndTimestampNs - profileStartTimestampNs;
return createAndroidWithHermesProfile(hermesProfileEvent, collectedProfiles.androidProfile, durationNs);
const androidProfile = createAndroidWithHermesProfile(hermesProfileEvent, collectedProfiles.androidProfile, durationNs);
androidProfile.profilingStartTimestampNs = profileStartTimestampNs;
return androidProfile;
} else if (collectedProfiles.nativeProfile) {
return addNativeProfileToHermesProfile(hermesProfileEvent, collectedProfiles.nativeProfile);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/js/profiling/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type HermesProfileEvent = {
transaction: {
active_thread_id: string;
};
profilingStartTimestampNs?: number;
};

/*
Expand All @@ -31,6 +32,7 @@ export type AndroidCombinedProfileEvent = {
android_api_level: number;
duration_ns: string;
active_thread_id: string;
profilingStartTimestampNs?: number;
};

/*
Expand Down
20 changes: 16 additions & 4 deletions packages/core/src/js/profiling/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,20 @@ export function enrichCombinedProfileWithEventContext(
}
}

const { profilingStartTimestampNs, ...profileWithoutInternalFields } = profile;

return {
...profile,
...profileWithoutInternalFields,
event_id: profile_id,
runtime: {
name: 'hermes',
version: '', // TODO: get hermes version
},
timestamp: event.start_timestamp ? new Date(event.start_timestamp * 1000).toISOString() : new Date().toISOString(),
timestamp: profilingStartTimestampNs
? new Date(profilingStartTimestampNs / 1e6).toISOString()
: event.start_timestamp
? new Date(event.start_timestamp * 1000).toISOString()
: new Date().toISOString(),
release: event.release || '',
environment: event.environment || getDefaultEnvironment(),
os: {
Expand Down Expand Up @@ -130,8 +136,10 @@ export function enrichAndroidProfileWithEventContext(
profile: AndroidCombinedProfileEvent,
event: Event,
): AndroidProfileEvent | null {
const { profilingStartTimestampNs, ...profileWithoutInternalFields } = profile;

return {
...profile,
...profileWithoutInternalFields,
debug_meta: {
images: getDebugMetadata(),
},
Expand All @@ -152,7 +160,11 @@ export function enrichAndroidProfileWithEventContext(

profile_id,

timestamp: event.start_timestamp ? new Date(event.start_timestamp * 1000).toISOString() : new Date().toISOString(),
timestamp: profilingStartTimestampNs
? new Date(profilingStartTimestampNs / 1e6).toISOString()
: event.start_timestamp
? new Date(event.start_timestamp * 1000).toISOString()
: new Date().toISOString(),

release: event.release || '',
dist: event.dist || '',
Expand Down
Loading