Skip to content

Commit 443fb02

Browse files
authored
fix: add platform to chunk envelope item headers (#5041)
1 parent 06bc323 commit 443fb02

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

Sources/Sentry/Profiling/SentryProfilerSerialization.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@
342342
const auto header =
343343
[[SentryEnvelopeItemHeader alloc] initWithType:SentryEnvelopeItemTypeProfileChunk
344344
length:JSONData.length];
345+
header.platform = @"cocoa";
345346
const auto envelopeItem = [[SentryEnvelopeItem alloc] initWithHeader:header data:JSONData];
346347

347348
return [[SentryEnvelope alloc] initWithId:chunkID singleItem:envelopeItem];

Sources/Sentry/Public/SentryEnvelopeItemHeader.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ SENTRY_NO_INIT
2828
@property (nonatomic, readonly, copy, nullable) NSString *filename;
2929
@property (nonatomic, readonly, copy, nullable) NSString *contentType;
3030

31+
/**
32+
* Some envelopes need to report the platform name for enhanced rate limiting functionality in
33+
* relay.
34+
*/
35+
@property (nonatomic, copy, nullable) NSString *platform;
36+
3137
@end
3238

3339
NS_ASSUME_NONNULL_END

Sources/Sentry/SentryEnvelopeItemHeader.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ - (NSDictionary *)serialize
4848
[target setValue:self.contentType forKey:@"content_type"];
4949
}
5050

51+
if (self.platform) {
52+
[target setValue:self.contentType forKey:@"platform"];
53+
}
54+
5155
[target setValue:[NSNumber numberWithUnsignedInteger:self.length] forKey:@"length"];
5256

5357
return target;

Tests/SentryProfilerTests/SentryContinuousProfilerTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ private extension SentryContinuousProfilerTests {
242242
XCTAssertEqual(1, envelope.items.count)
243243
let profileItem = try XCTUnwrap(envelope.items.first)
244244
XCTAssertEqual("profile_chunk", profileItem.header.type)
245+
XCTAssertEqual("cocoa", profileItem.header.platform)
245246
let data = profileItem.data
246247
let profile = try XCTUnwrap(try JSONSerialization.jsonObject(with: data) as? [String: Any])
247248

0 commit comments

Comments
 (0)