import { RequestOptionsFactory } from '@wix/fe-essentials/http-client';

export function withCairoViewsTestFlag<T>(
  factory: RequestOptionsFactory<T>,
): RequestOptionsFactory<T> {
  return (context) => {
    const requestOptions = factory(context);

    if (requestOptions.data == null) {
      requestOptions.data = {};
    }

    requestOptions.data.__CAIRO_VIEWS_TEST = 'true';

    return requestOptions;
  };
}
