@lightdash/cli 0.1477.3 → 0.1477.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -222,7 +222,17 @@ type CliContentAsCode = BaseTrack & ({
222
222
  error: string;
223
223
  };
224
224
  });
225
- type Track = CliGenerateStarted | CliGenerateCompleted | CliGenerateError | CliDbtCommand | CliDbtError | CliPreviewStarted | CliPreviewCompleted | CliPreviewStopped | CliPreviewError | CliRefreshStarted | CliRefreshCompleted | CliRefreshError | CliCompileStarted | CliCompileCompleted | CliCompileError | CliDeployTriggered | CliCreateStarted | CliCreateCompleted | CliCreateError | CliStartStopPreview | CliStopPreviewMissing | CliGenerateExposuresStarted | CliGenerateExposuresCompleted | CliGenerateExposuresError | CliLogin | CliContentAsCode;
225
+ type CliLightdashConfigLoaded = BaseTrack & {
226
+ event: 'lightdashconfig.loaded';
227
+ properties: {
228
+ userId?: string;
229
+ organizationId?: string;
230
+ projectId: string;
231
+ categories_count?: number;
232
+ default_visibility?: 'show' | 'hide';
233
+ };
234
+ };
235
+ type Track = CliGenerateStarted | CliGenerateCompleted | CliGenerateError | CliDbtCommand | CliDbtError | CliPreviewStarted | CliPreviewCompleted | CliPreviewStopped | CliPreviewError | CliRefreshStarted | CliRefreshCompleted | CliRefreshError | CliCompileStarted | CliCompileCompleted | CliCompileError | CliDeployTriggered | CliCreateStarted | CliCreateCompleted | CliCreateError | CliStartStopPreview | CliStopPreviewMissing | CliGenerateExposuresStarted | CliGenerateExposuresCompleted | CliGenerateExposuresError | CliLogin | CliContentAsCode | CliLightdashConfigLoaded;
226
236
  export declare class LightdashAnalytics {
227
237
  static track(payload: Track): Promise<void>;
228
238
  }
@@ -44,7 +44,7 @@ const deploy = async (explores, options) => {
44
44
  process.exit(1);
45
45
  }
46
46
  }
47
- const lightdashProjectConfig = await (0, lightdash_config_1.readAndLoadLightdashProjectConfig)(path_1.default.resolve(options.projectDir));
47
+ const lightdashProjectConfig = await (0, lightdash_config_1.readAndLoadLightdashProjectConfig)(path_1.default.resolve(options.projectDir), options.projectUuid);
48
48
  await replaceProjectYamlTags(options.projectUuid, lightdashProjectConfig);
49
49
  await (0, apiClient_1.lightdashApi)({
50
50
  method: 'PUT',
@@ -1 +1 @@
1
- export declare const readAndLoadLightdashProjectConfig: (projectDir: string) => Promise<import("@lightdash/common").LightdashProjectConfig>;
1
+ export declare const readAndLoadLightdashProjectConfig: (projectDir: string, projectUuid?: string) => Promise<import("@lightdash/common").LightdashProjectConfig>;
@@ -5,12 +5,26 @@ const tslib_1 = require("tslib");
5
5
  const common_1 = require("@lightdash/common");
6
6
  const promises_1 = tslib_1.__importDefault(require("fs/promises"));
7
7
  const path_1 = tslib_1.__importDefault(require("path"));
8
+ const analytics_1 = require("../analytics/analytics");
9
+ const config_1 = require("../config");
8
10
  const globalState_1 = tslib_1.__importDefault(require("../globalState"));
9
- const readAndLoadLightdashProjectConfig = async (projectDir) => {
11
+ const readAndLoadLightdashProjectConfig = async (projectDir, projectUuid) => {
12
+ const { user, context } = await (0, config_1.getConfig)();
10
13
  const configPath = path_1.default.join(projectDir, 'lightdash.config.yml');
11
14
  try {
12
15
  const fileContents = await promises_1.default.readFile(configPath, 'utf8');
13
- const config = await (0, common_1.loadLightdashProjectConfig)(fileContents);
16
+ const config = await (0, common_1.loadLightdashProjectConfig)(fileContents, async (lightdashConfig) => {
17
+ void analytics_1.LightdashAnalytics.track({
18
+ event: 'lightdashconfig.loaded',
19
+ properties: {
20
+ projectId: projectUuid ?? context?.project ?? '',
21
+ userId: user?.userUuid,
22
+ organizationId: user?.organizationUuid,
23
+ categories_count: Number(Object.keys(lightdashConfig.spotlight.categories ?? {}).length),
24
+ default_visibility: lightdashConfig.spotlight.default_visibility,
25
+ },
26
+ });
27
+ });
14
28
  return config;
15
29
  }
16
30
  catch (e) {
@@ -28,6 +28,10 @@ const VALID_CONFIG = {
28
28
  };
29
29
  const INVALID_CONFIG_CONTENTS = 'I am invalid';
30
30
  const readFileSpy = jest.spyOn(promises_1.default, 'readFile');
31
+ // Mock getConfig
32
+ jest.mock('../config', () => ({
33
+ getConfig: jest.fn().mockResolvedValue({ user: null, context: null }),
34
+ }));
31
35
  describe('Existing lightdash.config.yml file', () => {
32
36
  describe('when valid', () => {
33
37
  it('should load the config file', async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/cli",
3
- "version": "0.1477.3",
3
+ "version": "0.1477.5",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "lightdash": "dist/index.js"
@@ -30,8 +30,8 @@
30
30
  "parse-node-version": "^2.0.0",
31
31
  "unique-names-generator": "^4.7.1",
32
32
  "uuid": "^11.0.3",
33
- "@lightdash/common": "0.1477.3",
34
- "@lightdash/warehouses": "0.1477.3"
33
+ "@lightdash/common": "0.1477.5",
34
+ "@lightdash/warehouses": "0.1477.5"
35
35
  },
36
36
  "description": "Lightdash CLI tool",
37
37
  "devDependencies": {