mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Move server-side analytics service to packages (#134736)
* creating the empty packages * move public types to public package * move implement and mocks to packages * update readmes * move preboot contract into public package * fix imports * lint * update generated doc
This commit is contained in:
parent
4a7d910da5
commit
0f9714876c
37 changed files with 564 additions and 84 deletions
|
@ -149,6 +149,9 @@
|
|||
"@kbn/core-analytics-browser": "link:bazel-bin/packages/core/analytics/core-analytics-browser",
|
||||
"@kbn/core-analytics-browser-internal": "link:bazel-bin/packages/core/analytics/core-analytics-browser-internal",
|
||||
"@kbn/core-analytics-browser-mocks": "link:bazel-bin/packages/core/analytics/core-analytics-browser-mocks",
|
||||
"@kbn/core-analytics-server": "link:bazel-bin/packages/core/analytics/core-analytics-server",
|
||||
"@kbn/core-analytics-server-internal": "link:bazel-bin/packages/core/analytics/core-analytics-server-internal",
|
||||
"@kbn/core-analytics-server-mocks": "link:bazel-bin/packages/core/analytics/core-analytics-server-mocks",
|
||||
"@kbn/core-base-browser-internal": "link:bazel-bin/packages/core/base/core-base-browser-internal",
|
||||
"@kbn/core-base-browser-mocks": "link:bazel-bin/packages/core/base/core-base-browser-mocks",
|
||||
"@kbn/core-base-common": "link:bazel-bin/packages/core/base/core-base-common",
|
||||
|
@ -670,6 +673,9 @@
|
|||
"@types/kbn__core-analytics-browser": "link:bazel-bin/packages/core/analytics/core-analytics-browser/npm_module_types",
|
||||
"@types/kbn__core-analytics-browser-internal": "link:bazel-bin/packages/core/analytics/core-analytics-browser-internal/npm_module_types",
|
||||
"@types/kbn__core-analytics-browser-mocks": "link:bazel-bin/packages/core/analytics/core-analytics-browser-mocks/npm_module_types",
|
||||
"@types/kbn__core-analytics-server": "link:bazel-bin/packages/core/analytics/core-analytics-server/npm_module_types",
|
||||
"@types/kbn__core-analytics-server-internal": "link:bazel-bin/packages/core/analytics/core-analytics-server-internal/npm_module_types",
|
||||
"@types/kbn__core-analytics-server-mocks": "link:bazel-bin/packages/core/analytics/core-analytics-server-mocks/npm_module_types",
|
||||
"@types/kbn__core-base-browser": "link:bazel-bin/packages/core/base/core-base-browser/npm_module_types",
|
||||
"@types/kbn__core-base-browser-internal": "link:bazel-bin/packages/core/base/core-base-browser-internal/npm_module_types",
|
||||
"@types/kbn__core-base-browser-mocks": "link:bazel-bin/packages/core/base/core-base-browser-mocks/npm_module_types",
|
||||
|
|
|
@ -17,6 +17,9 @@ filegroup(
|
|||
"//packages/core/analytics/core-analytics-browser-internal:build",
|
||||
"//packages/core/analytics/core-analytics-browser-mocks:build",
|
||||
"//packages/core/analytics/core-analytics-browser:build",
|
||||
"//packages/core/analytics/core-analytics-server-internal:build",
|
||||
"//packages/core/analytics/core-analytics-server-mocks:build",
|
||||
"//packages/core/analytics/core-analytics-server:build",
|
||||
"//packages/core/base/core-base-browser-internal:build",
|
||||
"//packages/core/base/core-base-browser-mocks:build",
|
||||
"//packages/core/base/core-base-common-internal:build",
|
||||
|
@ -166,6 +169,9 @@ filegroup(
|
|||
"//packages/core/analytics/core-analytics-browser-internal:build_types",
|
||||
"//packages/core/analytics/core-analytics-browser-mocks:build_types",
|
||||
"//packages/core/analytics/core-analytics-browser:build_types",
|
||||
"//packages/core/analytics/core-analytics-server-internal:build_types",
|
||||
"//packages/core/analytics/core-analytics-server-mocks:build_types",
|
||||
"//packages/core/analytics/core-analytics-server:build_types",
|
||||
"//packages/core/base/core-base-browser-internal:build_types",
|
||||
"//packages/core/base/core-base-browser-mocks:build_types",
|
||||
"//packages/core/base/core-base-common-internal:build_types",
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
load("@npm//@bazel/typescript:index.bzl", "ts_config")
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
||||
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
|
||||
|
||||
PKG_DIRNAME = "core-analytics-server-internal"
|
||||
PKG_REQUIRE_NAME = "@kbn/core-analytics-server-internal"
|
||||
|
||||
SOURCE_FILES = glob(
|
||||
[
|
||||
"src/**/*.ts",
|
||||
],
|
||||
exclude = [
|
||||
"**/*.test.*",
|
||||
],
|
||||
)
|
||||
|
||||
SRCS = SOURCE_FILES
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = SRCS,
|
||||
)
|
||||
|
||||
NPM_MODULE_EXTRA_FILES = [
|
||||
"package.json",
|
||||
]
|
||||
|
||||
RUNTIME_DEPS = [
|
||||
"@npm//rxjs",
|
||||
"//packages/analytics/client",
|
||||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"@npm//@types/node",
|
||||
"@npm//@types/jest",
|
||||
"@npm//rxjs",
|
||||
"//packages/analytics/client:npm_module_types",
|
||||
"//packages/core/base/core-base-server-internal:npm_module_types",
|
||||
"//packages/core/analytics/core-analytics-server:npm_module_types",
|
||||
]
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_node",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
)
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
src = "tsconfig.json",
|
||||
deps = [
|
||||
"//:tsconfig.base.json",
|
||||
"//:tsconfig.bazel.json",
|
||||
],
|
||||
)
|
||||
|
||||
ts_project(
|
||||
name = "tsc_types",
|
||||
args = ['--pretty'],
|
||||
srcs = SRCS,
|
||||
deps = TYPES_DEPS,
|
||||
declaration = True,
|
||||
emit_declaration_only = True,
|
||||
out_dir = "target_types",
|
||||
root_dir = "src",
|
||||
tsconfig = ":tsconfig",
|
||||
)
|
||||
|
||||
js_library(
|
||||
name = PKG_DIRNAME,
|
||||
srcs = NPM_MODULE_EXTRA_FILES,
|
||||
deps = RUNTIME_DEPS + [":target_node"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm(
|
||||
name = "npm_module",
|
||||
deps = [":" + PKG_DIRNAME],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build",
|
||||
srcs = [":npm_module"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm_types(
|
||||
name = "npm_module_types",
|
||||
srcs = SRCS,
|
||||
deps = [":tsc_types"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
tsconfig = ":tsconfig",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build_types",
|
||||
srcs = [":npm_module_types"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -0,0 +1,4 @@
|
|||
# @kbn/core-analytics-server-internal
|
||||
|
||||
This package contains the internal types and implementation for Core's server-side analytics service.
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test/jest_node',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/packages/core/analytics/core-analytics-server-internal'],
|
||||
};
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "@kbn/core-analytics-server-internal",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./target_node/index.js",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0"
|
||||
}
|
|
@ -10,28 +10,11 @@ import { of } from 'rxjs';
|
|||
import type { AnalyticsClient } from '@kbn/analytics-client';
|
||||
import { createAnalytics } from '@kbn/analytics-client';
|
||||
import type { CoreContext } from '@kbn/core-base-server-internal';
|
||||
|
||||
/**
|
||||
* Exposes the public APIs of the AnalyticsClient during the preboot phase
|
||||
* {@link AnalyticsClient}
|
||||
* @public
|
||||
*/
|
||||
export type AnalyticsServicePreboot = Omit<AnalyticsClient, 'shutdown'>;
|
||||
/**
|
||||
* Exposes the public APIs of the AnalyticsClient during the setup phase.
|
||||
* {@link AnalyticsClient}
|
||||
* @public
|
||||
*/
|
||||
export type AnalyticsServiceSetup = Omit<AnalyticsClient, 'shutdown'>;
|
||||
/**
|
||||
* Exposes the public APIs of the AnalyticsClient during the start phase
|
||||
* {@link AnalyticsClient}
|
||||
* @public
|
||||
*/
|
||||
export type AnalyticsServiceStart = Pick<
|
||||
AnalyticsClient,
|
||||
'optIn' | 'reportEvent' | 'telemetryCounter$'
|
||||
>;
|
||||
import type {
|
||||
AnalyticsServiceSetup,
|
||||
AnalyticsServiceStart,
|
||||
AnalyticsServicePreboot,
|
||||
} from '@kbn/core-analytics-server';
|
||||
|
||||
export class AnalyticsService {
|
||||
private readonly analyticsClient: AnalyticsClient;
|
||||
|
@ -59,6 +42,7 @@ export class AnalyticsService {
|
|||
telemetryCounter$: this.analyticsClient.telemetryCounter$,
|
||||
};
|
||||
}
|
||||
|
||||
public setup(): AnalyticsServiceSetup {
|
||||
return {
|
||||
optIn: this.analyticsClient.optIn,
|
||||
|
@ -70,6 +54,7 @@ export class AnalyticsService {
|
|||
telemetryCounter$: this.analyticsClient.telemetryCounter$,
|
||||
};
|
||||
}
|
||||
|
||||
public start(): AnalyticsServiceStart {
|
||||
return {
|
||||
optIn: this.analyticsClient.optIn,
|
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export { AnalyticsService } from './analytics_service';
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "target_types",
|
||||
"rootDir": "src",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
100
packages/core/analytics/core-analytics-server-mocks/BUILD.bazel
Normal file
100
packages/core/analytics/core-analytics-server-mocks/BUILD.bazel
Normal file
|
@ -0,0 +1,100 @@
|
|||
load("@npm//@bazel/typescript:index.bzl", "ts_config")
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
||||
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
|
||||
|
||||
PKG_DIRNAME = "core-analytics-server-mocks"
|
||||
PKG_REQUIRE_NAME = "@kbn/core-analytics-server-mocks"
|
||||
|
||||
SOURCE_FILES = glob(
|
||||
[
|
||||
"src/**/*.ts",
|
||||
],
|
||||
exclude = [
|
||||
"**/*.test.*",
|
||||
],
|
||||
)
|
||||
|
||||
SRCS = SOURCE_FILES
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = SRCS,
|
||||
)
|
||||
|
||||
NPM_MODULE_EXTRA_FILES = [
|
||||
"package.json",
|
||||
]
|
||||
|
||||
RUNTIME_DEPS = [
|
||||
"@npm//rxjs",
|
||||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"@npm//@types/node",
|
||||
"@npm//@types/jest",
|
||||
"@npm//rxjs",
|
||||
"//packages/kbn-utility-types:npm_module_types",
|
||||
"//packages/core/analytics/core-analytics-server:npm_module_types",
|
||||
"//packages/core/analytics/core-analytics-server-internal:npm_module_types",
|
||||
]
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_node",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
)
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
src = "tsconfig.json",
|
||||
deps = [
|
||||
"//:tsconfig.base.json",
|
||||
"//:tsconfig.bazel.json",
|
||||
],
|
||||
)
|
||||
|
||||
ts_project(
|
||||
name = "tsc_types",
|
||||
args = ['--pretty'],
|
||||
srcs = SRCS,
|
||||
deps = TYPES_DEPS,
|
||||
declaration = True,
|
||||
emit_declaration_only = True,
|
||||
out_dir = "target_types",
|
||||
root_dir = "src",
|
||||
tsconfig = ":tsconfig",
|
||||
)
|
||||
|
||||
js_library(
|
||||
name = PKG_DIRNAME,
|
||||
srcs = NPM_MODULE_EXTRA_FILES,
|
||||
deps = RUNTIME_DEPS + [":target_node"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm(
|
||||
name = "npm_module",
|
||||
deps = [":" + PKG_DIRNAME],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build",
|
||||
srcs = [":npm_module"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm_types(
|
||||
name = "npm_module_types",
|
||||
srcs = SRCS,
|
||||
deps = [":tsc_types"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
tsconfig = ":tsconfig",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build_types",
|
||||
srcs = [":npm_module_types"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -0,0 +1,4 @@
|
|||
# @kbn/core-analytics-server-mocks
|
||||
|
||||
This package contains the mocks for Core's server-side analytics service.
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test/jest_node',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/packages/core/analytics/core-analytics-server-mocks'],
|
||||
};
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "@kbn/core-analytics-server-mocks",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./target_node/index.js",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0"
|
||||
}
|
|
@ -6,14 +6,14 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { Subject } from 'rxjs';
|
||||
import type { PublicMethodsOf } from '@kbn/utility-types';
|
||||
import type {
|
||||
AnalyticsService,
|
||||
AnalyticsServicePreboot,
|
||||
AnalyticsServiceSetup,
|
||||
AnalyticsServiceStart,
|
||||
} from './analytics_service';
|
||||
import { Subject } from 'rxjs';
|
||||
AnalyticsServicePreboot,
|
||||
} from '@kbn/core-analytics-server';
|
||||
import type { AnalyticsService } from '@kbn/core-analytics-server-internal';
|
||||
|
||||
type AnalyticsServiceContract = PublicMethodsOf<AnalyticsService>;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export { analyticsServiceMock } from './analytics_service.mock';
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "target_types",
|
||||
"rootDir": "src",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
96
packages/core/analytics/core-analytics-server/BUILD.bazel
Normal file
96
packages/core/analytics/core-analytics-server/BUILD.bazel
Normal file
|
@ -0,0 +1,96 @@
|
|||
load("@npm//@bazel/typescript:index.bzl", "ts_config")
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
||||
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
|
||||
|
||||
PKG_DIRNAME = "core-analytics-server"
|
||||
PKG_REQUIRE_NAME = "@kbn/core-analytics-server"
|
||||
|
||||
SOURCE_FILES = glob(
|
||||
[
|
||||
"src/**/*.ts",
|
||||
],
|
||||
exclude = [
|
||||
"**/*.test.*",
|
||||
],
|
||||
)
|
||||
|
||||
SRCS = SOURCE_FILES
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = SRCS,
|
||||
)
|
||||
|
||||
NPM_MODULE_EXTRA_FILES = [
|
||||
"package.json",
|
||||
]
|
||||
|
||||
RUNTIME_DEPS = [
|
||||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"@npm//@types/node",
|
||||
"@npm//@types/jest",
|
||||
"//packages/analytics/client:npm_module_types",
|
||||
]
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_node",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
)
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
src = "tsconfig.json",
|
||||
deps = [
|
||||
"//:tsconfig.base.json",
|
||||
"//:tsconfig.bazel.json",
|
||||
],
|
||||
)
|
||||
|
||||
ts_project(
|
||||
name = "tsc_types",
|
||||
args = ['--pretty'],
|
||||
srcs = SRCS,
|
||||
deps = TYPES_DEPS,
|
||||
declaration = True,
|
||||
emit_declaration_only = True,
|
||||
out_dir = "target_types",
|
||||
root_dir = "src",
|
||||
tsconfig = ":tsconfig",
|
||||
)
|
||||
|
||||
js_library(
|
||||
name = PKG_DIRNAME,
|
||||
srcs = NPM_MODULE_EXTRA_FILES,
|
||||
deps = RUNTIME_DEPS + [":target_node"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm(
|
||||
name = "npm_module",
|
||||
deps = [":" + PKG_DIRNAME],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build",
|
||||
srcs = [":npm_module"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm_types(
|
||||
name = "npm_module_types",
|
||||
srcs = SRCS,
|
||||
deps = [":tsc_types"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
tsconfig = ":tsconfig",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build_types",
|
||||
srcs = [":npm_module_types"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
4
packages/core/analytics/core-analytics-server/README.md
Normal file
4
packages/core/analytics/core-analytics-server/README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
# @kbn/core-analytics-server
|
||||
|
||||
This package contains the public types for Core's server-side analytics service.
|
||||
|
13
packages/core/analytics/core-analytics-server/jest.config.js
Normal file
13
packages/core/analytics/core-analytics-server/jest.config.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test/jest_node',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/packages/core/analytics/core-analytics-server'],
|
||||
};
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "@kbn/core-analytics-server",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./target_node/index.js",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0"
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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 { AnalyticsClient } from '@kbn/analytics-client';
|
||||
|
||||
/**
|
||||
* Exposes the public APIs of the AnalyticsClient during the preboot phase
|
||||
* {@link AnalyticsClient}
|
||||
* @public
|
||||
*/
|
||||
export type AnalyticsServicePreboot = Omit<AnalyticsClient, 'shutdown'>;
|
||||
|
||||
/**
|
||||
* Exposes the public APIs of the AnalyticsClient during the setup phase.
|
||||
* {@link AnalyticsClient}
|
||||
* @public
|
||||
*/
|
||||
export type AnalyticsServiceSetup = Omit<AnalyticsClient, 'shutdown'>;
|
||||
|
||||
/**
|
||||
* Exposes the public APIs of the AnalyticsClient during the start phase
|
||||
* {@link AnalyticsClient}
|
||||
* @public
|
||||
*/
|
||||
export type AnalyticsServiceStart = Pick<
|
||||
AnalyticsClient,
|
||||
'optIn' | 'reportEvent' | 'telemetryCounter$'
|
||||
>;
|
|
@ -6,24 +6,8 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export { AnalyticsService } from './analytics_service';
|
||||
export type {
|
||||
AnalyticsServicePreboot,
|
||||
AnalyticsServiceSetup,
|
||||
AnalyticsServiceStart,
|
||||
} from './analytics_service';
|
||||
|
||||
export type {
|
||||
AnalyticsClient,
|
||||
Event,
|
||||
EventContext,
|
||||
EventType,
|
||||
EventTypeOpts,
|
||||
IShipper,
|
||||
ShipperClassConstructor,
|
||||
OptInConfig,
|
||||
ContextProviderOpts,
|
||||
TelemetryCounter,
|
||||
} from '@kbn/analytics-client';
|
||||
|
||||
export { TelemetryCounterType } from '@kbn/analytics-client';
|
||||
AnalyticsServicePreboot,
|
||||
} from './contracts';
|
17
packages/core/analytics/core-analytics-server/tsconfig.json
Normal file
17
packages/core/analytics/core-analytics-server/tsconfig.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "target_types",
|
||||
"rootDir": "src",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
|
@ -29,6 +29,7 @@ import { Env } from '@kbn/config';
|
|||
import { configServiceMock, getEnvOptions } from '@kbn/config-mocks';
|
||||
import type { CoreContext } from '@kbn/core-base-server-internal';
|
||||
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
|
||||
import { analyticsServiceMock } from '@kbn/core-analytics-server-mocks';
|
||||
import { httpServiceMock } from '../http/http_service.mock';
|
||||
import { executionContextServiceMock } from '../execution_context/execution_context_service.mock';
|
||||
import { configSchema, ElasticsearchConfig } from './elasticsearch_config';
|
||||
|
@ -37,7 +38,6 @@ import { elasticsearchClientMock } from './client/mocks';
|
|||
import { duration } from 'moment';
|
||||
import { isValidConnection as isValidConnectionMock } from './is_valid_connection';
|
||||
import { pollEsNodesVersion as pollEsNodesVersionMocked } from './version_check/ensure_es_version';
|
||||
import { analyticsServiceMock } from '../analytics/analytics_service.mock';
|
||||
|
||||
const { pollEsNodesVersion: pollEsNodesVersionActual } = jest.requireActual(
|
||||
'./version_check/ensure_es_version'
|
||||
|
|
|
@ -11,8 +11,8 @@ import { map, shareReplay, takeUntil } from 'rxjs/operators';
|
|||
|
||||
import type { Logger } from '@kbn/logging';
|
||||
import type { CoreContext, CoreService } from '@kbn/core-base-server-internal';
|
||||
import type { AnalyticsServiceSetup } from '@kbn/core-analytics-server';
|
||||
import { registerAnalyticsContextProvider } from './register_analytics_context_provider';
|
||||
import { AnalyticsServiceSetup } from '../analytics';
|
||||
|
||||
import { ClusterClient, ElasticsearchClientConfig } from './client';
|
||||
import { ElasticsearchConfig, ElasticsearchConfigType } from './elasticsearch_config';
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
*/
|
||||
|
||||
import { firstValueFrom, of } from 'rxjs';
|
||||
import type { AnalyticsServiceSetup } from '../analytics';
|
||||
import { analyticsServiceMock } from '../analytics/analytics_service.mock';
|
||||
import { analyticsServiceMock } from '@kbn/core-analytics-server-mocks';
|
||||
import type { AnalyticsServiceSetup } from '@kbn/core-analytics-server';
|
||||
import { registerAnalyticsContextProvider } from './register_analytics_context_provider';
|
||||
|
||||
describe('registerAnalyticsContextProvider', () => {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { AnalyticsServiceSetup } from '../analytics';
|
||||
import type { AnalyticsServiceSetup } from '@kbn/core-analytics-server';
|
||||
import type { ClusterInfo } from './get_cluster_info';
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,16 +9,17 @@
|
|||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
import type { CoreContext } from '@kbn/core-base-server-internal';
|
||||
import type { AnalyticsServicePreboot } from '@kbn/core-analytics-server';
|
||||
|
||||
import { EnvironmentService } from './environment_service';
|
||||
import { resolveInstanceUuid } from './resolve_uuid';
|
||||
import { createDataFolder } from './create_data_folder';
|
||||
import { writePidFile } from './write_pid_file';
|
||||
import type { AnalyticsServicePreboot } from '../analytics';
|
||||
|
||||
import { configServiceMock } from '@kbn/config-mocks';
|
||||
import { mockCoreContext } from '@kbn/core-base-server-mocks';
|
||||
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
|
||||
import { analyticsServiceMock } from '../analytics/analytics_service.mock';
|
||||
import { analyticsServiceMock } from '@kbn/core-analytics-server-mocks';
|
||||
|
||||
jest.mock('./resolve_uuid', () => ({
|
||||
resolveInstanceUuid: jest.fn().mockResolvedValue('SOME_UUID'),
|
||||
|
|
|
@ -11,7 +11,7 @@ import { PathConfigType, config as pathConfigDef } from '@kbn/utils';
|
|||
import type { Logger } from '@kbn/logging';
|
||||
import type { IConfigService } from '@kbn/config';
|
||||
import type { CoreContext } from '@kbn/core-base-server-internal';
|
||||
import type { AnalyticsServicePreboot } from '../analytics';
|
||||
import type { AnalyticsServicePreboot } from '@kbn/core-analytics-server';
|
||||
import { HttpConfigType, config as httpConfigDef } from '../http';
|
||||
import { PidConfigType, config as pidConfigDef } from './pid_config';
|
||||
import { resolveInstanceUuid } from './resolve_uuid';
|
||||
|
|
|
@ -33,6 +33,11 @@ import { Type } from '@kbn/config-schema';
|
|||
import type { DocLinksServiceStart, DocLinksServiceSetup } from '@kbn/core-doc-links-server';
|
||||
import type { AppenderConfigType, LoggingServiceSetup } from '@kbn/core-logging-server';
|
||||
import { appendersSchema } from '@kbn/core-logging-server-internal';
|
||||
import type {
|
||||
AnalyticsServiceSetup,
|
||||
AnalyticsServiceStart,
|
||||
AnalyticsServicePreboot,
|
||||
} from '@kbn/core-analytics-server';
|
||||
import {
|
||||
ElasticsearchServiceSetup,
|
||||
configSchema as elasticsearchConfigSchema,
|
||||
|
@ -85,11 +90,6 @@ export type {
|
|||
};
|
||||
|
||||
import type { ExecutionContextSetup, ExecutionContextStart } from './execution_context';
|
||||
import type {
|
||||
AnalyticsServicePreboot,
|
||||
AnalyticsServiceSetup,
|
||||
AnalyticsServiceStart,
|
||||
} from './analytics';
|
||||
|
||||
export type { IExecutionContextContainer, KibanaExecutionContext } from './execution_context';
|
||||
|
||||
|
@ -453,9 +453,6 @@ export type {
|
|||
export type { DocLinksServiceStart, DocLinksServiceSetup } from '@kbn/core-doc-links-server';
|
||||
|
||||
export type {
|
||||
AnalyticsServiceSetup,
|
||||
AnalyticsServicePreboot,
|
||||
AnalyticsServiceStart,
|
||||
AnalyticsClient,
|
||||
Event,
|
||||
EventContext,
|
||||
|
@ -466,8 +463,13 @@ export type {
|
|||
OptInConfig,
|
||||
ShipperClassConstructor,
|
||||
TelemetryCounter,
|
||||
} from './analytics';
|
||||
export { TelemetryCounterType } from './analytics';
|
||||
} from '@kbn/analytics-client';
|
||||
export { TelemetryCounterType } from '@kbn/analytics-client';
|
||||
export type {
|
||||
AnalyticsServiceSetup,
|
||||
AnalyticsServicePreboot,
|
||||
AnalyticsServiceStart,
|
||||
} from '@kbn/core-analytics-server';
|
||||
|
||||
/** @public **/
|
||||
export interface RequestHandlerContextBase {
|
||||
|
|
|
@ -11,6 +11,11 @@ import {
|
|||
InternalLoggingServicePreboot,
|
||||
InternalLoggingServiceSetup,
|
||||
} from '@kbn/core-logging-server-internal';
|
||||
import type {
|
||||
AnalyticsServicePreboot,
|
||||
AnalyticsServiceSetup,
|
||||
AnalyticsServiceStart,
|
||||
} from '@kbn/core-analytics-server';
|
||||
import { CapabilitiesSetup, CapabilitiesStart } from './capabilities';
|
||||
import { InternalContextPreboot, ContextSetup } from './context';
|
||||
import {
|
||||
|
@ -45,11 +50,6 @@ import type {
|
|||
InternalExecutionContextStart,
|
||||
} from './execution_context';
|
||||
import { InternalPrebootServicePreboot } from './preboot';
|
||||
import type {
|
||||
AnalyticsServicePreboot,
|
||||
AnalyticsServiceSetup,
|
||||
AnalyticsServiceStart,
|
||||
} from './analytics';
|
||||
|
||||
/** @internal */
|
||||
export interface InternalCorePreboot {
|
||||
|
|
|
@ -13,6 +13,7 @@ import { isPromise } from '@kbn/std';
|
|||
import type { MockedKeys } from '@kbn/utility-types-jest';
|
||||
import { docLinksServiceMock } from '@kbn/core-doc-links-server-mocks';
|
||||
import { loggingSystemMock, loggingServiceMock } from '@kbn/core-logging-server-mocks';
|
||||
import { analyticsServiceMock } from '@kbn/core-analytics-server-mocks';
|
||||
import type {
|
||||
PluginInitializerContext,
|
||||
CoreSetup,
|
||||
|
@ -39,7 +40,6 @@ import { i18nServiceMock } from './i18n/i18n_service.mock';
|
|||
import { deprecationsServiceMock } from './deprecations/deprecations_service.mock';
|
||||
import { executionContextServiceMock } from './execution_context/execution_context_service.mock';
|
||||
import { prebootServiceMock } from './preboot/preboot_service.mock';
|
||||
import { analyticsServiceMock } from './analytics/analytics_service.mock';
|
||||
|
||||
export { configServiceMock, configDeprecationsMock } from '@kbn/config-mocks';
|
||||
export { loggingSystemMock } from '@kbn/core-logging-server-mocks';
|
||||
|
@ -64,7 +64,7 @@ export { i18nServiceMock } from './i18n/i18n_service.mock';
|
|||
export { deprecationsServiceMock } from './deprecations/deprecations_service.mock';
|
||||
export { executionContextServiceMock } from './execution_context/execution_context_service.mock';
|
||||
export { docLinksServiceMock } from '@kbn/core-doc-links-server-mocks';
|
||||
export { analyticsServiceMock } from './analytics/analytics_service.mock';
|
||||
export { analyticsServiceMock } from '@kbn/core-analytics-server-mocks';
|
||||
|
||||
export type {
|
||||
ElasticsearchClientMock,
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
import { AddConfigDeprecation } from '@kbn/config';
|
||||
import { AnalyticsClient } from '@kbn/analytics-client';
|
||||
import { AnalyticsServicePreboot } from '@kbn/core-analytics-server';
|
||||
import { AnalyticsServiceSetup } from '@kbn/core-analytics-server';
|
||||
import { AnalyticsServiceStart } from '@kbn/core-analytics-server';
|
||||
import apm from 'elastic-apm-node';
|
||||
import { AppenderConfigType } from '@kbn/core-logging-server';
|
||||
import { AwaitedProperties } from '@kbn/utility-types';
|
||||
|
@ -82,20 +85,11 @@ export { AddConfigDeprecation }
|
|||
|
||||
export { AnalyticsClient }
|
||||
|
||||
// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver
|
||||
//
|
||||
// @public
|
||||
export type AnalyticsServicePreboot = Omit<AnalyticsClient, 'shutdown'>;
|
||||
export { AnalyticsServicePreboot }
|
||||
|
||||
// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver
|
||||
//
|
||||
// @public
|
||||
export type AnalyticsServiceSetup = Omit<AnalyticsClient, 'shutdown'>;
|
||||
export { AnalyticsServiceSetup }
|
||||
|
||||
// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver
|
||||
//
|
||||
// @public
|
||||
export type AnalyticsServiceStart = Pick<AnalyticsClient, 'optIn' | 'reportEvent' | 'telemetryCounter$'>;
|
||||
export { AnalyticsServiceStart }
|
||||
|
||||
// @public
|
||||
export const APP_WRAPPER_CLASS = "kbnAppWrapper";
|
||||
|
@ -438,6 +432,8 @@ export type CoreIncrementUsageCounter = (params: CoreIncrementCounterParams) =>
|
|||
|
||||
// @public
|
||||
export interface CorePreboot {
|
||||
// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver
|
||||
//
|
||||
// (undocumented)
|
||||
analytics: AnalyticsServicePreboot;
|
||||
// (undocumented)
|
||||
|
@ -495,6 +491,8 @@ export interface CoreServicesUsageData {
|
|||
|
||||
// @public
|
||||
export interface CoreSetup<TPluginsStart extends object = object, TStart = unknown> {
|
||||
// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver
|
||||
//
|
||||
// (undocumented)
|
||||
analytics: AnalyticsServiceSetup;
|
||||
// (undocumented)
|
||||
|
@ -537,6 +535,8 @@ export interface CoreSetup<TPluginsStart extends object = object, TStart = unkno
|
|||
|
||||
// @public
|
||||
export interface CoreStart {
|
||||
// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver
|
||||
//
|
||||
// (undocumented)
|
||||
analytics: AnalyticsServiceStart;
|
||||
// (undocumented)
|
||||
|
|
|
@ -17,6 +17,8 @@ import {
|
|||
ILoggingSystem,
|
||||
config as loggingConfig,
|
||||
} from '@kbn/core-logging-server-internal';
|
||||
import { AnalyticsService } from '@kbn/core-analytics-server-internal';
|
||||
import type { AnalyticsServiceSetup } from '@kbn/core-analytics-server';
|
||||
import { coreDeprecationProvider, ensureValidConfiguration } from './config';
|
||||
import { CoreApp } from './core_app';
|
||||
import { I18nService } from './i18n';
|
||||
|
@ -51,7 +53,6 @@ import { config as executionContextConfig } from './execution_context';
|
|||
import { PrebootCoreRouteHandlerContext } from './preboot_core_route_handler_context';
|
||||
import { PrebootService } from './preboot';
|
||||
import { DiscoveredPlugins } from './plugins';
|
||||
import { AnalyticsService, AnalyticsServiceSetup } from './analytics';
|
||||
|
||||
const coreId = Symbol('core');
|
||||
const rootConfigPath = '';
|
||||
|
|
|
@ -24,7 +24,7 @@ import { mockRouter, RouterMock } from '../http/router/router.mock';
|
|||
import { metricsServiceMock } from '../metrics/metrics_service.mock';
|
||||
import { configServiceMock } from '@kbn/config-mocks';
|
||||
import { coreUsageDataServiceMock } from '../core_usage_data/core_usage_data_service.mock';
|
||||
import { analyticsServiceMock } from '../analytics/analytics_service.mock';
|
||||
import { analyticsServiceMock } from '@kbn/core-analytics-server-mocks';
|
||||
import { AnalyticsServiceSetup } from '..';
|
||||
|
||||
expect.addSnapshotSerializer(ServiceStatusLevelSnapshotSerializer);
|
||||
|
|
|
@ -22,7 +22,7 @@ import type { RootSchema } from '@kbn/analytics-client';
|
|||
import { Logger, LogMeta } from '@kbn/logging';
|
||||
import type { CoreContext, CoreService } from '@kbn/core-base-server-internal';
|
||||
import type { PluginName } from '@kbn/core-base-common';
|
||||
import { AnalyticsServiceSetup } from '../analytics';
|
||||
import type { AnalyticsServiceSetup } from '@kbn/core-analytics-server';
|
||||
import { InternalElasticsearchServiceSetup } from '../elasticsearch';
|
||||
import { InternalHttpServiceSetup } from '../http';
|
||||
import { InternalSavedObjectsServiceSetup } from '../saved_objects';
|
||||
|
|
24
yarn.lock
24
yarn.lock
|
@ -3027,6 +3027,18 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/core-analytics-server-internal@link:bazel-bin/packages/core/analytics/core-analytics-server-internal":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/core-analytics-server-mocks@link:bazel-bin/packages/core/analytics/core-analytics-server-mocks":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/core-analytics-server@link:bazel-bin/packages/core/analytics/core-analytics-server":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/core-base-browser-internal@link:bazel-bin/packages/core/base/core-base-browser-internal":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
@ -6406,6 +6418,18 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@types/kbn__core-analytics-server-internal@link:bazel-bin/packages/core/analytics/core-analytics-server-internal/npm_module_types":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@types/kbn__core-analytics-server-mocks@link:bazel-bin/packages/core/analytics/core-analytics-server-mocks/npm_module_types":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@types/kbn__core-analytics-server@link:bazel-bin/packages/core/analytics/core-analytics-server/npm_module_types":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@types/kbn__core-base-browser-internal@link:bazel-bin/packages/core/base/core-base-browser-internal/npm_module_types":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue