Skip to content

Commit 80b26a0

Browse files
authored
Fix inconsistencies between node v18 and v22 (#2741)
These changes allows Actions to be built both on Node 18 and Node 22 without breaking the build, tests or validation.
1 parent 3116241 commit 80b26a0

File tree

12 files changed

+84
-106
lines changed

12 files changed

+84
-106
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
]
1010
},
1111
"engines": {
12-
"node": "14 || ^18.12"
12+
"node": "^18.12 || ^22.13"
1313
},
1414
"scripts": {
1515
"alpha": "lerna version prerelease --allow-branch $(git branch --show-current) --preid $(git branch --show-current) --no-push --no-git-tag-version",
@@ -72,7 +72,7 @@
7272
"timers-browserify": "^2.0.12",
7373
"ts-jest": "^27.0.7",
7474
"ts-node": "^9.1.1",
75-
"typescript": "4.3.5",
75+
"typescript": "4.9.5",
7676
"ws": "^8.5.0"
7777
},
7878
"resolutions": {

packages/actions-shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"package.json"
1515
],
1616
"engines": {
17-
"node": "14 || ^18.12"
17+
"node": "^18.12 || ^22.13"
1818
},
1919
"engineStrict": true,
2020
"license": "MIT",

packages/browser-destinations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"serve": "^12.0.1",
4444
"size-limit": "^11.2.0",
4545
"terser-webpack-plugin": "^5.1.1",
46-
"ts-loader": "^9.2.6",
46+
"ts-loader": "^9.5.2",
4747
"webpack": "^5.82.0",
4848
"webpack-bundle-analyzer": "^4.4.1",
4949
"webpack-cli": "^5.1.1",

packages/cli/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"directory": "packages/cli"
1010
},
1111
"engines": {
12-
"node": "14 || ^18.12"
12+
"node": "^18.12 || ^22.13"
1313
},
1414
"engineStrict": true,
1515
"bin": {
@@ -43,7 +43,7 @@
4343
"@types/json-schema": "^7.0.7",
4444
"@types/lodash": "^4.14.175",
4545
"@types/mustache": "^4.1.0",
46-
"@types/node": "^14.0.0",
46+
"@types/node": "^22.13.1",
4747
"@types/prompts": "^2.0.10",
4848
"@types/rimraf": "^3.0.2",
4949
"@types/to-title-case": "^1.0.0",
@@ -59,7 +59,6 @@
5959
"@segment/action-destinations": "^3.288.0",
6060
"@segment/actions-core": "^3.121.0",
6161
"@segment/destinations-manifest": "^1.71.0",
62-
"@types/node": "^18.11.15",
6362
"chalk": "^4.1.1",
6463
"chokidar": "^3.5.1",
6564
"dotenv": "^10.0.0",

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"package.json"
5252
],
5353
"engines": {
54-
"node": ">=14"
54+
"node": ">=18.12"
5555
},
5656
"engineStrict": true,
5757
"license": "MIT",
@@ -83,7 +83,7 @@
8383
"@segment/action-emitters": "^1.3.6",
8484
"@segment/ajv-human-errors": "^2.14.0",
8585
"@segment/destination-subscriptions": "^3.36.0",
86-
"@types/node": "^18.11.15",
86+
"@types/node": "^22.13.1",
8787
"aggregate-error": "^3.1.0",
8888
"ajv": "^8.6.3",
8989
"ajv-formats": "^2.1.1",

packages/core/src/destination-kit/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -742,13 +742,13 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
742742
// Add datadog stats for events that are discarded by Actions
743743
options?.statsContext?.statsClient?.incr(
744744
'action.multistatus_discard',
745-
(events as SegmentEvent[]).length,
745+
events.length,
746746
options.statsContext?.tags
747747
)
748748

749749
return [
750750
{
751-
multistatus: Array((events as SegmentEvent[]).length).fill(response)
751+
multistatus: Array(events.length).fill(response)
752752
}
753753
]
754754
}
@@ -770,21 +770,21 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
770770
// Add datadog stats for events that are discarded by Actions
771771
options?.statsContext?.statsClient?.incr(
772772
'action.multistatus_discard',
773-
(events as SegmentEvent[]).length,
773+
events.length,
774774
options.statsContext?.tags
775775
)
776776

777777
return [
778778
{
779-
multistatus: Array((events as SegmentEvent[]).length).fill(response)
779+
multistatus: Array(events.length).fill(response)
780780
}
781781
]
782782
}
783783

784784
return [{ output: response.errormessage }]
785785
}
786786

787-
const allEvents = (isBatch ? events : [events]) as SegmentEvent[]
787+
const allEvents = isBatch ? events : [events]
788788

789789
// Filter invalid events and record discards
790790
const subscribedEvents: SegmentEvent[] = []
@@ -938,10 +938,10 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
938938
// eslint-disable-next-line @typescript-eslint/no-explicit-any
939939
const shouldRetry = async (response: any, attemptCount: number) => {
940940
const results = response as Result[]
941-
/*
941+
/*
942942
Here, we iterate over results array. Each result in the array is a response from a single subscription.
943-
However, we always execute one subscription at a time despite receiving an array of subscriptions as input.
944-
So, results array will always have a single result.
943+
However, we always execute one subscription at a time despite receiving an array of subscriptions as input.
944+
So, results array will always have a single result.
945945
TODO: Get rid of onSubscriptions method to reflect execution model in the code accurately.
946946
*/
947947
for (const result of results) {

packages/destination-actions/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"package.json"
1515
],
1616
"engines": {
17-
"node": "14 || ^18.12"
17+
"node": "^18.12 || ^22.13"
1818
},
1919
"engineStrict": true,
2020
"license": "MIT",
@@ -46,7 +46,7 @@
4646
"@segment/a1-notation": "^2.1.4",
4747
"@segment/actions-core": "^3.146.0",
4848
"@segment/actions-shared": "^1.127.0",
49-
"@types/node": "^18.11.15",
49+
"@types/node": "^22.13.1",
5050
"ajv-formats": "^2.1.1",
5151
"aws4": "^1.12.0",
5252
"cheerio": "^1.0.0-rc.10",
@@ -57,7 +57,7 @@
5757
"liquidjs": "^10.8.4",
5858
"lodash": "^4.17.21",
5959
"lru-cache": "10.4.3",
60-
"ssh2-sftp-client": "^9.1.0"
60+
"ssh2-sftp-client": "^10.0.3"
6161
},
6262
"jest": {
6363
"preset": "ts-jest",

packages/destination-actions/src/destinations/amplitude/__tests__/amplitude.test.ts

Lines changed: 12 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,19 +2246,9 @@ describe('Amplitude', () => {
22462246

22472247
expect(response.status).toBe(200)
22482248
expect(response.data).toMatchObject({})
2249-
expect(response.options.body).toMatchInlineSnapshot(`
2250-
URLSearchParams {
2251-
Symbol(query): Array [
2252-
"api_key",
2253-
"undefined",
2254-
"identification",
2255-
"[{\\"device_id\\":\\"some-anonymous-id\\",\\"groups\\":{\\"some-type\\":\\"some-value\\"},\\"insert_id\\":\\"some-insert-id\\",\\"library\\":\\"segment\\",\\"time\\":1618245157710,\\"user_id\\":\\"some-user-id\\",\\"user_properties\\":{\\"some-type\\":\\"some-value\\"}}]",
2256-
"options",
2257-
"undefined",
2258-
],
2259-
Symbol(context): null,
2260-
}
2261-
`)
2249+
expect(response.options.body?.toString()).toMatchInlineSnapshot(
2250+
`"api_key=undefined&identification=%5B%7B%22device_id%22%3A%22some-anonymous-id%22%2C%22groups%22%3A%7B%22some-type%22%3A%22some-value%22%7D%2C%22insert_id%22%3A%22some-insert-id%22%2C%22library%22%3A%22segment%22%2C%22time%22%3A1618245157710%2C%22user_id%22%3A%22some-user-id%22%2C%22user_properties%22%3A%7B%22some-type%22%3A%22some-value%22%7D%7D%5D&options=undefined"`
2251+
)
22622252
})
22632253

22642254
it('should fire groupidentify call to Amplitude', async () => {
@@ -2273,19 +2263,9 @@ describe('Amplitude', () => {
22732263

22742264
expect(response.status).toBe(200)
22752265
expect(response.data).toMatchObject({})
2276-
expect(response.options.body).toMatchInlineSnapshot(`
2277-
URLSearchParams {
2278-
Symbol(query): Array [
2279-
"api_key",
2280-
"undefined",
2281-
"identification",
2282-
"[{\\"group_properties\\":{\\"some-trait-key\\":\\"some-trait-value\\"},\\"group_value\\":\\"some-value\\",\\"group_type\\":\\"some-type\\",\\"library\\":\\"segment\\"}]",
2283-
"options",
2284-
"undefined",
2285-
],
2286-
Symbol(context): null,
2287-
}
2288-
`)
2266+
expect(response.options.body?.toString()).toMatchInlineSnapshot(
2267+
`"api_key=undefined&identification=%5B%7B%22group_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22group_value%22%3A%22some-value%22%2C%22group_type%22%3A%22some-type%22%2C%22library%22%3A%22segment%22%7D%5D&options=undefined"`
2268+
)
22892269
})
22902270

22912271
it('should fire identify call to Amplitude EU endpoint', async () => {
@@ -2305,19 +2285,9 @@ describe('Amplitude', () => {
23052285

23062286
expect(response.status).toBe(200)
23072287
expect(response.data).toMatchObject({})
2308-
expect(response.options.body).toMatchInlineSnapshot(`
2309-
URLSearchParams {
2310-
Symbol(query): Array [
2311-
"api_key",
2312-
"",
2313-
"identification",
2314-
"[{\\"device_id\\":\\"some-anonymous-id\\",\\"groups\\":{\\"some-type\\":\\"some-value\\"},\\"insert_id\\":\\"some-insert-id\\",\\"library\\":\\"segment\\",\\"time\\":1618245157710,\\"user_id\\":\\"some-user-id\\",\\"user_properties\\":{\\"some-type\\":\\"some-value\\"}}]",
2315-
"options",
2316-
"undefined",
2317-
],
2318-
Symbol(context): null,
2319-
}
2320-
`)
2288+
expect(response.options.body?.toString()).toMatchInlineSnapshot(
2289+
`"api_key=&identification=%5B%7B%22device_id%22%3A%22some-anonymous-id%22%2C%22groups%22%3A%7B%22some-type%22%3A%22some-value%22%7D%2C%22insert_id%22%3A%22some-insert-id%22%2C%22library%22%3A%22segment%22%2C%22time%22%3A1618245157710%2C%22user_id%22%3A%22some-user-id%22%2C%22user_properties%22%3A%7B%22some-type%22%3A%22some-value%22%7D%7D%5D&options=undefined"`
2290+
)
23212291
})
23222292

23232293
it('should fire groupidentify call to Amplitude EU endpoint', async () => {
@@ -2337,19 +2307,9 @@ describe('Amplitude', () => {
23372307

23382308
expect(response.status).toBe(200)
23392309
expect(response.data).toMatchObject({})
2340-
expect(response.options.body).toMatchInlineSnapshot(`
2341-
URLSearchParams {
2342-
Symbol(query): Array [
2343-
"api_key",
2344-
"",
2345-
"identification",
2346-
"[{\\"group_properties\\":{\\"some-trait-key\\":\\"some-trait-value\\"},\\"group_value\\":\\"some-value\\",\\"group_type\\":\\"some-type\\",\\"library\\":\\"segment\\"}]",
2347-
"options",
2348-
"undefined",
2349-
],
2350-
Symbol(context): null,
2351-
}
2352-
`)
2310+
expect(response.options.body?.toString()).toMatchInlineSnapshot(
2311+
`"api_key=&identification=%5B%7B%22group_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22group_value%22%3A%22some-value%22%2C%22group_type%22%3A%22some-type%22%2C%22library%22%3A%22segment%22%7D%5D&options=undefined"`
2312+
)
23532313
})
23542314
})
23552315

packages/destination-actions/src/destinations/braze/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function removeEmpty(obj: unknown) {
4848

4949
const cleaned = removeUndefined(obj)
5050
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
51-
if (typeof cleaned === 'object' && Object.keys(cleaned!).length > 0) {
51+
if (typeof cleaned === 'object' && Object.keys(cleaned).length > 0) {
5252
return cleaned
5353
}
5454

packages/destination-actions/src/destinations/pushwoosh/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function removeEmpty(obj: unknown) {
99

1010
const cleaned = removeUndefined(obj)
1111
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
12-
if (typeof cleaned === 'object' && Object.keys(cleaned!).length > 0) {
12+
if (typeof cleaned === 'object' && Object.keys(cleaned).length > 0) {
1313
return cleaned
1414
}
1515

packages/destination-actions/tsconfig.build.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"compilerOptions": {
44
"composite": true,
55
"rootDir": "src",
6-
"outDir": "dist"
6+
"outDir": "dist",
7+
"useUnknownInCatchVariables": false
78
},
89
"exclude": ["**/__tests__/**/*.ts"],
910
"include": ["src"],

0 commit comments

Comments
 (0)