Skip to content
Snippets Groups Projects
Unverified Commit a8c6aace authored by Romeo Van Snick's avatar Romeo Van Snick Committed by GitHub
Browse files

Add analytics event for combining/extracting columns (#41767)

* Add analytics event for combine columns shortcut

* Add new version for question analytics schema

* Add column_combine_via_shortcut event

* Add custom_expressions_used field

* Use trackSchemaEvent to track combine column event

* Move trackColumnCombineViaShortcut to separate file

* Fix typo in event key

* Add column_combine_via_column_header

* Add column_extract_via_shortcut

* Add column_extract_via_column_header

* Add database id for question

* Move analytics file to frontend/src/metabase/query_builder

* Allow null for custom_expressions_used

* Add test for snowplow event

* Fix typo in schema

* Add max length to custom expressions

* Add description to list item
parent 912b5e51
Branches
Tags
No related merge requests found
import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
import {
addCustomColumn,
restore,
popover,
openOrdersTable,
expressionEditorWidget,
describeWithSnowplow,
expectNoBadSnowplowEvents,
expectGoodSnowplowEvent,
resetSnowplow,
} from "e2e/support/helpers";
describe("scenarios > question > custom column > expression shortcuts", () => {
......@@ -108,6 +113,39 @@ describe("scenarios > question > custom column > expression shortcuts", () => {
});
});
describeWithSnowplow(
"scenarios > question > custom column > combine shortcuts",
() => {
beforeEach(() => {
restore();
resetSnowplow();
cy.signInAsNormalUser();
});
afterEach(() => {
expectNoBadSnowplowEvents();
});
it("should send an event for combine columns", () => {
openOrdersTable({ mode: "notebook" });
addCustomColumn();
selectCombineColumns();
selectColumn("User", "Email");
selectColumn("User", "Email");
expressionEditorWidget().button("Done").click();
expectGoodSnowplowEvent({
event: "column_combine_via_shortcut",
custom_expressions_used: ["concat"],
database_id: SAMPLE_DB_ID,
question_id: 0,
});
});
},
);
function selectCombineColumns() {
cy.findByTestId("expression-suggestions-list").within(() => {
cy.findByText("Combine columns").click();
......
import { trackSchemaEvent } from "metabase/lib/analytics";
import * as Lib from "metabase-lib";
export const trackNewQuestionSaved = (
draftQuestion,
......@@ -31,3 +32,12 @@ export const trackNotebookNativePreviewShown = (question, isShown) => {
question_id: question.id() ?? 0,
});
};
export const trackColumnCombineViaShortcut = (query, question) => {
trackSchemaEvent("question", "1-0-4", {
event: "column_combine_via_shortcut",
custom_expressions_used: ["concat"],
database_id: Lib.databaseID(query),
question_id: question?.id() ?? 0,
});
};
......@@ -9,6 +9,8 @@ import type * as Lib from "metabase-lib";
import { isExpression } from "metabase-lib/v1/expressions";
import type { Expression } from "metabase-types/api";
import { trackColumnCombineViaShortcut } from "../../analytics";
import { CombineColumns } from "./CombineColumns/CombineColumns";
import { ExpressionEditorTextfield } from "./ExpressionEditorTextfield";
import {
......@@ -122,6 +124,8 @@ export const ExpressionWidget = <Clause extends object = Lib.ExpressionClause>(
if (isCombiningColumns) {
const handleSubmit = (name: string, clause: Lib.ExpressionClause) => {
trackColumnCombineViaShortcut(query);
setIsCombiningColumns(false);
setClause(clause);
setName(name);
......
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Events related to questions",
"self": {
"vendor": "com.metabase",
"name": "question",
"format": "jsonschema",
"version": "1-0-4"
},
"type": "object",
"properties": {
"event": {
"description": "Event name",
"type": "string",
"enum": [
"new_question_saved",
"turn_into_model_clicked",
"notebook_native_preview_shown",
"notebook_native_preview_hidden",
"column_combine_via_shortcut",
"column_combine_via_column_header",
"column_extract_via_shortcut",
"column_extract_via_column_header"
],
"maxLength": 1024
},
"type": {
"description": "String identifying the type of the question when it is saved",
"type": [
"string",
"null"
],
"enum": [
"simple_question",
"custom_question",
"native_question"
],
"maxLength": 1024
},
"method": {
"description": "String indicating whether or not the question was created based off of an existing question",
"type": [
"string",
"null"
],
"enum": [
"from_scratch",
"existing_question"
],
"maxLength": 1024
},
"visualization_type": {
"description": "String describing the type of visualization used for the question",
"type": [
"string",
"null"
],
"maxLength": 1024
},
"question_id": {
"description": "Unique identifier for the question within the Metabase instance",
"type": "integer",
"minimum": 0,
"maximum": 2147483647
},
"database_id": {
"description": "Unique identifier(s) for the database connection(s) used to create the question",
"type": [
"integer",
"null"
],
"minimum": 0,
"maximum": 2147483647
},
"custom_expressions_used": {
"description": "A list of names of expression functions and aggregations used",
"type": [
"array",
"null"
],
"items": {
"description": "The name of a function used in the custom expression",
"type": "string",
"maxLength": 1024
}
}
},
"required": [
"event",
"question_id"
],
"additionalProperties": true
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment