Skip to content
Open
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
7 changes: 3 additions & 4 deletions packages/core/ios/Sources/DdFlagsImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class DdFlagsImplementation: NSObject {
}

@objc
public func enable(_ configuration: NSDictionary, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
public func enable(_ configuration: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) {
// Client providers become stale upon subsequent enable calls (which can happen e.g. in case of a React Native hot reload).
clientProviders.removeAll()

Expand All @@ -53,9 +53,8 @@ public class DdFlagsImplementation: NSObject {
return client
}

// Using @escaping RCTPromiseResolveBlock type will result in an issue when compiling the Swift header file.
@objc
public func setEvaluationContext(_ clientName: String, targetingKey: String, attributes: NSDictionary, resolve: @escaping ((Any?) -> Void), reject: @escaping ((String?, String?, NSError?) -> Void)) {
public func setEvaluationContext(_ clientName: String, targetingKey: String, attributes: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) {
let client = getClient(name: clientName)
guard let clientInternal = client as? FlagsClientInternal else {
reject("CLIENT_NOT_INITIALIZED", "Flags client '\(clientName)' is not properly initialized. Make sure the Datadog SDK has been initialized and Flags.enable() has been called.", nil)
Expand Down Expand Up @@ -102,7 +101,7 @@ public class DdFlagsImplementation: NSObject {
}

@objc
public func trackEvaluation(_ clientName: String, key: String, rawFlag: NSDictionary, targetingKey: String, attributes: NSDictionary, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
public func trackEvaluation(_ clientName: String, key: String, rawFlag: NSDictionary, targetingKey: String, attributes: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) {
guard let client = getClient(name: clientName) as? FlagsClientInternal else {
reject("CLIENT_NOT_INITIALIZED", "Flags client '\(clientName)' is not properly initialized. Make sure the Datadog SDK has been initialized and Flags.enable() has been called.", nil)
return
Expand Down
16 changes: 8 additions & 8 deletions packages/core/ios/Sources/DdLogsImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,56 +36,56 @@ public class DdLogsImplementation: NSObject {
}

@objc
public func debug(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func debug(message: String, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
logger.debug(message, error: nil, attributes: attributes)
resolve(nil)
}

@objc
public func info(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func info(message: String, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
logger.info(message, error: nil, attributes: attributes)
resolve(nil)
}

@objc
public func warn(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func warn(message: String, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
logger.warn(message, error: nil, attributes: attributes)
resolve(nil)
}

@objc
public func error(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func error(message: String, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
logger.error(message, error: nil, attributes: attributes)
resolve(nil)
}

@objc
public func debugWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func debugWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
logger._internal.log(level: .debug, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stacktrace, attributes: attributes)
resolve(nil)
}

@objc
public func infoWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func infoWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
logger._internal.log(level: .info, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stacktrace, attributes: attributes)
resolve(nil)
}

@objc
public func warnWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func warnWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
logger._internal.log(level: .warn, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stacktrace, attributes: attributes)
resolve(nil)
}

@objc
public func errorWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func errorWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
let attributes = castAttributesToSwift(context).mergeWithGlobalAttributes()
logger._internal.log(level: .error, message: message, errorKind: errorKind, errorMessage: errorMessage, stackTrace: stacktrace, attributes: attributes)
resolve(nil)
Expand Down
46 changes: 23 additions & 23 deletions packages/core/ios/Sources/DdRumImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,31 +131,31 @@ public class DdRumImplementation: NSObject {
}

@objc
public func startView(key: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func startView(key: String, name: String, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
nativeRUM.startView(key: key, name: name, attributes: attributes(from: context, with: timestampMs))
resolve(nil)
}

@objc
public func stopView(key: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func stopView(key: String, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
nativeRUM.stopView(key: key, attributes: attributes(from: context, with: timestampMs))
resolve(nil)
}

@objc
public func startAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func startAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
nativeRUM.startAction(type: RUMActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
resolve(nil)
}

@objc
public func stopAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func stopAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
nativeRUM.stopAction(type: RUMActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
resolve(nil)
}

@objc
public func addAction(type: String, name: String, touch: NSDictionary?, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func addAction(type: String, name: String, touch: NSDictionary?, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
if
let touch,
let reactTag = touch["reactTag"] as? NSNumber,
Expand All @@ -180,13 +180,13 @@ public class DdRumImplementation: NSObject {
}

@objc
public func startResource(key: String, method: String, url: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func startResource(key: String, method: String, url: String, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
nativeRUM.startResource(resourceKey: key, httpMethod: RUMMethod(from: method), urlString: url, attributes: attributes(from: context, with: timestampMs))
resolve(nil)
}

@objc
public func stopResource(key: String, statusCode: Int64, kind: String, size: Double, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func stopResource(key: String, statusCode: Int64, kind: String, size: Double, context: NSDictionary, timestampMs: Double, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
let mutableContext = NSMutableDictionary(dictionary: context)
if let resourceTimings = mutableContext.object(forKey: Self.resourceTimingsKey) as? [String: Any] {
mutableContext.removeObject(forKey: Self.resourceTimingsKey)
Expand All @@ -205,7 +205,7 @@ public class DdRumImplementation: NSObject {
}

@objc
public func addError(message: String, source: String, stacktrace: String, context: NSDictionary, timestampMs: Double, fingerprint: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func addError(message: String, source: String, stacktrace: String, context: NSDictionary, timestampMs: Double, fingerprint: String, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {

func addErrorWithContext(errorContext: NSDictionary) -> Void {
nativeRUM.addError(message: message, type: nil, stack: stacktrace, source: RUMErrorSource(from: source), attributes: attributes(from: errorContext, with: timestampMs), file: nil, line: nil)
Expand All @@ -223,13 +223,13 @@ public class DdRumImplementation: NSObject {
}

@objc
public func addTiming(name: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func addTiming(name: String, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
nativeRUM.addTiming(name: name)
resolve(nil)
}

@objc
public func addViewAttribute(key: AttributeKey, value: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func addViewAttribute(key: AttributeKey, value: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
if let attributeValue = value.object(forKey: "value") {
let castedAttribute = castValueToSwift(attributeValue)
nativeRUM.addViewAttribute(forKey: key, value: castedAttribute)
Expand All @@ -238,38 +238,38 @@ public class DdRumImplementation: NSObject {
}

@objc
public func removeViewAttribute(key: AttributeKey, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func removeViewAttribute(key: AttributeKey, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
nativeRUM.removeViewAttribute(forKey: key)
resolve(nil)
}

@objc
public func addViewAttributes(attributes: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func addViewAttributes(attributes: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
let castedAttributes = castAttributesToSwift(attributes)
nativeRUM.addViewAttributes(castedAttributes)
resolve(nil)
}

@objc
public func removeViewAttributes(keys: [AttributeKey], resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func removeViewAttributes(keys: [AttributeKey], resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
nativeRUM.removeViewAttributes(forKeys: keys)
resolve(nil)
}

@objc
public func addViewLoadingTime(overwrite: Bool, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func addViewLoadingTime(overwrite: Bool, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
nativeRUM.addViewLoadingTime(overwrite: overwrite)
resolve(nil)
}

@objc
public func stopSession(resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func stopSession(resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
nativeRUM.stopSession()
resolve(nil)
}

@objc
public func addFeatureFlagEvaluation(name: String, value: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
public func addFeatureFlagEvaluation(name: String, value: NSDictionary, resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
let valueAsEncodable = castAttributesToSwift(value)
if let value = valueAsEncodable["value"] {
nativeRUM.addFeatureFlagEvaluation(name: name, value: value)
Expand All @@ -278,7 +278,7 @@ public class DdRumImplementation: NSObject {
}

@objc
public func getCurrentSessionId(_ resolve: @escaping (Any?) -> Void, reject: RCTPromiseRejectBlock) -> Void {
public func getCurrentSessionId(_ resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
nativeRUM.currentSessionID { sessionId in
resolve(sessionId)
}
Expand All @@ -289,8 +289,8 @@ public class DdRumImplementation: NSObject {
name: String,
operationKey: String?,
attributes: NSDictionary,
resolve: @escaping (Any?) -> Void,
reject: RCTPromiseRejectBlock
resolve: @escaping RCTPromiseResolve,
reject: @escaping RCTPromiseReject
){
let castedAttributes = castAttributesToSwift(attributes)
nativeRUM.startFeatureOperation(name: name, operationKey: operationKey, attributes: castedAttributes)
Expand All @@ -302,8 +302,8 @@ public class DdRumImplementation: NSObject {
name: String,
operationKey: String?,
attributes: NSDictionary,
resolve: @escaping (Any?) -> Void,
reject: RCTPromiseRejectBlock
resolve: @escaping RCTPromiseResolve,
reject: @escaping RCTPromiseReject
){
let castedAttributes = castAttributesToSwift(attributes)
nativeRUM.succeedFeatureOperation(name: name, operationKey: operationKey, attributes: castedAttributes)
Expand All @@ -316,8 +316,8 @@ public class DdRumImplementation: NSObject {
operationKey: String?,
reason: String,
attributes: NSDictionary,
resolve: @escaping (Any?) -> Void,
reject: RCTPromiseRejectBlock
resolve: @escaping RCTPromiseResolve,
reject: @escaping RCTPromiseReject
){
let castedAttributes = castAttributesToSwift(attributes)
nativeRUM.failFeatureOperation(name: name, operationKey: operationKey,
Expand Down
Loading