Skip to content
Snippets Groups Projects
Unverified Commit 224f292f authored by Oisin Coveney's avatar Oisin Coveney Committed by GitHub
Browse files

Add instrumentation for "Turn into model" option on saved questions (#31438)

parent 03ce8fad
No related merge requests found
......@@ -9,6 +9,11 @@ import {
openQuestionActions,
questionInfoButton,
getPersonalCollectionName,
describeWithSnowplow,
resetSnowplow,
enableTracking,
expectNoBadSnowplowEvents,
expectGoodSnowplowEvents,
} from "e2e/support/helpers";
import { USERS } from "e2e/support/cypress_data";
......@@ -250,6 +255,35 @@ describe("managing question from the question's details sidebar", () => {
});
});
describeWithSnowplow("send snowplow question events", () => {
const NUMBERS_OF_GOOD_SNOWPLOW_EVENTS_BEFORE_MODEL_CONVERSION = 2;
beforeEach(() => {
restore();
resetSnowplow();
cy.signInAsAdmin();
enableTracking();
});
afterEach(() => {
expectNoBadSnowplowEvents();
});
it("should send event when clicking `Turn into a model`", () => {
visitQuestion(1);
openQuestionActions();
expectGoodSnowplowEvents(
NUMBERS_OF_GOOD_SNOWPLOW_EVENTS_BEFORE_MODEL_CONVERSION,
);
popover().within(() => {
cy.findByText("Turn into a model").click();
});
expectGoodSnowplowEvents(
NUMBERS_OF_GOOD_SNOWPLOW_EVENTS_BEFORE_MODEL_CONVERSION + 1,
);
});
});
function clickButton(name) {
cy.button(name).should("not.be.disabled").click();
}
......
......@@ -5,7 +5,7 @@ export const trackNewQuestionSaved = (
createdQuestion,
isBasedOnExistingQuestion,
) => {
trackSchemaEvent("question", "1-0-1", {
trackSchemaEvent("question", "1-0-2", {
event: "new_question_saved",
question_id: createdQuestion.id(),
database_id: createdQuestion.databaseId(),
......@@ -14,3 +14,10 @@ export const trackNewQuestionSaved = (
source: isBasedOnExistingQuestion ? "existing_question" : "from_scratch",
});
};
export const trackTurnIntoModelClicked = question => {
trackSchemaEvent("question", "1-0-2", {
event: "turn_into_model_clicked",
question_id: question.id(),
});
};
......@@ -19,6 +19,7 @@ import BookmarkToggle from "metabase/core/components/BookmarkToggle";
import { getSetting } from "metabase/selectors/settings";
import { canUseMetabotOnDatabase } from "metabase/metabot/utils";
import { useDispatch, useSelector } from "metabase/lib/redux";
import { trackTurnIntoModelClicked } from "metabase/query_builder/analytics";
import Question from "metabase-lib/Question";
import {
......@@ -107,6 +108,7 @@ const QuestionActions = ({
const modal = checkCanBeModel(question)
? MODAL_TYPES.TURN_INTO_DATASET
: MODAL_TYPES.CAN_NOT_CREATE_MODEL;
trackTurnIntoModelClicked(question);
onOpenModal(modal);
}, [onOpenModal, question]);
......
......@@ -5,7 +5,7 @@
"vendor": "com.metabase",
"name": "metabot",
"format": "jsonschema",
"version": "1-0-0"
"version": "1-0-1"
},
"type": "object",
"properties": {
......
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "New question creation",
"self": {
"vendor": "com.metabase",
"name": "question",
"format": "jsonschema",
"version": "1-0-2"
},
"type": "object",
"properties": {
"event": {
"description": "Event name",
"type": "string",
"enum": [
"new_question_saved",
"turn_into_model_clicked"
],
"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
}
},
"required": [
"event",
"question_id"
],
"additionalProperties": true
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment