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
42 changes: 32 additions & 10 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,25 @@ export const getDatadogProviderConfig = () => {
let config = new DatadogProviderConfiguration(
baseConfig.clientToken ?? '',
baseConfig.env ?? '',
TrackingConsent.GRANTED
TrackingConsent.GRANTED,
{
rumConfiguration: {
applicationId: baseConfig.applicationID ?? '',
trackInteractions: true,
trackResources: true,
trackErrors: true,
sessionSampleRate: 100,
nativeCrashReportEnabled: true
},
logsConfiguration: {
bundleLogsWithRum: true,
bundleLogsWithTraces: true,
},
traceConfiguration: {}
}
);
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 +68,25 @@ export const initializeDatadog = (clientToken?: string, environment?: string, ap
const config = new CoreConfiguration(
clientToken ?? '',
environment ?? '',
TrackingConsent.GRANTED
TrackingConsent.GRANTED,
{
rumConfiguration: {
applicationId: appId ?? "",
trackInteractions: true,
trackResources: true,
trackErrors: true,
sessionSampleRate: 100,
nativeCrashReportEnabled: true,
},
logsConfiguration: {
bundleLogsWithRum: true,
bundleLogsWithTraces: true,
},
traceConfiguration: {}
}
);
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
21 changes: 12 additions & 9 deletions example-new-architecture/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
RumActionType,
DdLogs,
DdTrace,
RumConfiguration,
TrackingConsent,
} from '@datadog/mobile-react-native';
import React from 'react';
import type {PropsWithChildren} from 'react';
Expand Down Expand Up @@ -36,18 +36,21 @@ import {APPLICATION_ID, CLIENT_TOKEN, ENVIRONMENT} from './ddCredentials';
const config = new CoreConfiguration(
CLIENT_TOKEN,
ENVIRONMENT,
TrackingConsent.GRANTED,
{
rumConfiguration: {
applicationId: APPLICATION_ID,
trackInteractions: true,
trackResources: true,
trackFrustrations: true,
sessionSampleRate: 100,
telemetrySampleRate: 100
}
}
);
config.verbosity = SdkVerbosity.DEBUG;
config.uploadFrequency = UploadFrequency.FREQUENT;
config.batchSize = BatchSize.SMALL;
config.rumConfiguration = new RumConfiguration(
APPLICATION_ID,
true,
true,
true
)
config.rumConfiguration.sessionSampleRate = 100;
config.rumConfiguration.telemetrySampleRate = 100;

await DdSdkReactNative.initialize(config);
await DdRum.startView('main', 'Main');
Expand Down
1 change: 0 additions & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const configuration = getDatadogConfig(TrackingConsent.GRANTED)
// see https://docs.datadoghq.com/real_user_monitoring/guide/initialize-your-native-sdk-before-react-native-starts

// const configuration = new DatadogProviderConfiguration("fake_value", "fake_value");
// configuration.rumConfiguration = new RumConfiguration("fake_value")

export default function App() {

Expand Down
49 changes: 40 additions & 9 deletions example/src/ddUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,49 @@ import {
DdLogs,
DdSdkReactNative,
CoreConfiguration,
RumConfiguration,
SdkVerbosity,
TrackingConsent
TrackingConsent,
BatchSize,
UploadFrequency,
} from '@datadog/mobile-react-native';

import {APPLICATION_ID, CLIENT_TOKEN, ENVIRONMENT} from './ddCredentials';
import { BatchProcessingLevel } from '@datadog/mobile-react-native/src/config/types';

// New SDK Setup - not available for react-native-navigation
export function getDatadogConfig(trackingConsent: TrackingConsent) {
const config = new DatadogProviderConfiguration(
CLIENT_TOKEN,
ENVIRONMENT,
trackingConsent,
{
batchSize: BatchSize.SMALL,
uploadFrequency: UploadFrequency.FREQUENT,
batchProcessingLevel: BatchProcessingLevel.MEDIUM,
additionalConfiguration: {
customProperty: "sdk-example-app"
},
rumConfiguration: {
applicationId: APPLICATION_ID,
trackInteractions: true,
trackResources: true,
trackErrors: true,
sessionSampleRate: 100,
nativeCrashReportEnabled: true
},
logsConfiguration: {
logEventMapper: (logEvent) => {
logEvent.message = `[CUSTOM] ${logEvent.message}`;
return logEvent;
}
},
traceConfiguration: {}
}
);

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 +61,21 @@ export function initializeDatadog(trackingConsent: TrackingConsent) {
const config = new CoreConfiguration(
CLIENT_TOKEN,
ENVIRONMENT,
trackingConsent
trackingConsent,
{
rumConfiguration: {
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
1 change: 0 additions & 1 deletion example/src/screens/MainScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { APPLICATION_KEY, API_KEY } from '../../src/ddCredentials';
import { DdLogs, DdSdkReactNative, TrackingConsent } from '@datadog/mobile-react-native';
import { getTrackingConsent, saveTrackingConsent } from '../utils';
import { ConsentModal } from '../components/consent';
import { DdRum } from '../../../packages/core/src/rum/DdRum';

const axios = require('../axiosConfig');

Expand Down
116 changes: 52 additions & 64 deletions packages/codepush/src/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jest.mock('@datadog/mobile-react-native', () => {
const flushPromises = () =>
new Promise(jest.requireActual('timers').setImmediate);

const createCodepushPackageMock = label => ({
const createCodepushPackageMock = (label: string | null) => ({
label,
isMandatory: false,
install: jest.fn(),
Expand Down Expand Up @@ -285,23 +285,28 @@ describe('AppCenter Codepush integration', () => {
} = require('@datadog/mobile-react-native');

const autoInstrumentationConfig = {
clientToken: 'fake-client-token',
env: 'fake-env',
rumConfiguration: {
applicationId: 'fake-app-id',
useAccessibilityLabel: true,
actionNameAttribute: 'test-action-name-attr',
trackErrors: true,
trackResources: true,
trackInteractions: true
trackInteractions: true,
resourceTraceSampleRate: 100,
nativeCrashReportEnabled: true,
nativeLongTaskThresholdMs: false,
nativeViewTracking: true,
firstPartyHosts: [
{
match: 'example.com',
propagatorTypes: [PropagatorType.DATADOG]
}
]
},
firstPartyHosts: [
{
match: 'example.com',
propagatorTypes: [PropagatorType.DATADOG]
}
],
useAccessibilityLabel: true,
logsConfiguration: {},
traceConfiguration: {
resourceTraceSampleRate: 100
}
traceConfiguration: {}
};

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

expect(
Expand All @@ -358,27 +364,14 @@ describe('AppCenter Codepush integration', () => {
const { DatadogCodepushProvider } = require('..');
const {
DdSdkReactNative,
PropagatorType,
FileBasedConfiguration
} = require('@datadog/mobile-react-native');

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

Expand All @@ -396,30 +389,25 @@ describe('AppCenter Codepush integration', () => {
});
expect(
DdSdkReactNative._enableFeaturesFromDatadogProvider
).toHaveBeenCalledWith({
rumConfiguration: {
actionNameAttribute: 'test-action-name-attr',
trackErrors: true,
trackResources: true,
trackInteractions: true,
actionEventMapper: null,
resourceEventMapper: null,
errorEventMapper: null
},
logsConfiguration: {
logEventMapper: null
},
firstPartyHosts: [
{
match: 'example.com',
propagatorTypes: [PropagatorType.DATADOG]
}
],
traceConfiguration: {
resourceTraceSampleRate: 100
},
useAccessibilityLabel: true
});
).toHaveBeenCalledWith(
expect.objectContaining({
rumConfiguration: expect.objectContaining({
useAccessibilityLabel: true,
actionNameAttribute: undefined,
trackErrors: false,
trackResources: false,
trackInteractions: false,
actionEventMapper: null,
resourceEventMapper: null,
errorEventMapper: null,
resourceTraceSampleRate: 100,
firstPartyHosts: []
}),
logsConfiguration: expect.objectContaining({
logEventMapper: null
})
})
);

expect(
DdSdkReactNative._enableFeaturesFromDatadogProvider
Expand Down
Loading