-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[RUM Dashboard] Visitors by region map #77135
Merged
Merged
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
64bbd06
update
shahzad31 8b86367
Merge branch 'master' into visitor-breakdown-usability
shahzad31 e409714
update
shahzad31 48e3009
Merge branch 'master' into visitor-breakdown-usability
shahzad31 54e8176
update
shahzad31 caa2328
Merge branch 'master' into visitor-breakdown-usability
shahzad31 85549e0
update
shahzad31 5e41f85
Merge branch 'master' into visitor-breakdown-usability
shahzad31 e978f57
Merge branch 'master' into visitor-breakdown-usability
shahzad31 7f7025a
update
shahzad31 a9b56b8
Merge branch 'master' into visitor-breakdown-usability
shahzad31 31d7ca5
WIP
shahzad31 1ee8627
WIP
shahzad31 529a853
added filters to map
shahzad31 2edd2f2
added filters to map
shahzad31 fe90084
Merge branch 'master' into visitor-map
shahzad31 3b6a371
update
shahzad31 e103c08
added few tests
shahzad31 7d50ad9
added a simple story
shahzad31 e94d3cb
added snapshot
shahzad31 69687d4
added some constants
shahzad31 54a85be
remove extra type changes
shahzad31 abbd95b
hide filter action
shahzad31 ace12e5
Merge branch 'master' into visitor-map
elasticmachine 5fa1e09
remove redundant file
shahzad31 92930d7
Merge branch 'visitor-map' of https://github.com/shahzad31/kibana int…
shahzad31 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export const APM_STATIC_INDEX_PATTERN_ID = 'apm_static_index_pattern_id'; | ||
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 |
---|---|---|
|
@@ -7,7 +7,8 @@ | |
"apmOss", | ||
"data", | ||
"licensing", | ||
"triggers_actions_ui" | ||
"triggers_actions_ui", | ||
"embeddable" | ||
], | ||
"optionalPlugins": [ | ||
"cloud", | ||
|
@@ -22,17 +23,13 @@ | |
], | ||
"server": true, | ||
"ui": true, | ||
"configPath": [ | ||
"xpack", | ||
"apm" | ||
], | ||
"extraPublicDirs": [ | ||
"public/style/variables" | ||
], | ||
"configPath": ["xpack", "apm"], | ||
"extraPublicDirs": ["public/style/variables"], | ||
"requiredBundles": [ | ||
"kibanaReact", | ||
"kibanaUtils", | ||
"observability", | ||
"home" | ||
"home", | ||
"maps" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps add a comment that this is used by csm. This way we can remove it when csm is moved to a separate app. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JSON doesn't have comments. |
||
] | ||
} |
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
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 |
---|---|---|
|
@@ -118,7 +118,6 @@ export function CoreVitalItem({ | |
setInFocusInd(ind); | ||
}} | ||
/> | ||
<EuiSpacer size="xl" /> | ||
</> | ||
); | ||
} |
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
183 changes: 183 additions & 0 deletions
183
x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/EmbeddedMap.tsx
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,183 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { useEffect, useState, useRef } from 'react'; | ||
import uuid from 'uuid'; | ||
import styled from 'styled-components'; | ||
|
||
import { | ||
MapEmbeddable, | ||
MapEmbeddableInput, | ||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths | ||
} from '../../../../../../maps/public/embeddable'; | ||
import { MAP_SAVED_OBJECT_TYPE } from '../../../../../../maps/common/constants'; | ||
import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; | ||
import { | ||
ErrorEmbeddable, | ||
ViewMode, | ||
isErrorEmbeddable, | ||
} from '../../../../../../../../src/plugins/embeddable/public'; | ||
import { getLayerList } from './LayerList'; | ||
import { useUrlParams } from '../../../../hooks/useUrlParams'; | ||
import { RenderTooltipContentParams } from '../../../../../../maps/public'; | ||
import { MapToolTip } from './MapToolTip'; | ||
import { useMapFilters } from './useMapFilters'; | ||
import { EmbeddableStart } from '../../../../../../../../src/plugins/embeddable/public'; | ||
|
||
const EmbeddedPanel = styled.div` | ||
z-index: auto; | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
position: relative; | ||
.embPanel__content { | ||
display: flex; | ||
flex: 1 1 100%; | ||
z-index: 1; | ||
min-height: 0; // Absolute must for Firefox to scroll contents | ||
} | ||
&&& .mapboxgl-canvas { | ||
animation: none !important; | ||
} | ||
`; | ||
|
||
interface KibanaDeps { | ||
embeddable: EmbeddableStart; | ||
} | ||
export function EmbeddedMapComponent() { | ||
const { urlParams } = useUrlParams(); | ||
|
||
const { start, end, serviceName } = urlParams; | ||
|
||
const mapFilters = useMapFilters(); | ||
|
||
const [embeddable, setEmbeddable] = useState< | ||
MapEmbeddable | ErrorEmbeddable | undefined | ||
>(); | ||
|
||
const embeddableRoot: React.RefObject<HTMLDivElement> = useRef< | ||
HTMLDivElement | ||
>(null); | ||
|
||
const { | ||
services: { embeddable: embeddablePlugin }, | ||
} = useKibana<KibanaDeps>(); | ||
|
||
if (!embeddablePlugin) { | ||
throw new Error('Embeddable start plugin not found'); | ||
} | ||
const factory: any = embeddablePlugin.getEmbeddableFactory( | ||
MAP_SAVED_OBJECT_TYPE | ||
); | ||
|
||
const input: MapEmbeddableInput = { | ||
id: uuid.v4(), | ||
filters: mapFilters, | ||
refreshConfig: { | ||
value: 0, | ||
pause: false, | ||
}, | ||
viewMode: ViewMode.VIEW, | ||
isLayerTOCOpen: false, | ||
query: { | ||
query: 'transaction.type : "page-load"', | ||
language: 'kuery', | ||
}, | ||
...(start && { | ||
timeRange: { | ||
from: new Date(start!).toISOString(), | ||
to: new Date(end!).toISOString(), | ||
}, | ||
}), | ||
hideFilterActions: true, | ||
}; | ||
|
||
function renderTooltipContent({ | ||
addFilters, | ||
closeTooltip, | ||
features, | ||
isLocked, | ||
getLayerName, | ||
loadFeatureProperties, | ||
loadFeatureGeometry, | ||
}: RenderTooltipContentParams) { | ||
const props = { | ||
addFilters, | ||
closeTooltip, | ||
isLocked, | ||
getLayerName, | ||
loadFeatureProperties, | ||
loadFeatureGeometry, | ||
}; | ||
|
||
return <MapToolTip {...props} features={features} />; | ||
} | ||
|
||
useEffect(() => { | ||
if (embeddable != null && serviceName) { | ||
embeddable.updateInput({ filters: mapFilters }); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [mapFilters]); | ||
|
||
// DateRange updated useEffect | ||
useEffect(() => { | ||
if (embeddable != null && start != null && end != null) { | ||
const timeRange = { | ||
from: new Date(start).toISOString(), | ||
to: new Date(end).toISOString(), | ||
}; | ||
embeddable.updateInput({ timeRange }); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [start, end]); | ||
|
||
useEffect(() => { | ||
async function setupEmbeddable() { | ||
if (!factory) { | ||
throw new Error('Map embeddable not found.'); | ||
} | ||
const embeddableObject: any = await factory.create({ | ||
...input, | ||
title: 'Visitors by region', | ||
}); | ||
|
||
if (embeddableObject && !isErrorEmbeddable(embeddableObject)) { | ||
embeddableObject.setRenderTooltipContent(renderTooltipContent); | ||
await embeddableObject.setLayerList(getLayerList()); | ||
} | ||
|
||
setEmbeddable(embeddableObject); | ||
} | ||
|
||
setupEmbeddable(); | ||
|
||
// we want this effect to execute exactly once after the component mounts | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
// We can only render after embeddable has already initialized | ||
useEffect(() => { | ||
if (embeddableRoot.current && embeddable) { | ||
embeddable.render(embeddableRoot.current); | ||
} | ||
}, [embeddable, embeddableRoot]); | ||
|
||
return ( | ||
<EmbeddedPanel> | ||
<div | ||
data-test-subj="xpack.apm.regionMap.embeddedPanel" | ||
className="embPanel__content" | ||
ref={embeddableRoot} | ||
/> | ||
</EmbeddedPanel> | ||
); | ||
} | ||
|
||
EmbeddedMapComponent.displayName = 'EmbeddedMap'; | ||
|
||
export const EmbeddedMap = React.memo(EmbeddedMapComponent); |
Oops, something went wrong.
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.
This file already exists in https://github.com/elastic/kibana/blob/master/src/plugins/apm_oss/common/index_pattern_constants.ts. Can we avoid duplicating it?