Report Connect usage events (#19564)

This commit is contained in:
Grzegorz Zdunek 2023-01-10 18:17:21 +01:00 committed by GitHub
parent 44f57bf346
commit 584e96efe0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 8801 additions and 624 deletions

View file

@ -848,6 +848,7 @@ ADDLICENSE_ARGS := -c 'Gravitational, Inc' -l apache \
-ignore 'lib/srv/desktop/rdp/rdpclient/target/**' \
-ignore 'lib/teleterm/api/protogen/**' \
-ignore 'lib/prehog/gen/**' \
-ignore 'lib/prehog/gen-js/**' \
-ignore 'lib/web/build/**' \
-ignore 'version.go' \
-ignore 'webassets/**' \
@ -1039,6 +1040,7 @@ grpc-teleterm:
# Unlike grpc-teleterm, this target runs locally.
.PHONY: grpc-teleterm/host
grpc-teleterm/host: protos/all
$(BUF) generate --template=lib/prehog/buf-teleterm.gen.yaml lib/prehog/proto
$(BUF) generate --template=lib/teleterm/buf.gen.yaml lib/teleterm/api/proto
.PHONY: goinstall

View file

@ -0,0 +1,30 @@
# buf-teleterm.gen.yaml is identical to buf.gen.yaml,
# with the exception of three additional JS plugins.
version: v1
managed:
enabled: true
go_package_prefix:
default: github.com/gravitational/teleport/lib/prehog/gen
plugins:
- name: go
path: lib/prehog/bin/protoc-gen-go
out: lib/prehog/gen
opt:
- paths=source_relative
- name: connect-go
path: lib/prehog/bin/protoc-gen-connect-go
out: lib/prehog/gen
opt:
- paths=source_relative
- name: js
out: lib/prehog/gen-js
opt:
- import_style=commonjs,binary
- name: grpc
out: lib/prehog/gen-js
opt: grpc_js
path: grpc_tools_node_protoc_plugin
- name: ts
out: lib/prehog/gen-js
opt: "service=grpc-node"

42
lib/prehog/gen-js/prehog/v1alpha/connect_grpc_pb.d.ts generated vendored Normal file
View file

@ -0,0 +1,42 @@
// package: prehog.v1alpha
// file: prehog/v1alpha/connect.proto
/* tslint:disable */
/* eslint-disable */
import * as grpc from "grpc";
import * as prehog_v1alpha_connect_pb from "../../prehog/v1alpha/connect_pb";
import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb";
interface IConnectReportingServiceService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
submitConnectEvent: IConnectReportingServiceService_ISubmitConnectEvent;
}
interface IConnectReportingServiceService_ISubmitConnectEvent extends grpc.MethodDefinition<prehog_v1alpha_connect_pb.SubmitConnectEventRequest, prehog_v1alpha_connect_pb.SubmitConnectEventResponse> {
path: "/prehog.v1alpha.ConnectReportingService/SubmitConnectEvent";
requestStream: false;
responseStream: false;
requestSerialize: grpc.serialize<prehog_v1alpha_connect_pb.SubmitConnectEventRequest>;
requestDeserialize: grpc.deserialize<prehog_v1alpha_connect_pb.SubmitConnectEventRequest>;
responseSerialize: grpc.serialize<prehog_v1alpha_connect_pb.SubmitConnectEventResponse>;
responseDeserialize: grpc.deserialize<prehog_v1alpha_connect_pb.SubmitConnectEventResponse>;
}
export const ConnectReportingServiceService: IConnectReportingServiceService;
export interface IConnectReportingServiceServer {
submitConnectEvent: grpc.handleUnaryCall<prehog_v1alpha_connect_pb.SubmitConnectEventRequest, prehog_v1alpha_connect_pb.SubmitConnectEventResponse>;
}
export interface IConnectReportingServiceClient {
submitConnectEvent(request: prehog_v1alpha_connect_pb.SubmitConnectEventRequest, callback: (error: grpc.ServiceError | null, response: prehog_v1alpha_connect_pb.SubmitConnectEventResponse) => void): grpc.ClientUnaryCall;
submitConnectEvent(request: prehog_v1alpha_connect_pb.SubmitConnectEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: prehog_v1alpha_connect_pb.SubmitConnectEventResponse) => void): grpc.ClientUnaryCall;
submitConnectEvent(request: prehog_v1alpha_connect_pb.SubmitConnectEventRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: prehog_v1alpha_connect_pb.SubmitConnectEventResponse) => void): grpc.ClientUnaryCall;
}
export class ConnectReportingServiceClient extends grpc.Client implements IConnectReportingServiceClient {
constructor(address: string, credentials: grpc.ChannelCredentials, options?: object);
public submitConnectEvent(request: prehog_v1alpha_connect_pb.SubmitConnectEventRequest, callback: (error: grpc.ServiceError | null, response: prehog_v1alpha_connect_pb.SubmitConnectEventResponse) => void): grpc.ClientUnaryCall;
public submitConnectEvent(request: prehog_v1alpha_connect_pb.SubmitConnectEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: prehog_v1alpha_connect_pb.SubmitConnectEventResponse) => void): grpc.ClientUnaryCall;
public submitConnectEvent(request: prehog_v1alpha_connect_pb.SubmitConnectEventRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: prehog_v1alpha_connect_pb.SubmitConnectEventResponse) => void): grpc.ClientUnaryCall;
}

View file

@ -0,0 +1,60 @@
// GENERATED CODE -- DO NOT EDIT!
// Original file comments:
// Copyright 2022 Gravitational, 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.
//
'use strict';
var grpc = require('@grpc/grpc-js');
var prehog_v1alpha_connect_pb = require('../../prehog/v1alpha/connect_pb.js');
var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js');
function serialize_prehog_v1alpha_SubmitConnectEventRequest(arg) {
if (!(arg instanceof prehog_v1alpha_connect_pb.SubmitConnectEventRequest)) {
throw new Error('Expected argument of type prehog.v1alpha.SubmitConnectEventRequest');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_prehog_v1alpha_SubmitConnectEventRequest(buffer_arg) {
return prehog_v1alpha_connect_pb.SubmitConnectEventRequest.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_prehog_v1alpha_SubmitConnectEventResponse(arg) {
if (!(arg instanceof prehog_v1alpha_connect_pb.SubmitConnectEventResponse)) {
throw new Error('Expected argument of type prehog.v1alpha.SubmitConnectEventResponse');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_prehog_v1alpha_SubmitConnectEventResponse(buffer_arg) {
return prehog_v1alpha_connect_pb.SubmitConnectEventResponse.deserializeBinary(new Uint8Array(buffer_arg));
}
var ConnectReportingServiceService = exports.ConnectReportingServiceService = {
submitConnectEvent: {
path: '/prehog.v1alpha.ConnectReportingService/SubmitConnectEvent',
requestStream: false,
responseStream: false,
requestType: prehog_v1alpha_connect_pb.SubmitConnectEventRequest,
responseType: prehog_v1alpha_connect_pb.SubmitConnectEventResponse,
requestSerialize: serialize_prehog_v1alpha_SubmitConnectEventRequest,
requestDeserialize: deserialize_prehog_v1alpha_SubmitConnectEventRequest,
responseSerialize: serialize_prehog_v1alpha_SubmitConnectEventResponse,
responseDeserialize: deserialize_prehog_v1alpha_SubmitConnectEventResponse,
},
};
exports.ConnectReportingServiceClient = grpc.makeGenericClientConstructor(ConnectReportingServiceService);

327
lib/prehog/gen-js/prehog/v1alpha/connect_pb.d.ts generated vendored Normal file
View file

@ -0,0 +1,327 @@
// package: prehog.v1alpha
// file: prehog/v1alpha/connect.proto
/* tslint:disable */
/* eslint-disable */
import * as jspb from "google-protobuf";
import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb";
export class ConnectClusterLoginEvent extends jspb.Message {
getClusterName(): string;
setClusterName(value: string): ConnectClusterLoginEvent;
getUserName(): string;
setUserName(value: string): ConnectClusterLoginEvent;
getConnectorType(): string;
setConnectorType(value: string): ConnectClusterLoginEvent;
getArch(): string;
setArch(value: string): ConnectClusterLoginEvent;
getOs(): string;
setOs(value: string): ConnectClusterLoginEvent;
getOsVersion(): string;
setOsVersion(value: string): ConnectClusterLoginEvent;
getAppVersion(): string;
setAppVersion(value: string): ConnectClusterLoginEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ConnectClusterLoginEvent.AsObject;
static toObject(includeInstance: boolean, msg: ConnectClusterLoginEvent): ConnectClusterLoginEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: ConnectClusterLoginEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ConnectClusterLoginEvent;
static deserializeBinaryFromReader(message: ConnectClusterLoginEvent, reader: jspb.BinaryReader): ConnectClusterLoginEvent;
}
export namespace ConnectClusterLoginEvent {
export type AsObject = {
clusterName: string,
userName: string,
connectorType: string,
arch: string,
os: string,
osVersion: string,
appVersion: string,
}
}
export class ConnectProtocolUseEvent extends jspb.Message {
getClusterName(): string;
setClusterName(value: string): ConnectProtocolUseEvent;
getUserName(): string;
setUserName(value: string): ConnectProtocolUseEvent;
getProtocol(): string;
setProtocol(value: string): ConnectProtocolUseEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ConnectProtocolUseEvent.AsObject;
static toObject(includeInstance: boolean, msg: ConnectProtocolUseEvent): ConnectProtocolUseEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: ConnectProtocolUseEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ConnectProtocolUseEvent;
static deserializeBinaryFromReader(message: ConnectProtocolUseEvent, reader: jspb.BinaryReader): ConnectProtocolUseEvent;
}
export namespace ConnectProtocolUseEvent {
export type AsObject = {
clusterName: string,
userName: string,
protocol: string,
}
}
export class ConnectAccessRequestCreateEvent extends jspb.Message {
getClusterName(): string;
setClusterName(value: string): ConnectAccessRequestCreateEvent;
getUserName(): string;
setUserName(value: string): ConnectAccessRequestCreateEvent;
getKind(): string;
setKind(value: string): ConnectAccessRequestCreateEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ConnectAccessRequestCreateEvent.AsObject;
static toObject(includeInstance: boolean, msg: ConnectAccessRequestCreateEvent): ConnectAccessRequestCreateEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: ConnectAccessRequestCreateEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ConnectAccessRequestCreateEvent;
static deserializeBinaryFromReader(message: ConnectAccessRequestCreateEvent, reader: jspb.BinaryReader): ConnectAccessRequestCreateEvent;
}
export namespace ConnectAccessRequestCreateEvent {
export type AsObject = {
clusterName: string,
userName: string,
kind: string,
}
}
export class ConnectAccessRequestReviewEvent extends jspb.Message {
getClusterName(): string;
setClusterName(value: string): ConnectAccessRequestReviewEvent;
getUserName(): string;
setUserName(value: string): ConnectAccessRequestReviewEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ConnectAccessRequestReviewEvent.AsObject;
static toObject(includeInstance: boolean, msg: ConnectAccessRequestReviewEvent): ConnectAccessRequestReviewEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: ConnectAccessRequestReviewEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ConnectAccessRequestReviewEvent;
static deserializeBinaryFromReader(message: ConnectAccessRequestReviewEvent, reader: jspb.BinaryReader): ConnectAccessRequestReviewEvent;
}
export namespace ConnectAccessRequestReviewEvent {
export type AsObject = {
clusterName: string,
userName: string,
}
}
export class ConnectAccessRequestAssumeRoleEvent extends jspb.Message {
getClusterName(): string;
setClusterName(value: string): ConnectAccessRequestAssumeRoleEvent;
getUserName(): string;
setUserName(value: string): ConnectAccessRequestAssumeRoleEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ConnectAccessRequestAssumeRoleEvent.AsObject;
static toObject(includeInstance: boolean, msg: ConnectAccessRequestAssumeRoleEvent): ConnectAccessRequestAssumeRoleEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: ConnectAccessRequestAssumeRoleEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ConnectAccessRequestAssumeRoleEvent;
static deserializeBinaryFromReader(message: ConnectAccessRequestAssumeRoleEvent, reader: jspb.BinaryReader): ConnectAccessRequestAssumeRoleEvent;
}
export namespace ConnectAccessRequestAssumeRoleEvent {
export type AsObject = {
clusterName: string,
userName: string,
}
}
export class ConnectFileTransferRunEvent extends jspb.Message {
getClusterName(): string;
setClusterName(value: string): ConnectFileTransferRunEvent;
getUserName(): string;
setUserName(value: string): ConnectFileTransferRunEvent;
getIsUpload(): boolean;
setIsUpload(value: boolean): ConnectFileTransferRunEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ConnectFileTransferRunEvent.AsObject;
static toObject(includeInstance: boolean, msg: ConnectFileTransferRunEvent): ConnectFileTransferRunEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: ConnectFileTransferRunEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ConnectFileTransferRunEvent;
static deserializeBinaryFromReader(message: ConnectFileTransferRunEvent, reader: jspb.BinaryReader): ConnectFileTransferRunEvent;
}
export namespace ConnectFileTransferRunEvent {
export type AsObject = {
clusterName: string,
userName: string,
isUpload: boolean,
}
}
export class ConnectUserJobRoleUpdateEvent extends jspb.Message {
getJobRole(): string;
setJobRole(value: string): ConnectUserJobRoleUpdateEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ConnectUserJobRoleUpdateEvent.AsObject;
static toObject(includeInstance: boolean, msg: ConnectUserJobRoleUpdateEvent): ConnectUserJobRoleUpdateEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: ConnectUserJobRoleUpdateEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ConnectUserJobRoleUpdateEvent;
static deserializeBinaryFromReader(message: ConnectUserJobRoleUpdateEvent, reader: jspb.BinaryReader): ConnectUserJobRoleUpdateEvent;
}
export namespace ConnectUserJobRoleUpdateEvent {
export type AsObject = {
jobRole: string,
}
}
export class SubmitConnectEventRequest extends jspb.Message {
getDistinctId(): string;
setDistinctId(value: string): SubmitConnectEventRequest;
hasTimestamp(): boolean;
clearTimestamp(): void;
getTimestamp(): google_protobuf_timestamp_pb.Timestamp | undefined;
setTimestamp(value?: google_protobuf_timestamp_pb.Timestamp): SubmitConnectEventRequest;
hasClusterLogin(): boolean;
clearClusterLogin(): void;
getClusterLogin(): ConnectClusterLoginEvent | undefined;
setClusterLogin(value?: ConnectClusterLoginEvent): SubmitConnectEventRequest;
hasProtocolUse(): boolean;
clearProtocolUse(): void;
getProtocolUse(): ConnectProtocolUseEvent | undefined;
setProtocolUse(value?: ConnectProtocolUseEvent): SubmitConnectEventRequest;
hasAccessRequestCreate(): boolean;
clearAccessRequestCreate(): void;
getAccessRequestCreate(): ConnectAccessRequestCreateEvent | undefined;
setAccessRequestCreate(value?: ConnectAccessRequestCreateEvent): SubmitConnectEventRequest;
hasAccessRequestReview(): boolean;
clearAccessRequestReview(): void;
getAccessRequestReview(): ConnectAccessRequestReviewEvent | undefined;
setAccessRequestReview(value?: ConnectAccessRequestReviewEvent): SubmitConnectEventRequest;
hasAccessRequestAssumeRole(): boolean;
clearAccessRequestAssumeRole(): void;
getAccessRequestAssumeRole(): ConnectAccessRequestAssumeRoleEvent | undefined;
setAccessRequestAssumeRole(value?: ConnectAccessRequestAssumeRoleEvent): SubmitConnectEventRequest;
hasFileTransferRun(): boolean;
clearFileTransferRun(): void;
getFileTransferRun(): ConnectFileTransferRunEvent | undefined;
setFileTransferRun(value?: ConnectFileTransferRunEvent): SubmitConnectEventRequest;
hasUserJobRoleUpdate(): boolean;
clearUserJobRoleUpdate(): void;
getUserJobRoleUpdate(): ConnectUserJobRoleUpdateEvent | undefined;
setUserJobRoleUpdate(value?: ConnectUserJobRoleUpdateEvent): SubmitConnectEventRequest;
getEventCase(): SubmitConnectEventRequest.EventCase;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SubmitConnectEventRequest.AsObject;
static toObject(includeInstance: boolean, msg: SubmitConnectEventRequest): SubmitConnectEventRequest.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: SubmitConnectEventRequest, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): SubmitConnectEventRequest;
static deserializeBinaryFromReader(message: SubmitConnectEventRequest, reader: jspb.BinaryReader): SubmitConnectEventRequest;
}
export namespace SubmitConnectEventRequest {
export type AsObject = {
distinctId: string,
timestamp?: google_protobuf_timestamp_pb.Timestamp.AsObject,
clusterLogin?: ConnectClusterLoginEvent.AsObject,
protocolUse?: ConnectProtocolUseEvent.AsObject,
accessRequestCreate?: ConnectAccessRequestCreateEvent.AsObject,
accessRequestReview?: ConnectAccessRequestReviewEvent.AsObject,
accessRequestAssumeRole?: ConnectAccessRequestAssumeRoleEvent.AsObject,
fileTransferRun?: ConnectFileTransferRunEvent.AsObject,
userJobRoleUpdate?: ConnectUserJobRoleUpdateEvent.AsObject,
}
export enum EventCase {
EVENT_NOT_SET = 0,
CLUSTER_LOGIN = 3,
PROTOCOL_USE = 4,
ACCESS_REQUEST_CREATE = 5,
ACCESS_REQUEST_REVIEW = 6,
ACCESS_REQUEST_ASSUME_ROLE = 7,
FILE_TRANSFER_RUN = 8,
USER_JOB_ROLE_UPDATE = 9,
}
}
export class SubmitConnectEventResponse extends jspb.Message {
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SubmitConnectEventResponse.AsObject;
static toObject(includeInstance: boolean, msg: SubmitConnectEventResponse): SubmitConnectEventResponse.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: SubmitConnectEventResponse, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): SubmitConnectEventResponse;
static deserializeBinaryFromReader(message: SubmitConnectEventResponse, reader: jspb.BinaryReader): SubmitConnectEventResponse;
}
export namespace SubmitConnectEventResponse {
export type AsObject = {
}
}

File diff suppressed because it is too large Load diff

42
lib/prehog/gen-js/prehog/v1alpha/teleport_grpc_pb.d.ts generated vendored Normal file
View file

@ -0,0 +1,42 @@
// package: prehog.v1alpha
// file: prehog/v1alpha/teleport.proto
/* tslint:disable */
/* eslint-disable */
import * as grpc from "grpc";
import * as prehog_v1alpha_teleport_pb from "../../prehog/v1alpha/teleport_pb";
import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb";
interface ITeleportReportingServiceService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
submitEvent: ITeleportReportingServiceService_ISubmitEvent;
}
interface ITeleportReportingServiceService_ISubmitEvent extends grpc.MethodDefinition<prehog_v1alpha_teleport_pb.SubmitEventRequest, prehog_v1alpha_teleport_pb.SubmitEventResponse> {
path: "/prehog.v1alpha.TeleportReportingService/SubmitEvent";
requestStream: false;
responseStream: false;
requestSerialize: grpc.serialize<prehog_v1alpha_teleport_pb.SubmitEventRequest>;
requestDeserialize: grpc.deserialize<prehog_v1alpha_teleport_pb.SubmitEventRequest>;
responseSerialize: grpc.serialize<prehog_v1alpha_teleport_pb.SubmitEventResponse>;
responseDeserialize: grpc.deserialize<prehog_v1alpha_teleport_pb.SubmitEventResponse>;
}
export const TeleportReportingServiceService: ITeleportReportingServiceService;
export interface ITeleportReportingServiceServer {
submitEvent: grpc.handleUnaryCall<prehog_v1alpha_teleport_pb.SubmitEventRequest, prehog_v1alpha_teleport_pb.SubmitEventResponse>;
}
export interface ITeleportReportingServiceClient {
submitEvent(request: prehog_v1alpha_teleport_pb.SubmitEventRequest, callback: (error: grpc.ServiceError | null, response: prehog_v1alpha_teleport_pb.SubmitEventResponse) => void): grpc.ClientUnaryCall;
submitEvent(request: prehog_v1alpha_teleport_pb.SubmitEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: prehog_v1alpha_teleport_pb.SubmitEventResponse) => void): grpc.ClientUnaryCall;
submitEvent(request: prehog_v1alpha_teleport_pb.SubmitEventRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: prehog_v1alpha_teleport_pb.SubmitEventResponse) => void): grpc.ClientUnaryCall;
}
export class TeleportReportingServiceClient extends grpc.Client implements ITeleportReportingServiceClient {
constructor(address: string, credentials: grpc.ChannelCredentials, options?: object);
public submitEvent(request: prehog_v1alpha_teleport_pb.SubmitEventRequest, callback: (error: grpc.ServiceError | null, response: prehog_v1alpha_teleport_pb.SubmitEventResponse) => void): grpc.ClientUnaryCall;
public submitEvent(request: prehog_v1alpha_teleport_pb.SubmitEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: prehog_v1alpha_teleport_pb.SubmitEventResponse) => void): grpc.ClientUnaryCall;
public submitEvent(request: prehog_v1alpha_teleport_pb.SubmitEventRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: prehog_v1alpha_teleport_pb.SubmitEventResponse) => void): grpc.ClientUnaryCall;
}

View file

@ -0,0 +1,60 @@
// GENERATED CODE -- DO NOT EDIT!
// Original file comments:
// Copyright 2022 Gravitational, 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.
//
'use strict';
var grpc = require('@grpc/grpc-js');
var prehog_v1alpha_teleport_pb = require('../../prehog/v1alpha/teleport_pb.js');
var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js');
function serialize_prehog_v1alpha_SubmitEventRequest(arg) {
if (!(arg instanceof prehog_v1alpha_teleport_pb.SubmitEventRequest)) {
throw new Error('Expected argument of type prehog.v1alpha.SubmitEventRequest');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_prehog_v1alpha_SubmitEventRequest(buffer_arg) {
return prehog_v1alpha_teleport_pb.SubmitEventRequest.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_prehog_v1alpha_SubmitEventResponse(arg) {
if (!(arg instanceof prehog_v1alpha_teleport_pb.SubmitEventResponse)) {
throw new Error('Expected argument of type prehog.v1alpha.SubmitEventResponse');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_prehog_v1alpha_SubmitEventResponse(buffer_arg) {
return prehog_v1alpha_teleport_pb.SubmitEventResponse.deserializeBinary(new Uint8Array(buffer_arg));
}
var TeleportReportingServiceService = exports.TeleportReportingServiceService = {
submitEvent: {
path: '/prehog.v1alpha.TeleportReportingService/SubmitEvent',
requestStream: false,
responseStream: false,
requestType: prehog_v1alpha_teleport_pb.SubmitEventRequest,
responseType: prehog_v1alpha_teleport_pb.SubmitEventResponse,
requestSerialize: serialize_prehog_v1alpha_SubmitEventRequest,
requestDeserialize: deserialize_prehog_v1alpha_SubmitEventRequest,
responseSerialize: serialize_prehog_v1alpha_SubmitEventResponse,
responseDeserialize: deserialize_prehog_v1alpha_SubmitEventResponse,
},
};
exports.TeleportReportingServiceClient = grpc.makeGenericClientConstructor(TeleportReportingServiceService);

433
lib/prehog/gen-js/prehog/v1alpha/teleport_pb.d.ts generated vendored Normal file
View file

@ -0,0 +1,433 @@
// package: prehog.v1alpha
// file: prehog/v1alpha/teleport.proto
/* tslint:disable */
/* eslint-disable */
import * as jspb from "google-protobuf";
import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb";
export class UserLoginEvent extends jspb.Message {
getUserName(): string;
setUserName(value: string): UserLoginEvent;
getConnectorType(): string;
setConnectorType(value: string): UserLoginEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): UserLoginEvent.AsObject;
static toObject(includeInstance: boolean, msg: UserLoginEvent): UserLoginEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: UserLoginEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): UserLoginEvent;
static deserializeBinaryFromReader(message: UserLoginEvent, reader: jspb.BinaryReader): UserLoginEvent;
}
export namespace UserLoginEvent {
export type AsObject = {
userName: string,
connectorType: string,
}
}
export class SSOCreateEvent extends jspb.Message {
getConnectorType(): string;
setConnectorType(value: string): SSOCreateEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SSOCreateEvent.AsObject;
static toObject(includeInstance: boolean, msg: SSOCreateEvent): SSOCreateEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: SSOCreateEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): SSOCreateEvent;
static deserializeBinaryFromReader(message: SSOCreateEvent, reader: jspb.BinaryReader): SSOCreateEvent;
}
export namespace SSOCreateEvent {
export type AsObject = {
connectorType: string,
}
}
export class ResourceCreateEvent extends jspb.Message {
getResourceType(): string;
setResourceType(value: string): ResourceCreateEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ResourceCreateEvent.AsObject;
static toObject(includeInstance: boolean, msg: ResourceCreateEvent): ResourceCreateEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: ResourceCreateEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ResourceCreateEvent;
static deserializeBinaryFromReader(message: ResourceCreateEvent, reader: jspb.BinaryReader): ResourceCreateEvent;
}
export namespace ResourceCreateEvent {
export type AsObject = {
resourceType: string,
}
}
export class SessionStartEvent extends jspb.Message {
getUserName(): string;
setUserName(value: string): SessionStartEvent;
getSessionType(): string;
setSessionType(value: string): SessionStartEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SessionStartEvent.AsObject;
static toObject(includeInstance: boolean, msg: SessionStartEvent): SessionStartEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: SessionStartEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): SessionStartEvent;
static deserializeBinaryFromReader(message: SessionStartEvent, reader: jspb.BinaryReader): SessionStartEvent;
}
export namespace SessionStartEvent {
export type AsObject = {
userName: string,
sessionType: string,
}
}
export class UIBannerClickEvent extends jspb.Message {
getUserName(): string;
setUserName(value: string): UIBannerClickEvent;
getAlert(): string;
setAlert(value: string): UIBannerClickEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): UIBannerClickEvent.AsObject;
static toObject(includeInstance: boolean, msg: UIBannerClickEvent): UIBannerClickEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: UIBannerClickEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): UIBannerClickEvent;
static deserializeBinaryFromReader(message: UIBannerClickEvent, reader: jspb.BinaryReader): UIBannerClickEvent;
}
export namespace UIBannerClickEvent {
export type AsObject = {
userName: string,
alert: string,
}
}
export class UIOnboardGetStartedClickEvent extends jspb.Message {
getUserName(): string;
setUserName(value: string): UIOnboardGetStartedClickEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): UIOnboardGetStartedClickEvent.AsObject;
static toObject(includeInstance: boolean, msg: UIOnboardGetStartedClickEvent): UIOnboardGetStartedClickEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: UIOnboardGetStartedClickEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): UIOnboardGetStartedClickEvent;
static deserializeBinaryFromReader(message: UIOnboardGetStartedClickEvent, reader: jspb.BinaryReader): UIOnboardGetStartedClickEvent;
}
export namespace UIOnboardGetStartedClickEvent {
export type AsObject = {
userName: string,
}
}
export class UIOnboardCompleteGoToDashboardClickEvent extends jspb.Message {
getUserName(): string;
setUserName(value: string): UIOnboardCompleteGoToDashboardClickEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): UIOnboardCompleteGoToDashboardClickEvent.AsObject;
static toObject(includeInstance: boolean, msg: UIOnboardCompleteGoToDashboardClickEvent): UIOnboardCompleteGoToDashboardClickEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: UIOnboardCompleteGoToDashboardClickEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): UIOnboardCompleteGoToDashboardClickEvent;
static deserializeBinaryFromReader(message: UIOnboardCompleteGoToDashboardClickEvent, reader: jspb.BinaryReader): UIOnboardCompleteGoToDashboardClickEvent;
}
export namespace UIOnboardCompleteGoToDashboardClickEvent {
export type AsObject = {
userName: string,
}
}
export class UIOnboardAddFirstResourceClickEvent extends jspb.Message {
getUserName(): string;
setUserName(value: string): UIOnboardAddFirstResourceClickEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): UIOnboardAddFirstResourceClickEvent.AsObject;
static toObject(includeInstance: boolean, msg: UIOnboardAddFirstResourceClickEvent): UIOnboardAddFirstResourceClickEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: UIOnboardAddFirstResourceClickEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): UIOnboardAddFirstResourceClickEvent;
static deserializeBinaryFromReader(message: UIOnboardAddFirstResourceClickEvent, reader: jspb.BinaryReader): UIOnboardAddFirstResourceClickEvent;
}
export namespace UIOnboardAddFirstResourceClickEvent {
export type AsObject = {
userName: string,
}
}
export class UIOnboardAddFirstResourceLaterClickEvent extends jspb.Message {
getUserName(): string;
setUserName(value: string): UIOnboardAddFirstResourceLaterClickEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): UIOnboardAddFirstResourceLaterClickEvent.AsObject;
static toObject(includeInstance: boolean, msg: UIOnboardAddFirstResourceLaterClickEvent): UIOnboardAddFirstResourceLaterClickEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: UIOnboardAddFirstResourceLaterClickEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): UIOnboardAddFirstResourceLaterClickEvent;
static deserializeBinaryFromReader(message: UIOnboardAddFirstResourceLaterClickEvent, reader: jspb.BinaryReader): UIOnboardAddFirstResourceLaterClickEvent;
}
export namespace UIOnboardAddFirstResourceLaterClickEvent {
export type AsObject = {
userName: string,
}
}
export class UIOnboardSetCredentialSubmitEvent extends jspb.Message {
getUserName(): string;
setUserName(value: string): UIOnboardSetCredentialSubmitEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): UIOnboardSetCredentialSubmitEvent.AsObject;
static toObject(includeInstance: boolean, msg: UIOnboardSetCredentialSubmitEvent): UIOnboardSetCredentialSubmitEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: UIOnboardSetCredentialSubmitEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): UIOnboardSetCredentialSubmitEvent;
static deserializeBinaryFromReader(message: UIOnboardSetCredentialSubmitEvent, reader: jspb.BinaryReader): UIOnboardSetCredentialSubmitEvent;
}
export namespace UIOnboardSetCredentialSubmitEvent {
export type AsObject = {
userName: string,
}
}
export class UIOnboardRegisterChallengeSubmitEvent extends jspb.Message {
getUserName(): string;
setUserName(value: string): UIOnboardRegisterChallengeSubmitEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): UIOnboardRegisterChallengeSubmitEvent.AsObject;
static toObject(includeInstance: boolean, msg: UIOnboardRegisterChallengeSubmitEvent): UIOnboardRegisterChallengeSubmitEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: UIOnboardRegisterChallengeSubmitEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): UIOnboardRegisterChallengeSubmitEvent;
static deserializeBinaryFromReader(message: UIOnboardRegisterChallengeSubmitEvent, reader: jspb.BinaryReader): UIOnboardRegisterChallengeSubmitEvent;
}
export namespace UIOnboardRegisterChallengeSubmitEvent {
export type AsObject = {
userName: string,
}
}
export class UIRecoveryCodesContinueClickEvent extends jspb.Message {
getUserName(): string;
setUserName(value: string): UIRecoveryCodesContinueClickEvent;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): UIRecoveryCodesContinueClickEvent.AsObject;
static toObject(includeInstance: boolean, msg: UIRecoveryCodesContinueClickEvent): UIRecoveryCodesContinueClickEvent.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: UIRecoveryCodesContinueClickEvent, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): UIRecoveryCodesContinueClickEvent;
static deserializeBinaryFromReader(message: UIRecoveryCodesContinueClickEvent, reader: jspb.BinaryReader): UIRecoveryCodesContinueClickEvent;
}
export namespace UIRecoveryCodesContinueClickEvent {
export type AsObject = {
userName: string,
}
}
export class SubmitEventRequest extends jspb.Message {
getClusterName(): string;
setClusterName(value: string): SubmitEventRequest;
hasTimestamp(): boolean;
clearTimestamp(): void;
getTimestamp(): google_protobuf_timestamp_pb.Timestamp | undefined;
setTimestamp(value?: google_protobuf_timestamp_pb.Timestamp): SubmitEventRequest;
hasUserLogin(): boolean;
clearUserLogin(): void;
getUserLogin(): UserLoginEvent | undefined;
setUserLogin(value?: UserLoginEvent): SubmitEventRequest;
hasSsoCreate(): boolean;
clearSsoCreate(): void;
getSsoCreate(): SSOCreateEvent | undefined;
setSsoCreate(value?: SSOCreateEvent): SubmitEventRequest;
hasResourceCreate(): boolean;
clearResourceCreate(): void;
getResourceCreate(): ResourceCreateEvent | undefined;
setResourceCreate(value?: ResourceCreateEvent): SubmitEventRequest;
hasSessionStart(): boolean;
clearSessionStart(): void;
getSessionStart(): SessionStartEvent | undefined;
setSessionStart(value?: SessionStartEvent): SubmitEventRequest;
hasUiBannerClick(): boolean;
clearUiBannerClick(): void;
getUiBannerClick(): UIBannerClickEvent | undefined;
setUiBannerClick(value?: UIBannerClickEvent): SubmitEventRequest;
hasUiOnboardGetStartedClick(): boolean;
clearUiOnboardGetStartedClick(): void;
getUiOnboardGetStartedClick(): UIOnboardGetStartedClickEvent | undefined;
setUiOnboardGetStartedClick(value?: UIOnboardGetStartedClickEvent): SubmitEventRequest;
hasUiOnboardCompleteGoToDashboardClick(): boolean;
clearUiOnboardCompleteGoToDashboardClick(): void;
getUiOnboardCompleteGoToDashboardClick(): UIOnboardCompleteGoToDashboardClickEvent | undefined;
setUiOnboardCompleteGoToDashboardClick(value?: UIOnboardCompleteGoToDashboardClickEvent): SubmitEventRequest;
hasUiOnboardAddFirstResourceClick(): boolean;
clearUiOnboardAddFirstResourceClick(): void;
getUiOnboardAddFirstResourceClick(): UIOnboardAddFirstResourceClickEvent | undefined;
setUiOnboardAddFirstResourceClick(value?: UIOnboardAddFirstResourceClickEvent): SubmitEventRequest;
hasUiOnboardAddFirstResourceLaterClick(): boolean;
clearUiOnboardAddFirstResourceLaterClick(): void;
getUiOnboardAddFirstResourceLaterClick(): UIOnboardAddFirstResourceLaterClickEvent | undefined;
setUiOnboardAddFirstResourceLaterClick(value?: UIOnboardAddFirstResourceLaterClickEvent): SubmitEventRequest;
hasUiOnboardSetCredentialSubmit(): boolean;
clearUiOnboardSetCredentialSubmit(): void;
getUiOnboardSetCredentialSubmit(): UIOnboardSetCredentialSubmitEvent | undefined;
setUiOnboardSetCredentialSubmit(value?: UIOnboardSetCredentialSubmitEvent): SubmitEventRequest;
hasUiOnboardRegisterChallengeSubmit(): boolean;
clearUiOnboardRegisterChallengeSubmit(): void;
getUiOnboardRegisterChallengeSubmit(): UIOnboardRegisterChallengeSubmitEvent | undefined;
setUiOnboardRegisterChallengeSubmit(value?: UIOnboardRegisterChallengeSubmitEvent): SubmitEventRequest;
hasUiRecoveryCodesContinueClick(): boolean;
clearUiRecoveryCodesContinueClick(): void;
getUiRecoveryCodesContinueClick(): UIRecoveryCodesContinueClickEvent | undefined;
setUiRecoveryCodesContinueClick(value?: UIRecoveryCodesContinueClickEvent): SubmitEventRequest;
getEventCase(): SubmitEventRequest.EventCase;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SubmitEventRequest.AsObject;
static toObject(includeInstance: boolean, msg: SubmitEventRequest): SubmitEventRequest.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: SubmitEventRequest, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): SubmitEventRequest;
static deserializeBinaryFromReader(message: SubmitEventRequest, reader: jspb.BinaryReader): SubmitEventRequest;
}
export namespace SubmitEventRequest {
export type AsObject = {
clusterName: string,
timestamp?: google_protobuf_timestamp_pb.Timestamp.AsObject,
userLogin?: UserLoginEvent.AsObject,
ssoCreate?: SSOCreateEvent.AsObject,
resourceCreate?: ResourceCreateEvent.AsObject,
sessionStart?: SessionStartEvent.AsObject,
uiBannerClick?: UIBannerClickEvent.AsObject,
uiOnboardGetStartedClick?: UIOnboardGetStartedClickEvent.AsObject,
uiOnboardCompleteGoToDashboardClick?: UIOnboardCompleteGoToDashboardClickEvent.AsObject,
uiOnboardAddFirstResourceClick?: UIOnboardAddFirstResourceClickEvent.AsObject,
uiOnboardAddFirstResourceLaterClick?: UIOnboardAddFirstResourceLaterClickEvent.AsObject,
uiOnboardSetCredentialSubmit?: UIOnboardSetCredentialSubmitEvent.AsObject,
uiOnboardRegisterChallengeSubmit?: UIOnboardRegisterChallengeSubmitEvent.AsObject,
uiRecoveryCodesContinueClick?: UIRecoveryCodesContinueClickEvent.AsObject,
}
export enum EventCase {
EVENT_NOT_SET = 0,
USER_LOGIN = 3,
SSO_CREATE = 4,
RESOURCE_CREATE = 5,
SESSION_START = 6,
UI_BANNER_CLICK = 7,
UI_ONBOARD_GET_STARTED_CLICK = 8,
UI_ONBOARD_COMPLETE_GO_TO_DASHBOARD_CLICK = 9,
UI_ONBOARD_ADD_FIRST_RESOURCE_CLICK = 10,
UI_ONBOARD_ADD_FIRST_RESOURCE_LATER_CLICK = 11,
UI_ONBOARD_SET_CREDENTIAL_SUBMIT = 12,
UI_ONBOARD_REGISTER_CHALLENGE_SUBMIT = 13,
UI_RECOVERY_CODES_CONTINUE_CLICK = 14,
}
}
export class SubmitEventResponse extends jspb.Message {
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SubmitEventResponse.AsObject;
static toObject(includeInstance: boolean, msg: SubmitEventResponse): SubmitEventResponse.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: SubmitEventResponse, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): SubmitEventResponse;
static deserializeBinaryFromReader(message: SubmitEventResponse, reader: jspb.BinaryReader): SubmitEventResponse;
}
export namespace SubmitEventResponse {
export type AsObject = {
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,87 @@
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: prehog/v1alpha/connect.proto
package prehogv1alphaconnect
import (
context "context"
errors "errors"
connect_go "github.com/bufbuild/connect-go"
v1alpha "github.com/gravitational/teleport/lib/prehog/gen/prehog/v1alpha"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect_go.IsAtLeastVersion0_1_0
const (
// ConnectReportingServiceName is the fully-qualified name of the ConnectReportingService service.
ConnectReportingServiceName = "prehog.v1alpha.ConnectReportingService"
)
// ConnectReportingServiceClient is a client for the prehog.v1alpha.ConnectReportingService service.
type ConnectReportingServiceClient interface {
SubmitConnectEvent(context.Context, *connect_go.Request[v1alpha.SubmitConnectEventRequest]) (*connect_go.Response[v1alpha.SubmitConnectEventResponse], error)
}
// NewConnectReportingServiceClient constructs a client for the
// prehog.v1alpha.ConnectReportingService service. By default, it uses the Connect protocol with the
// binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To use the
// gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewConnectReportingServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) ConnectReportingServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
return &connectReportingServiceClient{
submitConnectEvent: connect_go.NewClient[v1alpha.SubmitConnectEventRequest, v1alpha.SubmitConnectEventResponse](
httpClient,
baseURL+"/prehog.v1alpha.ConnectReportingService/SubmitConnectEvent",
opts...,
),
}
}
// connectReportingServiceClient implements ConnectReportingServiceClient.
type connectReportingServiceClient struct {
submitConnectEvent *connect_go.Client[v1alpha.SubmitConnectEventRequest, v1alpha.SubmitConnectEventResponse]
}
// SubmitConnectEvent calls prehog.v1alpha.ConnectReportingService.SubmitConnectEvent.
func (c *connectReportingServiceClient) SubmitConnectEvent(ctx context.Context, req *connect_go.Request[v1alpha.SubmitConnectEventRequest]) (*connect_go.Response[v1alpha.SubmitConnectEventResponse], error) {
return c.submitConnectEvent.CallUnary(ctx, req)
}
// ConnectReportingServiceHandler is an implementation of the prehog.v1alpha.ConnectReportingService
// service.
type ConnectReportingServiceHandler interface {
SubmitConnectEvent(context.Context, *connect_go.Request[v1alpha.SubmitConnectEventRequest]) (*connect_go.Response[v1alpha.SubmitConnectEventResponse], error)
}
// NewConnectReportingServiceHandler builds an HTTP handler from the service implementation. It
// returns the path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewConnectReportingServiceHandler(svc ConnectReportingServiceHandler, opts ...connect_go.HandlerOption) (string, http.Handler) {
mux := http.NewServeMux()
mux.Handle("/prehog.v1alpha.ConnectReportingService/SubmitConnectEvent", connect_go.NewUnaryHandler(
"/prehog.v1alpha.ConnectReportingService/SubmitConnectEvent",
svc.SubmitConnectEvent,
opts...,
))
return "/prehog.v1alpha.ConnectReportingService/", mux
}
// UnimplementedConnectReportingServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedConnectReportingServiceHandler struct{}
func (UnimplementedConnectReportingServiceHandler) SubmitConnectEvent(context.Context, *connect_go.Request[v1alpha.SubmitConnectEventRequest]) (*connect_go.Response[v1alpha.SubmitConnectEventResponse], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("prehog.v1alpha.ConnectReportingService.SubmitConnectEvent is not implemented"))
}

View file

@ -0,0 +1,103 @@
// Copyright 2022 Gravitational, 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.
syntax = "proto3";
package prehog.v1alpha;
import "google/protobuf/timestamp.proto";
option go_package = "github.com/gravitational/teleport/lib/prehog/gen/prehog/v1alpha";
message ConnectClusterLoginEvent {
// anonymized
string cluster_name = 1;
// anonymized
string user_name = 2;
// local/github/saml/oidc/passwordless
string connector_type = 3;
string arch = 4;
string os = 5;
string os_version = 6;
string app_version = 7;
}
message ConnectProtocolUseEvent {
// anonymized
string cluster_name = 1;
// anonymized
string user_name = 2;
// one of ssh/db/kube
string protocol = 3;
}
message ConnectAccessRequestCreateEvent {
// anonymized
string cluster_name = 1;
// anonymized
string user_name = 2;
// one of role/resource
string kind = 3;
}
message ConnectAccessRequestReviewEvent {
// anonymized
string cluster_name = 1;
// anonymized
string user_name = 2;
}
message ConnectAccessRequestAssumeRoleEvent {
// anonymized
string cluster_name = 1;
// anonymized
string user_name = 2;
}
message ConnectFileTransferRunEvent {
// anonymized
string cluster_name = 1;
// anonymized
string user_name = 2;
bool is_upload = 3;
}
message ConnectUserJobRoleUpdateEvent {
// Software Engineer, DevOps Engineer etc.
string job_role = 1;
}
message SubmitConnectEventRequest {
// UUID
string distinct_id = 1;
// optional, will default to the ingest time if unset
google.protobuf.Timestamp timestamp = 2;
oneof event {
ConnectClusterLoginEvent cluster_login = 3;
ConnectProtocolUseEvent protocol_use = 4;
ConnectAccessRequestCreateEvent access_request_create = 5;
ConnectAccessRequestReviewEvent access_request_review = 6;
ConnectAccessRequestAssumeRoleEvent access_request_assume_role = 7;
ConnectFileTransferRunEvent file_transfer_run = 8;
ConnectUserJobRoleUpdateEvent user_job_role_update = 9;
}
}
message SubmitConnectEventResponse {}
service ConnectReportingService {
rpc SubmitConnectEvent(SubmitConnectEventRequest) returns (SubmitConnectEventResponse) {}
}

View file

@ -18,6 +18,8 @@ package prehog.v1alpha;
import "google/protobuf/timestamp.proto";
option go_package = "github.com/gravitational/teleport/lib/prehog/gen/prehog/v1alpha";
message UserLoginEvent {
// anonymized
string user_name = 1;

View file

@ -24,6 +24,7 @@ import "v1/database.proto";
import "v1/gateway.proto";
import "v1/kube.proto";
import "v1/server.proto";
import "v1/usage_events.proto";
option go_package = "github.com/gravitational/teleport/lib/teleterm/v1";
@ -124,6 +125,8 @@ service TerminalService {
rpc Logout(LogoutRequest) returns (EmptyResponse);
// TransferFile sends a request to download/upload a file
rpc TransferFile(FileTransferRequest) returns (stream FileTransferProgress);
// ReportUsageEvent allows to send usage events that are then anonymized and forwarded to prehog
rpc ReportUsageEvent(ReportUsageEventRequest) returns (EmptyResponse);
}
message EmptyResponse {}

View file

@ -0,0 +1,26 @@
// Copyright 2022 Gravitational, 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.
syntax = "proto3";
package teleport.terminal.v1;
import "prehog/v1alpha/connect.proto";
option go_package = "github.com/gravitational/teleport/lib/teleterm/v1";
message ReportUsageEventRequest {
string auth_cluster_id = 1;
prehog.v1alpha.SubmitConnectEventRequest prehog_req = 2;
}

File diff suppressed because it is too large Load diff

View file

@ -114,6 +114,8 @@ type TerminalServiceClient interface {
Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*EmptyResponse, error)
// TransferFile sends a request to download/upload a file
TransferFile(ctx context.Context, in *FileTransferRequest, opts ...grpc.CallOption) (TerminalService_TransferFileClient, error)
// ReportUsageEvent allows to send usage events that are then anonymized and forwarded to prehog
ReportUsageEvent(ctx context.Context, in *ReportUsageEventRequest, opts ...grpc.CallOption) (*EmptyResponse, error)
}
type terminalServiceClient struct {
@ -457,6 +459,15 @@ func (x *terminalServiceTransferFileClient) Recv() (*FileTransferProgress, error
return m, nil
}
func (c *terminalServiceClient) ReportUsageEvent(ctx context.Context, in *ReportUsageEventRequest, opts ...grpc.CallOption) (*EmptyResponse, error) {
out := new(EmptyResponse)
err := c.cc.Invoke(ctx, "/teleport.terminal.v1.TerminalService/ReportUsageEvent", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// TerminalServiceServer is the server API for TerminalService service.
// All implementations must embed UnimplementedTerminalServiceServer
// for forward compatibility
@ -553,6 +564,8 @@ type TerminalServiceServer interface {
Logout(context.Context, *LogoutRequest) (*EmptyResponse, error)
// TransferFile sends a request to download/upload a file
TransferFile(*FileTransferRequest, TerminalService_TransferFileServer) error
// ReportUsageEvent allows to send usage events that are then anonymized and forwarded to prehog
ReportUsageEvent(context.Context, *ReportUsageEventRequest) (*EmptyResponse, error)
mustEmbedUnimplementedTerminalServiceServer()
}
@ -656,6 +669,9 @@ func (UnimplementedTerminalServiceServer) Logout(context.Context, *LogoutRequest
func (UnimplementedTerminalServiceServer) TransferFile(*FileTransferRequest, TerminalService_TransferFileServer) error {
return status.Errorf(codes.Unimplemented, "method TransferFile not implemented")
}
func (UnimplementedTerminalServiceServer) ReportUsageEvent(context.Context, *ReportUsageEventRequest) (*EmptyResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ReportUsageEvent not implemented")
}
func (UnimplementedTerminalServiceServer) mustEmbedUnimplementedTerminalServiceServer() {}
// UnsafeTerminalServiceServer may be embedded to opt out of forward compatibility for this service.
@ -1256,6 +1272,24 @@ func (x *terminalServiceTransferFileServer) Send(m *FileTransferProgress) error
return x.ServerStream.SendMsg(m)
}
func _TerminalService_ReportUsageEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ReportUsageEventRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TerminalServiceServer).ReportUsageEvent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/teleport.terminal.v1.TerminalService/ReportUsageEvent",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TerminalServiceServer).ReportUsageEvent(ctx, req.(*ReportUsageEventRequest))
}
return interceptor(ctx, in, info, handler)
}
// TerminalService_ServiceDesc is the grpc.ServiceDesc for TerminalService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -1383,6 +1417,10 @@ var TerminalService_ServiceDesc = grpc.ServiceDesc{
MethodName: "Logout",
Handler: _TerminalService_Logout_Handler,
},
{
MethodName: "ReportUsageEvent",
Handler: _TerminalService_ReportUsageEvent_Handler,
},
},
Streams: []grpc.StreamDesc{
{

View file

@ -0,0 +1,179 @@
// Copyright 2022 Gravitational, 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.
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc (unknown)
// source: v1/usage_events.proto
package v1
import (
v1alpha "github.com/gravitational/teleport/lib/prehog/gen/prehog/v1alpha"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type ReportUsageEventRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
AuthClusterId string `protobuf:"bytes,1,opt,name=auth_cluster_id,json=authClusterId,proto3" json:"auth_cluster_id,omitempty"`
PrehogReq *v1alpha.SubmitConnectEventRequest `protobuf:"bytes,2,opt,name=prehog_req,json=prehogReq,proto3" json:"prehog_req,omitempty"`
}
func (x *ReportUsageEventRequest) Reset() {
*x = ReportUsageEventRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_v1_usage_events_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ReportUsageEventRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ReportUsageEventRequest) ProtoMessage() {}
func (x *ReportUsageEventRequest) ProtoReflect() protoreflect.Message {
mi := &file_v1_usage_events_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ReportUsageEventRequest.ProtoReflect.Descriptor instead.
func (*ReportUsageEventRequest) Descriptor() ([]byte, []int) {
return file_v1_usage_events_proto_rawDescGZIP(), []int{0}
}
func (x *ReportUsageEventRequest) GetAuthClusterId() string {
if x != nil {
return x.AuthClusterId
}
return ""
}
func (x *ReportUsageEventRequest) GetPrehogReq() *v1alpha.SubmitConnectEventRequest {
if x != nil {
return x.PrehogReq
}
return nil
}
var File_v1_usage_events_proto protoreflect.FileDescriptor
var file_v1_usage_events_proto_rawDesc = []byte{
0x0a, 0x15, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74,
0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72,
0x74, 0x2e, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x70,
0x72, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x63, 0x6f,
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8b, 0x01, 0x0a, 0x17,
0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x55, 0x73, 0x61, 0x67, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0f, 0x61, 0x75, 0x74, 0x68, 0x5f,
0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12,
0x48, 0x0a, 0x0a, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x5f, 0x72, 0x65, 0x71, 0x18, 0x02, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x61,
0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65,
0x63, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x09,
0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74,
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x61, 0x76, 0x69, 0x74, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x6c,
0x69, 0x62, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x2f, 0x76, 0x31, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_v1_usage_events_proto_rawDescOnce sync.Once
file_v1_usage_events_proto_rawDescData = file_v1_usage_events_proto_rawDesc
)
func file_v1_usage_events_proto_rawDescGZIP() []byte {
file_v1_usage_events_proto_rawDescOnce.Do(func() {
file_v1_usage_events_proto_rawDescData = protoimpl.X.CompressGZIP(file_v1_usage_events_proto_rawDescData)
})
return file_v1_usage_events_proto_rawDescData
}
var file_v1_usage_events_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_v1_usage_events_proto_goTypes = []interface{}{
(*ReportUsageEventRequest)(nil), // 0: teleport.terminal.v1.ReportUsageEventRequest
(*v1alpha.SubmitConnectEventRequest)(nil), // 1: prehog.v1alpha.SubmitConnectEventRequest
}
var file_v1_usage_events_proto_depIdxs = []int32{
1, // 0: teleport.terminal.v1.ReportUsageEventRequest.prehog_req:type_name -> prehog.v1alpha.SubmitConnectEventRequest
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_v1_usage_events_proto_init() }
func file_v1_usage_events_proto_init() {
if File_v1_usage_events_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_v1_usage_events_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ReportUsageEventRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_v1_usage_events_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_v1_usage_events_proto_goTypes,
DependencyIndexes: file_v1_usage_events_proto_depIdxs,
MessageInfos: file_v1_usage_events_proto_msgTypes,
}.Build()
File_v1_usage_events_proto = out.File
file_v1_usage_events_proto_rawDesc = nil
file_v1_usage_events_proto_goTypes = nil
file_v1_usage_events_proto_depIdxs = nil
}

View file

@ -14,6 +14,7 @@ import * as v1_database_pb from "../v1/database_pb";
import * as v1_gateway_pb from "../v1/gateway_pb";
import * as v1_kube_pb from "../v1/kube_pb";
import * as v1_server_pb from "../v1/server_pb";
import * as v1_usage_events_pb from "../v1/usage_events_pb";
interface ITerminalServiceService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
updateTshdEventsServerAddress: ITerminalServiceService_IUpdateTshdEventsServerAddress;
@ -48,6 +49,7 @@ interface ITerminalServiceService extends grpc.ServiceDefinition<grpc.UntypedSer
loginPasswordless: ITerminalServiceService_ILoginPasswordless;
logout: ITerminalServiceService_ILogout;
transferFile: ITerminalServiceService_ITransferFile;
reportUsageEvent: ITerminalServiceService_IReportUsageEvent;
}
interface ITerminalServiceService_IUpdateTshdEventsServerAddress extends grpc.MethodDefinition<v1_service_pb.UpdateTshdEventsServerAddressRequest, v1_service_pb.UpdateTshdEventsServerAddressResponse> {
@ -338,6 +340,15 @@ interface ITerminalServiceService_ITransferFile extends grpc.MethodDefinition<v1
responseSerialize: grpc.serialize<v1_service_pb.FileTransferProgress>;
responseDeserialize: grpc.deserialize<v1_service_pb.FileTransferProgress>;
}
interface ITerminalServiceService_IReportUsageEvent extends grpc.MethodDefinition<v1_usage_events_pb.ReportUsageEventRequest, v1_service_pb.EmptyResponse> {
path: "/teleport.terminal.v1.TerminalService/ReportUsageEvent";
requestStream: false;
responseStream: false;
requestSerialize: grpc.serialize<v1_usage_events_pb.ReportUsageEventRequest>;
requestDeserialize: grpc.deserialize<v1_usage_events_pb.ReportUsageEventRequest>;
responseSerialize: grpc.serialize<v1_service_pb.EmptyResponse>;
responseDeserialize: grpc.deserialize<v1_service_pb.EmptyResponse>;
}
export const TerminalServiceService: ITerminalServiceService;
@ -374,6 +385,7 @@ export interface ITerminalServiceServer {
loginPasswordless: grpc.handleBidiStreamingCall<v1_service_pb.LoginPasswordlessRequest, v1_service_pb.LoginPasswordlessResponse>;
logout: grpc.handleUnaryCall<v1_service_pb.LogoutRequest, v1_service_pb.EmptyResponse>;
transferFile: grpc.handleServerStreamingCall<v1_service_pb.FileTransferRequest, v1_service_pb.FileTransferProgress>;
reportUsageEvent: grpc.handleUnaryCall<v1_usage_events_pb.ReportUsageEventRequest, v1_service_pb.EmptyResponse>;
}
export interface ITerminalServiceClient {
@ -472,6 +484,9 @@ export interface ITerminalServiceClient {
logout(request: v1_service_pb.LogoutRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: v1_service_pb.EmptyResponse) => void): grpc.ClientUnaryCall;
transferFile(request: v1_service_pb.FileTransferRequest, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<v1_service_pb.FileTransferProgress>;
transferFile(request: v1_service_pb.FileTransferRequest, metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<v1_service_pb.FileTransferProgress>;
reportUsageEvent(request: v1_usage_events_pb.ReportUsageEventRequest, callback: (error: grpc.ServiceError | null, response: v1_service_pb.EmptyResponse) => void): grpc.ClientUnaryCall;
reportUsageEvent(request: v1_usage_events_pb.ReportUsageEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: v1_service_pb.EmptyResponse) => void): grpc.ClientUnaryCall;
reportUsageEvent(request: v1_usage_events_pb.ReportUsageEventRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: v1_service_pb.EmptyResponse) => void): grpc.ClientUnaryCall;
}
export class TerminalServiceClient extends grpc.Client implements ITerminalServiceClient {
@ -570,4 +585,7 @@ export class TerminalServiceClient extends grpc.Client implements ITerminalServi
public logout(request: v1_service_pb.LogoutRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: v1_service_pb.EmptyResponse) => void): grpc.ClientUnaryCall;
public transferFile(request: v1_service_pb.FileTransferRequest, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<v1_service_pb.FileTransferProgress>;
public transferFile(request: v1_service_pb.FileTransferRequest, metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<v1_service_pb.FileTransferProgress>;
public reportUsageEvent(request: v1_usage_events_pb.ReportUsageEventRequest, callback: (error: grpc.ServiceError | null, response: v1_service_pb.EmptyResponse) => void): grpc.ClientUnaryCall;
public reportUsageEvent(request: v1_usage_events_pb.ReportUsageEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: v1_service_pb.EmptyResponse) => void): grpc.ClientUnaryCall;
public reportUsageEvent(request: v1_usage_events_pb.ReportUsageEventRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: v1_service_pb.EmptyResponse) => void): grpc.ClientUnaryCall;
}

View file

@ -26,6 +26,7 @@ var v1_database_pb = require('../v1/database_pb.js');
var v1_gateway_pb = require('../v1/gateway_pb.js');
var v1_kube_pb = require('../v1/kube_pb.js');
var v1_server_pb = require('../v1/server_pb.js');
var v1_usage_events_pb = require('../v1/usage_events_pb.js');
function serialize_teleport_terminal_v1_AddClusterRequest(arg) {
if (!(arg instanceof v1_service_pb.AddClusterRequest)) {
@ -544,6 +545,17 @@ function deserialize_teleport_terminal_v1_RemoveGatewayRequest(buffer_arg) {
return v1_service_pb.RemoveGatewayRequest.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_teleport_terminal_v1_ReportUsageEventRequest(arg) {
if (!(arg instanceof v1_usage_events_pb.ReportUsageEventRequest)) {
throw new Error('Expected argument of type teleport.terminal.v1.ReportUsageEventRequest');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_teleport_terminal_v1_ReportUsageEventRequest(buffer_arg) {
return v1_usage_events_pb.ReportUsageEventRequest.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_teleport_terminal_v1_RestartGatewayRequest(arg) {
if (!(arg instanceof v1_service_pb.RestartGatewayRequest)) {
throw new Error('Expected argument of type teleport.terminal.v1.RestartGatewayRequest');
@ -1036,6 +1048,18 @@ transferFile: {
responseSerialize: serialize_teleport_terminal_v1_FileTransferProgress,
responseDeserialize: deserialize_teleport_terminal_v1_FileTransferProgress,
},
// ReportUsageEvent allows to send usage events that are then anonymized and forwarded to prehog
reportUsageEvent: {
path: '/teleport.terminal.v1.TerminalService/ReportUsageEvent',
requestStream: false,
responseStream: false,
requestType: v1_usage_events_pb.ReportUsageEventRequest,
responseType: v1_service_pb.EmptyResponse,
requestSerialize: serialize_teleport_terminal_v1_ReportUsageEventRequest,
requestDeserialize: deserialize_teleport_terminal_v1_ReportUsageEventRequest,
responseSerialize: serialize_teleport_terminal_v1_EmptyResponse,
responseDeserialize: deserialize_teleport_terminal_v1_EmptyResponse,
},
};
exports.TerminalServiceClient = grpc.makeGenericClientConstructor(TerminalServiceService);

View file

@ -13,6 +13,7 @@ import * as v1_database_pb from "../v1/database_pb";
import * as v1_gateway_pb from "../v1/gateway_pb";
import * as v1_kube_pb from "../v1/kube_pb";
import * as v1_server_pb from "../v1/server_pb";
import * as v1_usage_events_pb from "../v1/usage_events_pb";
export class EmptyResponse extends jspb.Message {

View file

@ -31,6 +31,8 @@ var v1_kube_pb = require('../v1/kube_pb.js');
goog.object.extend(proto, v1_kube_pb);
var v1_server_pb = require('../v1/server_pb.js');
goog.object.extend(proto, v1_server_pb);
var v1_usage_events_pb = require('../v1/usage_events_pb.js');
goog.object.extend(proto, v1_usage_events_pb);
goog.exportSymbol('proto.teleport.terminal.v1.AddClusterRequest', null, global);
goog.exportSymbol('proto.teleport.terminal.v1.AssumeRoleRequest', null, global);
goog.exportSymbol('proto.teleport.terminal.v1.CreateAccessRequestRequest', null, global);

View file

@ -0,0 +1,41 @@
// package: teleport.terminal.v1
// file: v1/usage_events.proto
/* tslint:disable */
/* eslint-disable */
import * as grpc from "grpc";
import * as v1_usage_events_pb from "../v1/usage_events_pb";
interface IUsageEventsServiceService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
reportEvent: IUsageEventsServiceService_IReportEvent;
}
interface IUsageEventsServiceService_IReportEvent extends grpc.MethodDefinition<v1_usage_events_pb.ReportEventRequest, v1_usage_events_pb.EventReportedResponse> {
path: "/teleport.terminal.v1.UsageEventsService/ReportEvent";
requestStream: false;
responseStream: false;
requestSerialize: grpc.serialize<v1_usage_events_pb.ReportEventRequest>;
requestDeserialize: grpc.deserialize<v1_usage_events_pb.ReportEventRequest>;
responseSerialize: grpc.serialize<v1_usage_events_pb.EventReportedResponse>;
responseDeserialize: grpc.deserialize<v1_usage_events_pb.EventReportedResponse>;
}
export const UsageEventsServiceService: IUsageEventsServiceService;
export interface IUsageEventsServiceServer {
reportEvent: grpc.handleUnaryCall<v1_usage_events_pb.ReportEventRequest, v1_usage_events_pb.EventReportedResponse>;
}
export interface IUsageEventsServiceClient {
reportEvent(request: v1_usage_events_pb.ReportEventRequest, callback: (error: grpc.ServiceError | null, response: v1_usage_events_pb.EventReportedResponse) => void): grpc.ClientUnaryCall;
reportEvent(request: v1_usage_events_pb.ReportEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: v1_usage_events_pb.EventReportedResponse) => void): grpc.ClientUnaryCall;
reportEvent(request: v1_usage_events_pb.ReportEventRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: v1_usage_events_pb.EventReportedResponse) => void): grpc.ClientUnaryCall;
}
export class UsageEventsServiceClient extends grpc.Client implements IUsageEventsServiceClient {
constructor(address: string, credentials: grpc.ChannelCredentials, options?: object);
public reportEvent(request: v1_usage_events_pb.ReportEventRequest, callback: (error: grpc.ServiceError | null, response: v1_usage_events_pb.EventReportedResponse) => void): grpc.ClientUnaryCall;
public reportEvent(request: v1_usage_events_pb.ReportEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: v1_usage_events_pb.EventReportedResponse) => void): grpc.ClientUnaryCall;
public reportEvent(request: v1_usage_events_pb.ReportEventRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: v1_usage_events_pb.EventReportedResponse) => void): grpc.ClientUnaryCall;
}

View file

@ -0,0 +1 @@
// GENERATED CODE -- NO SERVICES IN PROTO

36
lib/teleterm/api/protogen/js/v1/usage_events_pb.d.ts generated vendored Normal file
View file

@ -0,0 +1,36 @@
// package: teleport.terminal.v1
// file: v1/usage_events.proto
/* tslint:disable */
/* eslint-disable */
import * as jspb from "google-protobuf";
import * as prehog_v1alpha_connect_pb from "../prehog/v1alpha/connect_pb";
export class ReportUsageEventRequest extends jspb.Message {
getAuthClusterId(): string;
setAuthClusterId(value: string): ReportUsageEventRequest;
hasPrehogReq(): boolean;
clearPrehogReq(): void;
getPrehogReq(): prehog_v1alpha_connect_pb.SubmitConnectEventRequest | undefined;
setPrehogReq(value?: prehog_v1alpha_connect_pb.SubmitConnectEventRequest): ReportUsageEventRequest;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ReportUsageEventRequest.AsObject;
static toObject(includeInstance: boolean, msg: ReportUsageEventRequest): ReportUsageEventRequest.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: ReportUsageEventRequest, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ReportUsageEventRequest;
static deserializeBinaryFromReader(message: ReportUsageEventRequest, reader: jspb.BinaryReader): ReportUsageEventRequest;
}
export namespace ReportUsageEventRequest {
export type AsObject = {
authClusterId: string,
prehogReq?: prehog_v1alpha_connect_pb.SubmitConnectEventRequest.AsObject,
}
}

View file

@ -0,0 +1,223 @@
// source: v1/usage_events.proto
/**
* @fileoverview
* @enhanceable
* @suppress {missingRequire} reports error on implicit type usages.
* @suppress {messageConventions} JS Compiler reports an error if a variable or
* field starts with 'MSG_' and isn't a translatable message.
* @public
*/
// GENERATED CODE -- DO NOT EDIT!
/* eslint-disable */
// @ts-nocheck
var jspb = require('google-protobuf');
var goog = jspb;
var global = (function() { return this || window || global || self || Function('return this')(); }).call(null);
var prehog_v1alpha_connect_pb = require('../prehog/v1alpha/connect_pb.js');
goog.object.extend(proto, prehog_v1alpha_connect_pb);
goog.exportSymbol('proto.teleport.terminal.v1.ReportUsageEventRequest', null, global);
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.teleport.terminal.v1.ReportUsageEventRequest = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.teleport.terminal.v1.ReportUsageEventRequest, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.displayName = 'proto.teleport.terminal.v1.ReportUsageEventRequest';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* Optional fields that are not set will be set to undefined.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
* JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @return {!Object}
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.prototype.toObject = function(opt_includeInstance) {
return proto.teleport.terminal.v1.ReportUsageEventRequest.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
* the JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.teleport.terminal.v1.ReportUsageEventRequest} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.toObject = function(includeInstance, msg) {
var f, obj = {
authClusterId: jspb.Message.getFieldWithDefault(msg, 1, ""),
prehogReq: (f = msg.getPrehogReq()) && prehog_v1alpha_connect_pb.SubmitConnectEventRequest.toObject(includeInstance, f)
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.teleport.terminal.v1.ReportUsageEventRequest}
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.teleport.terminal.v1.ReportUsageEventRequest;
return proto.teleport.terminal.v1.ReportUsageEventRequest.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.teleport.terminal.v1.ReportUsageEventRequest} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.teleport.terminal.v1.ReportUsageEventRequest}
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setAuthClusterId(value);
break;
case 2:
var value = new prehog_v1alpha_connect_pb.SubmitConnectEventRequest;
reader.readMessage(value,prehog_v1alpha_connect_pb.SubmitConnectEventRequest.deserializeBinaryFromReader);
msg.setPrehogReq(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.teleport.terminal.v1.ReportUsageEventRequest.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.teleport.terminal.v1.ReportUsageEventRequest} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getAuthClusterId();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
f = message.getPrehogReq();
if (f != null) {
writer.writeMessage(
2,
f,
prehog_v1alpha_connect_pb.SubmitConnectEventRequest.serializeBinaryToWriter
);
}
};
/**
* optional string auth_cluster_id = 1;
* @return {string}
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.prototype.getAuthClusterId = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/**
* @param {string} value
* @return {!proto.teleport.terminal.v1.ReportUsageEventRequest} returns this
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.prototype.setAuthClusterId = function(value) {
return jspb.Message.setProto3StringField(this, 1, value);
};
/**
* optional prehog.v1alpha.SubmitConnectEventRequest prehog_req = 2;
* @return {?proto.prehog.v1alpha.SubmitConnectEventRequest}
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.prototype.getPrehogReq = function() {
return /** @type{?proto.prehog.v1alpha.SubmitConnectEventRequest} */ (
jspb.Message.getWrapperField(this, prehog_v1alpha_connect_pb.SubmitConnectEventRequest, 2));
};
/**
* @param {?proto.prehog.v1alpha.SubmitConnectEventRequest|undefined} value
* @return {!proto.teleport.terminal.v1.ReportUsageEventRequest} returns this
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.prototype.setPrehogReq = function(value) {
return jspb.Message.setWrapperField(this, 2, value);
};
/**
* Clears the message field making it undefined.
* @return {!proto.teleport.terminal.v1.ReportUsageEventRequest} returns this
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.prototype.clearPrehogReq = function() {
return this.setPrehogReq(undefined);
};
/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.teleport.terminal.v1.ReportUsageEventRequest.prototype.hasPrehogReq = function() {
return jspb.Message.getField(this, 2) != null;
};
goog.object.extend(exports, proto.teleport.terminal.v1);

View file

@ -0,0 +1,31 @@
// Copyright 2022 Gravitational, 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.
package handler
import (
"context"
"github.com/gravitational/trace"
api "github.com/gravitational/teleport/lib/teleterm/api/protogen/golang/v1"
)
func (h *Handler) ReportUsageEvent(ctx context.Context, req *api.ReportUsageEventRequest) (*api.EmptyResponse, error) {
if err := h.DaemonService.ReportUsageEvent(req); err != nil {
return nil, trace.Wrap(err)
}
return &api.EmptyResponse{}, nil
}

View file

@ -27,6 +27,8 @@ import (
type Config struct {
// Addr is the bind address for the server
Addr string
// PrehogAddr is the URL where prehog events should be submitted.
PrehogAddr string
// ShutdownSignals is the set of captured signals that cause server shutdown.
ShutdownSignals []os.Signal
// HomeDir is the directory to store cluster profiles
@ -54,6 +56,10 @@ func (c *Config) CheckAndSetDefaults() error {
return trace.BadParameter("missing network address")
}
if c.PrehogAddr == "" {
return trace.BadParameter("missing prehog address")
}
addr, err := utils.ParseAddr(c.Addr)
if err != nil {
return trace.Wrap(err)

View file

@ -38,6 +38,8 @@ type Config struct {
// expected location by the time we get around to creating the client.
CreateTshdEventsClientCredsFunc CreateTshdEventsClientCredsFunc
GatewayCertReissuer *GatewayCertReissuer
// PrehogAddr is the URL where prehog events should be submitted.
PrehogAddr string
}
type CreateTshdEventsClientCredsFunc func() (grpc.DialOption, error)

View file

@ -24,9 +24,11 @@ import (
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/lib/client/db/dbcmd"
prehogapi "github.com/gravitational/teleport/lib/prehog/gen/prehog/v1alpha"
api "github.com/gravitational/teleport/lib/teleterm/api/protogen/golang/v1"
"github.com/gravitational/teleport/lib/teleterm/clusters"
"github.com/gravitational/teleport/lib/teleterm/gateway"
"github.com/gravitational/teleport/lib/usagereporter"
)
const (
@ -45,11 +47,20 @@ func New(cfg Config) (*Service, error) {
closeContext, cancel := context.WithCancel(context.Background())
connectUsageReporter, err := NewConnectUsageReporter(closeContext, cfg.PrehogAddr)
if err != nil {
cancel()
return nil, trace.Wrap(err)
}
go connectUsageReporter.Run(closeContext)
return &Service{
cfg: &cfg,
closeContext: closeContext,
cancel: cancel,
gateways: make(map[string]*gateway.Gateway),
cfg: &cfg,
closeContext: closeContext,
cancel: cancel,
gateways: make(map[string]*gateway.Gateway),
usageReporter: connectUsageReporter,
}, nil
}
@ -619,6 +630,8 @@ type Service struct {
// gateways holds the long-running gateways for resources on different clusters. So far it's been
// used mostly for database gateways but it has potential to be used for app access as well.
gateways map[string]*gateway.Gateway
// usageReporter batches the events and sends them to prehog
usageReporter *usagereporter.UsageReporter[prehogapi.SubmitConnectEventRequest]
}
type CreateGatewayParams struct {

View file

@ -0,0 +1,174 @@
// Copyright 2022 Gravitational, 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.
package daemon
import (
"context"
"net/http"
"time"
"github.com/bufbuild/connect-go"
"github.com/google/uuid"
"github.com/gravitational/trace"
"github.com/gravitational/teleport/lib/defaults"
prehogapi "github.com/gravitational/teleport/lib/prehog/gen/prehog/v1alpha"
prehogclient "github.com/gravitational/teleport/lib/prehog/gen/prehog/v1alpha/prehogv1alphaconnect"
api "github.com/gravitational/teleport/lib/teleterm/api/protogen/golang/v1"
"github.com/gravitational/teleport/lib/usagereporter"
"github.com/gravitational/teleport/lib/utils"
)
const (
// minBatchSize determines the size at which a batch is sent
// regardless of elapsed time
minBatchSize = 25
// maxBatchSize is the largest batch size that will be sent to
// the server; batches larger than this will be split into multiple
// requests.
maxBatchSize = 50
// maxBatchAge is the maximum age a batch may reach before
// being flushed, regardless of the batch size
maxBatchAge = time.Minute * 30
// maxBufferSize is the maximum size to which the event buffer
// may grow. Events submitted once this limit is reached will be discarded.
// Events that were in the submission queue that fail to submit may also be
// discarded when requeued.
maxBufferSize = 100
// submitDelay is a mandatory delay added to each batch submission
// to avoid spamming the prehog instance.
submitDelay = time.Second * 1
// usageReporterRetryAttempts is the max number of attempts that
// should be made to submit a particular event before it's dropped
retryAttempts = 2
)
func NewConnectUsageReporter(ctx context.Context, prehogAddr string) (*usagereporter.UsageReporter[prehogapi.SubmitConnectEventRequest], error) {
submitter, err := newPrehogSubmitter(ctx, prehogAddr)
if err != nil {
return nil, trace.Wrap(err)
}
return usagereporter.NewUsageReporter(&usagereporter.Options[prehogapi.SubmitConnectEventRequest]{
Submit: submitter,
MinBatchSize: minBatchSize,
MaxBatchSize: maxBatchSize,
MaxBufferSize: maxBufferSize,
MaxBatchAge: maxBatchAge,
SubmitDelay: submitDelay,
RetryAttempts: retryAttempts,
}), nil
}
func newPrehogSubmitter(ctx context.Context, prehogEndpoint string) (usagereporter.SubmitFunc[prehogapi.SubmitConnectEventRequest], error) {
httpClient := &http.Client{
Transport: &http.Transport{
ForceAttemptHTTP2: true,
Proxy: http.ProxyFromEnvironment,
IdleConnTimeout: defaults.HTTPIdleTimeout,
MaxIdleConns: defaults.HTTPMaxIdleConns,
MaxIdleConnsPerHost: defaults.HTTPMaxConnsPerHost,
},
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
},
Timeout: 5 * time.Second,
}
client := prehogclient.NewConnectReportingServiceClient(httpClient, prehogEndpoint)
return func(reporter *usagereporter.UsageReporter[prehogapi.SubmitConnectEventRequest], events []*usagereporter.SubmittedEvent[prehogapi.SubmitConnectEventRequest]) ([]*usagereporter.SubmittedEvent[prehogapi.SubmitConnectEventRequest], error) {
var failed []*usagereporter.SubmittedEvent[prehogapi.SubmitConnectEventRequest]
var errors []error
// Note: the backend doesn't support batching at the moment.
for _, event := range events {
// Note: this results in retrying the entire batch, which probably
// isn't ideal.
req := connect.NewRequest(event.Event)
if _, err := client.SubmitConnectEvent(ctx, req); err != nil {
failed = append(failed, event)
errors = append(errors, err)
}
}
return failed, trace.NewAggregate(errors...)
}, nil
}
func (s *Service) ReportUsageEvent(req *api.ReportUsageEventRequest) error {
prehogEvent, err := getAnonymizedPrehogEvent(req)
if err != nil {
return trace.Wrap(err)
}
s.usageReporter.AddEventsToQueue(prehogEvent)
return nil
}
func getAnonymizedPrehogEvent(req *api.ReportUsageEventRequest) (*prehogapi.SubmitConnectEventRequest, error) {
prehogEvent := req.PrehogReq
// non-anonymized
switch prehogEvent.GetEvent().(type) {
case *prehogapi.SubmitConnectEventRequest_UserJobRoleUpdate:
return prehogEvent, nil
}
// anonymized
anonymizer, err := newClusterAnonymizer(req.GetAuthClusterId()) // authClusterId is sent with each event that needs to be anonymized
if err != nil {
return nil, trace.Wrap(err)
}
switch e := prehogEvent.GetEvent().(type) {
case *prehogapi.SubmitConnectEventRequest_ClusterLogin:
e.ClusterLogin.ClusterName = anonymizer.AnonymizeString(e.ClusterLogin.ClusterName)
e.ClusterLogin.UserName = anonymizer.AnonymizeString(e.ClusterLogin.UserName)
return prehogEvent, nil
case *prehogapi.SubmitConnectEventRequest_ProtocolUse:
e.ProtocolUse.ClusterName = anonymizer.AnonymizeString(e.ProtocolUse.ClusterName)
e.ProtocolUse.UserName = anonymizer.AnonymizeString(e.ProtocolUse.UserName)
return prehogEvent, nil
case *prehogapi.SubmitConnectEventRequest_AccessRequestCreate:
e.AccessRequestCreate.ClusterName = anonymizer.AnonymizeString(e.AccessRequestCreate.ClusterName)
e.AccessRequestCreate.UserName = anonymizer.AnonymizeString(e.AccessRequestCreate.UserName)
return prehogEvent, nil
case *prehogapi.SubmitConnectEventRequest_AccessRequestReview:
e.AccessRequestReview.ClusterName = anonymizer.AnonymizeString(e.AccessRequestReview.ClusterName)
e.AccessRequestReview.UserName = anonymizer.AnonymizeString(e.AccessRequestReview.UserName)
return prehogEvent, nil
case *prehogapi.SubmitConnectEventRequest_AccessRequestAssumeRole:
e.AccessRequestAssumeRole.ClusterName = anonymizer.AnonymizeString(e.AccessRequestAssumeRole.ClusterName)
e.AccessRequestAssumeRole.UserName = anonymizer.AnonymizeString(e.AccessRequestAssumeRole.UserName)
return prehogEvent, nil
case *prehogapi.SubmitConnectEventRequest_FileTransferRun:
e.FileTransferRun.ClusterName = anonymizer.AnonymizeString(e.FileTransferRun.ClusterName)
e.FileTransferRun.UserName = anonymizer.AnonymizeString(e.FileTransferRun.UserName)
return prehogEvent, nil
}
return nil, trace.BadParameter("unexpected Event usage type %T", req)
}
func newClusterAnonymizer(authClusterID string) (utils.Anonymizer, error) {
_, err := uuid.Parse(authClusterID)
if err != nil {
return nil, trace.BadParameter("Invalid auth cluster ID %s", authClusterID)
}
return utils.NewHMACAnonymizer(authClusterID)
}

View file

@ -53,6 +53,7 @@ func Serve(ctx context.Context, cfg Config) error {
daemonService, err := daemon.New(daemon.Config{
Storage: storage,
CreateTshdEventsClientCredsFunc: grpcCredentials.tshdEvents,
PrehogAddr: cfg.PrehogAddr,
})
if err != nil {
return trace.Wrap(err)

View file

@ -111,6 +111,7 @@ func TestStart(t *testing.T) {
Addr: test.addr,
HomeDir: homeDir,
CertsDir: certsDir,
PrehogAddr: "https://prehog:9999",
ListeningC: listeningC,
}

View file

@ -44,6 +44,7 @@ func onDaemonStart(cf *CLIConf) error {
CertsDir: cf.DaemonCertsDir,
Addr: cf.DaemonAddr,
InsecureSkipVerify: cf.InsecureSkipVerify,
PrehogAddr: cf.DaemonPrehogAddr,
})
if err != nil {
return trace.Wrap(err)

View file

@ -179,6 +179,8 @@ type CLIConf struct {
DaemonAddr string
// DaemonCertsDir is the directory containing certs used to create secure gRPC connection with daemon service
DaemonCertsDir string
// DaemonPrehogAddr is the URL where prehog events should be submitted.
DaemonPrehogAddr string
// DatabaseService specifies the database proxy server to log into.
DatabaseService string
// DatabaseUser specifies database user to embed in the certificate.
@ -621,6 +623,7 @@ func Run(ctx context.Context, args []string, opts ...cliOption) error {
daemonStart := daemon.Command("start", "Starts tsh daemon service").Hidden()
daemonStart.Flag("addr", "Addr is the daemon listening address.").StringVar(&cf.DaemonAddr)
daemonStart.Flag("certs-dir", "Directory containing certs used to create secure gRPC connection with daemon service").StringVar(&cf.DaemonCertsDir)
daemonStart.Flag("prehog-addr", "URL where prehog events should be submitted").StringVar(&cf.DaemonPrehogAddr)
// AWS.
// Use Interspersed(false) to forward all flags to AWS CLI.