@toptal/davinci-cli-shared 2.5.2-alpha-bill-upgrade-node-v24-3f517b47.60 → 2.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#2586](https://github.com/toptal/davinci/pull/2586) [`61f98fa4`](https://github.com/toptal/davinci/commit/61f98fa464f45d28a37dfb626e5be20f134d6a5d) Thanks [@denieler](https://github.com/denieler)!
8
+
9
+ ---
10
+
11
+ - added support for node v24
12
+
3
13
  ## 2.5.1
4
14
 
5
15
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-cli-shared",
3
- "version": "2.5.2-alpha-bill-upgrade-node-v24-3f517b47.60+3f517b47",
3
+ "version": "2.6.0",
4
4
  "description": "Shared CLI code and CLI engine for davinci",
5
5
  "author": "Toptal",
6
6
  "license": "SEE LICENSE IN LICENSE.MD",
@@ -39,6 +39,5 @@
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
42
- },
43
- "gitHead": "3f517b47031dde1ac7d1b19ddaae7b8cf45d98dc"
42
+ }
44
43
  }
@@ -5,21 +5,37 @@ import { getConfig } from './id-config.js'
5
5
 
6
6
  const SEGMENT_WRITE_KEY = 'cwNYguEVVqdxFj5NyTKOhlrvaNQjlsXV'
7
7
 
8
- const { anonymousId, allowTracking } = await getConfig()
8
+ let configPromise = null
9
+ let analytics = null
9
10
 
10
- const analyticsEnabled = !process.env.DAVINCI_SKIP_ANALYTICS && allowTracking
11
+ const initializeAnalytics = async () => {
12
+ if (!configPromise) {
13
+ configPromise = getConfig()
14
+ }
15
+
16
+ const { anonymousId, allowTracking } = await configPromise
17
+
18
+ if (!analytics) {
19
+ const analyticsEnabled =
20
+ !process.env.DAVINCI_SKIP_ANALYTICS && allowTracking
21
+
22
+ analytics = new Analytics({
23
+ disable: !analyticsEnabled,
24
+ flushAt: 1,
25
+ writeKey: SEGMENT_WRITE_KEY,
26
+ })
27
+ }
11
28
 
12
- const analytics = new Analytics({
13
- disable: !analyticsEnabled,
14
- flushAt: 1,
15
- writeKey: SEGMENT_WRITE_KEY,
16
- })
29
+ return { anonymousId, allowTracking }
30
+ }
17
31
 
18
- export const identify = () => {
32
+ export const identify = async () => {
19
33
  if (isCi()) {
20
34
  return Promise.resolve()
21
35
  }
22
36
 
37
+ const { anonymousId } = await initializeAnalytics()
38
+
23
39
  return new Promise((resolve, reject) => {
24
40
  analytics.identify(
25
41
  {
@@ -30,8 +46,10 @@ export const identify = () => {
30
46
  })
31
47
  }
32
48
 
33
- export const track = properties =>
34
- new Promise((resolve, reject) => {
49
+ export const track = async properties => {
50
+ const { anonymousId } = await initializeAnalytics()
51
+
52
+ return new Promise((resolve, reject) => {
35
53
  analytics.track(
36
54
  {
37
55
  anonymousId,
@@ -41,6 +59,7 @@ export const track = properties =>
41
59
  err => (err ? reject(err) : resolve())
42
60
  )
43
61
  })
62
+ }
44
63
 
45
64
  export default {
46
65
  identify,