Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frontend/@types/console/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ declare interface Window {
// One of the following should be always available on prod env.
SEGMENT_API_KEY: string;
SEGMENT_PUBLIC_API_KEY: string;
// DevSandbox-specific configuration
DEVSANDBOX_SEGMENT_API_KEY: string;
DEVSANDBOX: 'true' | 'false';
// Optional override for analytics.min.js script URL
SEGMENT_JS_URL: string;
// Additional telemetry options passed to Console frontend
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { GetSegmentAnalytics } from '../extensions/console-types';

// Segment API key. Must be present for telemetry to be enabled.
// When running in DevSandbox mode, prefer the DevSandbox-specific key.
const TELEMETRY_API_KEY =
(window.SERVER_FLAGS.telemetry?.DEVSANDBOX === 'true' &&
window.SERVER_FLAGS.telemetry?.DEVSANDBOX_SEGMENT_API_KEY) ||
window.SERVER_FLAGS.telemetry?.SEGMENT_API_KEY ||
window.SERVER_FLAGS.telemetry?.SEGMENT_PUBLIC_API_KEY ||
window.SERVER_FLAGS.telemetry?.DEVSANDBOX_SEGMENT_API_KEY ||
'';

// Segment "apiHost" parameter, should be like "api.segment.io/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,28 @@ describe('getClusterProperties', () => {
expect(getClusterProperties().clusterType).toBe('TEST');
});

it('returns DEVSANDBOX when CLUSTER_TYPE is "OSD" but and DEVSANDBOX is "true"', () => {
it('returns DEVSANDBOX when DEVSANDBOX is "true" regardless of CLUSTER_TYPE', () => {
window.SERVER_FLAGS = {
...originServerFlags,
telemetry: { CLUSTER_TYPE: 'OSD', DEVSANDBOX: 'true' },
telemetry: { CLUSTER_TYPE: 'ROSA', DEVSANDBOX: 'true' },
};
expect(getClusterProperties().clusterType).toBe('DEVSANDBOX');
});

it('returns the clusterType that it is configured if CLUSTER_TYPE is not OSD (in the future) but DEVSANDBOX is still "true"', () => {
it('returns DEVSANDBOX when DEVSANDBOX is "true" even if CLUSTER_TYPE is a different value', () => {
window.SERVER_FLAGS = {
...originServerFlags,
telemetry: { CLUSTER_TYPE: 'a_FUTURE_DEVSANDBOX_KEY', DEVSANDBOX: 'true' },
};
expect(getClusterProperties().clusterType).toBe('a_FUTURE_DEVSANDBOX_KEY');
expect(getClusterProperties().clusterType).toBe('DEVSANDBOX');
});

it('returns the clusterType that it is configured if CLUSTER_TYPE is OSD but DEVSANDBOX is not exactly "true"', () => {
it('returns the configured clusterType when DEVSANDBOX is not exactly "true"', () => {
window.SERVER_FLAGS = {
...originServerFlags,
telemetry: { CLUSTER_TYPE: 'OSD', DEVSANDBOX: 'false' },
telemetry: { CLUSTER_TYPE: 'ROSA', DEVSANDBOX: 'false' },
};
expect(getClusterProperties().clusterType).toBe('OSD');
expect(getClusterProperties().clusterType).toBe('ROSA');
});
});

Expand Down Expand Up @@ -207,12 +207,12 @@ describe('useTelemetry', () => {
});
});

it('calls the listener with clusterType DEVSANDBOX when CLUSTER_TYPE is OSD and DEVSANDBOX is "true"', () => {
it('calls the listener with clusterType DEVSANDBOX when DEVSANDBOX is "true"', () => {
window.SERVER_FLAGS = {
...originServerFlags,
consoleVersion: 'x.y.z',
telemetry: {
CLUSTER_TYPE: 'OSD',
CLUSTER_TYPE: 'ROSA',
DEVSANDBOX: 'true',
STATE: CLUSTER_TELEMETRY_ANALYTICS.ENFORCE,
},
Expand Down
5 changes: 1 addition & 4 deletions frontend/packages/console-shared/src/hooks/useTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ export const getClusterProperties = () => {
const clusterProperties: ClusterProperties = {};
clusterProperties.clusterId = window.SERVER_FLAGS.telemetry?.CLUSTER_ID;
clusterProperties.clusterType = window.SERVER_FLAGS.telemetry?.CLUSTER_TYPE;
if (
window.SERVER_FLAGS.telemetry?.CLUSTER_TYPE === 'OSD' &&
window.SERVER_FLAGS.telemetry?.DEVSANDBOX === 'true'
) {
if (window.SERVER_FLAGS.telemetry?.DEVSANDBOX === 'true') {
clusterProperties.clusterType = 'DEVSANDBOX';
}
// Prefer to report the OCP version (releaseVersion) if available.
Expand Down