Skip to content
Closed
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
27 changes: 18 additions & 9 deletions benchmarks/src/testSetup/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
DatadogProviderConfiguration,
DdSdkReactNative,
CoreConfiguration,
RumConfiguration,
SdkVerbosity,
TrackingConsent
} from '@datadog/mobile-react-native';
Expand Down Expand Up @@ -41,14 +40,19 @@ export const getDatadogProviderConfig = () => {
let config = new DatadogProviderConfiguration(
baseConfig.clientToken ?? '',
baseConfig.env ?? '',
TrackingConsent.GRANTED
TrackingConsent.GRANTED,
{
applicationId: baseConfig.applicationID ?? '',
trackInteractions: true,
trackResources: true,
trackErrors: true,
sessionSampleRate: 100,
nativeCrashReportEnabled: true
}
);
config.service = `com.rn.${platform}.benchmark`
config.verbosity = SdkVerbosity.DEBUG;
config.nativeCrashReportEnabled = true

config.rumConfiguration = new RumConfiguration(baseConfig.applicationID ?? '', true, true, true);
config.rumConfiguration.sessionSampleRate = 100;

return config;
};
Expand All @@ -58,13 +62,18 @@ export const initializeDatadog = (clientToken?: string, environment?: string, ap
const config = new CoreConfiguration(
clientToken ?? '',
environment ?? '',
TrackingConsent.GRANTED
TrackingConsent.GRANTED,
{
applicationId:appId,
trackInteractions: true,
trackResources: true,
trackErrors: true,
sessionSampleRate: 100,
nativeCrashReportEnabled: true,
}
);
config.service = `com.rn.${platform}.benchmark`
config.verbosity = SdkVerbosity.DEBUG;
config.nativeCrashReportEnabled = true
config.rumConfiguration = new RumConfiguration(appId ?? '', true, true, true)
config.rumConfiguration.sessionSampleRate = 100;

return DdSdkReactNative.initialize(config);
};
Expand Down
25 changes: 17 additions & 8 deletions example/src/ddUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
DdLogs,
DdSdkReactNative,
CoreConfiguration,
RumConfiguration,
SdkVerbosity,
TrackingConsent
} from '@datadog/mobile-react-native';
Expand All @@ -16,13 +15,18 @@ export function getDatadogConfig(trackingConsent: TrackingConsent) {
CLIENT_TOKEN,
ENVIRONMENT,
trackingConsent,
{
applicationId: APPLICATION_ID,
trackInteractions: true,
trackResources: true,
trackErrors: true,
sessionSampleRate: 100,
nativeCrashReportEnabled: true
}
);

config.service = "com.datadoghq.reactnative.sample"
config.nativeCrashReportEnabled = true
config.verbosity = SdkVerbosity.DEBUG;
config.rumConfiguration = new RumConfiguration(APPLICATION_ID, true, true, true);
config.rumConfiguration.sessionSampleRate = 100
return config
}

Expand All @@ -38,13 +42,18 @@ export function initializeDatadog(trackingConsent: TrackingConsent) {
const config = new CoreConfiguration(
CLIENT_TOKEN,
ENVIRONMENT,
trackingConsent
trackingConsent,
{
applicationId: APPLICATION_ID,
trackInteractions: true,
trackResources: true,
trackErrors: true,
sessionSampleRate: 100,
nativeCrashReportEnabled: true
}
)
config.nativeCrashReportEnabled = true
config.verbosity = SdkVerbosity.DEBUG;
config.service = "com.datadoghq.reactnative.sample"
config.rumConfiguration = new RumConfiguration(APPLICATION_ID, true, true, true);
config.rumConfiguration.sessionSampleRate = 100

DdSdkReactNative.initialize(config).then(() => {
DdLogs.info('The RN Sdk was properly initialized')
Expand Down
38 changes: 17 additions & 21 deletions packages/codepush/src/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,22 +286,21 @@ describe('AppCenter Codepush integration', () => {

const autoInstrumentationConfig = {
rumConfiguration: {
useAccessibilityLabel: true,
actionNameAttribute: 'test-action-name-attr',
trackErrors: true,
trackResources: true,
trackInteractions: true
trackInteractions: true,
resourceTraceSampleRate: 100
},
firstPartyHosts: [
{
match: 'example.com',
propagatorTypes: [PropagatorType.DATADOG]
}
],
useAccessibilityLabel: true,
logsConfiguration: {},
traceConfiguration: {
resourceTraceSampleRate: 100
}
traceConfiguration: {}
};

const configuration = new FileBasedConfiguration({
Expand All @@ -320,27 +319,26 @@ describe('AppCenter Codepush integration', () => {
DdSdkReactNative._enableFeaturesFromDatadogProvider
).toHaveBeenCalledWith({
rumConfiguration: {
useAccessibilityLabel: true,
actionNameAttribute: 'test-action-name-attr',
actionEventMapper: null,
resourceEventMapper: null,
errorEventMapper: null,
trackErrors: true,
trackResources: true,
trackInteractions: true
trackInteractions: true,
resourceTraceSampleRate: 100
},
logsConfiguration: {
logEventMapper: null
},
traceConfiguration: {
resourceTraceSampleRate: 100
},
traceConfiguration: {},
firstPartyHosts: [
{
match: 'example.com',
propagatorTypes: [PropagatorType.DATADOG]
}
],
useAccessibilityLabel: true
]
});

expect(
Expand All @@ -364,10 +362,12 @@ describe('AppCenter Codepush integration', () => {

const autoInstrumentationConfig = {
rumConfiguration: {
useAccessibilityLabel: true,
actionNameAttribute: 'test-action-name-attr',
trackErrors: true,
trackResources: true,
trackInteractions: true
trackInteractions: true,
resourceTraceSampleRate: 100
},
logsConfiguration: {},
firstPartyHosts: [
Expand All @@ -376,10 +376,7 @@ describe('AppCenter Codepush integration', () => {
propagatorTypes: [PropagatorType.DATADOG]
}
],
useAccessibilityLabel: true,
traceConfiguration: {
resourceTraceSampleRate: 100
}
traceConfiguration: {}
};

const configuration = new FileBasedConfiguration({
Expand All @@ -398,13 +395,15 @@ describe('AppCenter Codepush integration', () => {
DdSdkReactNative._enableFeaturesFromDatadogProvider
).toHaveBeenCalledWith({
rumConfiguration: {
useAccessibilityLabel: true,
actionNameAttribute: 'test-action-name-attr',
trackErrors: true,
trackResources: true,
trackInteractions: true,
actionEventMapper: null,
resourceEventMapper: null,
errorEventMapper: null
errorEventMapper: null,
resourceTraceSampleRate: 100
},
logsConfiguration: {
logEventMapper: null
Expand All @@ -415,10 +414,7 @@ describe('AppCenter Codepush integration', () => {
propagatorTypes: [PropagatorType.DATADOG]
}
],
traceConfiguration: {
resourceTraceSampleRate: 100
},
useAccessibilityLabel: true
traceConfiguration: {}
});

expect(
Expand Down
10 changes: 5 additions & 5 deletions packages/codepush/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@ const buildPartialConfiguration = (
configuration: DatadogProviderConfiguration
): AutoInstrumentationConfiguration => {
const partialConfiguration: RequiredOrDiscard<AutoInstrumentationConfiguration> = {
useAccessibilityLabel: configuration.useAccessibilityLabel,
firstPartyHosts: configuration.firstPartyHosts,
rumConfiguration: {
useAccessibilityLabel:
configuration.rumConfiguration?.useAccessibilityLabel ?? true,
actionNameAttribute:
configuration.rumConfiguration?.actionNameAttribute,
trackErrors: configuration.rumConfiguration?.trackErrors ?? false,
trackResources:
configuration.rumConfiguration?.trackResources ?? false,
trackInteractions:
configuration.rumConfiguration?.trackInteractions ?? false,
resourceTraceSampleRate:
configuration.rumConfiguration?.resourceTraceSampleRate,
errorEventMapper: configuration.rumConfiguration?.errorEventMapper,
resourceEventMapper:
configuration.rumConfiguration?.resourceEventMapper,
Expand All @@ -62,10 +65,7 @@ const buildPartialConfiguration = (
logsConfiguration: {
logEventMapper: configuration.logsConfiguration?.logEventMapper
},
traceConfiguration: {
resourceTraceSampleRate:
configuration.traceConfiguration?.resourceTraceSampleRate
}
traceConfiguration: {}
};

return removeDiscardProperties(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import java.net.Proxy
* @param site The Datadog site of your organization (can be 'US', 'EU' or 'GOV', default is 'US').
* @param service Custom service name.
* @param verbosity Verbosity level of the SDK’s internal logging.
* @param nativeCrashReportEnabled Whether the SDK should track native Android crashes (default is false).
* @param nativeLongTaskThresholdMs The threshold for native long tasks reporting in milliseconds.
* @param trackingConsent Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
* @param uploadFrequency The frequency to which batches of data are sent (can be 'RARE', 'AVERAGE' (default), 'FREQUENT')
* @param batchSize The preferred size for uploaded batches of data (can be 'SMALL', 'MEDIUM' (default), 'LARGE')
Expand All @@ -39,8 +37,6 @@ data class DdSdkConfiguration(
val site: String? = null,
val service: String? = null,
val verbosity: String? = null,
val nativeCrashReportEnabled: Boolean? = null,
val nativeLongTaskThresholdMs: Double? = null,
val trackingConsent: String? = null,
val uploadFrequency: String? = null,
val batchSize: String? = null,
Expand All @@ -60,8 +56,11 @@ data class DdSdkConfiguration(
* @param trackFrustrations Whether to track frustration signals or not.
* @param longTaskThresholdMs The threshold for javascript long tasks reporting in milliseconds.
* @param sessionSampleRate The sample rate (between 0 and 100) of RUM sessions kept.
* @param resourceTraceSampleRate Percentage (0–100) of tracing integrations for network calls between your app and your backend.
* @param vitalsUpdateFrequency The frequency to which vitals update are sent (can be 'NEVER', 'RARE', 'AVERAGE' (default), 'FREQUENT').
* @param trackBackgroundEvents Enables/Disables tracking RUM event when no RUM View is active. Might increase number of sessions and billing.
* @param nativeCrashReportEnabled Whether the SDK should track native Android crashes (default is false).
* @param nativeLongTaskThresholdMs The threshold for native long tasks reporting in milliseconds.
* @param nativeViewTracking Enables/Disables tracking RUM Views on the native level.
* @param nativeInteractionTracking Enables/Disables tracking RUM Actions on the native level.
* @param trackNonFatalAnrs Enables tracking of non-fatal ANRs on Android.
Expand All @@ -74,8 +73,11 @@ data class RumConfiguration(
val trackFrustrations: Boolean? = null,
val longTaskThresholdMs: Double? = null,
val sessionSampleRate: Double? = null,
val resourceTraceSampleRate: Double? = null,
val vitalsUpdateFrequency: String? = null,
val trackBackgroundEvents: Boolean? = null,
val nativeCrashReportEnabled: Boolean? = null,
val nativeLongTaskThresholdMs: Double? = null,
val nativeViewTracking: Boolean? = null,
val nativeInteractionTracking: Boolean? = null,
val trackNonFatalAnrs: Boolean? = null,
Expand All @@ -100,12 +102,9 @@ data class LogsConfiguration(
/**
* A configuration object for Datadog Traces (APM) features.
*
* @param resourceTraceSampleRate Percentage (0–100) of tracing integrations for network calls between your app
* and your backend.
* @param customEndpoint Custom Trace intake endpoint used to override the default Datadog intake.
*/
data class TraceConfiguration(
val resourceTraceSampleRate: Double? = null,
val customEndpoint: String? = null
)

Expand All @@ -118,12 +117,9 @@ internal data class JSONDdSdkConfiguration(
val clientToken: String,
val env: String,
val trackingConsent: String? = null,
val useAccessibilityLabel: Boolean? = null,
val additionalConfiguration: Map<String, Any?>? = null,
val batchSize: String? = null,
val batchProcessingLevel: String? = null,
val nativeCrashReportEnabled: Boolean? = null,
val nativeLongTaskThresholdMs: Double? = null, // we treat only numeric in JSON
val proxyConfiguration: JSONProxyConfiguration? = null,
val service: String? = null,
val uploadFrequency: String? = null,
Expand All @@ -139,6 +135,7 @@ internal data class JSONDdSdkConfiguration(

internal data class JSONRumConfiguration(
val applicationId: String? = null,
val useAccessibilityLabel: Boolean? = null,
val trackInteractions: Boolean? = null,
val trackResources: Boolean? = null,
val trackErrors: Boolean? = null,
Expand All @@ -148,10 +145,12 @@ internal data class JSONRumConfiguration(

// schema: integer | boolean, we only support numeric in JSON file
val longTaskThresholdMs: Double? = null,

val nativeCrashReportEnabled: Boolean? = null,
val nativeLongTaskThresholdMs: Double? = null, // we treat only numeric in JSON
val nativeViewTracking: Boolean? = null,
val nativeInteractionTracking: Boolean? = null,
val sessionSampleRate: Double? = null,
val resourceTraceSampleRate: Double? = null,
val trackBackgroundEvents: Boolean? = null,
val trackFrustrations: Boolean? = null,
val trackNonFatalAnrs: Boolean? = null,
Expand All @@ -169,7 +168,6 @@ internal data class JSONLogsConfiguration(
)

internal data class JSONTraceConfiguration(
val resourceTraceSampleRate: Double? = null,
val customEndpoint: String? = null
)

Expand Down
Loading