Skip to content

Commit

Permalink
fix(core): use the repo name as the client name in analytics
Browse files Browse the repository at this point in the history
closes #85
  • Loading branch information
derevnjuk committed May 16, 2022
1 parent 8b86a6d commit 06578f1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"brightsec"
],
"secTester": {
"name": "sec-tester-js",
"repeaterVersion": "8.8.0"
}
}
15 changes: 11 additions & 4 deletions packages/core/src/configuration/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../credentials-provider';
import { first } from '../utils';
import { LogLevel } from '../logger';
import { name, secTester } from '../../package.json';
import { version, secTester } from '../../package.json';
import { container, injectable } from 'tsyringe';

export interface ConfigurationOptions {
Expand Down Expand Up @@ -57,12 +57,19 @@ export class Configuration {
return this._logLevel;
}

get version(): string {
/**
* @deprecated use {@link version} right after v1 has been released
*/
get repeaterVersion(): string {
return secTester.repeaterVersion;
}

get name() {
return name;
get version(): string {
return version;
}

get name(): string {
return secTester.name;
}

constructor({
Expand Down
2 changes: 1 addition & 1 deletion packages/repeater/src/lib/Repeater.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Repeater', () => {
beforeEach(() => {
when(mockedContainer.resolve(Logger)).thenReturn(instance(mockedLogger));
when(mockedContainer.isRegistered(Logger, anything())).thenReturn(true);
when(mockedConfiguration.version).thenReturn(version);
when(mockedConfiguration.repeaterVersion).thenReturn(version);
when(mockedConfiguration.container).thenReturn(instance(mockedContainer));
when(
mockedEventBus.execute(anyOfClass(RegisterRepeaterCommand))
Expand Down
4 changes: 2 additions & 2 deletions packages/repeater/src/lib/Repeater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class Repeater {
private async register(): Promise<void> {
const res = await this.bus.execute(
new RegisterRepeaterCommand({
version: this.configuration.version,
version: this.configuration.repeaterVersion,
repeaterId: this.repeaterId
})
);
Expand Down Expand Up @@ -144,7 +144,7 @@ export class Repeater {
if ('error' in payload) {
this.handleRegisterError(payload.error);
} else {
if (gt(payload.version, this.configuration.version)) {
if (gt(payload.version, this.configuration.repeaterVersion)) {
this.logger?.warn(
'%s: A new Repeater version (%s) is available, please update @sec-tester.',
chalk.yellow('(!) IMPORTANT'),
Expand Down

0 comments on commit 06578f1

Please sign in to comment.