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 analytics event for combining/extracting columns #41767

Merged
merged 17 commits into from
Apr 30, 2024

Conversation

romeovs
Copy link
Contributor

@romeovs romeovs commented Apr 24, 2024

Closes #41766

Diffs for the schema change

Description

Adds an analytics events that fires when the custom expression for combining or extracting columns is inserted via the notebook shortcut, or via the chill mode column header.

  • column_combine_via_shortcut
  • column_combine_via_column_header
  • column_extract_via_shortcut
  • column_extract_via_column_header

Adds an new property custom_expressions_used to track the expressions used.

I chose to add all of these at once here to avoid having to create new schema versions in 4 PR's.

@romeovs romeovs requested a review from a team April 24, 2024 08:30
@romeovs romeovs force-pushed the 41766-combine-shortcut-analytics-event branch from 7982cc0 to 83aa02b Compare April 24, 2024 08:31
@romeovs romeovs changed the base branch from master to notebook-expression-shortcuts April 24, 2024 08:32
@romeovs romeovs self-assigned this Apr 24, 2024
@romeovs romeovs added the no-backport Do not backport this PR to any branch label Apr 24, 2024
@romeovs romeovs changed the title Add analytics event for combin column shortcut Add analytics event for combine column shortcut Apr 24, 2024
Copy link

replay-io bot commented Apr 24, 2024

Status Complete ↗︎
Commit ddeb3a8
Results
⚠️ 14 Flaky
2423 Passed

@romeovs romeovs force-pushed the 41766-combine-shortcut-analytics-event branch from 952869d to a83a2be Compare April 24, 2024 16:42
@romeovs romeovs changed the title Add analytics event for combine column shortcut Add analytics event for combining/extracting columns Apr 25, 2024
@romeovs romeovs force-pushed the notebook-expression-shortcuts branch from 8acacd3 to 2f331b4 Compare April 26, 2024 07:24
@romeovs romeovs force-pushed the 41766-combine-shortcut-analytics-event branch from 6945e02 to 9414309 Compare April 26, 2024 07:48
@romeovs romeovs changed the base branch from notebook-expression-shortcuts to master April 26, 2024 08:45
@romeovs romeovs force-pushed the 41766-combine-shortcut-analytics-event branch from 9414309 to 62153f7 Compare April 26, 2024 08:47
Copy link
Contributor

github-actions bot commented Apr 26, 2024

Codenotify: Notifying subscribers in CODENOTIFY files for diff dd66a69...ddeb3a8.

No notifications.

@romeovs romeovs force-pushed the 41766-combine-shortcut-analytics-event branch from 62153f7 to a8860f1 Compare April 26, 2024 11:26
@nemanjaglumac nemanjaglumac requested a review from Somtom April 26, 2024 12:24
Copy link
Contributor

@Somtom Somtom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Just a question regarding the other properties in the question event schema 🙂

Comment on lines 4 to 7
trackSchemaEvent("question", "1-0-4", {
event: "column_combine_via_shortcut",
custom_expressions_used: ["concat"],
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion/question (not-blocking):

Does it make sense to populate other properties of the event as well here?
It seems like the following could make sense (if we have the info available):

  • visualization_type
  • database_id
  • ... I guess we don't have information about the question_id or something like that, do we?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think database_id is the only one that is trivial to find and pass. Is that fine?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure - let's start with that one 🙂 .

Just to check: I had the assumption that the column_combine_via_shortcut would only happen in table vizualizations but that seems not to hold, does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

column_combine_via_shortcut happens on the notebook editor, column_combine_via_header happens in the table vizualizations.

@romeovs romeovs force-pushed the 41766-combine-shortcut-analytics-event branch from 8ba222a to 4779153 Compare April 26, 2024 15:27
Copy link
Contributor

@ranquild ranquild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline comments

import { trackSchemaEvent } from "metabase/lib/analytics";
import * as Lib from "metabase-lib";

export const trackColumnCombineViaShortcut = (query: Lib.Query) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably go to metabase/query_builder folder

},
"custom_expressions_used": {
"description": "A list of names of expression functions and aggregations used",
"type": "array",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should allow null as well for events that haven't this property:

"type": [
        "array",
        "null"
      ]

import * as Lib from "metabase-lib";

export const trackColumnCombineViaShortcut = (query: Lib.Query) => {
trackSchemaEvent("question", "1-0-4", {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question_id is required and cannot be omitted unfortunately. You would also have to default to 0 for unsaved questions.

import { trackSchemaEvent } from "metabase/lib/analytics";
import * as Lib from "metabase-lib";

export const trackColumnCombineViaShortcut = (query: Lib.Query) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to add e2e tests for this event. Search for describeWithSnowplow for examples.

@romeovs romeovs requested a review from ranquild April 29, 2024 14:15
@@ -31,3 +32,12 @@ export const trackNotebookNativePreviewShown = (question, isShown) => {
question_id: question.id() ?? 0,
});
};

export const trackColumnCombineViaShortcut = (query, question) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you pass question you can use question.query() to know to pass query

@romeovs romeovs merged commit a8c6aac into master Apr 30, 2024
110 checks passed
@romeovs romeovs deleted the 41766-combine-shortcut-analytics-event branch April 30, 2024 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.Frontend no-backport Do not backport this PR to any branch .Team/Querying
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add analytics events for combine shortcut in notebook editor
3 participants