mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Merge pull request #26140 from overleaf/rh-cio-sub-status
Use analyticsId as primary identifier in customer.io and support best-subscription property GitOrigin-RevId: d412f2edbff2e430d7fe3192b8843ad9ac2c226a
This commit is contained in:
@@ -409,6 +409,15 @@ async function projectListPage(req, res, next) {
|
|||||||
'papers-notification-banner'
|
'papers-notification-banner'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const customerIoEnabled =
|
||||||
|
await SplitTestHandler.promises.hasUserBeenAssignedToVariant(
|
||||||
|
req,
|
||||||
|
userId,
|
||||||
|
'customer-io-trial-conversion',
|
||||||
|
'enabled',
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
res.render('project/list-react', {
|
res.render('project/list-react', {
|
||||||
title: 'your_projects',
|
title: 'your_projects',
|
||||||
usersBestSubscription,
|
usersBestSubscription,
|
||||||
@@ -440,6 +449,7 @@ async function projectListPage(req, res, next) {
|
|||||||
})),
|
})),
|
||||||
hasIndividualPaidSubscription,
|
hasIndividualPaidSubscription,
|
||||||
userRestrictions: Array.from(req.userRestrictions || []),
|
userRestrictions: Array.from(req.userRestrictions || []),
|
||||||
|
customerIoEnabled,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
if(customerIoEnabled && ExposedSettings.cioWriteKey && ExposedSettings.cioSiteId)
|
if(customerIoEnabled && ExposedSettings.cioWriteKey && ExposedSettings.cioSiteId)
|
||||||
script(type="text/javascript", id="cio-loader", nonce=scriptNonce, data-cio-write-key=ExposedSettings.cioWriteKey, data-cio-site-id=ExposedSettings.cioSiteId, data-session-analytics-id=getSessionAnalyticsId(), data-user-id=getLoggedInUserId()).
|
script(type="text/javascript", id="cio-loader", nonce=scriptNonce, data-best-subscription=(usersBestSubscription && usersBestSubscription.type), data-cio-write-key=ExposedSettings.cioWriteKey, data-cio-site-id=ExposedSettings.cioSiteId, data-session-analytics-id=getSessionAnalyticsId(), data-user-id=getLoggedInUserId()).
|
||||||
var cioSettings = document.querySelector('#cio-loader').dataset;
|
var cioSettings = document.querySelector('#cio-loader').dataset;
|
||||||
var analyticsId = cioSettings.sessionAnalyticsId;
|
var analyticsId = cioSettings.sessionAnalyticsId;
|
||||||
var siteId = cioSettings.cioSiteId;
|
var siteId = cioSettings.cioSiteId;
|
||||||
var writeKey = cioSettings.cioWriteKey;
|
var writeKey = cioSettings.cioWriteKey;
|
||||||
var userId = cioSettings.userId;
|
var userId = cioSettings.userId;
|
||||||
|
var usersBestSubscription = cioSettings.bestSubscription
|
||||||
|
|
||||||
|
|
||||||
!function(){var i="cioanalytics", analytics=(window[i]=window[i]||[]);if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.setAttribute('data-global-customerio-analytics-key', i);t.src="https://cdp.customer.io/v1/analytics-js/snippet/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._writeKey=key;analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.15.3";
|
!function(){var i="cioanalytics", analytics=(window[i]=window[i]||[]);if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.setAttribute('data-global-customerio-analytics-key', i);t.src="https://cdp.customer.io/v1/analytics-js/snippet/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._writeKey=key;analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.15.3";
|
||||||
analytics.load(
|
analytics.load(
|
||||||
@@ -21,6 +23,5 @@ if(customerIoEnabled && ExposedSettings.cioWriteKey && ExposedSettings.cioSiteId
|
|||||||
if (analyticsId) {
|
if (analyticsId) {
|
||||||
analytics.setAnonymousId(analyticsId);
|
analytics.setAnonymousId(analyticsId);
|
||||||
};
|
};
|
||||||
// If userId is undefined, identify sends only the anonymousId (aka analyticsId)
|
analytics.identify(analyticsId, {overleafId: userId, 'best-subscription-type': usersBestSubscription });
|
||||||
analytics.identify(userId);
|
|
||||||
}}();
|
}}();
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ describe('ProjectListController', function () {
|
|||||||
ctx.SplitTestHandler = {
|
ctx.SplitTestHandler = {
|
||||||
promises: {
|
promises: {
|
||||||
getAssignment: sinon.stub().resolves({ variant: 'default' }),
|
getAssignment: sinon.stub().resolves({ variant: 'default' }),
|
||||||
|
hasUserBeenAssignedToVariant: sinon.stub().resolves(false),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ctx.SplitTestSessionHandler = {
|
ctx.SplitTestSessionHandler = {
|
||||||
|
|||||||
Reference in New Issue
Block a user