Skip to content
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

Merged
merged 4 commits into from
Jan 25, 2024
Merged

add ENV to log snowplow events #37915

merged 4 commits into from
Jan 25, 2024

Conversation

npretto
Copy link
Member

@npretto npretto commented Jan 19, 2024

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

image

Copy link

github-actions bot commented Jan 19, 2024

Codenotify: Notifying subscribers in CODENOTIFY files for diff 6b4631a...aa0a71d.

Notify File(s)
@alxnddr frontend/src/metabase/lib/analytics.js
@ranquild frontend/src/metabase/lib/analytics.js

@npretto npretto added the no-backport Do not backport this PR to any branch label Jan 19, 2024
Copy link

replay-io bot commented Jan 19, 2024

StatusComplete ↗︎
Commit50daaff
Results
2235 Passed

@npretto npretto requested a review from a team January 19, 2024 12:35
@@ -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") {
Copy link
Contributor

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.

Copy link
Member Author

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

@npretto npretto requested review from kamilmielnik and a team January 19, 2024 13:17
@npretto npretto changed the title console log snowplow events in dev mode add ENV to log snowplow events Jan 19, 2024
@@ -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 {
Copy link
Contributor

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?

Copy link
Member Author

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",
Copy link
Contributor

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

Copy link
Member Author

@npretto npretto Jan 23, 2024

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") {
Copy link
Contributor

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 npretto merged commit e254ecd into master Jan 25, 2024
106 checks passed
@npretto npretto deleted the console-log-snowplow-events branch January 25, 2024 10:49
Copy link

@npretto Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone?

sloansparger pushed a commit that referenced this pull request Feb 5, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport Do not backport this PR to any branch .Team/Embedding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants