Skip to content

Commit

Permalink
Tracking querystring is added to non-gift urls
Browse files Browse the repository at this point in the history
  • Loading branch information
benbarnett committed Oct 30, 2018
1 parent fa8035f commit 5e3d407
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion __tests__/__snapshots__/snapshots.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ exports[`@financial-times/x-gift-article renders a default Free article x-gift-a
>
<a
className="o-buttons o-buttons--primary o-buttons--big"
href="mailto:?subject=Title%20Title%20Title%20Title&body=https%3A%2F%2Fwww.ft.com%2Fcontent%2Fblahblahblah"
href="mailto:?subject=Title%20Title%20Title%20Title&body=https%3A%2F%2Fwww.ft.com%2Fcontent%2Fblahblahblah%3FshareType%3Dnongift"
onClick={[Function]}
rel="noopener noreferrer"
target="_blank"
Expand Down
13 changes: 6 additions & 7 deletions components/x-gift-article/src/GiftArticle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ import api from './lib/api';
import { copyToClipboard } from './lib/share-link-actions';
import tracking from './lib/tracking';

const withGiftFormActions = withActions(({ articleId, articleUrl, sessionId, composer }) => ({
const withGiftFormActions = withActions(({ articleId, sessionId, composer }) => ({
showGiftUrlSection() {
return composer.showGiftUrlSection();
},

async showNonGiftUrlSection() {
if (composer.isNonGiftUrlShortened) {
return composer.showNonGiftUrlSection();
} else {
const { url, isShortened } = await api.getShorterUrl(articleUrl);
if (!composer.isNonGiftUrlShortened) {
const { url, isShortened } = await api.getShorterUrl(composer.urls.nonGift);
if (isShortened) {
composer.setShortenedNonGiftUrl(url);
}
return composer.showNonGiftUrlSection();
}

return composer.showNonGiftUrlSection();
},

async createGiftUrl() {
Expand All @@ -49,7 +48,7 @@ const withGiftFormActions = withActions(({ articleId, articleUrl, sessionId, com
},

async getShorterNonGiftUrl() {
const { url, isShortened } = await api.getShorterUrl(articleUrl);
const { url, isShortened } = await api.getShorterUrl(composer.urls.nonGift);

if (isShortened) {
return composer.setShortenedNonGiftUrl(url);
Expand Down
2 changes: 1 addition & 1 deletion components/x-gift-article/src/lib/props-composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class GiftArticlePropsComposer {

this.mailtoUrls = {
gift: undefined,
nonGift: createMailtoUrl(this.articleTitle, this.articleUrl)
nonGift: createMailtoUrl(this.articleTitle, `${this.articleUrl}?shareType=nongift`)
};

this.mobileShareLinks = this.showMobileShareLinks ? {
Expand Down
3 changes: 2 additions & 1 deletion components/x-gift-article/stories/free-article.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const articleUrl = 'https://www.ft.com/content/blahblahblah';
const nonGiftArticleUrl = `${articleUrl}?shareType=nongift`;

exports.title = 'Free article';

Expand Down Expand Up @@ -28,7 +29,7 @@ exports.fetchMock = fetchMock => {
}
)
.get(
`/article/shorten-url/${ encodeURIComponent(articleUrl) }`,
`/article/shorten-url/${ encodeURIComponent(nonGiftArticleUrl) }`,
{ shortenedUrl: 'https://shortened-non-gift-url' }
);
};
3 changes: 2 additions & 1 deletion components/x-gift-article/stories/native-share.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const articleUrl = 'https://www.ft.com/content/blahblahblah';
const articleUrlRedeemed = 'https://gift-url-redeemed';
const nonGiftArticleUrl = `${articleUrl}?shareType=nongift`;

exports.title = 'With native share on App';

Expand Down Expand Up @@ -36,7 +37,7 @@ exports.fetchMock = fetchMock => {
{ shortenedUrl: 'https://shortened-gift-url' }
)
.get(
`/article/shorten-url/${ encodeURIComponent(articleUrl) }`,
`/article/shorten-url/${ encodeURIComponent(nonGiftArticleUrl) }`,
{ shortenedUrl: 'https://shortened-non-gift-url' }
)
.post(
Expand Down
3 changes: 2 additions & 1 deletion components/x-gift-article/stories/with-gift-credits.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const articleUrl = 'https://www.ft.com/content/blahblahblah';
const articleUrlRedeemed = 'https://gift-url-redeemed';
const nonGiftArticleUrl = `${articleUrl}?shareType=nongift`;

exports.title = 'With gift credits';

Expand Down Expand Up @@ -36,7 +37,7 @@ exports.fetchMock = fetchMock => {
{ shortenedUrl: 'https://shortened-gift-url' }
)
.get(
`/article/shorten-url/${ encodeURIComponent(articleUrl) }`,
`/article/shorten-url/${ encodeURIComponent(nonGiftArticleUrl) }`,
{ shortenedUrl: 'https://shortened-non-gift-url' }
)
.post(
Expand Down
3 changes: 2 additions & 1 deletion components/x-gift-article/stories/without-gift-credits.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const articleUrl = 'https://www.ft.com/content/blahblahblah';
const nonGiftArticleUrl = `${articleUrl}?shareType=nongift`;

exports.title = 'Without gift credits';

Expand Down Expand Up @@ -28,7 +29,7 @@ exports.fetchMock = fetchMock => {
}
)
.get(
`/article/shorten-url/${ encodeURIComponent(articleUrl) }`,
`/article/shorten-url/${ encodeURIComponent(nonGiftArticleUrl) }`,
{ shortenedUrl: 'https://shortened-non-gift-url' }
);
};

0 comments on commit 5e3d407

Please sign in to comment.