From e74063f6fdb8e1d3e05e6cc309ff62cc9b942533 Mon Sep 17 00:00:00 2001
From: Vladimir <70273239+vladimir-8@users.noreply.github.com>
Date: Mon, 12 Aug 2024 16:53:59 -0700
Subject: [PATCH 1/5] added: datadog
---
.env.dist | 2 +
ios/Podfile.lock | 47 +++++++++++++++++
package.json | 2 +
src/App.js | 70 ++++++++++++------------
src/Datadog.js | 135 +++++++++++++++++++++++++++++++++++++++++++++++
yarn.lock | 10 ++++
6 files changed, 233 insertions(+), 33 deletions(-)
create mode 100644 src/Datadog.js
diff --git a/.env.dist b/.env.dist
index 1f2ec0812..ebb2516b6 100644
--- a/.env.dist
+++ b/.env.dist
@@ -12,3 +12,5 @@ DEFAULT_SERVER=
PRIMARY_COLOR=
SMARTLOOK_PROJECT_KEY=
DEBUG_REDUX_LOGGER_LEVEL=log
+DATADOG_CLIENT_TOKEN=
+DATADOG_APPLICATION_ID=
diff --git a/ios/Podfile.lock b/ios/Podfile.lock
index 6936035c1..8f92e728e 100644
--- a/ios/Podfile.lock
+++ b/ios/Podfile.lock
@@ -14,6 +14,29 @@ PODS:
- React
- CountlyReactNative/NotificationService (22.06.1):
- React
+ - DatadogCore (2.14.2):
+ - DatadogInternal (= 2.14.2)
+ - DatadogCrashReporting (2.14.2):
+ - DatadogInternal (= 2.14.2)
+ - PLCrashReporter (~> 1.11.2)
+ - DatadogInternal (2.14.2)
+ - DatadogLogs (2.14.2):
+ - DatadogInternal (= 2.14.2)
+ - DatadogRUM (2.14.2):
+ - DatadogInternal (= 2.14.2)
+ - DatadogSDKReactNative (2.4.3):
+ - DatadogCore (~> 2.14.1)
+ - DatadogCrashReporting (~> 2.14.1)
+ - DatadogLogs (~> 2.14.1)
+ - DatadogRUM (~> 2.14.1)
+ - DatadogTrace (~> 2.14.1)
+ - DatadogWebViewTracking (~> 2.14.1)
+ - React-Core
+ - DatadogTrace (2.14.2):
+ - DatadogInternal (= 2.14.2)
+ - OpenTelemetrySwiftApi (= 1.6.0)
+ - DatadogWebViewTracking (2.14.2):
+ - DatadogInternal (= 2.14.2)
- DoubleConversion (1.1.6)
- EXConstants (15.4.5):
- ExpoModulesCore
@@ -191,6 +214,8 @@ PODS:
- nanopb/encode (= 2.30909.1)
- nanopb/decode (2.30909.1)
- nanopb/encode (2.30909.1)
+ - OpenTelemetrySwiftApi (1.6.0)
+ - PLCrashReporter (1.11.2)
- PromisesObjC (2.4.0)
- PromisesSwift (2.4.0):
- PromisesObjC (= 2.4.0)
@@ -1401,6 +1426,7 @@ PODS:
DEPENDENCIES:
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
- CountlyReactNative (from `../node_modules/countly-sdk-react-native-bridge`)
+ - "DatadogSDKReactNative (from `../node_modules/@datadog/mobile-react-native`)"
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- EXConstants (from `../node_modules/expo-constants/ios`)
- EXFont (from `../node_modules/expo-font/ios`)
@@ -1501,6 +1527,13 @@ SPEC REPOS:
trunk:
- AppAuth
- CocoaLumberjack
+ - DatadogCore
+ - DatadogCrashReporting
+ - DatadogInternal
+ - DatadogLogs
+ - DatadogRUM
+ - DatadogTrace
+ - DatadogWebViewTracking
- FBAEMKit
- FBSDKCoreKit
- FBSDKCoreKit_Basics
@@ -1525,6 +1558,8 @@ SPEC REPOS:
- IQKeyboardManagerSwift
- libevent
- nanopb
+ - OpenTelemetrySwiftApi
+ - PLCrashReporter
- PromisesObjC
- PromisesSwift
- Sentry
@@ -1545,6 +1580,8 @@ EXTERNAL SOURCES:
:podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec"
CountlyReactNative:
:path: "../node_modules/countly-sdk-react-native-bridge"
+ DatadogSDKReactNative:
+ :path: "../node_modules/@datadog/mobile-react-native"
DoubleConversion:
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
EXConstants:
@@ -1734,6 +1771,14 @@ SPEC CHECKSUMS:
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
CocoaLumberjack: 543c79c114dadc3b1aba95641d8738b06b05b646
CountlyReactNative: f544f34347bc635e2951e2797d4750e66f886a09
+ DatadogCore: a3429f62b7da0e715e179833b3daa0203ba2a5ad
+ DatadogCrashReporting: 3b5e496c1f61971a93b9a1bff3312297be03f031
+ DatadogInternal: 11798eea970f195ad720168f9a51712e71affe33
+ DatadogLogs: 4192cc1979467ce0c2521d73ba92b6197e0c7f06
+ DatadogRUM: f732009eba7a848d6e2df9ef12944e30f0e94ba2
+ DatadogSDKReactNative: f418f95923dc78ad7b4dcd1710804f1672d8abfa
+ DatadogTrace: 5687191622d91152f10616e206500fe5acd8a342
+ DatadogWebViewTracking: cb818ee5943de63940b4f536320361c17af0f7b1
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
EXConstants: 988aa430ca0f76b43cd46b66e7fae3287f9cc2fc
EXFont: f20669cb266ef48b004f1eb1f2b20db96cd1df9f
@@ -1771,6 +1816,8 @@ SPEC CHECKSUMS:
IQKeyboardManagerSwift: 12d89768845bb77b55cc092ecc2b1f9370f06b76
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
+ OpenTelemetrySwiftApi: 657da8071c2908caecce11548e006f779924ff9c
+ PLCrashReporter: 499c53b0104f95c302d94fd723ebb03c56d9bac8
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0
diff --git a/package.json b/package.json
index 254d2074c..dd959e653 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,8 @@
},
"dependencies": {
"@babel/helper-get-function-arity": "^7.16.7",
+ "@datadog/mobile-react-native": "^2.4.3",
+ "@datadog/mobile-react-navigation": "^2.4.3",
"@heasy/react-native-sunmi-printer": "git+https://github.com/Surile/react-native-sunmi-printer.git#666f6f76ce737faf7a500b88a08ad10da68c5967",
"@invertase/react-native-apple-authentication": "^2.2.2",
"@mapbox/polyline": "^1.1.1",
diff --git a/src/App.js b/src/App.js
index 7ba03c0d2..29e46a097 100644
--- a/src/App.js
+++ b/src/App.js
@@ -61,6 +61,7 @@ import {
AccountResetPasswordNewPasswordScreen,
} from './navigation/navigators/AccountNavigator';
import { nativeBaseTheme } from './styles/theme';
+import { DatadogWrapper, navigationContainerOnReady } from './Datadog';
LogBox.ignoreLogs([
'Warning: isMounted(...) is deprecated in plain JavaScript React classes.',
@@ -86,6 +87,7 @@ function getCurrentRouteName() {
function onReady() {
routeNameRef.current = getCurrentRouteName();
+ navigationContainerOnReady(navigationRef);
}
/**
@@ -143,39 +145,41 @@ const App = () => {
}, []);
return (
-
-
-
-
- }
- persistor={persistor}>
-
-
-
-
-
-
-
- {
- DropdownHolder.setDropdown(ref);
- }}
- />
-
-
-
-
-
-
-
-
+
+
+
+
+
+ }
+ persistor={persistor}>
+
+
+
+
+
+
+
+ {
+ DropdownHolder.setDropdown(ref);
+ }}
+ />
+
+
+
+
+
+
+
+
+
);
};
diff --git a/src/Datadog.js b/src/Datadog.js
new file mode 100644
index 000000000..3ec13723a
--- /dev/null
+++ b/src/Datadog.js
@@ -0,0 +1,135 @@
+import React from 'react';
+import {
+ BatchSize,
+ DatadogProvider,
+ DatadogProviderConfiguration, DdLogs,
+ SdkVerbosity,
+ UploadFrequency,
+} from '@datadog/mobile-react-native'
+import Config from 'react-native-config';
+import { DdRumReactNavigationTracking } from '@datadog/mobile-react-navigation'
+
+// Enable Datadog only in production, change to true to test locally
+const enabled = !__DEV__
+
+const clientToken = Config.DATADOG_CLIENT_TOKEN;
+if (enabled && !clientToken) {
+ throw new Error('DATADOG_CLIENT_TOKEN is required');
+}
+
+const applicationId = Config.DATADOG_APPLICATION_ID;
+if (enabled && !applicationId) {
+ throw new Error('DATADOG_APPLICATION_ID is required');
+}
+
+const datadogConfig = new DatadogProviderConfiguration(
+ clientToken,
+ __DEV__ ? 'dev' : 'prod',
+ applicationId,
+ true, // track User interactions (e.g.: Tap on buttons. You can use 'accessibilityLabel' element property to give tap action the name, otherwise element type will be reported)
+ true, // track XHR Resources
+ true, // track Errors
+);
+// Optional: Select your Datadog website (one of "US1", "EU1", "US3", "US5", "AP1" or "GOV")
+datadogConfig.site = 'US1';
+// Optional: Enable JavaScript long task collection
+datadogConfig.longTaskThresholdMs = 100;
+// Optional: enable or disable native crash reports
+datadogConfig.nativeCrashReportEnabled = true;
+// Optional: Sample RUM sessions (% of session are sent to Datadog. Default is 100%).
+datadogConfig.sessionSamplingRate = __DEV__ ? 100 : 50;
+// Optional: Sample tracing integrations for network calls between your app and your backend (% of calls to your instrumented backend are linked from the RUM view to the APM view. Default is 20%)
+// You need to specify the hosts of your backends to enable tracing with these backends
+datadogConfig.resourceTracingSamplingRate = __DEV__ ? 100 : 50;
+datadogConfig.telemetrySampleRate = 0;
+datadogConfig.firstPartyHosts = ['coopcycle.org']; // matches 'example.com' and subdomains like 'api.example.com'
+// Optional: let the SDK print internal logs above or equal to the provided level. Default is undefined (meaning no logs)
+datadogConfig.verbosity = __DEV__ ? SdkVerbosity.DEBUG : SdkVerbosity.WARN;
+
+if (__DEV__) {
+ // Optional: Send data more frequently
+ datadogConfig.uploadFrequency = UploadFrequency.FREQUENT;
+ // Optional: Send smaller batches of data
+ datadogConfig.batchSize = BatchSize.SMALL;
+}
+
+export function DatadogWrapper({ children }) {
+ if (!enabled) {
+ return <>{children}>;
+ }
+
+ return (
+ {children}
+ );
+}
+
+const viewNamePredicate = function customViewNamePredicate(route, trackedName) {
+ // return custom view name or null to use the previous RUM view
+ return trackedName
+}
+
+export function navigationContainerOnReady(navigationRef) {
+ if (!enabled) {
+ return;
+ }
+
+ DdRumReactNavigationTracking.startTrackingViews(navigationRef.current, viewNamePredicate)
+}
+
+export const DatadogLogger = {
+ /**
+ * Send a log with debug level.
+ * @param message: The message to send.
+ * @param context: The additional context to send.
+ */
+ debug(message, context) {
+ if (!enabled) {
+ console.debug(message, context);
+ return;
+ }
+
+ DdLogs.debug(message, context)
+ },
+
+ /**
+ * Send a log with info level.
+ * @param message: The message to send.
+ * @param context: The additional context to send.
+ */
+ info(message, context) {
+ if (!enabled) {
+ console.info(message, context);
+ return;
+ }
+
+ DdLogs.info(message, context)
+ },
+
+ /**
+ * Send a log with warn level.
+ * @param message: The message to send.
+ * @param context: The additional context to send.
+ */
+ warn(message, context) {
+ if (!enabled) {
+ console.warn(message, context);
+ return;
+ }
+
+ DdLogs.warn(message, context)
+ },
+
+ /**
+ * Send a log with error level.
+ * @param message: The message to send.
+ * @param context: The additional context to send.
+ */
+ error(message, context) {
+ if (!enabled) {
+ console.error(message, context);
+ return;
+ }
+
+ DdLogs.error(message, context)
+ }
+};
diff --git a/yarn.lock b/yarn.lock
index 815d116f1..cf47c8675 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1917,6 +1917,16 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
+"@datadog/mobile-react-native@^2.4.3":
+ version "2.4.3"
+ resolved "https://registry.yarnpkg.com/@datadog/mobile-react-native/-/mobile-react-native-2.4.3.tgz#4e0e1d046b8e98d790a91de289264c5b9039d305"
+ integrity sha512-po+R7JKiFkTS65vWKwfIWAn+aQuWdxeU61C5wc1YYtXVVBpNDCPs3qbDXxQmxJMDxMcjyDnYC0F0tO2EXS62yQ==
+
+"@datadog/mobile-react-navigation@^2.4.3":
+ version "2.4.3"
+ resolved "https://registry.yarnpkg.com/@datadog/mobile-react-navigation/-/mobile-react-navigation-2.4.3.tgz#0008d5ae70ad892c2e587382baaa51d05e0eefc0"
+ integrity sha512-DcT8GQ2Ne1F5ryR7oM7jaKYn8pJ8r5r1BwbbqnKVkvxNAA2W4HDXn54u2C8ShuYhKs3STIjOo1zCDNxvSRsrgg==
+
"@egjs/hammerjs@^2.0.17":
version "2.0.17"
resolved "https://registry.yarnpkg.com/@egjs/hammerjs/-/hammerjs-2.0.17.tgz#5dc02af75a6a06e4c2db0202cae38c9263895124"
From 33ca41b167161e686b57293e5514dead13ab164a Mon Sep 17 00:00:00 2001
From: Vladimir <70273239+vladimir-8@users.noreply.github.com>
Date: Tue, 13 Aug 2024 09:40:55 -0700
Subject: [PATCH 2/5] updated: sample rate
---
src/Datadog.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Datadog.js b/src/Datadog.js
index 3ec13723a..078682634 100644
--- a/src/Datadog.js
+++ b/src/Datadog.js
@@ -37,10 +37,10 @@ datadogConfig.longTaskThresholdMs = 100;
// Optional: enable or disable native crash reports
datadogConfig.nativeCrashReportEnabled = true;
// Optional: Sample RUM sessions (% of session are sent to Datadog. Default is 100%).
-datadogConfig.sessionSamplingRate = __DEV__ ? 100 : 50;
+datadogConfig.sessionSamplingRate = __DEV__ ? 100 : 20;
// Optional: Sample tracing integrations for network calls between your app and your backend (% of calls to your instrumented backend are linked from the RUM view to the APM view. Default is 20%)
// You need to specify the hosts of your backends to enable tracing with these backends
-datadogConfig.resourceTracingSamplingRate = __DEV__ ? 100 : 50;
+datadogConfig.resourceTracingSamplingRate = __DEV__ ? 100 : 20;
datadogConfig.telemetrySampleRate = 0;
datadogConfig.firstPartyHosts = ['coopcycle.org']; // matches 'example.com' and subdomains like 'api.example.com'
// Optional: let the SDK print internal logs above or equal to the provided level. Default is undefined (meaning no logs)
From ff33f55c558717f0d9484ceff67671a575aed334 Mon Sep 17 00:00:00 2001
From: Vladimir <70273239+vladimir-8@users.noreply.github.com>
Date: Tue, 13 Aug 2024 11:26:22 -0700
Subject: [PATCH 3/5] added: instance_url and user roles to logs
---
src/Datadog.js | 47 ++++++++++++++++++++++++++++++----------
src/redux/App/actions.js | 35 ++++++++++++++++--------------
2 files changed, 55 insertions(+), 27 deletions(-)
diff --git a/src/Datadog.js b/src/Datadog.js
index 078682634..1bf1295ea 100644
--- a/src/Datadog.js
+++ b/src/Datadog.js
@@ -2,12 +2,14 @@ import React from 'react';
import {
BatchSize,
DatadogProvider,
- DatadogProviderConfiguration, DdLogs,
+ DatadogProviderConfiguration,
+ DdLogs,
+ DdSdkReactNative,
SdkVerbosity,
UploadFrequency,
-} from '@datadog/mobile-react-native'
+} from '@datadog/mobile-react-native';
import Config from 'react-native-config';
-import { DdRumReactNavigationTracking } from '@datadog/mobile-react-navigation'
+import { DdRumReactNavigationTracking } from '@datadog/mobile-react-navigation';
// Enable Datadog only in production, change to true to test locally
const enabled = !__DEV__
@@ -65,17 +67,40 @@ export function DatadogWrapper({ children }) {
const viewNamePredicate = function customViewNamePredicate(route, trackedName) {
// return custom view name or null to use the previous RUM view
- return trackedName
-}
+ return trackedName;
+};
export function navigationContainerOnReady(navigationRef) {
if (!enabled) {
return;
}
- DdRumReactNavigationTracking.startTrackingViews(navigationRef.current, viewNamePredicate)
+ DdRumReactNavigationTracking.startTrackingViews(
+ navigationRef.current,
+ viewNamePredicate,
+ );
}
+export const DatadogSdk = {
+ setAttributes(attributes) {
+ if (!enabled) {
+ console.debug('(disabled) DatadogSdk.setAttributes', attributes);
+ return;
+ }
+
+ DdSdkReactNative.setAttributes(attributes);
+ },
+
+ setUser(user) {
+ if (!enabled) {
+ console.debug('(disabled) DatadogSdk.setUser', user);
+ return;
+ }
+
+ DdSdkReactNative.setUser(user);
+ },
+};
+
export const DatadogLogger = {
/**
* Send a log with debug level.
@@ -88,7 +113,7 @@ export const DatadogLogger = {
return;
}
- DdLogs.debug(message, context)
+ DdLogs.debug(message, context);
},
/**
@@ -102,7 +127,7 @@ export const DatadogLogger = {
return;
}
- DdLogs.info(message, context)
+ DdLogs.info(message, context);
},
/**
@@ -116,7 +141,7 @@ export const DatadogLogger = {
return;
}
- DdLogs.warn(message, context)
+ DdLogs.warn(message, context);
},
/**
@@ -130,6 +155,6 @@ export const DatadogLogger = {
return;
}
- DdLogs.error(message, context)
- }
+ DdLogs.error(message, context);
+ },
};
diff --git a/src/redux/App/actions.js b/src/redux/App/actions.js
index 8330b83d3..144f886da 100644
--- a/src/redux/App/actions.js
+++ b/src/redux/App/actions.js
@@ -25,6 +25,7 @@ import {
selectIsAuthenticated,
selectResumeCheckoutAfterActivation,
} from './selectors';
+import { DatadogSdk } from '../../Datadog'
/*
* Action Types
@@ -221,6 +222,9 @@ export const stopSound = createAction('STOP_SOUND');
function setBaseURL(baseURL) {
return (dispatch, getState) => {
dispatch(_setBaseURL(baseURL));
+ DatadogSdk.setAttributes({
+ 'instance_url': baseURL,
+ })
tracker.setUserProperty(userProperty.server, baseURL);
};
}
@@ -241,7 +245,7 @@ function authenticationSuccess(user) {
await dispatch(loadAddresses());
await dispatch(assignAllCarts());
- setRolesProperty(user);
+ updateUserProperties(user);
tracker.logEvent(
analyticsEvent.user.login._category,
analyticsEvent.user.login.success,
@@ -265,28 +269,27 @@ function logoutSuccess() {
return (dispatch, getState) => {
dispatch(_logoutSuccess());
dispatch(updateCarts({}));
- setRolesProperty(null);
+ updateUserProperties(null);
};
}
-function setRolesProperty(user) {
+function updateUserProperties(user) {
let roles;
- if (user !== null && user.roles !== null) {
- roles = user.roles.slice();
- roles.sort();
- } else {
- roles = [];
- }
-
- if (user) {
- if (roles.length > 0) {
- tracker.setUserProperty(userProperty.roles, roles.toString());
+ if (user !== null && user.username !== null) {
+ if (user.roles !== null) {
+ roles = user.roles.slice();
+ roles.sort();
} else {
- tracker.setUserProperty(userProperty.roles, 'ROLE_USER');
+ roles = ['ROLE_USER'];
}
} else {
- tracker.setUserProperty(userProperty.roles, 'ROLE_AD_HOC_CUSTOMER');
+ roles = ['ROLE_AD_HOC_CUSTOMER'];
}
+
+ DatadogSdk.setUser({
+ roles: roles.toString(),
+ })
+ tracker.setUserProperty(userProperty.roles, roles.toString());
}
function navigateToHome(dispatch, getState) {
@@ -409,7 +412,7 @@ export function bootstrap(baseURL, user, loader = true) {
dispatch(setUser(user));
dispatch(setBaseURL(baseURL));
- setRolesProperty(user);
+ updateUserProperties(user);
const httpClient = getState().app.httpClient;
From 88bcff4fd5d65ef31f669a1eaeb69b783e576ff9 Mon Sep 17 00:00:00 2001
From: Vladimir <70273239+vladimir-8@users.noreply.github.com>
Date: Tue, 13 Aug 2024 11:36:46 -0700
Subject: [PATCH 4/5] read datadog credentials from secrets
---
.github/workflows/fastlane_android.yml | 4 ++++
.github/workflows/fastlane_ios.yml | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/.github/workflows/fastlane_android.yml b/.github/workflows/fastlane_android.yml
index 336c143d5..c16b93078 100644
--- a/.github/workflows/fastlane_android.yml
+++ b/.github/workflows/fastlane_android.yml
@@ -89,6 +89,8 @@ jobs:
- name: Create .env file
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
+ DATADOG_CLIENT_TOKEN: ${{ secrets.DATADOG_CLIENT_TOKEN }}
+ DATADOG_APPLICATION_ID: ${{ secrets.DATADOG_APPLICATION_ID }}
GOOGLE_MAPS_BROWSER_KEY: ${{ secrets.GOOGLE_MAPS_BROWSER_KEY }}
GOOGLE_MAPS_ANDROID_KEY: ${{ secrets.GOOGLE_MAPS_ANDROID_KEY }}
TRANSISTORSOFT_LICENSE_KEY: ${{ secrets.TRANSISTORSOFT_LICENSE_KEY }}
@@ -104,6 +106,8 @@ jobs:
echo COUNTLY_APP_KEY= >> .env
echo COUNTLY_SALT= >> .env
echo SENTRY_DSN="$SENTRY_DSN" >> .env
+ echo DATADOG_CLIENT_TOKEN="$DATADOG_CLIENT_TOKEN" >> .env
+ echo DATADOG_APPLICATION_ID="$DATADOG_APPLICATION_ID" >> .env
echo GOOGLE_MAPS_BROWSER_KEY="$GOOGLE_MAPS_BROWSER_KEY" >> .env
echo GOOGLE_MAPS_ANDROID_KEY="$GOOGLE_MAPS_ANDROID_KEY" >> .env
echo TRANSISTORSOFT_LICENSE_KEY="$TRANSISTORSOFT_LICENSE_KEY" >> .env
diff --git a/.github/workflows/fastlane_ios.yml b/.github/workflows/fastlane_ios.yml
index 6a664049c..f32c46d8a 100644
--- a/.github/workflows/fastlane_ios.yml
+++ b/.github/workflows/fastlane_ios.yml
@@ -83,6 +83,8 @@ jobs:
- name: Create .env file
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
+ DATADOG_CLIENT_TOKEN: ${{ secrets.DATADOG_CLIENT_TOKEN }}
+ DATADOG_APPLICATION_ID: ${{ secrets.DATADOG_APPLICATION_ID }}
GOOGLE_MAPS_BROWSER_KEY: ${{ secrets.GOOGLE_MAPS_BROWSER_KEY }}
GOOGLE_MAPS_ANDROID_KEY: ${{ secrets.GOOGLE_MAPS_ANDROID_KEY }}
TRANSISTORSOFT_LICENSE_KEY: ${{ secrets.TRANSISTORSOFT_LICENSE_KEY }}
@@ -97,6 +99,8 @@ jobs:
echo COUNTLY_APP_KEY= >> .env
echo COUNTLY_SALT= >> .env
echo SENTRY_DSN="$SENTRY_DSN" >> .env
+ echo DATADOG_CLIENT_TOKEN="$DATADOG_CLIENT_TOKEN" >> .env
+ echo DATADOG_APPLICATION_ID="$DATADOG_APPLICATION_ID" >> .env
echo GOOGLE_MAPS_BROWSER_KEY="$GOOGLE_MAPS_BROWSER_KEY" >> .env
echo GOOGLE_MAPS_ANDROID_KEY="$GOOGLE_MAPS_ANDROID_KEY" >> .env
echo TRANSISTORSOFT_LICENSE_KEY="$TRANSISTORSOFT_LICENSE_KEY" >> .env
From 3f7007be648cdf190b65a3b3a6a15aaf8bead5f0 Mon Sep 17 00:00:00 2001
From: Vladimir <70273239+vladimir-8@users.noreply.github.com>
Date: Tue, 13 Aug 2024 11:47:04 -0700
Subject: [PATCH 5/5] enable/disable datadog via env vars
---
.env.dist | 1 +
.github/workflows/fastlane_android.yml | 1 +
.github/workflows/fastlane_ios.yml | 1 +
src/Datadog.js | 3 +--
4 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/.env.dist b/.env.dist
index ebb2516b6..fd9c8e30a 100644
--- a/.env.dist
+++ b/.env.dist
@@ -12,5 +12,6 @@ DEFAULT_SERVER=
PRIMARY_COLOR=
SMARTLOOK_PROJECT_KEY=
DEBUG_REDUX_LOGGER_LEVEL=log
+DATADOG_ENABLED=0
DATADOG_CLIENT_TOKEN=
DATADOG_APPLICATION_ID=
diff --git a/.github/workflows/fastlane_android.yml b/.github/workflows/fastlane_android.yml
index c16b93078..541472939 100644
--- a/.github/workflows/fastlane_android.yml
+++ b/.github/workflows/fastlane_android.yml
@@ -106,6 +106,7 @@ jobs:
echo COUNTLY_APP_KEY= >> .env
echo COUNTLY_SALT= >> .env
echo SENTRY_DSN="$SENTRY_DSN" >> .env
+ echo DATADOG_ENABLED="1" >> .env
echo DATADOG_CLIENT_TOKEN="$DATADOG_CLIENT_TOKEN" >> .env
echo DATADOG_APPLICATION_ID="$DATADOG_APPLICATION_ID" >> .env
echo GOOGLE_MAPS_BROWSER_KEY="$GOOGLE_MAPS_BROWSER_KEY" >> .env
diff --git a/.github/workflows/fastlane_ios.yml b/.github/workflows/fastlane_ios.yml
index f32c46d8a..5e6c46c26 100644
--- a/.github/workflows/fastlane_ios.yml
+++ b/.github/workflows/fastlane_ios.yml
@@ -99,6 +99,7 @@ jobs:
echo COUNTLY_APP_KEY= >> .env
echo COUNTLY_SALT= >> .env
echo SENTRY_DSN="$SENTRY_DSN" >> .env
+ echo DATADOG_ENABLED="1" >> .env
echo DATADOG_CLIENT_TOKEN="$DATADOG_CLIENT_TOKEN" >> .env
echo DATADOG_APPLICATION_ID="$DATADOG_APPLICATION_ID" >> .env
echo GOOGLE_MAPS_BROWSER_KEY="$GOOGLE_MAPS_BROWSER_KEY" >> .env
diff --git a/src/Datadog.js b/src/Datadog.js
index 1bf1295ea..9463f28d9 100644
--- a/src/Datadog.js
+++ b/src/Datadog.js
@@ -11,8 +11,7 @@ import {
import Config from 'react-native-config';
import { DdRumReactNavigationTracking } from '@datadog/mobile-react-navigation';
-// Enable Datadog only in production, change to true to test locally
-const enabled = !__DEV__
+const enabled = Config.DATADOG_ENABLED === '1';
const clientToken = Config.DATADOG_CLIENT_TOKEN;
if (enabled && !clientToken) {