-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
add ENV to log snowplow events #37915
Conversation
Codenotify: Notifying subscribers in CODENOTIFY files for diff 6b4631a...aa0a71d.
|
|
@@ -41,6 +41,22 @@ export const trackStructEvent = (category, action, label, value) => { | |||
}; | |||
|
|||
export const trackSchemaEvent = (schema, version, data) => { | |||
// eslint-disable-next-line no-undef | |||
if (process?.env?.NODE_ENV === "development") { |
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.
Can we not do this by default, but require e.g. an env variable to be set up for it?
The console is already a pain to work with due to React prop-types errors.
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.
Good point, wrapped it in a env var
@@ -41,6 +41,22 @@ export const trackStructEvent = (category, action, label, value) => { | |||
}; | |||
|
|||
export const trackSchemaEvent = (schema, version, data) => { | |||
// eslint-disable-next-line no-undef | |||
if (process.env.MB_LOG_ANALYTICS === "true") { | |||
try { |
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.
Why do we need a try-catch here?
What error do you think could happen during console.log
call?
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.
Good catch, I added it when it wasn't under a env flag and I wasn't sure what we passed as data -> if my destructuring was safe
@@ -238,6 +238,7 @@ const config = (module.exports = { | |||
new NodePolyfillPlugin(), // for crypto, among others | |||
new webpack.EnvironmentPlugin({ | |||
WEBPACK_BUNDLE: "development", | |||
MB_LOG_ANALYTICS: "false", |
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.
I think we should also add a script to run the project with this setting on
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.
I don't think that's very scalable, we can't have a command for any combination of envs.
For example almost everyday I use both yarn dev
and yarn build:hot
, others may use yarn dev-ee
(which pretty much just sets MB_VERSION) etc
@@ -41,6 +41,18 @@ export const trackStructEvent = (category, action, label, value) => { | |||
}; | |||
|
|||
export const trackSchemaEvent = (schema, version, data) => { | |||
// eslint-disable-next-line no-undef | |||
if (process.env.MB_LOG_ANALYTICS === "true") { |
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.
We should probably add this variable to frontend/src/metabase/env.js
.
@npretto Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone? |
* console log snowplow events * wraps it in a env var to not spam the console * remove try catch now that's under a flag * moved reading the env to env.js
Description
This both makes testing things locally easier and also makes us more aware of the testing we do (and not do).
This would also help help PMs and PDs make sure we're tracking things as they expect.
Ideally we could do something similar on the BE
Demo