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

FPA M0.5 Adds contentType to article query param. #3540

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions src/runtime/entitlements-manager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,20 @@ describes.realWin('EntitlementsManager', (env) => {
});
});

it('adds content_type to query params when experiment is enabled', async () => {
it('should log error messages from entitlements server', async () => {
fetcherMock
.expects('fetch')
.withExactArgs(
'https://news.google.com/swg/_/api/v1/publication/pub1/entitlements',
{
method: 'GET',
headers: {'Accept': 'text/plain, application/json'},
credentials: 'include',
}
)
})

it('should accept encrypted document key', async () => {
fetcherMock
.expects('fetch')
Expand Down
20 changes: 20 additions & 0 deletions src/runtime/entitlements-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
GOOGLE_METERING_SOURCE,
PRIVILEGED_SOURCE,
} from '../api/entitlements';
import {ArticleExperimentFlags} from './experiment-flags';
import {Fetcher} from './fetcher';
import {Intervention} from './intervention';
import {InterventionType} from '../api/intervention-type';
Expand Down Expand Up @@ -823,6 +824,18 @@ export class EntitlementsManager {
if (this.useArticleEndpoint_) {
url = addQueryParam(url, 'locked', String(this.pageConfig_.isLocked()));
}
const experimentFlags = await this.getExperimentConfigFlags();
if (
experimentFlags.includes(
ArticleExperimentFlags.CONTENT_TYPE_ARTICLE_PARAM_ENABLED
justinchou-google marked this conversation as resolved.
Show resolved Hide resolved
)
) {
url = addQueryParam(
url,
'content_type',
getContentTypeParam(this.pageConfig_.isLocked())
);
}
const hashedCanonicalUrl = await this.getHashedCanonicalUrl_();

let encodableParams: GetEntitlementsParamsInternalDef | undefined = this
Expand Down Expand Up @@ -1019,3 +1032,10 @@ function irtpStringToBoolean(value: string | null): boolean | undefined {
return undefined;
}
}

/**
* Returns ContentType Enum string from isLocked page config status.
*/
function getContentTypeParam(isLocked: boolean) {
return isLocked ? 'CLOSED' : 'OPEN';
}
5 changes: 5 additions & 0 deletions src/runtime/experiment-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@ export enum ArticleExperimentFlags {
* Experiment flag to enable onsite preview.
*/
ONSITE_PREVIEW_ENABLED = 'onsite_preview_enabled',

/**
* Experiment flag to enable the content type article param.
*/
CONTENT_TYPE_ARTICLE_PARAM_ENABLED = 'content_type_article_param_enabled'
}
Loading