Skip to content

Commit 6432b00

Browse files
authored
fix(profiling): Add platform to envelope item header (#18954)
Adds the missing `platform` in the envelope item header. Related: getsentry/sentry-docs#16135 Closes https://linear.app/getsentry/issue/JS-1540/ui-profiling-add-platform-to-profile-chunk-item-header (internal Linear)
1 parent a2f7fad commit 6432b00

5 files changed

Lines changed: 9 additions & 6 deletions

File tree

dev-packages/browser-integration-tests/suites/profiling/manualMode/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ sentryTest('sends profile_chunk envelopes in manual mode', async ({ page, getLoc
4848
const envelopeItemHeader = profileChunkEnvelopeItem[0];
4949
const envelopeItemPayload1 = profileChunkEnvelopeItem[1];
5050

51-
expect(envelopeItemHeader).toHaveProperty('type', 'profile_chunk');
51+
expect(envelopeItemHeader).toEqual({ type: 'profile_chunk', platform: 'javascript' });
5252
expect(envelopeItemPayload1.profile).toBeDefined();
5353

5454
const profilerId1 = envelopeItemPayload1.profiler_id;
@@ -71,7 +71,7 @@ sentryTest('sends profile_chunk envelopes in manual mode', async ({ page, getLoc
7171
const envelopeItemHeader2 = profileChunkEnvelopeItem2[0];
7272
const envelopeItemPayload2 = profileChunkEnvelopeItem2[1];
7373

74-
expect(envelopeItemHeader2).toHaveProperty('type', 'profile_chunk');
74+
expect(envelopeItemHeader2).toEqual({ type: 'profile_chunk', platform: 'javascript' });
7575
expect(envelopeItemPayload2.profile).toBeDefined();
7676

7777
expect(envelopeItemPayload2.profiler_id).toBe(profilerId1); // same profiler id for the whole session

dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_multiple-chunks/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ sentryTest(
5151
const envelopeItemHeader = profileChunkEnvelopeItem[0];
5252
const envelopeItemPayload1 = profileChunkEnvelopeItem[1];
5353

54-
expect(envelopeItemHeader).toHaveProperty('type', 'profile_chunk');
54+
expect(envelopeItemHeader).toEqual({ type: 'profile_chunk', platform: 'javascript' });
5555
expect(envelopeItemPayload1.profile).toBeDefined();
5656

5757
validateProfilePayloadMetadata(envelopeItemPayload1);
@@ -77,7 +77,7 @@ sentryTest(
7777
const envelopeItemHeader2 = profileChunkEnvelopeItem2[0];
7878
const envelopeItemPayload2 = profileChunkEnvelopeItem2[1];
7979

80-
expect(envelopeItemHeader2).toHaveProperty('type', 'profile_chunk');
80+
expect(envelopeItemHeader2).toEqual({ type: 'profile_chunk', platform: 'javascript' });
8181
expect(envelopeItemPayload2.profile).toBeDefined();
8282

8383
validateProfilePayloadMetadata(envelopeItemPayload2);

dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_overlapping-spans/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ sentryTest(
5252
const envelopeItemHeader = profileChunkEnvelopeItem[0];
5353
const envelopeItemPayload = profileChunkEnvelopeItem[1];
5454

55-
expect(envelopeItemHeader).toHaveProperty('type', 'profile_chunk');
55+
expect(envelopeItemHeader).toEqual({ type: 'profile_chunk', platform: 'javascript' });
5656
expect(envelopeItemPayload.profile).toBeDefined();
5757

5858
validateProfilePayloadMetadata(envelopeItemPayload);

packages/browser/src/profiling/UIProfiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ export class UIProfiler implements ContinuousProfiler<Client> {
401401
...(sdkInfo && { sdk: sdkInfo }),
402402
...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),
403403
},
404-
[[{ type: 'profile_chunk' }, chunk]],
404+
[[{ type: 'profile_chunk', platform: 'javascript' }, chunk]],
405405
);
406406

407407
client.sendEnvelope(envelope).then(null, reason => {

packages/browser/test/profiling/UIProfiler.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ describe('Browser Profiling v2 trace lifecycle', () => {
106106
const transactionEnvelopeHeader = send.mock.calls?.[0]?.[0]?.[1]?.[0]?.[0];
107107
const profileChunkEnvelopeHeader = send.mock.calls?.[1]?.[0]?.[1]?.[0]?.[0];
108108
expect(profileChunkEnvelopeHeader?.type).toBe('profile_chunk');
109+
expect(profileChunkEnvelopeHeader?.platform).toBe('javascript');
109110
expect(transactionEnvelopeHeader?.type).toBe('transaction');
110111
});
111112

@@ -207,6 +208,7 @@ describe('Browser Profiling v2 trace lifecycle', () => {
207208
expect(mockConstructor.mock.calls.length).toBe(2);
208209
const firstChunkHeader = send.mock.calls?.[0]?.[0]?.[1]?.[0]?.[0];
209210
expect(firstChunkHeader?.type).toBe('profile_chunk');
211+
expect(firstChunkHeader?.platform).toBe('javascript');
210212

211213
// Second chunk after another 60s
212214
vi.advanceTimersByTime(60_000);
@@ -679,6 +681,7 @@ describe('Browser Profiling v2 manual lifecycle', () => {
679681
expect(send).toHaveBeenCalledTimes(1);
680682
const envelopeHeader = send.mock.calls?.[0]?.[0]?.[1]?.[0]?.[0];
681683
expect(envelopeHeader?.type).toBe('profile_chunk');
684+
expect(envelopeHeader?.platform).toBe('javascript');
682685
});
683686

684687
it('calling start and stop while profile session is running prints warnings', async () => {

0 commit comments

Comments
 (0)