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
8 changes: 6 additions & 2 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1044,9 +1044,9 @@
F4DCC9DD2E4AA9D0008ECE45 /* SentrySDKSettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DCC9DC2E4AA9D0008ECE45 /* SentrySDKSettingsTests.swift */; };
F4DCC9E52E4AACE0008ECE45 /* SentrySDKSettings+Equality.m in Sources */ = {isa = PBXBuildFile; fileRef = F4DCC9E42E4AACE0008ECE45 /* SentrySDKSettings+Equality.m */; };
F4E3DCCB2E1579240093CB80 /* SentryScopePersistentStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4E3DCCA2E1579240093CB80 /* SentryScopePersistentStore.swift */; };
F4FE9DBD2E621F100014FED5 /* SentryRandom.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DBC2E621F100014FED5 /* SentryRandom.swift */; };
F4FE9DFD2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DFB2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift */; };
F4FE9DFE2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DFC2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift */; };
F4FE9DBD2E621F100014FED5 /* SentryRandom.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DBC2E621F100014FED5 /* SentryRandom.swift */; };
FA034AC82DD3DB4900FE3107 /* SentryIntegrationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = FA034AC72DD3DB4900FE3107 /* SentryIntegrationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
FA21A2EF2E60E9CB00E7EADB /* EnvelopeComparison.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA21A2E92E60E9C700E7EADB /* EnvelopeComparison.swift */; };
FA21F0B42E4A2A80008B4E5A /* SentryAppState.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4C32972DF7513F001D7B01 /* SentryAppState.swift */; };
Expand All @@ -1055,6 +1055,7 @@
FA3734862E0F09320091EF24 /* SentryDependencyContainerSwiftHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = FA3734852E0F092F0091EF24 /* SentryDependencyContainerSwiftHelper.m */; };
FA3854362E267DA60045A563 /* SentryUser+Serialize.h in Headers */ = {isa = PBXBuildFile; fileRef = FA3854352E267DA20045A563 /* SentryUser+Serialize.h */; };
FA3A42722E1C5F9B00A08C39 /* SentryNSNotificationCenterWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA3A42712E1C5F9B00A08C39 /* SentryNSNotificationCenterWrapper.swift */; };
FA3AEE782E68E2830092283E /* SentryEnvelopeHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA3AEE772E68E2830092283E /* SentryEnvelopeHeader.swift */; };
FA4C32972DF7513F001D7B00 /* SentryExperimentalOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4C32962DF7513F001D7B00 /* SentryExperimentalOptions.swift */; };
FA6555142E30181B009917BC /* SentrySDKInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = FA6555132E30181B009917BC /* SentrySDKInternal.h */; };
FA6555162E30182B009917BC /* SentrySDKInternal.m in Sources */ = {isa = PBXBuildFile; fileRef = FA6555152E30182B009917BC /* SentrySDKInternal.m */; };
Expand Down Expand Up @@ -2390,16 +2391,17 @@
F4DCC9E32E4AACE0008ECE45 /* SentrySDKSettings+Equality.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentrySDKSettings+Equality.h"; sourceTree = "<group>"; };
F4DCC9E42E4AACE0008ECE45 /* SentrySDKSettings+Equality.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SentrySDKSettings+Equality.m"; sourceTree = "<group>"; };
F4E3DCCA2E1579240093CB80 /* SentryScopePersistentStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScopePersistentStore.swift; sourceTree = "<group>"; };
F4FE9DBC2E621F100014FED5 /* SentryRandom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRandom.swift; sourceTree = "<group>"; };
F4FE9DFB2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryDefaultObjCRuntimeWrapper.swift; sourceTree = "<group>"; };
F4FE9DFC2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryObjCRuntimeWrapper.swift; sourceTree = "<group>"; };
F4FE9DBC2E621F100014FED5 /* SentryRandom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRandom.swift; sourceTree = "<group>"; };
FA034AC72DD3DB4900FE3107 /* SentryIntegrationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryIntegrationProtocol.h; path = Public/SentryIntegrationProtocol.h; sourceTree = "<group>"; };
FA21A2E92E60E9C700E7EADB /* EnvelopeComparison.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnvelopeComparison.swift; sourceTree = "<group>"; };
FA3734812E0EEA670091EF24 /* SentryScreenshot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScreenshot.swift; sourceTree = "<group>"; };
FA3734832E0F07A20091EF24 /* SentryDependencyContainerSwiftHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDependencyContainerSwiftHelper.h; path = include/SentryDependencyContainerSwiftHelper.h; sourceTree = "<group>"; };
FA3734852E0F092F0091EF24 /* SentryDependencyContainerSwiftHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryDependencyContainerSwiftHelper.m; sourceTree = "<group>"; };
FA3854352E267DA20045A563 /* SentryUser+Serialize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryUser+Serialize.h"; path = "include/SentryUser+Serialize.h"; sourceTree = "<group>"; };
FA3A42712E1C5F9B00A08C39 /* SentryNSNotificationCenterWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryNSNotificationCenterWrapper.swift; sourceTree = "<group>"; };
FA3AEE772E68E2830092283E /* SentryEnvelopeHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnvelopeHeader.swift; sourceTree = "<group>"; };
FA4C32962DF7513F001D7B00 /* SentryExperimentalOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExperimentalOptions.swift; sourceTree = "<group>"; };
FA4C32972DF7513F001D7B01 /* SentryAppState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryAppState.swift; sourceTree = "<group>"; };
FA6555132E30181B009917BC /* SentrySDKInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentrySDKInternal.h; path = include/SentrySDKInternal.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4482,6 +4484,7 @@
D856272A2A374A6800FB8062 /* Tools */ = {
isa = PBXGroup;
children = (
FA3AEE772E68E2830092283E /* SentryEnvelopeHeader.swift */,
92235CAD2E15549C00865983 /* SentryLogger.swift */,
92235CAB2E15369900865983 /* SentryLogBatcher.swift */,
F451FAA52E0B304E0050ACF2 /* LoadValidator.swift */,
Expand Down Expand Up @@ -5811,6 +5814,7 @@
D452FCBF2DDB6FD200AFF56F /* SentryWatchdogTerminationAttributesProcessor.swift in Sources */,
7B6D1261265F784000C9BE4B /* PrivateSentrySDKOnly.m in Sources */,
63BE85711ECEC6DE00DC44F5 /* SentryDateUtils.m in Sources */,
FA3AEE782E68E2830092283E /* SentryEnvelopeHeader.swift in Sources */,
D451ED5D2D92ECD200C9BEA8 /* SentryOnDemandReplayError.swift in Sources */,
7BD4BD4927EB2A5D0071F4FF /* SentryDiscardedEvent.m in Sources */,
628308612D50ADAC00EAEF77 /* SentryRequestCodable.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions SentryTestUtilsTests/TestConstantTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
@_spi(Private) import Sentry
@_spi(Private) @testable import SentryTestUtils
import XCTest

Expand Down
3 changes: 3 additions & 0 deletions Sources/Sentry/SentryClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,11 @@ - (void)captureSession:(SentrySession *)session
}

SentryEnvelopeItem *item = [[SentryEnvelopeItem alloc] initWithSession:session];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SentryEnvelope *envelope = [[SentryEnvelope alloc] initWithHeader:[SentryEnvelopeHeader empty]
singleItem:item];
#pragma clang diagnostic pop
[self captureEnvelope:envelope];
}

Expand Down
55 changes: 15 additions & 40 deletions Sources/Sentry/SentryEnvelope.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,6 @@

NS_ASSUME_NONNULL_BEGIN

@implementation SentryEnvelopeHeader

// id can be null if no event in the envelope or attachment related to event
- (instancetype)initWithId:(SentryId *_Nullable)eventId
{
self = [self initWithId:eventId traceContext:nil];
return self;
}

- (instancetype)initWithId:(nullable SentryId *)eventId
traceContext:(nullable SentryTraceContext *)traceContext
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SentrySdkInfo *sdkInfo = [SentrySdkInfo global];
#pragma clang diagnostic pop
self = [self initWithId:eventId sdkInfo:sdkInfo traceContext:traceContext];
return self;
}

- (instancetype)initWithId:(nullable SentryId *)eventId
sdkInfo:(nullable SentrySdkInfo *)sdkInfo
traceContext:(nullable SentryTraceContext *)traceContext
{
if (self = [super init]) {
_eventId = eventId;
_sdkInfo = sdkInfo;
_traceContext = traceContext;
}

return self;
}

+ (instancetype)empty
{
return [[SentryEnvelopeHeader alloc] initWithId:nil traceContext:nil];
}

@end

@implementation SentryEnvelopeItem

- (instancetype)initWithHeader:(SentryEnvelopeItemHeader *)header data:(NSData *)data
Expand Down Expand Up @@ -285,7 +245,10 @@ @implementation SentryEnvelope
- (instancetype)initWithSession:(SentrySession *)session
{
SentryEnvelopeItem *item = [[SentryEnvelopeItem alloc] initWithSession:session];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return [self initWithHeader:[[SentryEnvelopeHeader alloc] initWithId:nil] singleItem:item];
#pragma clang diagnostic pop
}

- (instancetype)initWithSessions:(NSArray<SentrySession *> *)sessions
Expand All @@ -296,14 +259,20 @@ - (instancetype)initWithSessions:(NSArray<SentrySession *> *)sessions
[[SentryEnvelopeItem alloc] initWithSession:[sessions objectAtIndex:i]];
[envelopeItems addObject:item];
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return [self initWithHeader:[[SentryEnvelopeHeader alloc] initWithId:nil] items:envelopeItems];
#pragma clang diagnostic pop
}

- (instancetype)initWithEvent:(SentryEvent *)event
{
SentryEnvelopeItem *item = [[SentryEnvelopeItem alloc] initWithEvent:event];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return [self initWithHeader:[[SentryEnvelopeHeader alloc] initWithId:event.eventId]
singleItem:item];
#pragma clang diagnostic pop
}

#if !SDK_V9
Expand All @@ -318,12 +287,18 @@ - (instancetype)initWithUserFeedback:(SentryUserFeedback *)userFeedback

- (instancetype)initWithId:(SentryId *_Nullable)id singleItem:(SentryEnvelopeItem *)item
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return [self initWithHeader:[[SentryEnvelopeHeader alloc] initWithId:id] singleItem:item];
#pragma clang diagnostic pop
}

- (instancetype)initWithId:(SentryId *_Nullable)id items:(NSArray<SentryEnvelopeItem *> *)items
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return [self initWithHeader:[[SentryEnvelopeHeader alloc] initWithId:id] items:items];
#pragma clang diagnostic pop
}

- (instancetype)initWithHeader:(SentryEnvelopeHeader *)header singleItem:(SentryEnvelopeItem *)item
Expand Down
9 changes: 9 additions & 0 deletions Sources/Sentry/SentryTransportAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ - (void)sendEvent:(SentryEvent *)event
attachments:attachments];
[items addObjectsFromArray:additionalEnvelopeItems];

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SentryEnvelopeHeader *envelopeHeader = [[SentryEnvelopeHeader alloc] initWithId:event.eventId
traceContext:traceContext];
#pragma clang diagnostic pop
SentryEnvelope *envelope = [[SentryEnvelope alloc] initWithHeader:envelopeHeader items:items];

[self sendEnvelope:envelope];
Expand All @@ -68,8 +71,11 @@ - (void)sendEvent:(SentryEvent *)event
attachments:attachments];
[items addObject:[[SentryEnvelopeItem alloc] initWithSession:session]];

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SentryEnvelopeHeader *envelopeHeader = [[SentryEnvelopeHeader alloc] initWithId:event.eventId
traceContext:traceContext];
#pragma clang diagnostic pop

SentryEnvelope *envelope = [[SentryEnvelope alloc] initWithHeader:envelopeHeader items:items];

Expand All @@ -80,8 +86,11 @@ - (void)storeEvent:(SentryEvent *)event traceContext:(nullable SentryTraceContex
{
SentryEnvelopeItem *item = [[SentryEnvelopeItem alloc] initWithEvent:event];

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SentryEnvelopeHeader *envelopeHeader = [[SentryEnvelopeHeader alloc] initWithId:event.eventId
traceContext:traceContext];
#pragma clang diagnostic pop

SentryEnvelope *envelope = [[SentryEnvelope alloc] initWithHeader:envelopeHeader
items:@[ item ]];
Expand Down
61 changes: 1 addition & 60 deletions Sources/Sentry/include/HybridPublic/SentryEnvelope.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# import "PrivatesHeader.h"
#endif

@class SentrySdkInfo;
@class SentryAttachment;
@class SentryEnvelopeItemHeader;
@class SentryEvent;
Expand All @@ -13,68 +12,10 @@
@class SentrySession;
@class SentryTraceContext;
@class SentryUserFeedback;
@class SentryEnvelopeHeader;

NS_ASSUME_NONNULL_BEGIN

@interface SentryEnvelopeHeader : NSObject
SENTRY_NO_INIT

/**
* Initializes an @c SentryEnvelopeHeader object with the specified eventId.
* @note Sets the @c sdkInfo from @c SentryMeta.
* @param eventId The identifier of the event. Can be nil if no event in the envelope or attachment
* related to event.
*/
- (instancetype)initWithId:(SentryId *_Nullable)eventId;

/**
* Initializes a @c SentryEnvelopeHeader object with the specified @c eventId and @c traceContext.
* @param eventId The identifier of the event. Can be @c nil if no event in the envelope or
* attachment related to event.
* @param traceContext Current trace state.
*/
- (instancetype)initWithId:(nullable SentryId *)eventId
traceContext:(nullable SentryTraceContext *)traceContext;

/**
* Initializes a @c SentryEnvelopeHeader object with the specified @c eventId, @c skdInfo and
* @c traceContext. It is recommended to use @c initWithId:traceContext: because it sets the
* @c sdkInfo for you.
* @param eventId The identifier of the event. Can be @c nil if no event in the envelope or
* attachment related to event.
* @param sdkInfo Describes the Sentry SDK. Can be @c nil for backwards compatibility. New
* instances should always provide a version.
* @param traceContext Current trace state.
*/
- (instancetype)initWithId:(nullable SentryId *)eventId
sdkInfo:(nullable SentrySdkInfo *)sdkInfo
traceContext:(nullable SentryTraceContext *)traceContext NS_DESIGNATED_INITIALIZER;

/**
* The event identifier, if available.
* An event id exist if the envelope contains an event of items within it are related. i.e
* Attachments
*/
@property (nullable, nonatomic, readonly, copy) SentryId *eventId;

@property (nullable, nonatomic, readonly, copy) SentrySdkInfo *sdkInfo;

@property (nullable, nonatomic, readonly, copy) SentryTraceContext *traceContext;

/**
* The timestamp when the event was sent from the SDK as string in RFC 3339 format. Used
* for clock drift correction of the event timestamp. The time zone must be UTC.
*
* The timestamp should be generated as close as possible to the transmision of the event,
* so that the delay between sending the envelope and receiving it on the server-side is
* minimized.
*/
@property (nullable, nonatomic, copy) NSDate *sentAt;

+ (instancetype)empty;

@end

@interface SentryEnvelopeItem : NSObject
SENTRY_NO_INIT

Expand Down
66 changes: 66 additions & 0 deletions Sources/Swift/Tools/SentryEnvelopeHeader.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@_implementationOnly import _SentryPrivate

@_spi(Private) @objc public final class SentryEnvelopeHeader: NSObject {
/**
* Initializes an @c SentryEnvelopeHeader object with the specified eventId.
* @note Sets the @c sdkInfo from @c SentryMeta.
* @param eventId The identifier of the event. Can be nil if no event in the envelope or attachment
* related to event.
*/
@available(*, deprecated, message: "This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")
@objc public convenience init(id eventId: SentryId?) {
self.init(id: eventId, traceContext: nil)
}

/**
* Initializes a @c SentryEnvelopeHeader object with the specified @c eventId and @c traceContext.
* @param eventId The identifier of the event. Can be @c nil if no event in the envelope or
* attachment related to event.
* @param traceContext Current trace state.
*/
@available(*, deprecated, message: "This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")
@objc public convenience init(id eventId: SentryId?, traceContext: TraceContext?) {
self.init(id: eventId, sdkInfo: SentrySdkInfo.global(), traceContext: traceContext)
}

/**
* Initializes a @c SentryEnvelopeHeader object with the specified @c eventId, @c skdInfo and
* @c traceContext. It is recommended to use @c initWithId:traceContext: because it sets the
* @c sdkInfo for you.
* @param eventId The identifier of the event. Can be @c nil if no event in the envelope or
* attachment related to event.
* @param sdkInfo Describes the Sentry SDK. Can be @c nil for backwards compatibility. New
* instances should always provide a version.
* @param traceContext Current trace state.
*/
@objc public
init(id eventId: SentryId?, sdkInfo: SentrySdkInfo?, traceContext: TraceContext?) {
self.eventId = eventId
self.sdkInfo = sdkInfo
self.traceContext = traceContext
}

@available(*, deprecated, message: "This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")
@objc public static func empty() -> Self {
Self(id: nil, traceContext: nil)
}

/**
* The event identifier, if available.
* An event id exist if the envelope contains an event of items within it are related. i.e
* Attachments
*/
@objc public var eventId: SentryId?
@objc public var sdkInfo: SentrySdkInfo?
@objc public var traceContext: TraceContext?

/**
* The timestamp when the event was sent from the SDK as string in RFC 3339 format. Used
* for clock drift correction of the event timestamp. The time zone must be UTC.
*
* The timestamp should be generated as close as possible to the transmision of the event,
* so that the delay between sending the envelope and receiving it on the server-side is
* minimized.
*/
@objc public var sentAt: Date?
}
Loading
Loading