diff --git a/components/x-gift-article/src/GiftArticle.jsx b/components/x-gift-article/src/GiftArticle.jsx
index 08ded5b38..9c47d4ba2 100644
--- a/components/x-gift-article/src/GiftArticle.jsx
+++ b/components/x-gift-article/src/GiftArticle.jsx
@@ -145,11 +145,22 @@ const withGiftFormActions = withActions(
const { giftCredits, monthlyAllowance, nextRenewalDate } = await api.getGiftArticleAllowance()
const { enabled, limit, hasCredits, firstTimeUser, requestAccess } =
await enterpriseApi.getEnterpriseArticleAllowance()
+ if (enabled) {
+ tracking.initEnterpriseSharing(
+ requestAccess
+ ? 'enterprise-request-access'
+ : !hasCredits
+ ? 'enterprise-no-credits'
+ : 'enterprise-enabled'
+ )
+ } else {
+ tracking.initEnterpriseSharing('enterprise-disabled')
+ }
// avoid to use giftCredits >= 0 because it returns true when null and ""
if (giftCredits > 0 || giftCredits === 0) {
return {
...updaters.setAllowance(giftCredits, monthlyAllowance, nextRenewalDate),
- shareType: enabled ? ShareType.enterprise : ShareType.gift,
+ shareType: enabled && hasCredits ? ShareType.enterprise : ShareType.gift,
enterpriseEnabled: enabled,
enterpriseLimit: limit,
enterpriseHasCredits: hasCredits,
diff --git a/components/x-gift-article/src/Message.jsx b/components/x-gift-article/src/Message.jsx
index e4ee1d5bb..ea93384aa 100644
--- a/components/x-gift-article/src/Message.jsx
+++ b/components/x-gift-article/src/Message.jsx
@@ -100,9 +100,7 @@ export default ({
if (isGiftUrlCreated === true) {
return (
-
- This link can be opened by up to {enterpriseLimit} people and is valid for 90 days
-
+ This link can be opened by up to {enterpriseLimit} people.
)
}
if (enterpriseHasCredits === true) {
@@ -136,6 +134,7 @@ export default ({
href="https://enterprise.ft.com/ft-enterprise-sharing-request-access/?segmentId=c87259e0-7073-3ea8-7f83-b988f05c3f94"
target="_blank"
rel="noreferrer"
+ data-trackable="enterprise-request-access"
className={styles['buttonBaseStyle']}>
Learn more
@@ -153,6 +152,7 @@ export default ({
href="https://enterprise.ft.com/ft-enterprise-sharing-request-access/?segmentId=c87259e0-7073-3ea8-7f83-b988f05c3f94"
target="_blank"
rel="noreferrer"
+ data-trackable="enterprise-out-of-credits"
className={styles['buttonBaseStyle']}
type="button">
Request more credits
diff --git a/components/x-gift-article/src/lib/enterpriseApi.js b/components/x-gift-article/src/lib/enterpriseApi.js
index a6fca28ba..f7dbeadf7 100644
--- a/components/x-gift-article/src/lib/enterpriseApi.js
+++ b/components/x-gift-article/src/lib/enterpriseApi.js
@@ -27,7 +27,10 @@ export default class EnterpriseApiClient {
const url = this.getFetchUrl(path)
const options = Object.assign(
{
- credentials: 'include'
+ credentials: 'include',
+ headers: {
+ 'Content-Type': 'application/json'
+ }
},
additionalOptions
)
@@ -56,7 +59,7 @@ export default class EnterpriseApiClient {
/**
* Retrieves the Enterprise Sharing allowance for an user
- * @returns {EnterpriseSharingAllowance} the Enterprise Sharing allowance for an user
+ * @returns {Promise} the Enterprise Sharing allowance for an user
*/
async getEnterpriseArticleAllowance() {
try {
@@ -81,14 +84,18 @@ export default class EnterpriseApiClient {
/**
* Generates an enterprise sharing redeem link for the contentId
* @param {string} contentId Article ID
- * @returns {string} enterprise sharing redeem link URL
+ * @returns {Promise<{ redeemLimit: number, redemptionUrl: string }>} object with enterprise sharing redeem link URL and limit
*/
async getESUrl(contentId) {
- const json = await this.fetchJson('/v1/shares', { method: 'POST', body: JSON.stringify({ contentId }) })
+ try {
+ const json = await this.fetchJson('/v1/shares', { method: 'POST', body: JSON.stringify({ contentId }) })
- return {
- redemptionUrl: json.url,
- redemptionLimit: json.redeemLimit
+ return {
+ redemptionUrl: json.url,
+ redemptionLimit: json.redeemLimit
+ }
+ } catch (e) {
+ return { redemptionUrl: undefined, redemptionLimit: undefined }
}
}
}
diff --git a/components/x-gift-article/src/lib/tracking.js b/components/x-gift-article/src/lib/tracking.js
index 7e72df219..a1e6a0267 100644
--- a/components/x-gift-article/src/lib/tracking.js
+++ b/components/x-gift-article/src/lib/tracking.js
@@ -21,10 +21,17 @@ module.exports = {
dispatchEvent({
category: 'gift-link',
action: 'create',
- linkType: 'enterpriseSharingLink',
+ linkType: 'enterpriseLink',
link
}),
+ initEnterpriseSharing: (status) =>
+ dispatchEvent({
+ category: 'gift-link',
+ action: 'open',
+ status
+ }),
+
copyLink: (linkType, link) =>
dispatchEvent({
category: 'gift-link',