@finos/legend-application
Version:
Legend application core
60 lines • 2.08 kB
JavaScript
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AbstractPlugin, } from '@finos/legend-shared';
export class TelemetryServicePlugin extends AbstractPlugin {
userId;
appName;
appVersion;
appEnv;
appSessionId;
appStartTime;
install(pluginManager) {
pluginManager.registerTelemetryServicePlugin(this);
}
setup(config) {
this.userId = config.userId;
this.appName = config.appName;
this.appVersion = config.appVersion;
this.appEnv = config.appEnv;
this.appSessionId = config.appSessionId;
this.appStartTime = config.appStartTime;
}
}
export class TelemetryService {
applicationStore;
plugins = [];
constructor(applicationStore) {
this.applicationStore = applicationStore;
}
registerPlugins(plugins) {
this.plugins = plugins;
}
setup() {
const config = {
userId: this.applicationStore.identityService.currentUser,
appName: this.applicationStore.config.appName,
appEnv: this.applicationStore.config.env,
appVersion: this.applicationStore.config.appVersion,
appSessionId: this.applicationStore.uuid,
appStartTime: this.applicationStore.timeService.timestamp,
};
this.plugins.forEach((plugin) => plugin.setup(config));
}
logEvent(eventType, data) {
this.plugins.forEach((plugin) => plugin.logEvent(eventType, data));
}
}
//# sourceMappingURL=TelemetryService.js.map