@salesforce/plugin-telemetry 2.3.8 → 2.3.9-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/commandExecution.js +25 -16
- package/lib/commandExecution.js.map +1 -1
- package/lib/commands/telemetry.js +8 -11
- package/lib/commands/telemetry.js.map +1 -1
- package/lib/debugger.d.ts +2 -3
- package/lib/debugger.js +2 -8
- package/lib/debugger.js.map +1 -1
- package/lib/hooks/telemetryPrerun.js +24 -44
- package/lib/hooks/telemetryPrerun.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -17
- package/lib/index.js.map +1 -1
- package/lib/telemetry.js +55 -53
- package/lib/telemetry.js.map +1 -1
- package/lib/telemetryGlobal.d.ts +1 -1
- package/lib/telemetryGlobal.js +1 -2
- package/lib/telemetryGlobal.js.map +1 -1
- package/lib/uploader.d.ts +2 -1
- package/lib/uploader.js +22 -23
- package/lib/uploader.js.map +1 -1
- package/oclif.lock +8476 -0
- package/oclif.manifest.json +26 -12
- package/package.json +29 -25
- package/processes/upload.js +21 -0
- package/processes/upload +0 -13
package/README.md
CHANGED
|
@@ -10,10 +10,10 @@ This plugin is bundled with the CLI and will automatically collect usage data on
|
|
|
10
10
|
|
|
11
11
|
All command usage is recorded by initializing on the `init` oclif hook, recording all events to a log file, then spawning a process on exit to send the data to appinsights.
|
|
12
12
|
|
|
13
|
-
To debug the telemetry spawned process, run a command with the environment variables `SF_TELEMETRY_DEBUG=true` and `DEBUG=
|
|
13
|
+
To debug the telemetry spawned process, run a command with the environment variables `SF_TELEMETRY_DEBUG=true` and `DEBUG=sf:telemetry`.
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
SF_TELEMETRY_DEBUG=true DEBUG=
|
|
16
|
+
SF_TELEMETRY_DEBUG=true DEBUG=sf:telemetry* ./bin/dev telemetry
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Getting Started
|
package/lib/commandExecution.js
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
3
|
* All rights reserved.
|
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
import { Flags, Parser } from '@oclif/core';
|
|
8
|
+
import { AsyncCreatable } from '@salesforce/kit';
|
|
9
|
+
import { isNumber } from '@salesforce/ts-types';
|
|
10
|
+
import { debug } from './debugger.js';
|
|
11
|
+
export class CommandExecution extends AsyncCreatable {
|
|
12
|
+
status;
|
|
13
|
+
specifiedFlags = [];
|
|
14
|
+
specifiedFlagFullNames = [];
|
|
15
|
+
deprecatedFlagsUsed = [];
|
|
16
|
+
deprecatedCommandUsed;
|
|
17
|
+
command;
|
|
18
|
+
argv;
|
|
19
|
+
config;
|
|
20
|
+
orgId;
|
|
21
|
+
devhubId;
|
|
22
|
+
orgApiVersion;
|
|
23
|
+
devhubApiVersion;
|
|
15
24
|
constructor(options) {
|
|
16
25
|
super(options);
|
|
17
|
-
this.specifiedFlags = [];
|
|
18
|
-
this.specifiedFlagFullNames = [];
|
|
19
|
-
this.deprecatedFlagsUsed = [];
|
|
20
26
|
this.command = options.command;
|
|
21
27
|
this.argv = options.argv;
|
|
22
28
|
this.config = options.config;
|
|
@@ -61,7 +67,7 @@ class CommandExecution extends kit_1.AsyncCreatable {
|
|
|
61
67
|
// Execution information
|
|
62
68
|
date: new Date().toUTCString(),
|
|
63
69
|
// Don't log status or timestamp as a number, otherwise vscode will think it is a metric
|
|
64
|
-
status:
|
|
70
|
+
status: isNumber(this.status) ? this.status.toString() : undefined,
|
|
65
71
|
timestamp: String(Date.now()),
|
|
66
72
|
// Salesforce Information
|
|
67
73
|
orgId: this.orgId,
|
|
@@ -81,7 +87,11 @@ class CommandExecution extends kit_1.AsyncCreatable {
|
|
|
81
87
|
}
|
|
82
88
|
async init() {
|
|
83
89
|
const argv = this.argv;
|
|
84
|
-
const flagDefinitions =
|
|
90
|
+
const flagDefinitions = {
|
|
91
|
+
...this.command.flags,
|
|
92
|
+
...this.command.baseFlags,
|
|
93
|
+
...(this.command.enableJsonFlag ? { json: Flags.boolean() } : {}),
|
|
94
|
+
};
|
|
85
95
|
// slice off node or bin path, and the executable path, and then remove anything that's been processed as a flag
|
|
86
96
|
const typedCommand = process.argv
|
|
87
97
|
.splice(2)
|
|
@@ -97,7 +107,7 @@ class CommandExecution extends kit_1.AsyncCreatable {
|
|
|
97
107
|
}
|
|
98
108
|
let flags = {};
|
|
99
109
|
try {
|
|
100
|
-
flags = (await
|
|
110
|
+
flags = (await Parser.parse(argv, {
|
|
101
111
|
flags: flagDefinitions,
|
|
102
112
|
args: this.command.args,
|
|
103
113
|
// @ts-expect-error because varargs is not on SfCommand but is on SfdxCommand
|
|
@@ -105,7 +115,7 @@ class CommandExecution extends kit_1.AsyncCreatable {
|
|
|
105
115
|
})).flags;
|
|
106
116
|
}
|
|
107
117
|
catch (error) {
|
|
108
|
-
|
|
118
|
+
debug('Error parsing flags');
|
|
109
119
|
}
|
|
110
120
|
this.orgId = flags['target-org'] ? flags['target-org'].getOrgId() : null;
|
|
111
121
|
this.devhubId = flags['target-dev-hub'] ? flags['target-dev-hub'].getOrgId() : null;
|
|
@@ -155,5 +165,4 @@ class CommandExecution extends kit_1.AsyncCreatable {
|
|
|
155
165
|
}
|
|
156
166
|
}
|
|
157
167
|
}
|
|
158
|
-
exports.CommandExecution = CommandExecution;
|
|
159
168
|
//# sourceMappingURL=commandExecution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandExecution.js","sourceRoot":"","sources":["../src/commandExecution.ts"],"names":[],"mappings":"
|
|
1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AC,MAAM,QAAQ,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;oBAC5E,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oBACnC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBAC5C;qBAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,CAAC,gBAAgB,EAAE;oBACrD,+FAA+F;oBAC/F,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;oBACrG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;oBAC3G,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oBAC3C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBACpC;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;CACF"}
|
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4
3
|
* All rights reserved.
|
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
8
|
+
import { isEnabled } from '@salesforce/telemetry/enabledCheck';
|
|
9
|
+
import Telemetry from '../telemetry.js';
|
|
10
|
+
export default class TelemetryGet extends SfCommand {
|
|
11
|
+
static hidden = true;
|
|
13
12
|
async run() {
|
|
14
|
-
const enabled = await
|
|
13
|
+
const enabled = await isEnabled();
|
|
15
14
|
const cliId = global.cliTelemetry?.getCLIId();
|
|
16
15
|
this.log(`Telemetry is ${enabled ? 'enabled' : 'disabled'}.`);
|
|
17
|
-
this.log(`Telemetry tmp directory is ${
|
|
16
|
+
this.log(`Telemetry tmp directory is ${Telemetry.tmpDir}.`);
|
|
18
17
|
this.log(`Telemetry cache directory is ${this.config.cacheDir}.`);
|
|
19
18
|
this.log();
|
|
20
19
|
this.log(`Salesforce CLI ID is ${cliId}.`);
|
|
21
20
|
return {
|
|
22
21
|
enabled,
|
|
23
22
|
cliId,
|
|
24
|
-
tmpDir:
|
|
23
|
+
tmpDir: Telemetry.tmpDir,
|
|
25
24
|
cacheDir: this.config.cacheDir,
|
|
26
25
|
};
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
|
-
exports.default = TelemetryGet;
|
|
30
|
-
TelemetryGet.hidden = true;
|
|
31
28
|
//# sourceMappingURL=telemetry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/commands/telemetry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/commands/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,SAAS,MAAM,iBAAiB,CAAC;AAYxC,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,SAA6B;IAC9D,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;IAErB,KAAK,CAAC,GAAG;QACd,MAAM,OAAO,GAAG,MAAM,SAAS,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAC;QAE9C,IAAI,CAAC,GAAG,CAAC,gBAAgB,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC;QAC9D,IAAI,CAAC,GAAG,CAAC,8BAA8B,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;QAC5D,IAAI,CAAC,GAAG,CAAC,gCAAgC,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClE,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,IAAI,CAAC,GAAG,CAAC,wBAAwB,KAAK,GAAG,CAAC,CAAC;QAE3C,OAAO;YACL,OAAO;YACP,KAAK;YACL,MAAM,EAAE,SAAS,CAAC,MAAM;YACxB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;SAC/B,CAAC;IACJ,CAAC"}
|
package/lib/debugger.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const debug: import("debug").Debugger;
|
|
1
|
+
import Debug from 'debug';
|
|
2
|
+
export declare const debug: Debug.Debugger;
|
package/lib/debugger.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
3
|
* All rights reserved.
|
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const debug_1 = require("debug");
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
12
|
-
const packageJson = require('../package.json');
|
|
13
|
-
exports.version = packageJson.version;
|
|
14
|
-
exports.debug = (0, debug_1.default)(`sfdx:telemetry@${exports.version}`);
|
|
7
|
+
import Debug from 'debug';
|
|
8
|
+
export const debug = Debug('sf:telemetry');
|
|
15
9
|
//# sourceMappingURL=debugger.js.map
|
package/lib/debugger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugger.js","sourceRoot":"","sources":["../src/debugger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debugger.js","sourceRoot":"","sources":["../src/debugger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4
3
|
* All rights reserved.
|
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const debugger_1 = require("../debugger");
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { Performance } from '@oclif/core';
|
|
9
|
+
import { Lifecycle } from '@salesforce/core';
|
|
10
|
+
import enabledCheck from '@salesforce/telemetry/enabledCheck';
|
|
11
|
+
import Telemetry from '../telemetry.js';
|
|
12
|
+
import { CommandExecution } from '../commandExecution.js';
|
|
13
|
+
import { debug } from '../debugger.js';
|
|
16
14
|
/**
|
|
17
15
|
* A hook that runs before every command that:
|
|
18
16
|
* 1. Warns the user about command usage data collection the CLI does unless they have already acknowledged the warning.
|
|
@@ -21,8 +19,8 @@ const debugger_1 = require("../debugger");
|
|
|
21
19
|
*/
|
|
22
20
|
const hook = async function (options) {
|
|
23
21
|
// Don't even bother logging if telemetry is disabled
|
|
24
|
-
if (!(await
|
|
25
|
-
|
|
22
|
+
if (!(await enabledCheck.isEnabled())) {
|
|
23
|
+
debug('Telemetry disabled. Doing nothing.');
|
|
26
24
|
return;
|
|
27
25
|
}
|
|
28
26
|
try {
|
|
@@ -30,18 +28,18 @@ const hook = async function (options) {
|
|
|
30
28
|
// Instantiating telemetry shows data collection warning.
|
|
31
29
|
// Adding this to the global so that telemetry events are sent even when different
|
|
32
30
|
// versions of this plugin are in use by the CLI.
|
|
33
|
-
const telemetry = (global.cliTelemetry = await
|
|
31
|
+
const telemetry = (global.cliTelemetry = await Telemetry.create({
|
|
34
32
|
cacheDir: this.config.cacheDir,
|
|
35
33
|
executable: this.config.bin,
|
|
36
34
|
}));
|
|
37
|
-
const commandExecution = await
|
|
35
|
+
const commandExecution = await CommandExecution.create({
|
|
38
36
|
command: options.Command,
|
|
39
37
|
argv: options.argv,
|
|
40
38
|
config: this.config,
|
|
41
39
|
});
|
|
42
40
|
let commonData;
|
|
43
41
|
try {
|
|
44
|
-
|
|
42
|
+
Lifecycle.getInstance().onTelemetry(async (data) => {
|
|
45
43
|
await Promise.resolve(telemetry.record({
|
|
46
44
|
type: 'EVENT',
|
|
47
45
|
...commonDataMemoized(),
|
|
@@ -52,7 +50,7 @@ const hook = async function (options) {
|
|
|
52
50
|
catch (err) {
|
|
53
51
|
// even if this throws, the rest of telemetry is not affected
|
|
54
52
|
const error = err;
|
|
55
|
-
|
|
53
|
+
debug('Error subscribing to telemetry events', error.message);
|
|
56
54
|
}
|
|
57
55
|
process.on('warning', (warning) => {
|
|
58
56
|
telemetry.record({
|
|
@@ -63,40 +61,22 @@ const hook = async function (options) {
|
|
|
63
61
|
message: warning.message,
|
|
64
62
|
});
|
|
65
63
|
});
|
|
66
|
-
|
|
64
|
+
debug('Setting up process exit handler');
|
|
67
65
|
process.once('exit', (status) => {
|
|
68
|
-
let oclifPerf
|
|
66
|
+
let oclifPerf;
|
|
67
|
+
let nonOclifPerf;
|
|
69
68
|
try {
|
|
70
|
-
oclifPerf =
|
|
71
|
-
|
|
72
|
-
// The amount of time (ms) required for oclif to get to the point where it can start running the command.
|
|
73
|
-
'oclif.initMs': core_1.Performance.highlights.initTime,
|
|
74
|
-
// The amount of time (ms) required for oclif to load the Config.
|
|
75
|
-
'oclif.configLoadMs': core_1.Performance.highlights.configLoadTime,
|
|
76
|
-
// The amount of time (ms) required for oclif to load the command.
|
|
77
|
-
'oclif.commandLoadMs': core_1.Performance.highlights.commandLoadTime,
|
|
78
|
-
// The amount of time (ms) required for oclif to load core (i.e. bundled) plugins.
|
|
79
|
-
'oclif.corePluginsLoadMs': core_1.Performance.highlights.corePluginsLoadTime,
|
|
80
|
-
// The amount of time (ms) required for oclif to load user plugins.
|
|
81
|
-
'oclif.userPluginsLoadMs': core_1.Performance.highlights.userPluginsLoadTime,
|
|
82
|
-
// The amount of time (ms) required for oclif to load linked plugins.
|
|
83
|
-
'oclif.linkedPluginsLoadMs': core_1.Performance.highlights.linkedPluginsLoadTime,
|
|
84
|
-
// The amount of time (ms) required for oclif to run all the init hooks
|
|
85
|
-
'oclif.initHookMs': core_1.Performance.highlights.hookRunTimes.init?.total,
|
|
86
|
-
// The amount of time (ms) required for oclif to run all the prerun hooks
|
|
87
|
-
'oclif.prerunHookMs': core_1.Performance.highlights.hookRunTimes.prerun?.total,
|
|
88
|
-
// The amount of time (ms) required for oclif to run all the postrun hooks
|
|
89
|
-
'oclif.postrunHookMs': core_1.Performance.highlights.hookRunTimes.postrun?.total,
|
|
90
|
-
};
|
|
69
|
+
oclifPerf = Performance.oclifPerf;
|
|
70
|
+
nonOclifPerf = Object.fromEntries(Array.from(Performance.results.entries()).flatMap(([owner, results]) => results.map((result) => [`${owner}__${result.name}`, result.duration ?? 0])));
|
|
91
71
|
}
|
|
92
72
|
catch (err) {
|
|
93
|
-
|
|
73
|
+
debug('Unable to get oclif performance metrics', err);
|
|
94
74
|
}
|
|
95
75
|
for (const { event, error } of errors) {
|
|
96
|
-
telemetry.recordError(error, { ...event, ...oclifPerf });
|
|
76
|
+
telemetry.recordError(error, { ...event, ...oclifPerf, ...nonOclifPerf });
|
|
97
77
|
}
|
|
98
78
|
commandExecution.status = status;
|
|
99
|
-
telemetry.record({ ...commandExecution.toJson(), ...oclifPerf });
|
|
79
|
+
telemetry.record({ ...commandExecution.toJson(), ...oclifPerf, ...nonOclifPerf });
|
|
100
80
|
if (process.listenerCount('exit') >= 20) {
|
|
101
81
|
// On exit listeners have been a problem in the past. Make sure we don't accumulate too many...
|
|
102
82
|
// This could be from too many plugins. If we start getting this, log number of plugins too.
|
|
@@ -109,7 +89,7 @@ const hook = async function (options) {
|
|
|
109
89
|
if (telemetry.firstRun) {
|
|
110
90
|
telemetry.record({
|
|
111
91
|
eventName: 'INSTALL',
|
|
112
|
-
installType: this.config.binPath?.includes(
|
|
92
|
+
installType: this.config.binPath?.includes(join('sfdx', 'client')) || this.config.binPath?.includes(join('sf', 'client'))
|
|
113
93
|
? 'installer'
|
|
114
94
|
: 'npm',
|
|
115
95
|
platform: this.config.platform,
|
|
@@ -144,8 +124,8 @@ const hook = async function (options) {
|
|
|
144
124
|
}
|
|
145
125
|
catch (err) {
|
|
146
126
|
const error = err;
|
|
147
|
-
|
|
127
|
+
debug('Error with logging or sending telemetry:', error.message);
|
|
148
128
|
}
|
|
149
129
|
};
|
|
150
|
-
|
|
130
|
+
export default hook;
|
|
151
131
|
//# sourceMappingURL=telemetryPrerun.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetryPrerun.js","sourceRoot":"","sources":["../../src/hooks/telemetryPrerun.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"telemetryPrerun.js","sourceRoot":"","sources":["../../src/hooks/telemetryPrerun.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,M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M,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;QAC9F,CAAC,CAAC,CAAC;QAEH,uEAAuE;QACvE,OAAO,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,KAAc,EAAE,EAAE;YAC9C,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,GAAG,gBAAgB,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;QAC9F,CAAC,CAAC,CAAC;QAEH,MAAM,kBAAkB,GAAG,GAAe,EAAE;YAC1C,IAAI,CAAC,UAAU,EAAE;gBACf,MAAM,UAAU,GAAG,gBAAgB,CAAC,aAAa,EAAE,CAAC;gBACpD,UAAU,GAAG;oBACX,WAAW,EAAE,OAAO,CAAC,OAAO;oBAC5B,MAAM,EAAE,UAAU,CAAC,IAAI;oBACvB,qCAAqC;oBACrC,cAAc,EAAE,UAAU,CAAC,OAAO;oBAClC,OAAO,EAAE,gBAAgB,CAAC,cAAc,EAAE;iBAC3C,CAAC;aACH;YACD,OAAO,UAAU,CAAC;QACpB,CAAC,CAAC;KACH;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,KAAK,GAAG,GAAc,CAAC;QAC7B,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;KAClE;AACH,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './telemetry';
|
|
1
|
+
export * from './telemetry.js';
|
package/lib/index.js
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
3
|
* All rights reserved.
|
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
__exportStar(require("./telemetry"), exports);
|
|
7
|
+
export * from './telemetry.js';
|
|
24
8
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,gBAAgB,CAAC"}
|