@awsui/component-toolkit
Advanced tools
Comparing version 1.0.0-beta.77 to 1.0.0-beta.78
export interface MetricsV2EventItem { | ||
eventName?: string; | ||
eventType?: string; | ||
eventContext?: string; | ||
@@ -5,0 +3,0 @@ eventDetail?: string | Record<string, string | number | boolean>; |
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
const AWSUI_EVENT = 'awsui'; | ||
function validateLength(value, maxLength) { | ||
@@ -27,3 +28,3 @@ return !value || value.length <= maxLength; | ||
const wasSent = new PanoramaClient().sendMetric({ | ||
eventName: metricName, | ||
eventContext: metricName, | ||
eventDetail: detail, | ||
@@ -70,29 +71,16 @@ eventValue: `${value}`, | ||
} | ||
if (typeof metric.eventDetail === 'object') { | ||
metric.eventDetail = JSON.stringify(metric.eventDetail); | ||
} | ||
if (typeof metric.eventValue === 'object') { | ||
metric.eventValue = JSON.stringify(metric.eventValue); | ||
} | ||
if (!validateLength(metric.eventName, 1000)) { | ||
this.onMetricError(`Event name for metric is too long: ${metric.eventName}`); | ||
const payload = Object.assign(Object.assign({ eventType: AWSUI_EVENT, timestamp: Date.now() }, metric), { eventDetail: typeof metric.eventDetail === 'object' ? JSON.stringify(metric.eventDetail) : metric.eventDetail, eventValue: typeof metric.eventValue === 'object' ? JSON.stringify(metric.eventValue) : metric.eventValue }); | ||
if (!validateLength(payload.eventDetail, 4000)) { | ||
this.onMetricError(`Event detail for metric is too long: ${payload.eventDetail}`); | ||
return true; | ||
} | ||
if (!validateLength(metric.eventDetail, 4000)) { | ||
this.onMetricError(`Event detail for metric is too long: ${metric.eventDetail}`); | ||
if (!validateLength(payload.eventValue, 4000)) { | ||
this.onMetricError(`Event value for metric is too long: ${payload.eventValue}`); | ||
return true; | ||
} | ||
if (!validateLength(metric.eventValue, 4000)) { | ||
this.onMetricError(`Event value for metric is too long: ${metric.eventValue}`); | ||
if (!validateLength(payload.eventContext, 4000)) { | ||
this.onMetricError(`Event context for metric is too long: ${payload.eventContext}`); | ||
return true; | ||
} | ||
if (!validateLength(metric.eventContext, 4000)) { | ||
this.onMetricError(`Event context for metric is too long: ${metric.eventContext}`); | ||
return true; | ||
} | ||
if (!validateLength(metric.eventType, 50)) { | ||
this.onMetricError(`Event type for metric is too long: ${metric.eventType}`); | ||
return true; | ||
} | ||
panorama('trackCustomEvent', Object.assign({ timestamp: Date.now() }, metric)); | ||
panorama('trackCustomEvent', payload); | ||
return true; | ||
@@ -105,4 +93,6 @@ } | ||
panorama('trackCustomEvent', { | ||
eventName: 'awsui-metric-error', | ||
eventType: AWSUI_EVENT, | ||
eventContext: 'awsui-metric-error', | ||
eventDetail: message.slice(0, 4000), | ||
timestamp: Date.now(), | ||
}); | ||
@@ -109,0 +99,0 @@ } |
{ | ||
"commit": "3c08c6f77e60b69344fd3eafb9efde7a220d1896" | ||
"commit": "9b48c5ed8b91fb75684a7a68736367388bc96590" | ||
} |
{ | ||
"name": "@awsui/component-toolkit", | ||
"version": "1.0.0-beta.77", | ||
"version": "1.0.0-beta.78", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "container-queries", |
102542
2069