Skip to content

Commit 20e8cdd

Browse files
authored
Add GA event tracking for actions in trace view (jaegertracing#191)
* Track errors in GA w raven-js; TODO: tests, readme Signed-off-by: Joe Farro <joef@uber.com> * Include CSS selector with last error breadcrumb Signed-off-by: Joe Farro <joef@uber.com> * README for GA error tracking Signed-off-by: Joe Farro <joef@uber.com> * Misc cleanup Signed-off-by: Joe Farro <joef@uber.com> * README info on GA Application Tracking Signed-off-by: Joe Farro <joef@uber.com> * Misc fix to tracking README Signed-off-by: Joe Farro <joef@uber.com> * Misc cleanup to raven message conversion to GA Signed-off-by: Joe Farro <joef@uber.com> * Tests for tracking Signed-off-by: Joe Farro <joef@uber.com> * Apply prettier to markdown files Signed-off-by: Joe Farro <joef@uber.com> * Error tracking fn name fallback, CSS import order Signed-off-by: Joe Farro <joef@uber.com> * GA event tracking in trace view, tests are TODO Signed-off-by: Joe Farro <joef@uber.com> * Fix broken tests Signed-off-by: Joe Farro <joef@uber.com> * Tests for TracePage tracking Signed-off-by: Joe Farro <joef@uber.com> * Additional tests for trace GA event tracking Signed-off-by: Joe Farro <joef@uber.com> * Better names for tracking functions Signed-off-by: Joe Farro <joef@uber.com> * Make GA event tracking more concise (PR feedback) Signed-off-by: Joe Farro <joef@uber.com> * Revert the "more concise" changes Signed-off-by: Joe Farro <joef@uber.com> * Update changelog Signed-off-by: Joe Farro <joef@uber.com> Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
1 parent ec14b16 commit 20e8cdd

31 files changed

+641
-84
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changes merged into master
22

3+
### [#191](https://github.com/jaegertracing/jaeger-ui/pull/191) Add GA event tracking for actions in trace view
4+
5+
* Partially addresses [#157](https://github.com/jaegertracing/jaeger-ui/issues/157) - Enhanced Google Analytics integration
6+
7+
### [#198](https://github.com/jaegertracing/jaeger-ui/pull/198) Use `<base>` and config webpack at runtime to allow path prefix
8+
9+
* Fix [#42](https://github.com/jaegertracing/jaeger-ui/issues/42) - No support for Jaeger behind a reverse proxy
10+
11+
### [#195](https://github.com/jaegertracing/jaeger-ui/pull/195) Handle Error stored in redux trace.traces
12+
13+
* Fix [#166](https://github.com/jaegertracing/jaeger-ui/issues/166) - JS error on search page after viewing 404 trace
14+
315
### [#192](https://github.com/jaegertracing/jaeger-ui/pull/192) Change fallback trace name to be more informative
416

517
* Fix [#190](https://github.com/jaegertracing/jaeger-ui/issues/190) - Change `cannot-find-trace-name` to `trace-without-root-span`

src/components/TracePage/KeyboardShortcutsHelp.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ limitations under the License.
2424
border: 1px solid #e8e8e8;
2525
border-bottom: 1px solid #ddd;
2626
color: #000;
27-
margin-right: 0.4em;
2827
font-family: monospace;
2928
padding: 0.25em 0.3em;
3029
}

src/components/TracePage/KeyboardShortcutsHelp.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import React from 'react';
1818
import { Button, Modal, Table } from 'antd';
1919

2020
import { kbdMappings } from './keyboard-shortcuts';
21+
import track from './KeyboardShortcutsHelp.track';
2122

2223
import './KeyboardShortcutsHelp.css';
2324

@@ -56,13 +57,14 @@ function convertKeys(keyConfig: string | string[]): string[][] {
5657
}
5758

5859
function helpModal() {
60+
track();
5961
const data = [];
6062
Object.keys(kbdMappings).forEach(title => {
6163
const keyConfigs = convertKeys(kbdMappings[title]);
6264
data.push(
6365
...keyConfigs.map(config => ({
6466
key: String(config),
65-
kbds: config.map(s => <kbd key={s}>{s}</kbd>),
67+
kbds: <kbd>{config.join(' ')}</kbd>,
6668
description: descriptions[title],
6769
}))
6870
);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// @flow
2+
3+
// Copyright (c) 2017 Uber Technologies, Inc.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
import { OPEN } from '../../utils/tracking/common';
18+
import { trackEvent } from '../../utils/tracking';
19+
20+
const CATEGORY = 'jaeger/ux/trace/kbd-modal';
21+
22+
export default trackEvent.bind(null, CATEGORY, OPEN);

src/components/TracePage/SpanGraph/ViewingLayer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import './ViewingLayer.css';
2828
type ViewingLayerProps = {
2929
height: number,
3030
numTicks: number,
31-
updateViewRangeTime: (number, number) => void,
31+
updateViewRangeTime: (number, number, ?string) => void,
3232
updateNextViewRangeTime: ViewRangeTimeUpdate => void,
3333
viewRange: ViewRange,
3434
};
@@ -188,7 +188,7 @@ export default class ViewingLayer extends React.PureComponent<ViewingLayerProps,
188188
const anchor = time.reframe ? time.reframe.anchor : value;
189189
const [start, end] = value < anchor ? [value, anchor] : [anchor, value];
190190
manager.resetBounds();
191-
this.props.updateViewRangeTime(start, end);
191+
this.props.updateViewRangeTime(start, end, 'minimap');
192192
};
193193

194194
_handleScrubberEnterLeave = ({ type }: DraggingUpdate) => {
@@ -220,7 +220,7 @@ export default class ViewingLayer extends React.PureComponent<ViewingLayerProps,
220220
}
221221
manager.resetBounds();
222222
this.setState({ preventCursorLine: false });
223-
this.props.updateViewRangeTime(...update);
223+
this.props.updateViewRangeTime(update[0], update[1], 'minimap');
224224
};
225225

226226
/**

src/components/TracePage/SpanGraph/ViewingLayer.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ describe('<SpanGraph>', () => {
141141
wrapper.instance()._handleReframeDragEnd({ manager, value });
142142
expect(manager.resetBounds.mock.calls).toEqual([[]]);
143143
const calls = props.updateViewRangeTime.mock.calls;
144-
expect(calls).toEqual([[value, value]]);
144+
expect(calls).toEqual([[value, value, 'minimap']]);
145145
});
146146

147147
it('handles dragged left (anchor is greater)', () => {
@@ -154,7 +154,7 @@ describe('<SpanGraph>', () => {
154154

155155
expect(manager.resetBounds.mock.calls).toEqual([[]]);
156156
const calls = props.updateViewRangeTime.mock.calls;
157-
expect(calls).toEqual([[value, anchor]]);
157+
expect(calls).toEqual([[value, anchor, 'minimap']]);
158158
});
159159

160160
it('handles dragged right (anchor is less)', () => {
@@ -167,7 +167,7 @@ describe('<SpanGraph>', () => {
167167

168168
expect(manager.resetBounds.mock.calls).toEqual([[]]);
169169
const calls = props.updateViewRangeTime.mock.calls;
170-
expect(calls).toEqual([[anchor, value]]);
170+
expect(calls).toEqual([[anchor, value, 'minimap']]);
171171
});
172172
});
173173
});
@@ -251,7 +251,7 @@ describe('<SpanGraph>', () => {
251251
instance._handleScrubberDragEnd(_case.dragUpdate);
252252
expect(wrapper.state('preventCursorLine')).toBe(false);
253253
expect(manager.resetBounds.mock.calls).toEqual([[]]);
254-
expect(props.updateViewRangeTime).lastCalledWith(..._case.viewRangeUpdate);
254+
expect(props.updateViewRangeTime).lastCalledWith(..._case.viewRangeUpdate, 'minimap');
255255
});
256256
});
257257
});

src/components/TracePage/TracePageHeader.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import IoIosFilingOutline from 'react-icons/lib/io/ios-filing-outline';
2222
import { Link } from 'react-router-dom';
2323

2424
import * as markers from './TracePageHeader.markers';
25+
import { trackAltViewOpen } from './TracePageHeader.track';
2526
import KeyboardShortcutsHelp from './KeyboardShortcutsHelp';
2627
import LabeledList from '../common/LabeledList';
2728
import { FALLBACK_TRACE_NAME } from '../../constants';
@@ -109,12 +110,22 @@ export default function TracePageHeader(props: TracePageHeaderProps) {
109110
const viewMenu = (
110111
<Menu>
111112
<Menu.Item>
112-
<Link to={prefixUrl(`/api/traces/${traceID}`)} rel="noopener noreferrer" target="_blank">
113+
<Link
114+
to={prefixUrl(`/api/traces/${traceID}`)}
115+
rel="noopener noreferrer"
116+
target="_blank"
117+
onClick={trackAltViewOpen}
118+
>
113119
Trace JSON
114120
</Link>
115121
</Menu.Item>
116122
<Menu.Item>
117-
<Link to={prefixUrl(`/api/traces/${traceID}?raw=true`)} rel="noopener noreferrer" target="_blank">
123+
<Link
124+
to={prefixUrl(`/api/traces/${traceID}?raw=true`)}
125+
rel="noopener noreferrer"
126+
target="_blank"
127+
onClick={trackAltViewOpen}
128+
>
118129
Trace JSON (unadjusted)
119130
</Link>
120131
</Menu.Item>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// @flow
2+
3+
// Copyright (c) 2017 Uber Technologies, Inc.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
import { getToggleValue, OPEN } from '../../utils/tracking/common';
18+
import { trackEvent } from '../../utils/tracking';
19+
20+
const CATEGORY_ALT_VIEW = 'jaeger/ux/trace/alt-view';
21+
const CATEGORY_SLIM_HEADER = 'jaeger/ux/trace/slim-header';
22+
23+
// use a closure instead of bind to prevent forwarding any arguments to trackEvent()
24+
export const trackAltViewOpen = () => trackEvent(CATEGORY_ALT_VIEW, OPEN);
25+
26+
export const trackSlimHeaderToggle = (isOpen: boolean) =>
27+
trackEvent(CATEGORY_SLIM_HEADER, getToggleValue(isOpen));

src/components/TracePage/TraceTimelineViewer/SpanDetail/AccordianKeyValues.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import KeyValuesTable from './KeyValuesTable';
2525
import './AccordianKeyValues.css';
2626

2727
type AccordianKeyValuesProps = {
28-
className: ?string,
28+
className?: ?string,
2929
data: { key: string, value: any }[],
3030
highContrast?: boolean,
3131
isOpen: boolean,
@@ -86,5 +86,6 @@ export default function AccordianKeyValues(props: AccordianKeyValuesProps) {
8686
}
8787

8888
AccordianKeyValues.defaultProps = {
89+
className: null,
8990
highContrast: false,
9091
};

src/components/TracePage/TraceTimelineViewer/SpanDetail/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @flow
2+
13
// Copyright (c) 2017 Uber Technologies, Inc.
24
//
35
// Licensed under the Apache License, Version 2.0 (the "License");

0 commit comments

Comments
 (0)