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
1 change: 1 addition & 0 deletions packages/core/ios/Sources/DdSdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
@property(nonatomic, strong) DdSdkImplementation *ddSdkImplementation;

+ (void)initFromNative;
+ (RCTBridge * _Nullable)latestBridgeReference;

@end
10 changes: 8 additions & 2 deletions packages/core/ios/Sources/DdSdk.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@

@implementation DdSdk

@synthesize bridge = _bridge;
static __weak RCTBridge *s_latestBridge = nil;

+ (RCTBridge *)latestBridgeReference {
return s_latestBridge;
}

RCT_EXPORT_MODULE()

RCT_REMAP_METHOD(initialize, withConfiguration:(NSDictionary*)configuration
Expand Down Expand Up @@ -105,7 +110,8 @@ @implementation DdSdk
- (DdSdkImplementation*)ddSdkImplementation
{
if (_ddSdkImplementation == nil) {
_ddSdkImplementation = [[DdSdkImplementation alloc] initWithBridge:_bridge];
s_latestBridge = self.bridge;
_ddSdkImplementation = [[DdSdkImplementation alloc] initWithBridge:self.bridge];
}
return _ddSdkImplementation;
}
Expand Down
13 changes: 12 additions & 1 deletion packages/core/ios/Sources/DdSdkNativeInitialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,18 @@ public class DdSdkNativeInitialization: NSObject {
}
}
let onSessionStart: RUM.SessionListener = { sessionId, isDiscarded in
let body: [String: Any?] = ["sessionId": sessionId, "isDiscarded": isDiscarded]
guard
let emitter = eventEmitter,
let bridge = emitter.bridge,
let latestBridge = DdSdk.latestBridgeReference(),
bridge === latestBridge
else {
return
}

let body: [String: Any?] = [
"sessionId": sessionId, "isDiscarded": isDiscarded,
]
eventEmitter?.sendEvent(withName: "RumSessionStarted", body: body)
}

Expand Down
Loading