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]) 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