Browse Source

fix(sampling): Rename the keys received from dyn sampling response (#39678)

Renames the dynamic sampling keys returned from the response of the
project dynamic sampling endpoint to match its counterpart
Ahmed Etefy 2 years ago
parent
commit
08a2fda581

+ 3 - 2
static/app/actionCreators/serverSideSampling.tsx

@@ -22,7 +22,7 @@ export function fetchSamplingSdkVersions({
 
   const distribution = ServerSideSamplingStore.getState().distribution.data;
 
-  const {startTimestamp, endTimestamp, project_breakdown} = distribution ?? {};
+  const {startTimestamp, endTimestamp, projectBreakdown} = distribution ?? {};
 
   ServerSideSamplingStore.sdkVersionsRequestLoading();
 
@@ -33,7 +33,8 @@ export function fetchSamplingSdkVersions({
 
   const projectIds = [
     projectID,
-    ...(project_breakdown?.map(projectBreakdown => projectBreakdown.project_id) ?? []),
+    ...(projectBreakdown?.map(projectBreakdownObj => projectBreakdownObj.project_id) ??
+      []),
   ];
 
   const promise = api.requestPromise(

+ 2 - 2
static/app/types/sampling.tsx

@@ -102,14 +102,14 @@ export type SamplingRule = {
 
 export type SamplingDistribution = {
   endTimestamp: string | null;
-  project_breakdown:
+  projectBreakdown:
     | null
     | {
         'count()': number;
         project: string;
         project_id: number;
       }[];
-  sample_size: number;
+  sampleSize: number;
   startTimestamp: string | null;
 };
 

+ 1 - 1
static/app/views/settings/project/server-side-sampling/samplingBreakdown.spec.tsx

@@ -27,7 +27,7 @@ describe('Server-Side Sampling - SamplingBreakdown', function () {
 
   it('renders project breakdown', function () {
     const {organization} = getMockData();
-    const projectBreakdown = mockedSamplingDistribution.project_breakdown;
+    const projectBreakdown = mockedSamplingDistribution.projectBreakdown;
 
     ProjectsStore.loadInitialData(
       projectBreakdown!.map(p => TestStubs.Project({id: p.project_id, slug: p.project}))

+ 1 - 1
static/app/views/settings/project/server-side-sampling/samplingBreakdown.tsx

@@ -27,7 +27,7 @@ type Props = {
 export function SamplingBreakdown({orgSlug}: Props) {
   const theme = useTheme();
   const {distribution, loading} = useDistribution();
-  const projectBreakdown = distribution?.project_breakdown;
+  const projectBreakdown = distribution?.projectBreakdown;
 
   const {projects} = useProjects({
     slugs: projectBreakdown?.map(project => project.project) ?? [],

+ 1 - 1
static/app/views/settings/project/server-side-sampling/serverSideSampling.spec.tsx

@@ -53,7 +53,7 @@ function renderMockRequests({
   const projects = MockApiClient.addMockResponse({
     url: `/organizations/${organizationSlug}/projects/`,
     method: 'GET',
-    body: mockedSamplingDistribution.project_breakdown!.map(p =>
+    body: mockedSamplingDistribution.projectBreakdown!.map(p =>
       TestStubs.Project({id: p.project_id, slug: p.project})
     ),
   });

+ 2 - 2
static/app/views/settings/project/server-side-sampling/testUtils.tsx

@@ -129,7 +129,7 @@ export const recommendedSdkUpgrades: RecommendedSdkUpgrade[] = [
 ];
 
 export const mockedSamplingDistribution: SamplingDistribution = {
-  project_breakdown: [
+  projectBreakdown: [
     {
       project: mockedProjects[0].slug,
       project_id: mockedProjects[0].id,
@@ -141,7 +141,7 @@ export const mockedSamplingDistribution: SamplingDistribution = {
       'count()': 100,
     },
   ],
-  sample_size: 100,
+  sampleSize: 100,
   startTimestamp: '2017-08-04T07:52:11Z',
   endTimestamp: '2017-08-05T07:52:11Z',
 };