Skip to content
Closed
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
9 changes: 9 additions & 0 deletions static/app/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,12 @@ export function generateOrgSlugUrl(orgSlug: any) {
const sentryDomain = window.__initialData.links.sentryUrl.split('/')[2];
return `${window.location.protocol}//${orgSlug}.${sentryDomain}${window.location.pathname}`;
}

/**
* Encodes given object into url-friendly format
*/
export function urlEncode(object: {[key: string]: any}): string {
return Object.keys(object)
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(object[key])}`)
.join('&');
}
11 changes: 2 additions & 9 deletions static/app/utils/metrics/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {urlEncode} from '@sentry/utils';

import type {PageFilters} from 'sentry/types/core';
import {defined} from 'sentry/utils';
import {defined, urlEncode} from 'sentry/utils';
import {MRIToField} from 'sentry/utils/metrics/mri';
import type {MetricDisplayType, MetricsQuery} from 'sentry/utils/metrics/types';
import type {Widget, WidgetQuery} from 'sentry/views/dashboards/types';
Expand Down Expand Up @@ -70,12 +68,7 @@ export function getWidgetEquation(equation: EquationParams): WidgetQuery {
}

export function encodeWidgetQuery(query: any) {
return urlEncode({
...query,
aggregates: query.aggregates.join(','),
fields: query.fields?.join(','),
columns: query.columns.join(','),
});
return urlEncode(query);
Comment on lines -73 to -78
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be changed?

}

export function getWidgetAsQueryParams(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {urlEncode} from '@sentry/utils';
import {DashboardFixture} from 'sentry-fixture/dashboard';
import {LocationFixture} from 'sentry-fixture/locationFixture';
import {MetricsFieldFixture} from 'sentry-fixture/metrics';
Expand All @@ -21,6 +20,7 @@ import selectEvent from 'sentry-test/selectEvent';
import * as modals from 'sentry/actionCreators/modal';
import ProjectsStore from 'sentry/stores/projectsStore';
import TagStore from 'sentry/stores/tagStore';
import {urlEncode} from 'sentry/utils';
import {DatasetSource, TOP_N} from 'sentry/utils/discover/types';
import type {DashboardDetails, Widget} from 'sentry/views/dashboards/types';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {urlEncode} from '@sentry/utils';
import {DashboardFixture} from 'sentry-fixture/dashboard';
import {LocationFixture} from 'sentry-fixture/locationFixture';
import {MetricsFieldFixture} from 'sentry-fixture/metrics';
Expand All @@ -18,6 +17,7 @@ import {resetMockDate, setMockDate} from 'sentry-test/utils';

import ProjectsStore from 'sentry/stores/projectsStore';
import TagStore from 'sentry/stores/tagStore';
import {urlEncode} from 'sentry/utils';
import {ERROR_FIELDS, ERRORS_AGGREGATION_FUNCTIONS} from 'sentry/utils/discover/fields';
import type {DashboardDetails, Widget} from 'sentry/views/dashboards/types';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {urlEncode} from '@sentry/utils';
import {DashboardFixture} from 'sentry-fixture/dashboard';
import {LocationFixture} from 'sentry-fixture/locationFixture';
import {MetricsFieldFixture} from 'sentry-fixture/metrics';
Expand All @@ -11,6 +10,7 @@ import selectEvent from 'sentry-test/selectEvent';

import ProjectsStore from 'sentry/stores/projectsStore';
import TagStore from 'sentry/stores/tagStore';
import {urlEncode} from 'sentry/utils';
import type {DashboardDetails, Widget} from 'sentry/views/dashboards/types';
import {
DashboardWidgetSource,
Expand Down
3 changes: 1 addition & 2 deletions static/app/views/discover/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {urlEncode} from '@sentry/utils';
import type {Location, Query} from 'history';
import * as Papa from 'papaparse';

Expand All @@ -15,7 +14,7 @@ import type {
OrganizationSummary,
} from 'sentry/types/organization';
import type {Project} from 'sentry/types/project';
import {defined} from 'sentry/utils';
import {defined, urlEncode} from 'sentry/utils';
import {getUtcDateString} from 'sentry/utils/dates';
import type {TableDataRow} from 'sentry/utils/discover/discoverQuery';
import type {EventData} from 'sentry/utils/discover/eventView';
Expand Down
3 changes: 1 addition & 2 deletions static/app/views/integrationOrganizationLink/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Fragment} from 'react';
import styled from '@emotion/styled';
import {urlEncode} from '@sentry/utils';

import {addErrorMessage} from 'sentry/actionCreators/indicator';
import {Alert} from 'sentry/components/alert';
Expand All @@ -18,7 +17,7 @@ import ConfigStore from 'sentry/stores/configStore';
import type {Integration, IntegrationProvider} from 'sentry/types/integrations';
import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
import type {Organization} from 'sentry/types/organization';
import {generateOrgSlugUrl} from 'sentry/utils';
import {generateOrgSlugUrl, urlEncode} from 'sentry/utils';
import type {IntegrationAnalyticsKey} from 'sentry/utils/analytics/integrations';
import {
getIntegrationFeatureGate,
Expand Down
Loading