diff --git a/packages/core/ios/Sources/DdSdkConfiguration.swift b/packages/core/ios/Sources/DdSdkConfiguration.swift index f2593b363..c59357edd 100644 --- a/packages/core/ios/Sources/DdSdkConfiguration.swift +++ b/packages/core/ios/Sources/DdSdkConfiguration.swift @@ -39,6 +39,7 @@ import DatadogRUM - bundleLogsWithRum: Correlates logs with RUM. - bundleLogsWithTraces: Correlates logs with traces. - appHangThreshold: The threshold for non-fatal app hangs reporting in seconds. + - trackWatchdogTerminations: Whether the SDK should track application termination by the watchdog */ @objc(DdSdkConfiguration) public class DdSdkConfiguration: NSObject { @@ -70,6 +71,7 @@ public class DdSdkConfiguration: NSObject { public var bundleLogsWithRum: Bool public var bundleLogsWithTraces: Bool public var appHangThreshold: Double? = nil + public var trackWatchdogTerminations: Bool public init( clientToken: String, @@ -99,7 +101,8 @@ public class DdSdkConfiguration: NSObject { resourceTracingSamplingRate: Double?, bundleLogsWithRum: Bool, bundleLogsWithTraces: Bool, - appHangThreshold: Double? + appHangThreshold: Double?, + trackWatchdogTerminations: Bool ) { self.clientToken = clientToken self.env = env @@ -129,6 +132,7 @@ public class DdSdkConfiguration: NSObject { self.bundleLogsWithRum = bundleLogsWithRum self.bundleLogsWithTraces = bundleLogsWithTraces self.appHangThreshold = appHangThreshold + self.trackWatchdogTerminations = trackWatchdogTerminations } } diff --git a/packages/core/ios/Sources/DdSdkNativeInitialization.swift b/packages/core/ios/Sources/DdSdkNativeInitialization.swift index c40642db0..15b66e79b 100644 --- a/packages/core/ios/Sources/DdSdkNativeInitialization.swift +++ b/packages/core/ios/Sources/DdSdkNativeInitialization.swift @@ -160,6 +160,7 @@ public class DdSdkNativeInitialization: NSObject { trackBackgroundEvents: configuration.trackBackgroundEvents ?? false, longTaskThreshold: longTaskThreshold, appHangThreshold: configuration.appHangThreshold, + trackWatchdogTerminations: configuration.trackWatchdogTerminations, vitalsUpdateFrequency: configuration.vitalsUpdateFrequency, resourceEventMapper: { resourceEvent in if resourceEvent.context?.contextInfo[InternalConfigurationAttributes.dropResource] != nil { diff --git a/packages/core/ios/Sources/RNDdSdkConfiguration.swift b/packages/core/ios/Sources/RNDdSdkConfiguration.swift index b277fef35..166495c16 100644 --- a/packages/core/ios/Sources/RNDdSdkConfiguration.swift +++ b/packages/core/ios/Sources/RNDdSdkConfiguration.swift @@ -40,6 +40,7 @@ extension NSDictionary { let bundleLogsWithRum = object(forKey: "bundleLogsWithRum") as? Bool let bundleLogsWithTraces = object(forKey: "bundleLogsWithTraces") as? Bool let appHangThreshold = object(forKey: "appHangThreshold") as? Double + let trackWatchdogTerminations = object(forKey: "trackWatchdogTerminations") as? Bool return DdSdkConfiguration( clientToken: (clientToken != nil) ? clientToken! : String(), @@ -69,7 +70,8 @@ extension NSDictionary { resourceTracingSamplingRate: resourceTracingSamplingRate, bundleLogsWithRum: bundleLogsWithRum ?? DefaultConfiguration.bundleLogsWithRum, bundleLogsWithTraces: bundleLogsWithTraces ?? DefaultConfiguration.bundleLogsWithTraces, - appHangThreshold: appHangThreshold + appHangThreshold: appHangThreshold, + trackWatchdogTerminations: trackWatchdogTerminations ?? DefaultConfiguration.trackWatchdogTerminations ) } @@ -199,6 +201,7 @@ internal struct DefaultConfiguration { static let trackBackgroundEvents = false static let bundleLogsWithRum = true static let bundleLogsWithTraces = true + static let trackWatchdogTerminations = false } extension Dictionary where Key == String, Value == AnyObject { @@ -234,6 +237,7 @@ extension Dictionary where Key == String, Value == AnyObject { let bundleLogsWithRum = configuration["bundleLogsWithRum"] as? Bool let bundleLogsWithTraces = configuration["bundleLogsWithTraces"] as? Bool let appHangThreshold = configuration["appHangThreshold"] as? Double + let trackWatchdogTerminations = configuration["trackWatchdogTerminations"] as? Bool return DdSdkConfiguration( clientToken: clientToken ?? String(), @@ -266,7 +270,8 @@ extension Dictionary where Key == String, Value == AnyObject { resourceTracingSamplingRate: resourceTracingSamplingRate ?? DefaultConfiguration.resourceTracingSamplingRate, bundleLogsWithRum: bundleLogsWithRum ?? DefaultConfiguration.bundleLogsWithRum, bundleLogsWithTraces: bundleLogsWithTraces ?? DefaultConfiguration.bundleLogsWithTraces, - appHangThreshold: appHangThreshold + appHangThreshold: appHangThreshold, + trackWatchdogTerminations: trackWatchdogTerminations ?? DefaultConfiguration.trackWatchdogTerminations ) } } diff --git a/packages/core/src/DdSdkReactNative.tsx b/packages/core/src/DdSdkReactNative.tsx index 224d0989a..c710f31d3 100644 --- a/packages/core/src/DdSdkReactNative.tsx +++ b/packages/core/src/DdSdkReactNative.tsx @@ -308,7 +308,8 @@ export class DdSdkReactNative { configuration.bundleLogsWithRum, configuration.bundleLogsWithTraces, configuration.trackNonFatalAnrs, - configuration.appHangThreshold + configuration.appHangThreshold, + configuration.trackWatchdogTerminations ); }; diff --git a/packages/core/src/DdSdkReactNativeConfiguration.tsx b/packages/core/src/DdSdkReactNativeConfiguration.tsx index e8aa77e81..32242f5e6 100644 --- a/packages/core/src/DdSdkReactNativeConfiguration.tsx +++ b/packages/core/src/DdSdkReactNativeConfiguration.tsx @@ -116,7 +116,8 @@ export const DEFAULTS = { getCustomEndpoints: () => ({}), bundleLogsWithRum: true, bundleLogsWithTraces: true, - useAccessibilityLabel: true + useAccessibilityLabel: true, + trackWatchdogTerminations: false }; /** @@ -291,6 +292,12 @@ export class DdSdkReactNativeConfiguration { */ public appHangThreshold?: number; + /** + * Determines whether the SDK should track application termination by the watchdog on iOS. Default: `false`. + */ + public trackWatchdogTerminations: boolean = + DEFAULTS.trackWatchdogTerminations; + /** * Specifies a custom prop to name RUM actions on elements having an `onPress` prop. * diff --git a/packages/core/src/__tests__/DdSdkReactNativeConfiguration.test.ts b/packages/core/src/__tests__/DdSdkReactNativeConfiguration.test.ts index 70c176f9b..e0006dd94 100644 --- a/packages/core/src/__tests__/DdSdkReactNativeConfiguration.test.ts +++ b/packages/core/src/__tests__/DdSdkReactNativeConfiguration.test.ts @@ -60,6 +60,7 @@ describe('DdSdkReactNativeConfiguration', () => { "trackFrustrations": true, "trackInteractions": false, "trackResources": false, + "trackWatchdogTerminations": false, "trackingConsent": "granted", "uploadFrequency": "AVERAGE", "useAccessibilityLabel": true, @@ -166,6 +167,7 @@ describe('DdSdkReactNativeConfiguration', () => { "trackFrustrations": true, "trackInteractions": true, "trackResources": true, + "trackWatchdogTerminations": false, "trackingConsent": "pending", "uploadFrequency": "FREQUENT", "useAccessibilityLabel": true, @@ -240,6 +242,7 @@ describe('DdSdkReactNativeConfiguration', () => { "trackFrustrations": false, "trackInteractions": false, "trackResources": false, + "trackWatchdogTerminations": false, "trackingConsent": "granted", "uploadFrequency": "AVERAGE", "useAccessibilityLabel": false, diff --git a/packages/core/src/sdk/FileBasedConfiguration/__tests__/FileBasedConfiguration.test.ts b/packages/core/src/sdk/FileBasedConfiguration/__tests__/FileBasedConfiguration.test.ts index c876615a9..b4ed90df6 100644 --- a/packages/core/src/sdk/FileBasedConfiguration/__tests__/FileBasedConfiguration.test.ts +++ b/packages/core/src/sdk/FileBasedConfiguration/__tests__/FileBasedConfiguration.test.ts @@ -89,6 +89,7 @@ describe('FileBasedConfiguration', () => { "trackFrustrations": true, "trackInteractions": true, "trackResources": true, + "trackWatchdogTerminations": false, "trackingConsent": "not_granted", "uploadFrequency": "AVERAGE", "useAccessibilityLabel": true, @@ -140,6 +141,7 @@ describe('FileBasedConfiguration', () => { "trackFrustrations": true, "trackInteractions": false, "trackResources": false, + "trackWatchdogTerminations": false, "trackingConsent": "granted", "uploadFrequency": "AVERAGE", "useAccessibilityLabel": true, diff --git a/packages/core/src/types.tsx b/packages/core/src/types.tsx index f5cb79425..28a5f89f8 100644 --- a/packages/core/src/types.tsx +++ b/packages/core/src/types.tsx @@ -58,7 +58,8 @@ export class DdSdkConfiguration { readonly bundleLogsWithRum: boolean, readonly bundleLogsWithTraces: boolean, readonly trackNonFatalAnrs: boolean | undefined, - readonly appHangThreshold: number | undefined + readonly appHangThreshold: number | undefined, + readonly trackWatchdogTerminations: boolean | undefined ) {} }