Skip to content

Commit

Permalink
Merge pull request #9717 from bbc/optimo-contentId
Browse files Browse the repository at this point in the history
 Update ATI Optimo contentId logic after Ares change
  • Loading branch information
rebeccamcginn committed Dec 3, 2021
2 parents 17709b7 + b93bdb9 commit 9776ad5
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 20 deletions.
4 changes: 3 additions & 1 deletion data/news/articles/c5jje4ejkqvo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"metadata": {
"analyticsLabels": {},
"analyticsLabels": {
"contentId": "urn:bbc:optimo:asset:c5jje4ejkqvo"
},
"blockTypes": [
"headline",
"text",
Expand Down
3 changes: 3 additions & 0 deletions data/persian/articles/c4vlle3q337o.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"locators": {
"optimoUrn": "urn:bbc:optimo:asset:c4vlle3q337o"
},
"analyticsLabels": {
"contentId": "urn:bbc:optimo:asset:c4vlle3q337o"
},
"type": "article",
"createdBy": "",
"created": 1535122662000,
Expand Down
4 changes: 3 additions & 1 deletion data/scotland/articles/czwj5l0n210o.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"firstPublished": 1568378189124,
"lastPublished": 1568378189124,
"options": {},
"analyticsLabels": {},
"analyticsLabels": {
"contentId": "urn:bbc:optimo:asset:czwj5l0n210o"
},
"passport": {
"language": "en-gb",
"home": "http://www.bbc.co.uk/ontologies/passport/home/BBCScotland"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const serviceContext = {

const validURLParams = {
appName: serviceContext.atiAnalyticsAppName,
contentId: 'urn:bbc:optimo://www.bbc.co.uk',
contentId: 'urn:bbc:optimo:asset://www.bbc.co.uk',
contentType: 'article',
language: 'language',
ldpThingIds: 'thing+id+1~thing+id+2',
Expand All @@ -42,6 +42,7 @@ const article = {
metadata: {
analyticsLabels: {
counterName: 'service.page',
contentId: 'urn:bbc:optimo:asset://www.bbc.co.uk',
},
locators: {
optimoUrn: 'http://www.bbc.co.uk',
Expand Down Expand Up @@ -96,7 +97,7 @@ describe('buildParams', () => {
serviceContext,
);
expect(result).toMatchInlineSnapshot(
`"s=598285&s2=atiAnalyticsProducerId&p=service.articles.%2F%2Fwww.bbc.co.uk.page&r=0x0x24x24&re=1024x768&hl=00-00-00&lng=en-US&x1=[urn%3Abbc%3Aoptimo%3A%2F%2Fwww.bbc.co.uk]&x2=[responsive]&x3=[atiAnalyticsAppName]&x4=[language]&x5=[http%253A%252F%252Flocalhost%252F]&x6=[originpreviousPath]&x7=[article]&x8=[simorgh]&x9=[pageTitle]&x11=[1970-01-01T00%3A00%3A00.000Z]&x12=[1970-01-01T00%3A00%3A00.000Z]&x13=[thing%2Benglish%2Blabel%2B1~thing%2Benglish%2Blabel%2B2]&x14=[thing%2Bid%2B1~thing%2Bid%2B2]&ref=originpreviousPath"`,
`"s=598285&s2=atiAnalyticsProducerId&p=service.articles.%2F%2Fwww.bbc.co.uk.page&r=0x0x24x24&re=1024x768&hl=00-00-00&lng=en-US&x1=[urn%3Abbc%3Aoptimo%3Aasset%3A%2F%2Fwww.bbc.co.uk]&x2=[responsive]&x3=[atiAnalyticsAppName]&x4=[language]&x5=[http%253A%252F%252Flocalhost%252F]&x6=[originpreviousPath]&x7=[article]&x8=[simorgh]&x9=[pageTitle]&x11=[1970-01-01T00%3A00%3A00.000Z]&x12=[1970-01-01T00%3A00%3A00.000Z]&x13=[thing%2Benglish%2Blabel%2B1~thing%2Benglish%2Blabel%2B2]&x14=[thing%2Bid%2B1~thing%2Bid%2B2]&ref=originpreviousPath"`,
);
});
});
Expand Down
5 changes: 3 additions & 2 deletions src/app/containers/ATIAnalytics/params/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const article = {
metadata: {
analyticsLabels: {
counterName: 'service.page',
contentId: 'urn:bbc:optimo:asset:54321',
},
locators: {
optimoUrn: 'http://www.bbc.co.uk',
Expand Down Expand Up @@ -164,7 +165,7 @@ describe('ATIAnalytics params', () => {
serviceContext,
);
expect(url).toMatchInlineSnapshot(
`"s=598285&s2=atiAnalyticsProducerId&p=service.articles.%2F%2Fwww.bbc.co.uk.page&r=0x0x24x24&re=1024x768&hl=00-00-00&lng=en-US&x1=[urn%3Abbc%3Aoptimo%3A%2F%2Fwww.bbc.co.uk]&x2=[responsive]&x3=[atiAnalyticsAppName]&x4=[language]&x5=[http%253A%252F%252Flocalhost%252F]&x6=[originhttp%253A%252F%252Fwww.example.com]&x7=[article]&x8=[simorgh]&x9=[pageTitle]&x11=[1970-01-01T00%3A00%3A00.000Z]&x12=[1970-01-01T00%3A00%3A00.000Z]&x13=[thing%2Benglish%2Blabel%2B1~thing%2Benglish%2Blabel%2B2]&x14=[thing%2Bid%2B1~thing%2Bid%2B2]&ref=originhttp://www.example.com"`,
`"s=598285&s2=atiAnalyticsProducerId&p=service.articles.%2F%2Fwww.bbc.co.uk.page&r=0x0x24x24&re=1024x768&hl=00-00-00&lng=en-US&x1=[urn%3Abbc%3Aoptimo%3Aasset%3A54321]&x2=[responsive]&x3=[atiAnalyticsAppName]&x4=[language]&x5=[http%253A%252F%252Flocalhost%252F]&x6=[originhttp%253A%252F%252Fwww.example.com]&x7=[article]&x8=[simorgh]&x9=[pageTitle]&x11=[1970-01-01T00%3A00%3A00.000Z]&x12=[1970-01-01T00%3A00%3A00.000Z]&x13=[thing%2Benglish%2Blabel%2B1~thing%2Benglish%2Blabel%2B2]&x14=[thing%2Bid%2B1~thing%2Bid%2B2]&ref=originhttp://www.example.com"`,
);
});

Expand Down Expand Up @@ -268,7 +269,7 @@ describe('ATIAnalytics params', () => {
);
expect(params).toEqual({
appName: 'atiAnalyticsAppName',
contentId: 'urn:bbc:optimo://www.bbc.co.uk',
contentId: 'urn:bbc:optimo:asset:54321',
contentType: 'article',
isUK: 'isUK',
language: 'language',
Expand Down
13 changes: 5 additions & 8 deletions src/app/lib/analyticsUtils/article/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import pathOr from 'ramda/src/pathOr';
const getOptimoUrn = articleData =>
pathOr(null, ['metadata', 'locators', 'optimoUrn'], articleData);

export const getContentId = articleData => {
const optimoUrn = getOptimoUrn(articleData);
const id = optimoUrn ? optimoUrn.split(':').pop() : null;
if (!id) {
return null;
}
return `urn:bbc:optimo:${id}`;
};
export const getContentId = pathOr(null, [
'metadata',
'analyticsLabels',
'contentId',
]);

export const getOptimoId = articleData => {
const optimoUrn = getOptimoUrn(articleData);
Expand Down
6 changes: 3 additions & 3 deletions src/app/lib/analyticsUtils/article/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ describe('getContentId', () => {
it('should find value in good data', () => {
const goodData = {
metadata: {
locators: {
optimoUrn: 'urn:bbc:optimo:asset:c0g992jmmkko',
analyticsLabels: {
contentId: 'urn:bbc:optimo:asset:c0g992jmmkko',
},
},
};

const contentId = getContentId(goodData);

expect(contentId).toEqual('urn:bbc:optimo:c0g992jmmkko');
expect(contentId).toEqual('urn:bbc:optimo:asset:c0g992jmmkko');
});

it('should return null in bad data', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/app/pages/ArticlePage/fixtureData.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const articleDataBuilder = (
locators: {
optimoUrn: `urn:bbc:optimo:asset:${id}`,
},
analyticsLabels: {
contentId: 'urn:bbc:optimo:c0000000001o',
},
type: 'article',
createdBy,
created: 1514808060000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`Canonical Articles A11y I can see the skip to content link 1`] = `"Skip to content"`;

exports[`Canonical Articles Analytics ATI 1`] = `"<img height=\\"1px\\" width=\\"1px\\" alt=\\"\\" style=\\"position:absolute\\" src=\\"https://logws1363.ati-host.net?s=598286&amp;s2=64&amp;p=news.articles.c5jje4ejkqvo.page&amp;x1=[urn%3Abbc%3Aoptimo%3Ac5jje4ejkqvo]&amp;x2=[responsive]&amp;x3=[news]&amp;x4=[en-gb]&amp;x7=[article]&amp;x8=[simorgh-nojs]&amp;x9=[The%2BGermans%2Bsolving%2Brising%2Brents%2Bwith%2Bpeople%2Bpower]&amp;x11=[2019-03-27T16%3A13%3A36.863Z]&amp;x12=[2019-03-27T16%3A20%3A33.751Z]\\"/>"`;
exports[`Canonical Articles Analytics ATI 1`] = `"<img height=\\"1px\\" width=\\"1px\\" alt=\\"\\" style=\\"position:absolute\\" src=\\"https://logws1363.ati-host.net?s=598286&amp;s2=64&amp;p=news.articles.c5jje4ejkqvo.page&amp;x1=[urn%3Abbc%3Aoptimo%3Aasset%3Ac5jje4ejkqvo]&amp;x2=[responsive]&amp;x3=[news]&amp;x4=[en-gb]&amp;x7=[article]&amp;x8=[simorgh-nojs]&amp;x9=[The%2BGermans%2Bsolving%2Brising%2Brents%2Bwith%2Bpeople%2Bpower]&amp;x11=[2019-03-27T16%3A13%3A36.863Z]&amp;x12=[2019-03-27T16%3A20%3A33.751Z]\\"/>"`;
exports[`Canonical Articles Footer Anchors should match text and url 1`] = `
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`Canonical Articles A11y I can see the skip to content link 1`] = `"مشاهده محتوا"`;

exports[`Canonical Articles Analytics ATI 1`] = `"<img height=\\"1px\\" width=\\"1px\\" alt=\\"\\" style=\\"position:absolute\\" src=\\"https://logws1363.ati-host.net?s=598343&amp;s2=69&amp;p=persian.articles.c4vlle3q337o.page&amp;x1=[urn%3Abbc%3Aoptimo%3Ac4vlle3q337o]&amp;x2=[responsive]&amp;x3=[news-persian]&amp;x4=[fa]&amp;x7=[article]&amp;x8=[simorgh-nojs]&amp;x9=[%D9%BE%D9%87%D9%BE%D8%A7%D8%AF%DB%8C%2B%DA%A9%D9%87%2B%D8%A8%D8%B1%D8%A7%DB%8C%D8%AA%D8%A7%D9%86%2B%D9%82%D9%87%D9%88%D9%87%2B%D9%85%DB%8C%E2%80%8C%D8%A2%D9%88%D8%B1%D8%AF]&amp;x11=[2018-08-24T14%3A57%3A42.000Z]&amp;x12=[2018-08-24T14%3A57%3A42.000Z]&amp;x13=[Drones]&amp;x14=[c6176220-b6bb-4a1c-b3b4-3a6fcdc283b1]\\"/>"`;
exports[`Canonical Articles Analytics ATI 1`] = `"<img height=\\"1px\\" width=\\"1px\\" alt=\\"\\" style=\\"position:absolute\\" src=\\"https://logws1363.ati-host.net?s=598343&amp;s2=69&amp;p=persian.articles.c4vlle3q337o.page&amp;x1=[urn%3Abbc%3Aoptimo%3Aasset%3Ac4vlle3q337o]&amp;x2=[responsive]&amp;x3=[news-persian]&amp;x4=[fa]&amp;x7=[article]&amp;x8=[simorgh-nojs]&amp;x9=[%D9%BE%D9%87%D9%BE%D8%A7%D8%AF%DB%8C%2B%DA%A9%D9%87%2B%D8%A8%D8%B1%D8%A7%DB%8C%D8%AA%D8%A7%D9%86%2B%D9%82%D9%87%D9%88%D9%87%2B%D9%85%DB%8C%E2%80%8C%D8%A2%D9%88%D8%B1%D8%AF]&amp;x11=[2018-08-24T14%3A57%3A42.000Z]&amp;x12=[2018-08-24T14%3A57%3A42.000Z]&amp;x13=[Drones]&amp;x14=[c6176220-b6bb-4a1c-b3b4-3a6fcdc283b1]\\"/>"`;
exports[`Canonical Articles Footer Anchors should match text and url 1`] = `
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`Canonical Articles A11y I can see the skip to content link 1`] = `"Skip to content"`;

exports[`Canonical Articles Analytics ATI 1`] = `"<img height=\\"1px\\" width=\\"1px\\" alt=\\"\\" style=\\"position:absolute\\" src=\\"https://logws1363.ati-host.net?s=598274&amp;s2=79&amp;p=scotland.articles.czwj5l0n210o.page&amp;x1=[urn%3Abbc%3Aoptimo%3Aczwj5l0n210o]&amp;x2=[responsive]&amp;x3=[scotland]&amp;x4=[en-gb]&amp;x7=[article]&amp;x8=[simorgh-nojs]&amp;x9=[This%2Bis%2Bthe%2BSEO%2Bheadline%2Bof%2Bthis%2Btest%2Barticle]&amp;x11=[2019-09-13T12%3A36%3A29.124Z]&amp;x12=[2019-09-13T12%3A36%3A29.124Z]\\"/>"`;
exports[`Canonical Articles Analytics ATI 1`] = `"<img height=\\"1px\\" width=\\"1px\\" alt=\\"\\" style=\\"position:absolute\\" src=\\"https://logws1363.ati-host.net?s=598274&amp;s2=79&amp;p=scotland.articles.czwj5l0n210o.page&amp;x1=[urn%3Abbc%3Aoptimo%3Aasset%3Aczwj5l0n210o]&amp;x2=[responsive]&amp;x3=[scotland]&amp;x4=[en-gb]&amp;x7=[article]&amp;x8=[simorgh-nojs]&amp;x9=[This%2Bis%2Bthe%2BSEO%2Bheadline%2Bof%2Bthis%2Btest%2Barticle]&amp;x11=[2019-09-13T12%3A36%3A29.124Z]&amp;x12=[2019-09-13T12%3A36%3A29.124Z]\\"/>"`;
exports[`Canonical Articles Footer Anchors should match text and url 1`] = `
Object {
Expand Down

0 comments on commit 9776ad5

Please sign in to comment.