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
5 changes: 4 additions & 1 deletion packages/core/ios/Sources/DdSdkConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class DdSdkConfiguration: NSObject {
public var trackWatchdogTerminations: Bool
public var batchProcessingLevel: Datadog.Configuration.BatchProcessingLevel
public var initialResourceThreshold: Double? = nil
public var trackMemoryWarnings: Bool

public init(
clientToken: String,
Expand Down Expand Up @@ -108,7 +109,8 @@ public class DdSdkConfiguration: NSObject {
appHangThreshold: Double?,
trackWatchdogTerminations: Bool,
batchProcessingLevel: Datadog.Configuration.BatchProcessingLevel,
initialResourceThreshold: Double?
initialResourceThreshold: Double?,
trackMemoryWarnings: Bool = true
) {
self.clientToken = clientToken
self.env = env
Expand Down Expand Up @@ -141,6 +143,7 @@ public class DdSdkConfiguration: NSObject {
self.trackWatchdogTerminations = trackWatchdogTerminations
self.batchProcessingLevel = batchProcessingLevel
self.initialResourceThreshold = initialResourceThreshold
self.trackMemoryWarnings = trackMemoryWarnings
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public class DdSdkNativeInitialization: NSObject {
},
onSessionStart: DdSdkSessionStartedListener.instance.rumSessionListener,
customEndpoint: customRUMEndpointURL,
trackMemoryWarnings: configuration.trackMemoryWarnings,
telemetrySampleRate: (configuration.telemetrySampleRate as? NSNumber)?.floatValue ?? Float(DefaultConfiguration.telemetrySampleRate)
)
}
Expand Down
9 changes: 7 additions & 2 deletions packages/core/ios/Sources/RNDdSdkConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extension NSDictionary {
let trackWatchdogTerminations = object(forKey: "trackWatchdogTerminations") as? Bool
let batchProcessingLevel = object(forKey: "batchProcessingLevel") as? NSString
let initialResourceThreshold = object(forKey: "initialResourceThreshold") as? Double
let trackMemoryWarnings = object(forKey: "trackMemoryWarnings") as? Bool

return DdSdkConfiguration(
clientToken: (clientToken != nil) ? clientToken! : String(),
Expand Down Expand Up @@ -75,7 +76,8 @@ extension NSDictionary {
appHangThreshold: appHangThreshold,
trackWatchdogTerminations: trackWatchdogTerminations ?? DefaultConfiguration.trackWatchdogTerminations,
batchProcessingLevel: batchProcessingLevel.asBatchProcessingLevel(),
initialResourceThreshold: initialResourceThreshold
initialResourceThreshold: initialResourceThreshold,
trackMemoryWarnings: trackMemoryWarnings ?? DefaultConfiguration.trackMemoryWarnings
)
}

Expand Down Expand Up @@ -206,6 +208,7 @@ internal struct DefaultConfiguration {
static let bundleLogsWithRum = true
static let bundleLogsWithTraces = true
static let trackWatchdogTerminations = false
static let trackMemoryWarnings = true
}

extension Dictionary where Key == String, Value == AnyObject {
Expand Down Expand Up @@ -244,6 +247,7 @@ extension Dictionary where Key == String, Value == AnyObject {
let trackWatchdogTerminations = configuration["trackWatchdogTerminations"] as? Bool
let batchProcessingLevel = configuration["batchProcessingLevel"] as? NSString
let initialResourceThreshold = configuration["initialResourceThreshold"] as? Double
let trackMemoryWarnings = configuration["trackMemoryWarnings"] as? Bool

return DdSdkConfiguration(
clientToken: clientToken ?? String(),
Expand Down Expand Up @@ -279,7 +283,8 @@ extension Dictionary where Key == String, Value == AnyObject {
appHangThreshold: appHangThreshold,
trackWatchdogTerminations: trackWatchdogTerminations ?? DefaultConfiguration.trackWatchdogTerminations,
batchProcessingLevel: batchProcessingLevel.asBatchProcessingLevel(),
initialResourceThreshold: initialResourceThreshold
initialResourceThreshold: initialResourceThreshold,
trackMemoryWarnings: trackMemoryWarnings ?? DefaultConfiguration.trackMemoryWarnings
)
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/DdSdkReactNative.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ export class DdSdkReactNative {
configuration.resourceTracingSamplingRate,
configuration.trackWatchdogTerminations,
configuration.batchProcessingLevel,
configuration.initialResourceThreshold
configuration.initialResourceThreshold,
configuration.trackMemoryWarnings
);
};

Expand Down
14 changes: 13 additions & 1 deletion packages/core/src/DdSdkReactNativeConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ export const DEFAULTS = {
bundleLogsWithTraces: true,
useAccessibilityLabel: true,
trackWatchdogTerminations: false,
batchProcessingLevel: BatchProcessingLevel.MEDIUM
batchProcessingLevel: BatchProcessingLevel.MEDIUM,
trackMemoryWarnings: true
};

/**
Expand Down Expand Up @@ -328,6 +329,16 @@ export class DdSdkReactNativeConfiguration {
public trackWatchdogTerminations: boolean =
DEFAULTS.trackWatchdogTerminations;

/**
* Enables tracking of memory warnings as RUM events.
*
* When enabled, the SDK will automatically record a RUM event each time the app
* receives a memory warning from the operating system.
*
* **Note:** This setting is only supported on **iOS**. It has no effect on other platforms.
*/
public trackMemoryWarnings: boolean = DEFAULTS.trackMemoryWarnings;

/**
* Specifies a custom prop to name RUM actions on elements having an `onPress` prop.
*
Expand Down Expand Up @@ -469,6 +480,7 @@ export type PartialInitializationConfiguration = {
readonly bundleLogsWithTraces?: boolean;
readonly batchProcessingLevel?: BatchProcessingLevel;
readonly initialResourceThreshold?: number;
readonly trackMemoryWarnings?: boolean;
};

const setConfigurationAttribute = <
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('DdSdkReactNativeConfiguration', () => {
"trackErrors": false,
"trackFrustrations": true,
"trackInteractions": false,
"trackMemoryWarnings": true,
"trackResources": false,
"trackWatchdogTerminations": false,
"trackingConsent": "granted",
Expand Down Expand Up @@ -170,6 +171,7 @@ describe('DdSdkReactNativeConfiguration', () => {
"trackErrors": true,
"trackFrustrations": true,
"trackInteractions": true,
"trackMemoryWarnings": true,
"trackResources": true,
"trackWatchdogTerminations": false,
"trackingConsent": "pending",
Expand Down Expand Up @@ -246,6 +248,7 @@ describe('DdSdkReactNativeConfiguration', () => {
"trackErrors": false,
"trackFrustrations": false,
"trackInteractions": false,
"trackMemoryWarnings": true,
"trackResources": false,
"trackWatchdogTerminations": false,
"trackingConsent": "granted",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ describe('DatadogProvider', () => {
"telemetrySampleRate": 20,
"trackBackgroundEvents": false,
"trackFrustrations": true,
"trackMemoryWarnings": true,
"trackNonFatalAnrs": undefined,
"trackWatchdogTerminations": false,
"trackingConsent": "granted",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('FileBasedConfiguration', () => {
"trackErrors": true,
"trackFrustrations": true,
"trackInteractions": true,
"trackMemoryWarnings": true,
"trackResources": true,
"trackWatchdogTerminations": false,
"trackingConsent": "not_granted",
Expand Down Expand Up @@ -154,6 +155,7 @@ describe('FileBasedConfiguration', () => {
"trackErrors": true,
"trackFrustrations": true,
"trackInteractions": true,
"trackMemoryWarnings": true,
"trackResources": true,
"trackWatchdogTerminations": false,
"trackingConsent": "not_granted",
Expand Down Expand Up @@ -205,6 +207,7 @@ describe('FileBasedConfiguration', () => {
"trackErrors": false,
"trackFrustrations": true,
"trackInteractions": false,
"trackMemoryWarnings": true,
"trackResources": false,
"trackWatchdogTerminations": false,
"trackingConsent": "granted",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export class DdSdkConfiguration {
readonly resourceTracingSamplingRate: number,
readonly trackWatchdogTerminations: boolean | undefined,
readonly batchProcessingLevel: BatchProcessingLevel, // eslint-disable-next-line no-empty-function
readonly initialResourceThreshold: number | undefined
readonly initialResourceThreshold: number | undefined,
readonly trackMemoryWarnings: boolean
) {}
}

Expand Down