Skip to content
Snippets Groups Projects
Commit 2d57e9bd authored by Sameer Al-Sakran's avatar Sameer Al-Sakran Committed by GitHub
Browse files

Merge pull request #3530 from metabase/0.20.0-instrumentation

Instrument 0.20
parents f3e68c09 ee5173ae
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import _ from "underscore";
import cx from "classnames";
import { AngularResourceProxy } from "metabase/lib/redux";
import MetabaseAnalytics from "metabase/lib/analytics";
import Icon from "metabase/components/Icon.jsx";
import Input from "metabase/components/Input.jsx";
......@@ -191,7 +192,9 @@ export default class GroupsListing extends Component {
});
}
// TODO: move this to Redux
onAddGroupCreateButtonClicked() {
MetabaseAnalytics.trackEvent("People Groups", "Group Added");
PermissionsAPI.createGroup({name: this.state.text}).then((function(newGroup) {
const groups = this.state.groups || this.props.groups || [];
const newGroups = sortGroups(_.union(groups, [newGroup]));
......@@ -244,6 +247,7 @@ export default class GroupsListing extends Component {
});
}
// TODO: move this to Redux
onEditGroupDoneClicked() {
const groups = this.state.groups || this.props.groups || [];
const originalGroup = _.findWhere(groups, {id: this.state.groupBeingEdited.id});
......@@ -258,6 +262,7 @@ export default class GroupsListing extends Component {
}
// ok, fire off API call to change the group
MetabaseAnalytics.trackEvent("People Groups", "Group Updated");
PermissionsAPI.updateGroup({id: group.id, name: group.name}).then((function (newGroup) {
// now replace the original group with the new group and update state
let newGroups = _.reject(groups, (g) => g.id === group.id);
......@@ -274,8 +279,10 @@ export default class GroupsListing extends Component {
});
}
// TODO: move this to Redux
onDeleteGroupClicked(group) {
const groups = this.state.groups || this.props.groups || [];
MetabaseAnalytics.trackEvent("People Groups", "Group Deleted");
PermissionsAPI.deleteGroup({id: group.id}).then((function () {
const newGroups = sortGroups(_.reject(groups, (g) => g.id === group.id));
this.setState({
......
......@@ -60,6 +60,7 @@ export const loadMemberships = createAction(LOAD_MEMBERSHIPS, async () =>
export const createMembership = createAction(CREATE_MEMBERSHIP, async ({ userId, groupId }) => {
// pull the membership_id from the list of all memberships of the group
let groupMemberships = await PermissionsApi.createMembership({ user_id: userId, group_id: groupId });
MetabaseAnalytics.trackEvent("People Groups", "Membership Added");
return {
user_id: userId,
group_id: groupId,
......@@ -68,6 +69,7 @@ export const createMembership = createAction(CREATE_MEMBERSHIP, async ({ userId,
});
export const deleteMembership = createAction(DELETE_MEMBERSHIP, async ({ membershipId }) => {
await PermissionsApi.deleteMembership({ id: membershipId });
MetabaseAnalytics.trackEvent("People Groups", "Membership Deleted");
return membershipId;
});
......
import { createAction, createThunkAction, handleActions, combineReducers, AngularResourceProxy } from "metabase/lib/redux";
import { canEditPermissions } from "metabase/lib/groups";
import MetabaseAnalytics from "metabase/lib/analytics";
const MetadataApi = new AngularResourceProxy("Metabase", ["db_list_with_tables"]);
const PermissionsApi = new AngularResourceProxy("Permissions", ["groups", "graph", "updateGraph"]);
......@@ -41,6 +42,7 @@ export const updatePermission = createThunkAction(UPDATE_PERMISSION, ({ groupId,
const SAVE_PERMISSIONS = "metabase/admin/permissions/SAVE_PERMISSIONS";
export const savePermissions = createThunkAction(SAVE_PERMISSIONS, () =>
async (dispatch, getState) => {
MetabaseAnalytics.trackEvent("Permissions", "save");
const { permissions, revision } = getState().permissions;
let result = await PermissionsApi.updateGraph({
revision: revision,
......
......@@ -5,6 +5,7 @@ import { createSelector } from 'reselect';
import { push } from "react-router-redux";
import Metadata from "metabase/meta/metadata/Metadata";
import MetabaseAnalytics from "metabase/lib/analytics";
import type { DatabaseId } from "metabase/meta/types/Database";
import type { SchemaName } from "metabase/meta/types/Table";
......@@ -92,6 +93,7 @@ export const getTablesPermissionsGrid = createSelector(
return getFieldsPermission(permissions, groupId, entityId);
},
updater(groupId, entityId, value) {
MetabaseAnalytics.trackEvent("Permissions", "fields", value);
return updateFieldsPermission(permissions, groupId, entityId, value, metadata);
},
confirm(groupId, entityId, value) {
......@@ -143,6 +145,7 @@ export const getSchemasPermissionsGrid = createSelector(
return getTablesPermission(permissions, groupId, entityId);
},
updater(groupId, entityId, value) {
MetabaseAnalytics.trackEvent("Permissions", "tables", value);
return updateTablesPermission(permissions, groupId, entityId, value, metadata);
},
postAction(groupId, { databaseId, schemaName }, value) {
......@@ -192,6 +195,7 @@ export const getDatabasesPermissionsGrid = createSelector(
return getSchemasPermission(permissions, groupId, entityId);
},
updater(groupId, entityId, value) {
MetabaseAnalytics.trackEvent("Permissions", "schemas", value);
return updateSchemasPermission(permissions, groupId, entityId, value, metadata)
},
postAction(groupId, { databaseId }, value) {
......@@ -220,6 +224,7 @@ export const getDatabasesPermissionsGrid = createSelector(
return getNativePermission(permissions, groupId, entityId);
},
updater(groupId, entityId, value) {
MetabaseAnalytics.trackEvent("Permissions", "native", value);
return updateNativePermission(permissions, groupId, entityId, value, metadata);
},
confirm(groupId, entityId, value) {
......
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