@salesforce/pwa-kit-runtime 3.15.0 → 3.16.0-nightly-20260116080227
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/pwa-kit-runtime",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.0-nightly-20260116080227",
|
|
4
4
|
"description": "The PWAKit Runtime",
|
|
5
5
|
"homepage": "https://github.com/SalesforceCommerceCloud/pwa-kit/tree/develop/packages/pwa-kit-runtime#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"version": "node ./scripts/version.js"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@aws-sdk/client-cloudwatch": "^3.962.0",
|
|
33
34
|
"@h4ad/serverless-adapter": "4.4.0",
|
|
34
35
|
"@loadable/babel-plugin": "^5.15.3",
|
|
35
|
-
"aws-sdk": "^2.1354.0",
|
|
36
36
|
"cosmiconfig": "8.1.3",
|
|
37
37
|
"cross-env": "^5.2.1",
|
|
38
38
|
"express": "^4.19.2",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@loadable/component": "^5.15.3",
|
|
49
|
-
"@salesforce/pwa-kit-dev": "3.
|
|
49
|
+
"@salesforce/pwa-kit-dev": "3.16.0-nightly-20260116080227",
|
|
50
50
|
"@serverless/event-mocks": "^1.1.1",
|
|
51
51
|
"aws-lambda-mock-context": "^3.2.1",
|
|
52
52
|
"fs-extra": "^11.1.1",
|
|
53
|
-
"internal-lib-build": "3.
|
|
53
|
+
"internal-lib-build": "3.16.0-nightly-20260116080227",
|
|
54
54
|
"nock": "^13.3.0",
|
|
55
55
|
"nodemon": "^2.0.22",
|
|
56
56
|
"sinon": "^13.0.2",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"supertest": "^4.0.2"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@salesforce/pwa-kit-dev": "3.
|
|
61
|
+
"@salesforce/pwa-kit-dev": "3.16.0-nightly-20260116080227"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
64
64
|
"@salesforce/pwa-kit-dev": {
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"directory": "dist"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "e77808bcd68817cdcaa7cc010e8942ab99e294c6"
|
|
76
76
|
}
|
|
@@ -291,9 +291,9 @@ describe('SSRServer Lambda integration', () => {
|
|
|
291
291
|
// track them.
|
|
292
292
|
const metrics = [];
|
|
293
293
|
app.metrics._CW = {
|
|
294
|
-
putMetricData:
|
|
294
|
+
putMetricData: params => {
|
|
295
295
|
metrics.push(params);
|
|
296
|
-
|
|
296
|
+
return Promise.resolve();
|
|
297
297
|
}
|
|
298
298
|
};
|
|
299
299
|
const metricSent = name => !!metrics.find(metric => !!metric.MetricData.find(data => data.MetricName === name));
|
|
@@ -54,16 +54,19 @@ class MetricsSender {
|
|
|
54
54
|
/* istanbul ignore next */
|
|
55
55
|
if (!this._CW && ((0, _utils.isRemote)() || MetricsSender._override)) {
|
|
56
56
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
57
|
-
const
|
|
57
|
+
const {
|
|
58
|
+
CloudWatch: Cloudwatch
|
|
59
|
+
} = require('@aws-sdk/client-cloudwatch');
|
|
58
60
|
this._CW = new Cloudwatch({
|
|
59
|
-
apiVersion: '2010-08-01',
|
|
60
61
|
// The AWS_REGION variable is defined by the Lambda
|
|
61
62
|
// environment.
|
|
62
63
|
region: process.env.AWS_REGION || 'us-east-1',
|
|
63
64
|
// Setting maxRetries to 0 will prevent the SDK from retrying.
|
|
64
65
|
// This is necessary because under high load, there will be backpressure
|
|
65
66
|
// on the Lambda function, and causing severe performance issues (400-500ms latency)
|
|
66
|
-
maxRetries
|
|
67
|
+
// The key maxRetries is renamed to maxAttempts.
|
|
68
|
+
// The value of maxAttempts needs to be maxRetries + 1.
|
|
69
|
+
maxAttempts: 1
|
|
67
70
|
});
|
|
68
71
|
}
|
|
69
72
|
return this._CW;
|
|
@@ -83,21 +86,18 @@ class MetricsSender {
|
|
|
83
86
|
if (!cw) {
|
|
84
87
|
return Promise.resolve();
|
|
85
88
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
});
|
|
89
|
+
|
|
90
|
+
// v3 supports promises, so we can use that instead of a callback.
|
|
91
|
+
return cw.putMetricData({
|
|
92
|
+
MetricData: metrics,
|
|
93
|
+
Namespace: 'ssr'
|
|
94
|
+
}).catch(err => {
|
|
95
|
+
_loggerInstance.default.warn(`Metrics: error sending data: ${err}`, {
|
|
96
|
+
namespace: 'metrics-sender._putMetricData',
|
|
97
|
+
additionalProperties: {
|
|
98
|
+
metrics,
|
|
99
|
+
error: err
|
|
99
100
|
}
|
|
100
|
-
resolve();
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
103
|
}
|
|
@@ -168,8 +168,8 @@ class MetricsSender {
|
|
|
168
168
|
const metricData = {
|
|
169
169
|
MetricName: metric.name,
|
|
170
170
|
Value: metric.value || 0,
|
|
171
|
-
//
|
|
172
|
-
Timestamp:
|
|
171
|
+
// AWS SDK expects a Date object
|
|
172
|
+
Timestamp: metric.timestamp instanceof Date ? metric.timestamp : typeof metric.timestamp === 'number' ? new Date(metric.timestamp) : now,
|
|
173
173
|
Unit: metric.unit || 'Count'
|
|
174
174
|
};
|
|
175
175
|
if (metric.dimensions) {
|
package/utils/ssr-server.test.js
CHANGED
|
@@ -360,13 +360,14 @@ describe('MetricsSender', () => {
|
|
|
360
360
|
const calledParams = [];
|
|
361
361
|
let callCount = 0;
|
|
362
362
|
sender._CW = {
|
|
363
|
-
putMetricData:
|
|
363
|
+
putMetricData: params => {
|
|
364
364
|
callCount += 1;
|
|
365
|
-
// This returns a fake error on the first call, and then
|
|
366
|
-
// accepts all subsequent calls.
|
|
367
|
-
const err = calledParams.length ? null : new Error('imaginary error');
|
|
368
365
|
params.MetricData.forEach(metric => calledParams.push(metric));
|
|
369
|
-
|
|
366
|
+
// This returns a fake promise that resolves immediately
|
|
367
|
+
if (callCount === 1) {
|
|
368
|
+
return Promise.reject(new Error('Some error'));
|
|
369
|
+
}
|
|
370
|
+
return Promise.resolve();
|
|
370
371
|
}
|
|
371
372
|
};
|
|
372
373
|
|
|
@@ -393,7 +394,7 @@ describe('MetricsSender', () => {
|
|
|
393
394
|
expect(actual).toBeDefined();
|
|
394
395
|
expect(actual.MetricName).toEqual(metric.name);
|
|
395
396
|
expect(actual.Value).toEqual(metric.value || 0);
|
|
396
|
-
expect(actual.Timestamp).toEqual(nowISO);
|
|
397
|
+
expect(actual.Timestamp.toISOString()).toEqual(nowISO);
|
|
397
398
|
if (metric.dimensions) {
|
|
398
399
|
expect(actual.Dimensions).toBeDefined();
|
|
399
400
|
actual.Dimensions.forEach(dimension => {
|
|
@@ -422,10 +423,8 @@ describe('MetricsSender', () => {
|
|
|
422
423
|
// Set up a fake CloudWatch client that will return a Throttling
|
|
423
424
|
// error every time it's called.
|
|
424
425
|
sender._CW = {
|
|
425
|
-
putMetricData:
|
|
426
|
-
|
|
427
|
-
err.code = 'Throttling';
|
|
428
|
-
callback(err);
|
|
426
|
+
putMetricData: params => {
|
|
427
|
+
return Promise.reject(new Error('Throttled'));
|
|
429
428
|
}
|
|
430
429
|
};
|
|
431
430
|
|