Skip to content
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first.
<!-- prettier-ignore-end -->

## Unreleased

### Fixes

- Populate the Hermes runtime version on JS profiles instead of sending an empty value ([#6817](https://github.com/getsentry/sentry-react-native/pull/6817))

## 8.29.0

### Features
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/js/profiling/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
RawThreadCpuProfile,
} from './types';

import { getDefaultEnvironment } from '../utils/environment';
import { getDefaultEnvironment, getHermesVersion } from '../utils/environment';
import { getDebugMetadata } from './debugid';

/**
Expand Down Expand Up @@ -95,7 +95,7 @@ export function enrichCombinedProfileWithEventContext(
event_id: profile_id,
runtime: {
name: 'hermes',
version: '', // TODO: get hermes version
version: getHermesVersion() ?? '',
},
timestamp: profilingStartTimestampNs
? new Date(profilingStartTimestampNs / 1e6).toISOString()
Expand Down
25 changes: 24 additions & 1 deletion packages/core/test/profiling/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
enrichAndroidProfileWithEventContext,
enrichCombinedProfileWithEventContext,
} from '../../src/js/profiling/utils';
import { getDefaultEnvironment } from '../../src/js/utils/environment';
import { getDefaultEnvironment, getHermesVersion } from '../../src/js/utils/environment';
import { createMockMinimalValidAndroidProfile, createMockMinimalValidHermesProfileEvent } from './fixtures';

describe('enrichCombinedProfileWithEventContext', () => {
Expand All @@ -19,6 +19,29 @@ describe('enrichCombinedProfileWithEventContext', () => {
(getDebugMetadata as jest.Mock).mockReturnValue([]);
});

test('should set the hermes runtime version from getHermesVersion', () => {
// OSS Hermes reports the version it was built against, e.g. `for RN 0.76.0`, not a semver.
(getHermesVersion as jest.Mock).mockReturnValue('for RN 0.76.0');
const profile: CombinedProfileEvent = createMockMinimalValidHermesProfileEvent();
const event = createMockEvent();

const result = enrichCombinedProfileWithEventContext('profile-id', profile, event);

expect(result).not.toBeNull();
expect(result!.runtime).toEqual({ name: 'hermes', version: 'for RN 0.76.0' });
});

test('should fall back to an empty runtime version when the hermes version is unavailable', () => {
(getHermesVersion as jest.Mock).mockReturnValue(undefined);
const profile: CombinedProfileEvent = createMockMinimalValidHermesProfileEvent();
const event = createMockEvent();

const result = enrichCombinedProfileWithEventContext('profile-id', profile, event);

expect(result).not.toBeNull();
expect(result!.runtime).toEqual({ name: 'hermes', version: '' });
});

function createMockEvent(overrides?: Partial<Event>): Event {
return {
event_id: 'test-event-id',
Expand Down
Loading