-
Notifications
You must be signed in to change notification settings - Fork 485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate Google Analytics into Search Page #220
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,7 @@ coverage | |
.DS_Store | ||
npm-debug.log | ||
.vscode | ||
.idea | ||
yarn-error.log | ||
|
||
lerna-debug\.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/jaeger-ui/src/components/SearchTracePage/SearchForm.track.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// @flow | ||
|
||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import type { Store } from 'redux'; | ||
|
||
import * as constants from '../../constants/search-form'; | ||
import { trackEvent } from '../../utils/tracking'; | ||
|
||
export const ACTION_SET = 'set'; | ||
export const ACTION_CLEAR = 'clear'; | ||
export const ACTION_DEFAULT = 'default'; | ||
|
||
export const CATEGORY_SORTBY = `jaeger/ux/search/results/sortby`; | ||
export const FORM_CATEGORY_BASE = 'jaeger/ux/search/form'; | ||
export const CATEGORY_OPERATION = `${FORM_CATEGORY_BASE}/operation`; | ||
export const CATEGORY_LOOKBACK = `${FORM_CATEGORY_BASE}/lookback`; | ||
export const CATEGORY_TAGS = `${FORM_CATEGORY_BASE}/tags`; | ||
export const CATEGORY_MIN_DURATION = `${FORM_CATEGORY_BASE}/min_duration`; | ||
export const CATEGORY_MAX_DURATION = `${FORM_CATEGORY_BASE}/max_duration`; | ||
export const CATEGORY_LIMIT = `${FORM_CATEGORY_BASE}/limit`; | ||
|
||
export function trackFormInput( | ||
resultsLimit: number, | ||
operation: string, | ||
tags: any, | ||
minDuration: number, | ||
maxDuration: number, | ||
lookback: string | ||
) { | ||
trackEvent(CATEGORY_OPERATION, operation === constants.DEFAULT_OPERATION ? ACTION_DEFAULT : ACTION_SET); | ||
trackEvent(CATEGORY_LIMIT, resultsLimit === constants.DEFAULT_LIMIT ? ACTION_DEFAULT : ACTION_SET); | ||
trackEvent(CATEGORY_MAX_DURATION, maxDuration ? ACTION_SET : ACTION_CLEAR); | ||
trackEvent(CATEGORY_MIN_DURATION, minDuration ? ACTION_SET : ACTION_CLEAR); | ||
trackEvent(CATEGORY_TAGS, tags ? ACTION_SET : ACTION_CLEAR); | ||
trackEvent(CATEGORY_LOOKBACK, lookback); | ||
} | ||
|
||
export const middlewareHooks = { | ||
[constants.FORM_CHANGE_ACTION_TYPE]: (store: Store, action: any) => { | ||
if (action.meta.form === 'sortBy') { | ||
trackEvent(CATEGORY_SORTBY, action.payload); | ||
} | ||
}, | ||
}; |
56 changes: 56 additions & 0 deletions
56
packages/jaeger-ui/src/components/SearchTracePage/SearchForm.track.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/* eslint-disable import/first */ | ||
jest.mock('../../utils/tracking'); | ||
|
||
import { | ||
middlewareHooks, | ||
trackFormInput, | ||
CATEGORY_LIMIT, | ||
CATEGORY_LOOKBACK, | ||
CATEGORY_MAX_DURATION, | ||
CATEGORY_MIN_DURATION, | ||
CATEGORY_OPERATION, | ||
CATEGORY_SORTBY, | ||
CATEGORY_TAGS, | ||
} from './SearchForm.track'; | ||
import { FORM_CHANGE_ACTION_TYPE } from '../../constants/search-form'; | ||
import { trackEvent } from '../../utils/tracking'; | ||
|
||
describe('GA tracking', () => { | ||
it('tracks changing sort criteria', () => { | ||
const action = { meta: { form: 'sortBy' }, payload: 'MOST_RECENT' }; | ||
middlewareHooks[FORM_CHANGE_ACTION_TYPE]({}, action); | ||
expect(trackEvent.mock.calls.length).toBe(1); | ||
expect(trackEvent.mock.calls[0]).toEqual([CATEGORY_SORTBY, expect.any(String)]); | ||
}); | ||
|
||
it('sends form input to GA', () => { | ||
trackEvent.mockClear(); | ||
trackFormInput(0, '', {}, 0, 0, ''); | ||
expect(trackEvent.mock.calls.length).toBe(6); | ||
const categoriesTracked = trackEvent.mock.calls.map(call => call[0]).sort(); | ||
expect(categoriesTracked).toEqual( | ||
[ | ||
CATEGORY_OPERATION, | ||
CATEGORY_LIMIT, | ||
CATEGORY_TAGS, | ||
CATEGORY_MAX_DURATION, | ||
CATEGORY_MIN_DURATION, | ||
CATEGORY_LOOKBACK, | ||
].sort() | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
export const DEFAULT_OPERATION = 'all'; | ||
export const DEFAULT_LOOKBACK = '1h'; | ||
export const DEFAULT_LIMIT = 20; | ||
|
||
export const FORM_CHANGE_ACTION_TYPE = '@@redux-form/CHANGE'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
../../constants/etc...
is out of orderThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we not using something like Prettier to auto-format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are. My remark refers to the order of the lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no auto-formatter for order? Go and Java both have that for imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in prettier, which is the auto-formatter we're using. There might be something around that fits the bill, thought...