From ba5edea43049ec703bf68482157dc6c00a86a923 Mon Sep 17 00:00:00 2001 From: Andrew McKnight Date: Mon, 31 Mar 2025 11:50:47 -0800 Subject: [PATCH 1/2] update clang-format --- scripts/.clang-format-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/.clang-format-version b/scripts/.clang-format-version index e43bba47d76..2a0e5e0a153 100644 --- a/scripts/.clang-format-version +++ b/scripts/.clang-format-version @@ -1 +1 @@ -20.1.0 +20.1.1 From 9b532a1d339c8a56ea659ee9df31d536271cdc4c Mon Sep 17 00:00:00 2001 From: Andrew McKnight Date: Mon, 31 Mar 2025 11:52:29 -0800 Subject: [PATCH 2/2] fix: add platform to chunk envelope item headers --- Sources/Sentry/Profiling/SentryProfilerSerialization.mm | 1 + Sources/Sentry/Public/SentryEnvelopeItemHeader.h | 6 ++++++ Sources/Sentry/SentryEnvelopeItemHeader.m | 4 ++++ .../SentryProfilerTests/SentryContinuousProfilerTests.swift | 1 + 4 files changed, 12 insertions(+) diff --git a/Sources/Sentry/Profiling/SentryProfilerSerialization.mm b/Sources/Sentry/Profiling/SentryProfilerSerialization.mm index b60ab6e7248..45412249694 100644 --- a/Sources/Sentry/Profiling/SentryProfilerSerialization.mm +++ b/Sources/Sentry/Profiling/SentryProfilerSerialization.mm @@ -342,6 +342,7 @@ const auto header = [[SentryEnvelopeItemHeader alloc] initWithType:SentryEnvelopeItemTypeProfileChunk length:JSONData.length]; + header.platform = @"cocoa"; const auto envelopeItem = [[SentryEnvelopeItem alloc] initWithHeader:header data:JSONData]; return [[SentryEnvelope alloc] initWithId:chunkID singleItem:envelopeItem]; diff --git a/Sources/Sentry/Public/SentryEnvelopeItemHeader.h b/Sources/Sentry/Public/SentryEnvelopeItemHeader.h index ae6aaaedb1b..0612432a4ae 100644 --- a/Sources/Sentry/Public/SentryEnvelopeItemHeader.h +++ b/Sources/Sentry/Public/SentryEnvelopeItemHeader.h @@ -28,6 +28,12 @@ SENTRY_NO_INIT @property (nonatomic, readonly, copy, nullable) NSString *filename; @property (nonatomic, readonly, copy, nullable) NSString *contentType; +/** + * Some envelopes need to report the platform name for enhanced rate limiting functionality in + * relay. + */ +@property (nonatomic, copy, nullable) NSString *platform; + @end NS_ASSUME_NONNULL_END diff --git a/Sources/Sentry/SentryEnvelopeItemHeader.m b/Sources/Sentry/SentryEnvelopeItemHeader.m index 7370d08d76a..8ba8fff3d43 100644 --- a/Sources/Sentry/SentryEnvelopeItemHeader.m +++ b/Sources/Sentry/SentryEnvelopeItemHeader.m @@ -48,6 +48,10 @@ - (NSDictionary *)serialize [target setValue:self.contentType forKey:@"content_type"]; } + if (self.platform) { + [target setValue:self.contentType forKey:@"platform"]; + } + [target setValue:[NSNumber numberWithUnsignedInteger:self.length] forKey:@"length"]; return target; diff --git a/Tests/SentryProfilerTests/SentryContinuousProfilerTests.swift b/Tests/SentryProfilerTests/SentryContinuousProfilerTests.swift index bd2964e7f43..706ce7c5f81 100644 --- a/Tests/SentryProfilerTests/SentryContinuousProfilerTests.swift +++ b/Tests/SentryProfilerTests/SentryContinuousProfilerTests.swift @@ -242,6 +242,7 @@ private extension SentryContinuousProfilerTests { XCTAssertEqual(1, envelope.items.count) let profileItem = try XCTUnwrap(envelope.items.first) XCTAssertEqual("profile_chunk", profileItem.header.type) + XCTAssertEqual("cocoa", profileItem.header.platform) let data = profileItem.data let profile = try XCTUnwrap(try JSONSerialization.jsonObject(with: data) as? [String: Any])