Skip to content

Commit 33a8fc4

Browse files
fix(deps): devScripts update (#232)
* chore: updates from devScripts * feat: use new core --------- Co-authored-by: mshanemc <shane.mclaughlin@salesforce.com>
1 parent f13afde commit 33a8fc4

File tree

4 files changed

+70
-119
lines changed

4 files changed

+70
-119
lines changed

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
"!lib/**/*.map"
3636
],
3737
"dependencies": {
38-
"@salesforce/core": "^3.36.0",
39-
"@salesforce/ts-types": "^2.0.1",
38+
"@salesforce/core": "^4.0.1",
39+
"@salesforce/ts-types": "^2.0.2",
4040
"applicationinsights": "^2.7.0",
4141
"axios": "^1.4.0"
4242
},
4343
"devDependencies": {
4444
"@salesforce/dev-config": "^4.0.1",
45-
"@salesforce/dev-scripts": "^5.1.0",
45+
"@salesforce/dev-scripts": "^5.4.2",
4646
"@salesforce/prettier-config": "^0.0.3",
4747
"@salesforce/ts-sinon": "^1.4.7",
4848
"@typescript-eslint/eslint-plugin": "^5.59.8",
@@ -53,7 +53,7 @@
5353
"eslint-config-salesforce": "^2.0.1",
5454
"eslint-config-salesforce-license": "^0.2.0",
5555
"eslint-config-salesforce-typescript": "^1.1.1",
56-
"eslint-plugin-header": "^3.0.0",
56+
"eslint-plugin-header": "^3.1.1",
5757
"eslint-plugin-import": "2.27.5",
5858
"eslint-plugin-jsdoc": "^44.2.7",
5959
"husky": "^8.0.3",
@@ -142,4 +142,4 @@
142142
"output": []
143143
}
144144
}
145-
}
145+
}

src/telemetryReporter.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import * as os from 'os';
8-
import { Logger, SfdxConfigAggregator, SfConfigProperties } from '@salesforce/core';
8+
import { Logger, ConfigAggregator, SfConfigProperties } from '@salesforce/core';
99
import { AsyncCreatable, env } from '@salesforce/kit';
1010

1111
import axios from 'axios';
@@ -19,11 +19,11 @@ export { TelemetryOptions, Attributes, Properties, TelemetryClient } from './app
1919
*/
2020
export class TelemetryReporter extends AsyncCreatable<TelemetryOptions> {
2121
// Keep a cache of config aggregator so we aren't loading it every time.
22-
private static config: SfdxConfigAggregator;
22+
private static config: ConfigAggregator;
2323

2424
private options: TelemetryOptions;
2525
private logger!: Logger;
26-
private config!: SfdxConfigAggregator;
26+
private config!: ConfigAggregator;
2727
private reporter!: AppInsights;
2828

2929
public constructor(options: TelemetryOptions) {
@@ -37,7 +37,7 @@ export class TelemetryReporter extends AsyncCreatable<TelemetryOptions> {
3737
*/
3838
public static async determineSfdxTelemetryEnabled(): Promise<boolean> {
3939
if (!TelemetryReporter.config) {
40-
TelemetryReporter.config = await SfdxConfigAggregator.create({});
40+
TelemetryReporter.config = await ConfigAggregator.create({});
4141
}
4242
const configValue = TelemetryReporter.config.getPropertyValue(SfConfigProperties.DISABLE_TELEMETRY);
4343
// SF_DISABLE_TELEMETRY is the proper name for this env that will be cheked by config.getPropertyValue. SFDX_DISABLE_INSIGHTS is present for backwards compatibility
@@ -48,7 +48,7 @@ export class TelemetryReporter extends AsyncCreatable<TelemetryOptions> {
4848
public async init(): Promise<void> {
4949
this.logger = await Logger.child('TelemetryReporter');
5050
if (!TelemetryReporter.config) {
51-
TelemetryReporter.config = await SfdxConfigAggregator.create({});
51+
TelemetryReporter.config = await ConfigAggregator.create({});
5252
}
5353
this.config = TelemetryReporter.config;
5454
if (this.options.waitForConnection) await this.waitForConnection();

test/unit/telemetryReporter.test.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import * as os from 'os';
8-
import { SfdxConfigAggregator, Logger } from '@salesforce/core';
8+
import { ConfigAggregator, Logger } from '@salesforce/core';
99
import axios from 'axios';
1010
import { expect } from 'chai';
1111
import * as sinon from 'sinon';
@@ -30,7 +30,7 @@ describe('TelemetryReporter', () => {
3030

3131
it('should send a telemetry event', async () => {
3232
const options = { project, key };
33-
sandbox.stub(SfdxConfigAggregator.prototype, 'getPropertyValue').returns('false');
33+
sandbox.stub(ConfigAggregator.prototype, 'getPropertyValue').returns('false');
3434
const reporter = await TelemetryReporter.create(options);
3535
const sendStub = sandbox.stub(reporter.getTelemetryClient(), 'trackEvent').callsFake(() => {});
3636

@@ -40,7 +40,7 @@ describe('TelemetryReporter', () => {
4040

4141
it('should send a telemetry exception', async () => {
4242
const options = { project, key };
43-
sandbox.stub(SfdxConfigAggregator.prototype, 'getPropertyValue').returns('false');
43+
sandbox.stub(ConfigAggregator.prototype, 'getPropertyValue').returns('false');
4444
const reporter = await TelemetryReporter.create(options);
4545
const sendStub = sandbox.stub(reporter.getTelemetryClient(), 'trackException').callsFake(() => {});
4646

@@ -56,7 +56,7 @@ describe('TelemetryReporter', () => {
5656

5757
it('should send a telemetry trace', async () => {
5858
const options = { project, key };
59-
sandbox.stub(SfdxConfigAggregator.prototype, 'getPropertyValue').returns('false');
59+
sandbox.stub(ConfigAggregator.prototype, 'getPropertyValue').returns('false');
6060
const reporter = await TelemetryReporter.create(options);
6161
const sendStub = sandbox.stub(reporter.getTelemetryClient(), 'trackTrace').callsFake(() => {});
6262

@@ -66,7 +66,7 @@ describe('TelemetryReporter', () => {
6666

6767
it('should send a telemetry metric', async () => {
6868
const options = { project, key };
69-
sandbox.stub(SfdxConfigAggregator.prototype, 'getPropertyValue').returns('false');
69+
sandbox.stub(ConfigAggregator.prototype, 'getPropertyValue').returns('false');
7070
const reporter = await TelemetryReporter.create(options);
7171
const sendStub = sandbox.stub(reporter.getTelemetryClient(), 'trackMetric').callsFake(() => {});
7272

@@ -75,7 +75,7 @@ describe('TelemetryReporter', () => {
7575
});
7676

7777
it('should not send a telemetry event when disabled', async () => {
78-
sandbox.stub(SfdxConfigAggregator.prototype, 'getPropertyValue').returns('true');
78+
sandbox.stub(ConfigAggregator.prototype, 'getPropertyValue').returns('true');
7979
const options = { project, key };
8080
const reporter = await TelemetryReporter.create(options);
8181
const sendStub = sandbox.stub(reporter.getTelemetryClient(), 'trackEvent').callsFake(() => {});
@@ -85,7 +85,7 @@ describe('TelemetryReporter', () => {
8585
});
8686

8787
it('should not send a telemetry exception when disabled', async () => {
88-
sandbox.stub(SfdxConfigAggregator.prototype, 'getPropertyValue').returns('true');
88+
sandbox.stub(ConfigAggregator.prototype, 'getPropertyValue').returns('true');
8989
const options = { project, key };
9090
const reporter = await TelemetryReporter.create(options);
9191
const sendStub = sandbox.stub(reporter.getTelemetryClient(), 'trackException').callsFake(() => {});
@@ -95,7 +95,7 @@ describe('TelemetryReporter', () => {
9595
});
9696

9797
it('should not send a telemetry trace when disabled', async () => {
98-
sandbox.stub(SfdxConfigAggregator.prototype, 'getPropertyValue').returns('true');
98+
sandbox.stub(ConfigAggregator.prototype, 'getPropertyValue').returns('true');
9999
const options = { project, key };
100100
const reporter = await TelemetryReporter.create(options);
101101
const sendStub = sandbox.stub(reporter.getTelemetryClient(), 'trackTrace').callsFake(() => {});
@@ -105,7 +105,7 @@ describe('TelemetryReporter', () => {
105105
});
106106

107107
it('should not send a telemetry metric when disabled', async () => {
108-
sandbox.stub(SfdxConfigAggregator.prototype, 'getPropertyValue').returns('true');
108+
sandbox.stub(ConfigAggregator.prototype, 'getPropertyValue').returns('true');
109109
const options = { project, key };
110110
const reporter = await TelemetryReporter.create(options);
111111
const sendStub = sandbox.stub(reporter.getTelemetryClient(), 'trackMetric').callsFake(() => {});
@@ -115,7 +115,7 @@ describe('TelemetryReporter', () => {
115115
});
116116

117117
it('should log to enable telemetry metric when disabled', async () => {
118-
sandbox.stub(SfdxConfigAggregator.prototype, 'getPropertyValue').returns('true');
118+
sandbox.stub(ConfigAggregator.prototype, 'getPropertyValue').returns('true');
119119
const warn = sandbox.stub();
120120
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
121121
sandbox.stub(Logger, 'child').resolves({ warn, debug: sandbox.stub() } as any);
@@ -129,7 +129,7 @@ describe('TelemetryReporter', () => {
129129

130130
it('should log to disable telemetry metric when enabled', async () => {
131131
const warn = sandbox.stub();
132-
sandbox.stub(SfdxConfigAggregator.prototype, 'getPropertyValue').returns('false');
132+
sandbox.stub(ConfigAggregator.prototype, 'getPropertyValue').returns('false');
133133
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
134134
sandbox.stub(Logger, 'child').resolves({ warn, debug: sandbox.stub() } as any);
135135
const options = { project, key };
@@ -141,7 +141,7 @@ describe('TelemetryReporter', () => {
141141
});
142142

143143
it('should cache config aggregator', async () => {
144-
const stub = sandbox.stub(SfdxConfigAggregator, 'create');
144+
const stub = sandbox.stub(ConfigAggregator, 'create');
145145

146146
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
147147
stub.resolves({ getPropertyValue: () => false } as any);

0 commit comments

Comments
 (0)