Skip to content

Commit

Permalink
Disable analytics on CI (#3929)
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev authored Sep 1, 2021
1 parent 64736ee commit aadefa3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ x.x.x Release notes (yyyy-MM-dd)
* <Either mention core version or upgrade>
* <Using Realm Core vX.Y.Z>
* <Upgraded Realm Core from vX.Y.Z to vA.B.C>
* Disable analytics if the `CI` environment variable is set to some value.

10.7.0 Release notes (2021-8-30)
=============================================================
Expand Down
4 changes: 2 additions & 2 deletions lib/submit-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ function isAnalyticsDisabled() {
// ignore error
}

// Or if the user has specifically opted-out
return "REALM_DISABLE_ANALYTICS" in process.env;
// If the user has specifically opted-out or if we're running in a CI environment
return "REALM_DISABLE_ANALYTICS" in process.env || "CI" in process.env;
}

function sha256(data) {
Expand Down
5 changes: 3 additions & 2 deletions react-native/android/analytics.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ class SendAnalyticsTask extends DefaultTask {
def sendAnalytics() {
try {
def env = System.getenv()
def disableAnalytics= env['REALM_DISABLE_ANALYTICS']
if (disableAnalytics == null || disableAnalytics != "true") {
def disableAnalytics = env['REALM_DISABLE_ANALYTICS'] != null
def isCI = env['CI'] != null
if (!disableAnalytics && !isCI) {
send()
}
} catch(all) {}
Expand Down
2 changes: 1 addition & 1 deletion react-native/ios/RealmReact/RealmAnalytics.mm
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static bool RLMIsDebuggerAttached() {
}

void RLMSendAnalytics() {
if (getenv("REALM_DISABLE_ANALYTICS") || !RLMIsDebuggerAttached()) {
if (getenv("REALM_DISABLE_ANALYTICS") || getenv("CI") || !RLMIsDebuggerAttached()) {
return;
}

Expand Down

0 comments on commit aadefa3

Please sign in to comment.