Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1874901: add utm_source parameter to Red Hat Marketplace URLs for attribution #6363

Merged
merged 5 commits into from Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -849,6 +849,16 @@ export const ClusterServiceVersionDetails: React.SFC<ClusterServiceVersionDetail
}
}

let supportWorkflowUrl = marketplaceSupportWorkflow;
try {
const url = new URL(supportWorkflowUrl);
url.searchParams.set('utm_source', 'openshift_console');
supportWorkflowUrl = url.toString();
} catch (error) {
// eslint-disable-next-line no-console
console.error(error.message);
}

return (
<>
<ScrollToTopOnMount />
Expand Down Expand Up @@ -882,11 +892,11 @@ export const ClusterServiceVersionDetails: React.SFC<ClusterServiceVersionDetail
<dd>
{spec.provider && spec.provider.name ? spec.provider.name : 'Not available'}
</dd>
{marketplaceSupportWorkflow && (
{supportWorkflowUrl && (
<>
<dt>Support</dt>
<dd>
<ExternalLink href={marketplaceSupportWorkflow} text="Get support" />
<ExternalLink href={supportWorkflowUrl} text="Get support" />
</dd>
</>
)}
Expand Down
Expand Up @@ -138,6 +138,16 @@ export const OperatorHubItemDetails: React.SFC<OperatorHubItemDetailsProps> = ({
const mappedInfraFeatures = mappedData(infraFeatures);
const mappedValidSubscription = mappedData(validSubscription);

let supportWorkflowUrl = marketplaceSupportWorkflow;
try {
const url = new URL(supportWorkflowUrl);
url.searchParams.set('utm_source', 'openshift_console');
supportWorkflowUrl = url.toString();
} catch (error) {
// eslint-disable-next-line no-console
console.error(error.message);
}

return (
<div className="modal-body modal-body-border">
<div className="modal-body-content">
Expand Down Expand Up @@ -169,8 +179,8 @@ export const OperatorHubItemDetails: React.SFC<OperatorHubItemDetailsProps> = ({
<PropertyItem
label="Support"
value={
marketplaceSupportWorkflow ? (
<ExternalLink href={marketplaceSupportWorkflow} text="Get support" />
supportWorkflowUrl ? (
<ExternalLink href={supportWorkflowUrl} text="Get support" />
) : (
support || notAvailable
)
Expand Down
Expand Up @@ -421,6 +421,16 @@ export const OperatorHubTileView: React.FC<OperatorHubTileViewProps> = (props) =
detailsItem &&
`/k8s/ns/${detailsItem.subscription.metadata.namespace}/${SubscriptionModel.plural}/${detailsItem.subscription.metadata.name}?showDelete=true`;

let remoteWorkflowUrl = detailsItem.marketplaceRemoteWorkflow;
Copy link
Member

Choose a reason for hiding this comment

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

It looks like detailsItem is not always defined.

try {
const url = new URL(remoteWorkflowUrl);
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this tries to parse an undefined URL and spams the console with errors like

URL constructor: undefined is not a valid URL.

We should only try to parse the URL if defined. (Sorry I missed this on previous review.)

Copy link
Member Author

Choose a reason for hiding this comment

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

No worries, I should have caught it. Thank you for the review!

url.searchParams.set('utm_source', 'openshift_console');
remoteWorkflowUrl = url.toString();
} catch (error) {
// eslint-disable-next-line no-console
console.error(error.message);
}

if (_.isEmpty(filteredItems)) {
return (
<>
Expand Down Expand Up @@ -468,10 +478,10 @@ export const OperatorHubTileView: React.FC<OperatorHubTileViewProps> = (props) =
id="catalog-item-header"
/>
<div className="co-catalog-page__overlay-actions">
{detailsItem.marketplaceRemoteWorkflow && (
{remoteWorkflowUrl && (
<ExternalLink
additionalClassName="pf-c-button pf-m-primary co-catalog-page__overlay-action"
href={detailsItem.marketplaceRemoteWorkflow}
href={remoteWorkflowUrl}
text={
<>
<div className="co-catalog-page__overlay-action-label">
Expand All @@ -486,8 +496,8 @@ export const OperatorHubTileView: React.FC<OperatorHubTileViewProps> = (props) =
<Link
className={classNames(
'pf-c-button',
{ 'pf-m-secondary': detailsItem.marketplaceRemoteWorkflow },
{ 'pf-m-primary': !detailsItem.marketplaceRemoteWorkflow },
{ 'pf-m-secondary': remoteWorkflowUrl },
{ 'pf-m-primary': !remoteWorkflowUrl },
'co-catalog-page__overlay-action',
)}
data-test-id="operator-install-btn"
Expand Down