-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable analytics on CI #3929
Disable analytics on CI #3929
Conversation
def disableAnalytics = env['REALM_DISABLE_ANALYTICS'] != null | ||
def isCI = env['CI'] != null | ||
if (!disableAnalytics && !isCI) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would have the unfortunate side-effect of disabling analytics when REALM_DISABLE_ANALYTICS=false
which does not match the semantics that the previous implementation.
I don't know how we document this environment variable, but I just wanted to make it obvious.
Is this what you meant to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It matches the semantics for iOS and Node/Electron so it made sense to align on all platforms:
realm-js/lib/submit-analytics.js
Line 99 in 48144ae
return "REALM_DISABLE_ANALYTICS" in process.env; |
if (getenv("REALM_DISABLE_ANALYTICS") || !RLMIsDebuggerAttached()) { |
I feel like just setting REALM_DISABLE_ANALYTICS
to any value should stop analytics submission. For example, realm-js's own CI workflow sets REALM_DISABLE_ANALYTICS
to 1
rather than true
, and I assume many users might feel these are interchangeable. Rather than special-case truthy and falsy values, it's more straightforward to just check for existence. If a user wants to enable analytics, they should just not set the environment variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the integration tests, we have https://github.com/realm/realm-js/blob/master/.github/workflows/integration-tests.yml#L4 (REALM_DISABLE_ANALYTICS
is not null
).
Moreover, we should set REALM_DISABLE_ANATYTICS
for all test runner in Jenkinsfile
(as we do for MacOS: https://github.com/realm/realm-js/blob/master/Jenkinsfile#L486).
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def disableAnalytics = env['REALM_DISABLE_ANALYTICS'] != null | |
def disableAnalytics = env['REALM_DISABLE_ANALYTICS'] != null || env['REALM_DISABLE_ANALYTICS'] == "true" || env['REALM_DISABLE_ANALYTICS'] == "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!= null
is already stronger than == true
. If REALM_DISABLE_ANALYTICS
is set to true
, then it won't be null.
def disableAnalytics= env['REALM_DISABLE_ANALYTICS'] | ||
if (disableAnalytics == null || disableAnalytics != "true") { | ||
def disableAnalytics = env['REALM_DISABLE_ANALYTICS'] != null | ||
def isCI = env['CI'] != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def isCI = env['CI'] != null | |
def isCI = env['CI'] != null || env['CI'] == "true" || env['CI'] == "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly with REALM_DISABLE_ANALYTICS
, I think it makes sense to check for existence rather than a particular value. I don't suppose many developers have a CI
environment variable set on their machines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine by me to simplify the semantics of REALM_DISABLE_ANALYTICS
. Have you checked if we have to documentation that needs updating too?
The current docs mention setting an env variable, but are not prescriptive about the value, which would be in line with the changes in this PR: realm-js/lib/submit-analytics.js Lines 32 to 34 in 48144ae
realm-js/react-native/ios/RealmReact/RealmAnalytics.h Lines 40 to 42 in 48144ae
|
@nirinchev Once |
Merging as I don't believe the jest test runner is a real issue |
What, How & Why?
Most CI services will set the environment variable
CI
to some value, so it's a good idea to check for it and make sure we don't count CI builds as actual developers.Additionally, it modifies the Gradle analytics plugin to not check for the value of
REALM_DISABLE_ANALYTICS
since that is what we do on node/electron and React Native for iOS.☑️ ToDos