@dcl/sdk-commands 7.1.3-4451863481.commit-c67e152 → 7.1.3-4479179155.commit-b0d720f

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.
@@ -1,6 +1,6 @@
1
1
  import { CliComponents } from '../../components';
2
2
  interface Options {
3
- args: Omit<typeof args, '_'>;
3
+ args: typeof args;
4
4
  components: Pick<CliComponents, 'fs' | 'logger' | 'dclInfoConfig' | 'analytics'>;
5
5
  }
6
6
  export declare const args: import("arg").Result<{
@@ -55,10 +55,11 @@ async function main(options) {
55
55
  }
56
56
  const sceneJson = await (0, scene_validations_1.getValidSceneJson)(options.components, projectRoot);
57
57
  const coords = (0, scene_validations_1.getBaseCoords)(sceneJson);
58
- await options.components.analytics.track('Build scene', {
58
+ options.components.analytics.trackSync('Build scene', {
59
59
  projectHash: await (0, project_files_1.b64HashingFunction)(projectRoot),
60
60
  coords,
61
- isWorkspace: false
61
+ isWorkspace: false,
62
+ args: (0, args_1.getArgsUsed)(options.args)
62
63
  });
63
64
  await watchingFuture;
64
65
  }
@@ -66,11 +66,16 @@ async function main(options) {
66
66
  }
67
67
  const sceneJson = await (0, scene_validations_1.getValidSceneJson)(options.components, projectRoot);
68
68
  const coords = (0, scene_validations_1.getBaseCoords)(sceneJson);
69
- const analyticsOpts = {
69
+ const isWorld = !!Object.keys(sceneJson.worldConfiguration || {}).length;
70
+ const trackProps = {
70
71
  projectHash: await (0, project_files_1.b64HashingFunction)(projectRoot),
71
- coords
72
+ coords,
73
+ isWorld,
74
+ args: (0, args_1.getArgsUsed)(options.args)
72
75
  };
73
- await options.components.analytics.track('Scene deploy started', analyticsOpts);
76
+ const packageJson = await (0, project_files_1.getPackageJson)(options.components, projectRoot);
77
+ const dependencies = Array.from(new Set([...Object.keys(packageJson.dependencies || {}), ...Object.keys(packageJson.devDependencies || {})]));
78
+ options.components.analytics.trackSync('Scene deploy started', trackProps);
74
79
  if (!skipBuild) {
75
80
  await (0, project_validations_1.npmRun)(projectRoot, 'build');
76
81
  }
@@ -111,9 +116,10 @@ async function main(options) {
111
116
  }
112
117
  catch (e) {
113
118
  error('Could not upload content:');
114
- console.log(e);
119
+ console.log(e.message);
120
+ options.components.analytics.trackSync('Scene deploy failure', { ...trackProps, error: e.message ?? '' });
115
121
  }
116
- await options.components.analytics.track('Scene deploy success', analyticsOpts);
122
+ options.components.analytics.trackSync('Scene deploy success', { ...trackProps, dependencies });
117
123
  }
118
124
  exports.main = main;
119
125
  async function getCatalyst(target, targetContent) {
@@ -117,9 +117,10 @@ async function main(options) {
117
117
  (0, beautiful_logs_1.printSuccess)(logger, `Export finished!`, `=> The entity URN is ${log_1.colors.bold(urn)}`);
118
118
  const sceneJson = await (0, scene_validations_1.getValidSceneJson)(options.components, projectRoot);
119
119
  const coords = (0, scene_validations_1.getBaseCoords)(sceneJson);
120
- await options.components.analytics.track('Export static', {
120
+ options.components.analytics.trackSync('Export static', {
121
121
  projectHash: await (0, project_files_1.b64HashingFunction)(projectRoot),
122
- coords
122
+ coords,
123
+ args: (0, args_1.getArgsUsed)(options.args)
123
124
  });
124
125
  return { urn, entityId, destination: destDirectory };
125
126
  }
@@ -34,7 +34,7 @@ async function main(options) {
34
34
  if (shouldInstallDeps && !options.args['--skip-install']) {
35
35
  await (0, project_validations_1.installDependencies)(options.components, dir);
36
36
  }
37
- await options.components.analytics.track('Scene created', { projectType: scene, url });
37
+ options.components.analytics.trackSync('Scene created', { projectType: scene, url, args: (0, args_1.getArgsUsed)(options.args) });
38
38
  }
39
39
  exports.main = main;
40
40
  const moveFilesFromDir = async (components, dir, folder) => {
@@ -114,7 +114,7 @@ async function main(options) {
114
114
  }
115
115
  // then start the embedded compiler, this can be disabled with --no-watch
116
116
  if (watch) {
117
- await (0, build_1.main)({ ...options, args: { '--dir': projectRoot, '--watch': watch } });
117
+ await (0, build_1.main)({ ...options, args: { '--dir': projectRoot, '--watch': watch, _: [] } });
118
118
  }
119
119
  const sceneJson = await (0, scene_validations_1.getValidSceneJson)(options.components, projectRoot);
120
120
  const baseCoords = (0, scene_validations_1.getBaseCoords)(sceneJson);
@@ -170,10 +170,11 @@ async function main(options) {
170
170
  await startComponents();
171
171
  const networkInterfaces = os.networkInterfaces();
172
172
  const availableURLs = [];
173
- await components.analytics.track('Preview started', {
173
+ components.analytics.trackSync('Preview started', {
174
174
  projectHash: await (0, project_files_1.b64HashingFunction)(projectRoot),
175
175
  coords: baseCoords,
176
- isWorkspace: false
176
+ isWorkspace: false,
177
+ args: (0, args_1.getArgsUsed)(options.args)
177
178
  });
178
179
  components.logger.log(`Preview server is now running!`);
179
180
  components.logger.log('Available on:\n');
@@ -4,11 +4,14 @@ export type IAnalyticsComponent = {
4
4
  get(): Analytics;
5
5
  identify(): Promise<void>;
6
6
  track<T extends keyof Events>(eventName: T, eventProps: Events[T]): Promise<void>;
7
+ trackSync<T extends keyof Events>(eventName: T, eventProps: Events[T]): void;
8
+ stop(): Promise<void>;
7
9
  };
8
- type Events = {
10
+ export type Events = {
9
11
  'Scene created': {
10
12
  projectType: string;
11
13
  url: string;
14
+ args: Record<string, unknown>;
12
15
  };
13
16
  'Preview started': {
14
17
  projectHash: string;
@@ -17,6 +20,7 @@ type Events = {
17
20
  y: number;
18
21
  };
19
22
  isWorkspace: boolean;
23
+ args: Record<string, unknown>;
20
24
  };
21
25
  'Build scene': {
22
26
  projectHash: string;
@@ -25,6 +29,7 @@ type Events = {
25
29
  y: number;
26
30
  };
27
31
  isWorkspace: boolean;
32
+ args: Record<string, unknown>;
28
33
  };
29
34
  'Export static': {
30
35
  projectHash: string;
@@ -32,6 +37,7 @@ type Events = {
32
37
  x: number;
33
38
  y: number;
34
39
  };
40
+ args: Record<string, unknown>;
35
41
  };
36
42
  'Scene deploy started': {
37
43
  projectHash: string;
@@ -39,6 +45,8 @@ type Events = {
39
45
  x: number;
40
46
  y: number;
41
47
  };
48
+ isWorld: boolean;
49
+ args: Record<string, unknown>;
42
50
  };
43
51
  'Scene deploy success': {
44
52
  projectHash: string;
@@ -46,7 +54,19 @@ type Events = {
46
54
  x: number;
47
55
  y: number;
48
56
  };
57
+ isWorld: boolean;
58
+ args: Record<string, unknown>;
59
+ dependencies: string[];
60
+ };
61
+ 'Scene deploy failure': {
62
+ projectHash: string;
63
+ coords: {
64
+ x: number;
65
+ y: number;
66
+ };
67
+ isWorld: boolean;
68
+ args: Record<string, unknown>;
69
+ error: string;
49
70
  };
50
71
  };
51
72
  export declare function createAnalyticsComponent({ dclInfoConfig }: Pick<CliComponents, 'dclInfoConfig'>): Promise<IAnalyticsComponent>;
52
- export {};
@@ -12,15 +12,55 @@ async function createAnalyticsComponent({ dclInfoConfig }) {
12
12
  const USER_ID = 'sdk-commands-user';
13
13
  const config = await dclInfoConfig.get();
14
14
  const analytics = new analytics_node_1.Analytics({ writeKey: config.segmentKey ?? '' });
15
+ const promises = [];
16
+ async function track(eventName, eventProps) {
17
+ const trackFuture = (0, fp_future_1.default)();
18
+ const { userId, trackStats } = await dclInfoConfig.get();
19
+ const version = await dclInfoConfig.getVersion();
20
+ if (!trackStats) {
21
+ return trackFuture.resolve();
22
+ }
23
+ const trackInfo = {
24
+ userId: USER_ID,
25
+ event: eventName,
26
+ properties: {
27
+ ...eventProps,
28
+ os: process.platform,
29
+ nodeVersion: process.version,
30
+ cliVersion: version,
31
+ isCI: dclInfoConfig.isCI(),
32
+ isEditor: dclInfoConfig.isEditor(),
33
+ devId: userId,
34
+ ecs: {
35
+ ecsVersion: 'ecs7',
36
+ packageVersion: version
37
+ }
38
+ }
39
+ };
40
+ analytics.track(trackInfo, () => {
41
+ trackFuture.resolve();
42
+ });
43
+ if (!dclInfoConfig.isProduction()) {
44
+ console.log(trackInfo);
45
+ }
46
+ return trackFuture;
47
+ }
15
48
  return {
16
49
  get() {
17
50
  return analytics;
18
51
  },
19
52
  async identify() {
53
+ if (config.userId && !config.trackStats) {
54
+ return;
55
+ }
56
+ const userId = config.userId ?? (0, uuid_1.v4)();
57
+ let dclInfo = {};
20
58
  if (!config.userId) {
59
+ dclInfo = { userId, trackStats: true };
21
60
  console.log(`Decentraland CLI sends anonymous usage stats to improve their products, if you want to disable it change the configuration at ${log_1.colors.bold('~/.dclinfo')}\n`);
22
- const userId = (0, uuid_1.v4)();
23
- await dclInfoConfig.updateDCLInfo({ userId, trackStats: true });
61
+ }
62
+ if (!config.userIdentified) {
63
+ dclInfo.userIdentified = true;
24
64
  analytics.identify({
25
65
  userId: USER_ID,
26
66
  traits: {
@@ -29,37 +69,20 @@ async function createAnalyticsComponent({ dclInfoConfig }) {
29
69
  }
30
70
  });
31
71
  }
32
- },
33
- async track(eventName, eventProps) {
34
- const trackFuture = (0, fp_future_1.default)();
35
- const { userId, trackStats } = await dclInfoConfig.get();
36
- if (!trackStats) {
37
- return trackFuture.resolve();
72
+ if (Object.keys(dclInfo).length) {
73
+ await dclInfoConfig.updateDCLInfo(dclInfo);
38
74
  }
39
- const trackInfo = {
40
- userId: USER_ID,
41
- event: eventName,
42
- properties: {
43
- ...eventProps,
44
- os: process.platform,
45
- nodeVersion: process.version,
46
- cliVersion: await dclInfoConfig.getVersion(),
47
- isCI: dclInfoConfig.isCI(),
48
- isEditor: dclInfoConfig.isEditor(),
49
- devId: userId,
50
- ecs: {
51
- ecsVersion: 'ecs7',
52
- packageVersion: await dclInfoConfig.getVersion()
53
- }
54
- }
55
- };
56
- analytics.track(trackInfo, () => {
57
- trackFuture.resolve();
75
+ },
76
+ trackSync(eventName, eventProps) {
77
+ const futurePromise = (0, fp_future_1.default)();
78
+ promises.push(futurePromise);
79
+ void track(eventName, eventProps).then(() => {
80
+ futurePromise.resolve();
58
81
  });
59
- if (!dclInfoConfig.isProduction()) {
60
- console.log(trackInfo);
61
- }
62
- return trackFuture;
82
+ },
83
+ track,
84
+ async stop() {
85
+ await Promise.all(promises);
63
86
  }
64
87
  };
65
88
  }
@@ -1,5 +1,5 @@
1
1
  import { CliComponents } from '.';
2
- import { DCLInfo } from '../logic/config';
2
+ import { DCLInfo } from '../logic/dcl-info';
3
3
  export type IDCLInfoConfigComponent = {
4
4
  get(): Promise<DCLInfo>;
5
5
  updateDCLInfo(value: Partial<DCLInfo>): Promise<Partial<DCLInfo>>;
@@ -36,14 +36,18 @@ async function createDCLInfoConfigComponent({ fs }) {
36
36
  trackStats: false,
37
37
  segmentKey: isProduction() ? 'sFdziRVDJo0taOnGzTZwafEL9nLIANZ3' : 'mjCV5Dc4VAKXLJAH5g7LyHyW1jrIR3to'
38
38
  };
39
+ let dclInfoConfig;
39
40
  return {
40
41
  async get() {
41
- const dclInfoConfig = await (0, config_1.getDCLInfoConfig)({ fs });
42
+ if (!dclInfoConfig) {
43
+ dclInfoConfig = await (0, config_1.getDCLInfoConfig)({ fs });
44
+ }
42
45
  const envConfig = (0, config_1.getEnvConfig)();
43
46
  const config = { ...defaultConfig, ...dclInfoConfig, ...envConfig };
44
47
  return config;
45
48
  },
46
49
  updateDCLInfo(value) {
50
+ dclInfoConfig = { ...dclInfoConfig, ...value };
47
51
  return (0, fs_1.writeJSON)({ fs }, (0, config_1.getDclInfoPath)(), value);
48
52
  },
49
53
  async getVersion() {
package/dist/index.js CHANGED
@@ -50,6 +50,7 @@ async function main() {
50
50
  }
51
51
  }
52
52
  }
53
+ await components.analytics.stop();
53
54
  // rollup watcher leaves many open FSWatcher even in build mode. we must call
54
55
  // process.exit at this point to prevent the program halting forever
55
56
  process.exit(process.exitCode || 0);
@@ -9,3 +9,4 @@ export declare const DEFAULT_ARGS: {
9
9
  };
10
10
  export declare function getArgs(): Result<typeof DEFAULT_ARGS>;
11
11
  export declare function getArgs<T extends Args>(args: T): Result<typeof DEFAULT_ARGS & T>;
12
+ export declare function getArgsUsed(value: Result<typeof DEFAULT_ARGS>): Record<string, unknown>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getArgs = exports.DEFAULT_ARGS = void 0;
6
+ exports.getArgsUsed = exports.getArgs = exports.DEFAULT_ARGS = void 0;
7
7
  const arg_1 = __importDefault(require("arg"));
8
8
  // updating to TS 4.9 will prevent losing types when
9
9
  // enforcing type to be "Args" by using "satisfies Args"
@@ -16,3 +16,8 @@ function getArgs(args) {
16
16
  return (0, arg_1.default)({ ...exports.DEFAULT_ARGS, ...args }, { permissive: true });
17
17
  }
18
18
  exports.getArgs = getArgs;
19
+ function getArgsUsed(value) {
20
+ const { _, ...args } = value;
21
+ return args;
22
+ }
23
+ exports.getArgsUsed = getArgsUsed;
@@ -1,9 +1,5 @@
1
1
  import { CliComponents } from '../components';
2
- export interface DCLInfo {
3
- segmentKey?: string;
4
- userId?: string;
5
- trackStats?: boolean;
6
- }
2
+ import { DCLInfo } from './dcl-info';
7
3
  export declare const getDclInfoPath: () => string;
8
4
  /**
9
5
  * Reads the contents of the `.dclinfo` file
@@ -4,9 +4,10 @@ import { CliComponents } from '../components';
4
4
  */
5
5
  export declare function removeEmptyKeys(obj: Record<string, unknown>): Record<string, unknown>;
6
6
  export type DCLInfo = {
7
+ userIdentified?: boolean;
7
8
  fileExists?: boolean;
8
- userId: string;
9
- trackStats: boolean;
9
+ userId?: string;
10
+ trackStats?: boolean;
10
11
  provider?: string;
11
12
  MANAToken?: string;
12
13
  LANDRegistry?: string;
@@ -17,3 +17,9 @@ export declare function normalizeDecentralandFilename(filename: string): string;
17
17
  */
18
18
  export declare function getProjectContentMappings(components: Pick<CliComponents, 'fs'>, projectRoot: string, hashingFunction: (filePath: string) => Promise<string>): Promise<ContentMapping[]>;
19
19
  export declare const b64HashingFunction: (str: string) => Promise<string>;
20
+ interface PackageJson {
21
+ dependencies: Record<string, string>;
22
+ devDependencies: Record<string, string>;
23
+ }
24
+ export declare function getPackageJson(components: Pick<CliComponents, 'fs'>, projectRoot: string): Promise<PackageJson>;
25
+ export {};
@@ -1,13 +1,36 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.b64HashingFunction = exports.getProjectContentMappings = exports.normalizeDecentralandFilename = exports.getPublishableFiles = void 0;
29
+ exports.getPackageJson = exports.b64HashingFunction = exports.getProjectContentMappings = exports.normalizeDecentralandFilename = exports.getPublishableFiles = void 0;
7
30
  const dcl_ignore_1 = require("./dcl-ignore");
8
31
  const glob_1 = require("glob");
9
32
  const ignore_1 = __importDefault(require("ignore"));
10
- const path_1 = __importDefault(require("path"));
33
+ const path_1 = __importStar(require("path"));
11
34
  const error_1 = require("./error");
12
35
  /**
13
36
  * Returns an array of the publishable files for a given folder.
@@ -70,3 +93,15 @@ hashingFunction) {
70
93
  exports.getProjectContentMappings = getProjectContentMappings;
71
94
  const b64HashingFunction = async (str) => 'b64-' + Buffer.from(str).toString('base64');
72
95
  exports.b64HashingFunction = b64HashingFunction;
96
+ /* istanbul ignore next */
97
+ async function getPackageJson(components, projectRoot) {
98
+ try {
99
+ const packageJsonRaw = await components.fs.readFile((0, path_1.resolve)(projectRoot, 'package.json'), 'utf8');
100
+ const packageJson = JSON.parse(packageJsonRaw);
101
+ return packageJson;
102
+ }
103
+ catch (err) {
104
+ throw new error_1.CliError(`Error reading the package.json file: ${err.message}`);
105
+ }
106
+ }
107
+ exports.getPackageJson = getPackageJson;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/sdk-commands",
3
- "version": "7.1.3-4451863481.commit-c67e152",
3
+ "version": "7.1.3-4479179155.commit-b0d720f",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "start": "tsc -p tsconfig.json --watch",
@@ -16,9 +16,9 @@
16
16
  "author": "Decentraland",
17
17
  "license": "Apache-2.0",
18
18
  "dependencies": {
19
- "@dcl/dcl-rollup": "7.1.3-4451863481.commit-c67e152",
19
+ "@dcl/dcl-rollup": "7.1.3-4479179155.commit-b0d720f",
20
20
  "@dcl/hashing": "1.1.3",
21
- "@dcl/inspector": "7.1.3-4451863481.commit-c67e152",
21
+ "@dcl/inspector": "7.1.3-4479179155.commit-b0d720f",
22
22
  "@dcl/linker-dapp": "0.7.0",
23
23
  "@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be",
24
24
  "@dcl/protocol": "1.0.0-4408137944.commit-a67c796",
@@ -56,5 +56,5 @@
56
56
  "files": [
57
57
  "dist"
58
58
  ],
59
- "commit": "c67e1523bd2d41ca4cc5a6d1c4b0a46d4d09008c"
59
+ "commit": "b0d720fbc0eb0809ffab5e477aa4ae9512b79539"
60
60
  }