Skip to content

Commit

Permalink
Merge pull request #2051 from metabase/instrumentation
Browse files Browse the repository at this point in the history
Instrumentation
  • Loading branch information
agilliland committed Feb 29, 2016
2 parents 1c164b4 + afd0827 commit 9d1ed5f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
5 changes: 5 additions & 0 deletions frontend/src/card/card.controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,17 @@ CardControllers.controller('CardDetail', [
onBeginEditing: function() {
isEditing = true;
renderAll();
MetabaseAnalytics.trackEvent('QueryBuilder', 'Edit Begin');
},
onCancelEditing: function() {
// reset back to our original card
isEditing = false;
setCard(originalCard, {resetDirty: true});
MetabaseAnalytics.trackEvent('QueryBuilder', 'Edit Cancel');
},
onRestoreOriginalQuery: function () {
setCard(originalCard, {resetDirty: true});
MetabaseAnalytics.trackEvent('QueryBuilder', 'Restore Original');
},
cardIsNewFn: cardIsNew,
cardIsDirtyFn: cardIsDirty
Expand Down Expand Up @@ -373,6 +376,7 @@ CardControllers.controller('CardDetail', [
isShowingTutorial = false;
updateUrl();
renderAll();
MetabaseAnalytics.trackEvent('QueryBuilder', 'Tutorial Close');
}
}

Expand Down Expand Up @@ -989,6 +993,7 @@ CardControllers.controller('CardDetail', [

if (isShowingTutorial) {
setSampleDataset();
MetabaseAnalytics.trackEvent('QueryBuilder', 'Tutorial Start');
}
} catch (error) {
console.log('error getting database list', error);
Expand Down
20 changes: 17 additions & 3 deletions frontend/src/dashboard/components/AddSeriesModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import Icon from "metabase/components/Icon.jsx";
import Tooltip from "metabase/components/Tooltip.jsx";
import CheckBox from "metabase/components/CheckBox.jsx";

import MetabaseAnalytics from "metabase/lib/analytics";
import Query from "metabase/lib/query";

import visualizations from "metabase/visualizations";

import _ from "underscore";
import cx from "classnames";


function getQueryColumns(card, databases) {
let dbId = card.dataset_query.database;
if (card.dataset_query.type !== "query") {
Expand All @@ -37,7 +39,7 @@ export default class AddSeriesModal extends Component {
badCards: {}
};

_.bindAll(this, "onSearchChange", "onDone", "filteredCards", "onRemoveSeries")
_.bindAll(this, "onSearchChange", "onSearchFocus", "onDone", "filteredCards", "onRemoveSeries")
}

static propTypes = {
Expand All @@ -64,6 +66,10 @@ export default class AddSeriesModal extends Component {
}
}

onSearchFocus() {
MetabaseAnalytics.trackEvent("Dashboard", "Edit Series Modal", "search");
}

onSearchChange(e) {
this.setState({ searchValue: e.target.value.toLowerCase() });
}
Expand All @@ -87,15 +93,21 @@ export default class AddSeriesModal extends Component {
state: null,
series: this.state.series.concat(card)
});

MetabaseAnalytics.trackEvent("Dashboard", "Add Series", card.display+", success");
} else {
this.setState({
state: "incompatible",
badCards: { ...this.state.badCards, [card.id]: true }
});
setTimeout(() => this.setState({ state: null }), 2000);

MetabaseAnalytics.trackEvent("Dashboard", "Add Series", card.dataset_query.type+", "+card.display+", fail");
}
} else {
this.setState({ series: this.state.series.filter(c => c.id !== card.id) });

MetabaseAnalytics.trackEvent("Dashboard", "Remove Series");
}
} catch (e) {
console.error("onCardChange", e);
Expand All @@ -109,6 +121,7 @@ export default class AddSeriesModal extends Component {

onRemoveSeries(card) {
this.setState({ series: this.state.series.filter(c => c.id !== card.id) });
MetabaseAnalytics.trackEvent("Dashboard", "Remove Series");
}

onDone() {
Expand All @@ -117,6 +130,7 @@ export default class AddSeriesModal extends Component {
attributes: { series: this.state.series }
});
this.props.onClose();
MetabaseAnalytics.trackEvent("Dashboard", "Edit Series Modal", "done");
}

filteredCards() {
Expand Down Expand Up @@ -214,13 +228,13 @@ export default class AddSeriesModal extends Component {
</div>
<div className="flex-no-shrink pl4 pb4 pt1">
<button className="Button Button--primary" onClick={this.onDone}>Done</button>
<button className="Button Button--borderless" onClick={this.props.onClose}>Cancel</button>
<button data-metabase-event={"Dashboard;Edit Series Modal;cancel"} className="Button Button--borderless" onClick={this.props.onClose}>Cancel</button>
</div>
</div>
<div className="border-left flex flex-column" style={{width: 370, backgroundColor: "#F8FAFA", borderColor: "#DBE1DF" }}>
<div className="flex-no-shrink border-bottom flex flex-row align-center" style={{ borderColor: "#DBE1DF" }}>
<Icon className="ml2" name="search" width={16} height={16} />
<input className="h4 input full pl1" style={{ border: "none", backgroundColor: "transparent" }} type="search" placeholder="Search for a question" onChange={this.onSearchChange}/>
<input className="h4 input full pl1" style={{ border: "none", backgroundColor: "transparent" }} type="search" placeholder="Search for a question" onFocus={this.onSearchFocus} onChange={this.onSearchChange}/>
</div>
<LoadingAndErrorWrapper className="flex flex-full" loading={!filteredCards} error={error} noBackground>
{ () =>
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/query_builder/QueryHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import QueryModeToggle from './QueryModeToggle.jsx';
import QuestionSavedModal from 'metabase/components/QuestionSavedModal.jsx';
import SaveQuestionModal from 'metabase/components/SaveQuestionModal.jsx';

import MetabaseAnalytics from "metabase/lib/analytics";
import Query from "metabase/lib/query";

import cx from "classnames";
Expand Down Expand Up @@ -101,6 +102,7 @@ export default React.createClass({
onDelete: async function () {
await this.props.cardApi.delete({ 'cardId': this.props.card.id }).$promise;
this.onGoBack();
MetabaseAnalytics.trackEvent("QueryBuilder", "Delete");
},

onFollowBreadcrumb: function() {
Expand Down Expand Up @@ -233,7 +235,7 @@ export default React.createClass({
if (!this.props.cardIsNewFn() && !this.props.isEditing) {
// simply adding an existing saved card to a dashboard, so show the modal to do so
buttonSections.push([
<span className="cursor-pointer text-brand-hover" onClick={() => this.setState({ modal: "add-to-dashboard" })}>
<span data-metabase-event={"QueryBuilder;AddToDash Modal;normal"} className="cursor-pointer text-brand-hover" onClick={() => this.setState({ modal: "add-to-dashboard" })}>
<Icon name="addtodash" width="16px" height="16px" />
</span>
]);
Expand All @@ -244,7 +246,7 @@ export default React.createClass({
key="addtodashsave"
ref="addToDashSaveModal"
triggerClasses="h4 px1 text-grey-4 text-brand-hover text-uppercase"
triggerElement={<span className="text-brand-hover"><Icon name="addtodash" width="16px" height="16px" /></span>}
triggerElement={<span data-metabase-event={"QueryBuilder;AddToDash Modal;pre-save"} className="text-brand-hover"><Icon name="addtodash" width="16px" height="16px" /></span>}
>
<SaveQuestionModal
card={this.props.card}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/tutorial/Tutorial.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Portal from "./Portal.jsx";
import PageFlag from "./PageFlag.jsx";
import TutorialModal from "./TutorialModal.jsx";

import MetabaseAnalytics from "metabase/lib/analytics";

import _ from "underscore";

export function qs(selector) {
Expand Down Expand Up @@ -90,6 +92,7 @@ export default class Tutorial extends Component {
next() {
if (this.state.step + 1 === this.props.steps.length) {
this.close();
MetabaseAnalytics.trackEvent('QueryBuilder', 'Tutorial Finish');
} else {
this.setStep(this.state.step + 1);
}
Expand Down Expand Up @@ -129,6 +132,7 @@ export default class Tutorial extends Component {
step,
stepTimeout: setTimeout(() => this.setState({ stepTimeout: null }), STEP_WARNING_TIMEOUT)
});
MetabaseAnalytics.trackEvent('QueryBuilder', 'Tutorial Step', step);
}

close() {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/visualizations/components/LegendHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class LegendItem extends Component {
}

const AddSeriesItem = ({ onAddSeries, showTitles }) =>
<a className={cx(styles.AddSeriesItem, "h3 ml1 mr2 cursor-pointer flex align-center text-brand-hover")} onClick={onAddSeries}>
<a data-metabase-event={"Dashboard;Edit Series Modal;open"} className={cx(styles.AddSeriesItem, "h3 ml1 mr2 cursor-pointer flex align-center text-brand-hover")} onClick={onAddSeries}>
<span className="flex-no-shrink circular bordered border-brand flex layout-centered" style={{ width: 20, height: 20, marginRight: 8 }}>
<Icon className="text-brand" name="add" width={10} height={10} />
</span>
Expand Down

0 comments on commit 9d1ed5f

Please sign in to comment.