neonctl 1.23.0 → 1.23.1

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.
Files changed (2) hide show
  1. package/analytics.js +16 -1
  2. package/package.json +1 -1
package/analytics.js CHANGED
@@ -6,6 +6,7 @@ import { CREDENTIALS_FILE } from './config.js';
6
6
  import { isCi } from './env.js';
7
7
  import { log } from './log.js';
8
8
  import pkg from './pkg.js';
9
+ import { getApiClient } from './api.js';
9
10
  const WRITE_KEY = '3SQXn5ejjXWLEJ8xU2PRYhAotLtTaeeV';
10
11
  let client;
11
12
  let userId = '';
@@ -21,6 +22,19 @@ export const analyticsMiddleware = async (args) => {
21
22
  catch (err) {
22
23
  log.debug('Failed to read credentials file', err);
23
24
  }
25
+ try {
26
+ if (!userId && args.apiKey) {
27
+ const apiClient = getApiClient({
28
+ apiKey: args.apiKey,
29
+ apiHost: args.apiHost,
30
+ });
31
+ const resp = await apiClient?.getCurrentUserInfo?.();
32
+ userId = resp?.data?.id;
33
+ }
34
+ }
35
+ catch (err) {
36
+ log.debug('Failed to get user id from api', err);
37
+ }
24
38
  client = new Analytics({
25
39
  writeKey: WRITE_KEY,
26
40
  host: 'https://track.neon.tech',
@@ -40,8 +54,9 @@ export const analyticsMiddleware = async (args) => {
40
54
  ci: isCi(),
41
55
  },
42
56
  });
57
+ log.debug('Flushing CLI started event with userId: %s', userId);
43
58
  await client.closeAndFlush();
44
- log.debug('Sent CLI started event with userId: %s', userId);
59
+ log.debug('Flushed CLI started event with userId: %s', userId);
45
60
  };
46
61
  export const sendError = (err, errCode) => {
47
62
  if (!client) {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "git@github.com:neondatabase/neonctl.git"
6
6
  },
7
7
  "type": "module",
8
- "version": "1.23.0",
8
+ "version": "1.23.1",
9
9
  "description": "CLI tool for NeonDB Cloud management",
10
10
  "main": "index.js",
11
11
  "author": "NeonDB",