chore: validate segment key
@@ -57,7 +57,12 @@ const AppView: React.FC = () => {
}, [ infoResponse, setInfo ]);
useEffect(() => {
- if (info.telemetry.enabled && info.telemetry.segmentKey && window.analytics) {
+ /*
+ * Check for analytics library and the validity of the segment key:
+ * 32 characters composed of upper case letters, lower case letters and numbers 0-9.
+ */
+ if (window.analytics && info.telemetry.enabled &&
+ info.telemetry.segmentKey && /^[a-z0-9]{32}$/i.test(info.telemetry.segmentKey)) {
window.analytics.load(info.telemetry.segmentKey);
window.analytics.identify(info.clusterId);
window.analytics.page();
