-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into limit-rows-find-cat…
…egory-api
- Loading branch information
Showing
100 changed files
with
2,507 additions
and
317 deletions.
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
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
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
38 changes: 38 additions & 0 deletions
38
...ication/core-application-browser-internal/src/register_analytics_context_provider.test.ts
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,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { firstValueFrom, ReplaySubject, Subject } from 'rxjs'; | ||
import { registerAnalyticsContextProvider } from './register_analytics_context_provider'; | ||
import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks'; | ||
|
||
describe('registerAnalyticsContextProvider', () => { | ||
let analytics: ReturnType<typeof analyticsServiceMock.createAnalyticsServiceSetup>; | ||
let location$: Subject<string>; | ||
|
||
beforeEach(() => { | ||
analytics = analyticsServiceMock.createAnalyticsServiceSetup(); | ||
location$ = new ReplaySubject<string>(1); | ||
registerAnalyticsContextProvider({ analytics, location$ }); | ||
}); | ||
|
||
test('should register the analytics context provider', () => { | ||
expect(analytics.registerContextProvider).toHaveBeenCalledTimes(1); | ||
expect(analytics.registerContextProvider).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
name: 'page url', | ||
}) | ||
); | ||
}); | ||
|
||
test('emits a context value when location$ emits', async () => { | ||
location$.next('/some_url'); | ||
await expect( | ||
firstValueFrom(analytics.registerContextProvider.mock.calls[0][0].context$) | ||
).resolves.toEqual({ page_url: '/some_url' }); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
.../application/core-application-browser-internal/src/register_analytics_context_provider.ts
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,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { AnalyticsServiceSetup } from '@kbn/core-analytics-browser'; | ||
import { type Observable, map } from 'rxjs'; | ||
|
||
export function registerAnalyticsContextProvider({ | ||
analytics, | ||
location$, | ||
}: { | ||
analytics: AnalyticsServiceSetup; | ||
location$: Observable<string>; | ||
}) { | ||
analytics.registerContextProvider({ | ||
name: 'page url', | ||
context$: location$.pipe(map((location) => ({ page_url: location }))), | ||
schema: { | ||
page_url: { type: 'text', _meta: { description: 'The page url' } }, | ||
}, | ||
}); | ||
} |
Oops, something went wrong.