fix(ui): change conditonal capture key names

This commit is contained in:
nick-delirium 2024-01-12 14:37:37 +01:00
parent 35ed2c9c70
commit c9bd62c243
5 changed files with 19 additions and 20 deletions

View file

@ -26,8 +26,8 @@ function CaptureRate(props: Props) {
sessionSettings: {
captureRate,
changeCaptureRate,
captureAll,
changeCaptureAll,
conditionalCapture,
changeConditionalCapture,
captureConditions,
},
loadingCaptureRate,
@ -52,8 +52,8 @@ function CaptureRate(props: Props) {
const toggleRate = () => {
setChanged(true);
const newValue = !captureAll;
changeCaptureAll(newValue);
const newValue = !conditionalCapture;
changeConditionalCapture(newValue);
if (newValue) {
changeCaptureRate('100');
}
@ -62,12 +62,12 @@ function CaptureRate(props: Props) {
const onUpdate = () => {
updateCaptureConditions(projectId!, {
rate: parseInt(captureRate, 10),
captureAll,
conditionalCapture: conditionalCapture,
conditions: conditions.map((c) => c.toCaptureCondition()),
}).finally(() => setChanged(false));
};
const updateDisabled = !changed || !isAdmin || (captureAll && conditions.length === 0);
const updateDisabled = !changed || !isAdmin || (conditionalCapture && conditions.length === 0);
return (
<Drawer
size={'large'}
@ -102,13 +102,13 @@ function CaptureRate(props: Props) {
<Icon size={16} color={'black'} name={'info-circle'} />
</Tooltip>
<Switch
checked={captureAll}
checked={conditionalCapture}
onChange={toggleRate}
checkedChildren={'Conditional'}
disabled={!isAdmin}
unCheckedChildren={'Capture Rate'}
/>
{!captureAll ? (
{!conditionalCapture ? (
<div className={cn('relative', { disabled: !isAdmin })}>
<Input
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
@ -118,7 +118,7 @@ function CaptureRate(props: Props) {
}}
value={captureRate.toString()}
style={{ height: '38px', width: '70px' }}
disabled={captureAll}
disabled={conditionalCapture}
min={0}
max={100}
/>
@ -131,7 +131,7 @@ function CaptureRate(props: Props) {
</div>
) : null}
</div>
{captureAll && isEnterprise ? (
{conditionalCapture && isEnterprise ? (
<ConditionalRecordingSettings
setChanged={setChanged}
conditions={conditions}

View file

@ -9,7 +9,7 @@ import { MENU_COLLAPSED } from 'App/constants/storageKeys';
interface CaptureConditions {
rate: number;
captureAll: boolean;
conditionalCapture: boolean;
conditions: { name: string; captureRate: number; filters: any[] }[];
}
@ -42,7 +42,7 @@ export default class SettingsStore {
.then(({ data }) => {
this.sessionSettings.merge({
captureRate: data.rate,
captureAll: data.captureAll,
conditionalCapture: data.conditionalCapture,
});
toast.success('Settings updated successfully');
})
@ -58,7 +58,7 @@ export default class SettingsStore {
.then((data) => {
this.sessionSettings.merge({
captureRate: data.rate,
captureAll: data.captureAll,
conditionalCapture: data.conditionalCapture,
});
this.captureRateFetched = true;
})
@ -74,7 +74,7 @@ export default class SettingsStore {
.then((data) => {
this.sessionSettings.merge({
captureRate: data.rate,
captureAll: data.captureAll,
conditionalCapture: data.conditionalCapture,
captureConditions: data.conditions,
});
})
@ -91,7 +91,7 @@ export default class SettingsStore {
.then(({ data }) => {
this.sessionSettings.merge({
captureRate: data.rate,
captureAll: data.captureAll,
conditionalCapture: data.conditionalCapture,
captureConditions: data.conditions,
});
toast.success('Settings updated successfully');

View file

@ -60,7 +60,6 @@ export default class FilterItem {
fromJson(json: any, mainFilterKey = '') {
const isMetadata = json.type === FilterKey.METADATA;
let _filter: any = (isMetadata ? filtersMap['_' + json.source] : filtersMap[json.type]) || {};
console.log(_filter, json);
if (this.isConditional) {
_filter = conditionalFiltersMap[json.type] || conditionalFiltersMap[json.source];
}

View file

@ -70,7 +70,7 @@ export default class SessionSettings {
localStorage.getItem(DURATION_FILTER) || JSON.stringify(defaultDurationFilter)
);
captureRate: string = '0';
captureAll: boolean = false;
conditionalCapture: boolean = false;
captureConditions: { name: string; captureRate: number; filters: any[] }[] = [];
mouseTrail: boolean = localStorage.getItem(MOUSE_TRAIL) !== 'false';
shownTimezone: 'user' | 'local';
@ -108,8 +108,8 @@ export default class SessionSettings {
if (parseInt(rate, 10) <= 100) this.captureRate = `${parseInt(rate, 10)}`;
};
changeCaptureAll = (all: boolean) => {
this.captureAll = all;
changeConditionalCapture = (all: boolean) => {
this.conditionalCapture = all;
};
timezoneFix(defaultTimezone: Record<string, string>) {

View file

@ -27,7 +27,7 @@ export default class SettingsService {
fetchCaptureConditions(
projectId: number
): Promise<{ rate: number; captureAll: boolean; conditions: any[] }> {
): Promise<{ rate: number; conditionalCapture: boolean; conditions: any[] }> {
return this.client
.get(`/${projectId}/conditions`)
.then((response) => response.json())