Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2498 from woocommerce/add/tracks/activity-panel-open
Browse files Browse the repository at this point in the history
Activity Panels: Add track event when panels are opened.
  • Loading branch information
psealock authored Jun 25, 2019
2 parents df0fb82 + defa4ce commit dc1dc36
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 30 deletions.
8 changes: 8 additions & 0 deletions client/header/activity-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import InboxPanel from './panels/inbox';
import OrdersPanel from './panels/orders';
import StockPanel from './panels/stock';
import { recordEvent } from 'lib/tracks';
import ReviewsPanel from './panels/reviews';
import withSelect from 'wc-api/with-select';
import WordPressNotices from './wordpress-notices';
Expand All @@ -45,6 +46,13 @@ class ActivityPanel extends Component {
}

togglePanel( tabName ) {
const { isPanelOpen, currentTab } = this.state;

// If a panel is being opened, or if an existing panel is already open and a different one is being opened, record a track.
if ( ! isPanelOpen || tabName !== currentTab ) {
recordEvent( 'wcadmin_activity_panel_open', { tab: tabName } );
}

// The WordPress Notices tab is handled differently, since they are displayed inline, so the panel should be closed,
// Close behavior of the expanded notices is based on current tab.
if ( 'wpnotices' === tabName ) {
Expand Down
11 changes: 11 additions & 0 deletions client/lib/tracks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/** @format */
/**
* External dependencies
*/
import debug from 'debug';

/**
* Module variables
*/
const tracksDebug = debug( 'wc-admin:tracks' );

/**
* Record an event to Tracks
Expand All @@ -8,6 +17,8 @@
*/

export function recordEvent( eventName, eventProperties ) {
tracksDebug( 'recordevent %s %o', eventName, eventProperties );

if (
! window.wcTracks ||
'function' !== typeof window.wcTracks.recordEvent ||
Expand Down
41 changes: 11 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"d3-selection": "1.4.0",
"d3-shape": "1.3.5",
"d3-time-format": "2.1.3",
"debug": "3.2.6",
"dompurify": "1.0.11",
"emoji-flags": "1.2.0",
"gfm-code-blocks": "1.0.0",
Expand Down

0 comments on commit dc1dc36

Please sign in to comment.