mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #28378 from overleaf/oa-expose-last-active
[web] Expose lastActive to customer.io GitOrigin-RevId: 5a0f3b43a6c8288e7e5f7b1de05b409a2d3ac86a
This commit is contained in:
@@ -157,7 +157,7 @@ async function projectListPage(req, res, next) {
|
||||
})
|
||||
const user = await User.findById(
|
||||
userId,
|
||||
`email emails features alphaProgram betaProgram lastPrimaryEmailCheck signUpDate refProviders${
|
||||
`email emails features alphaProgram betaProgram lastPrimaryEmailCheck lastActive signUpDate refProviders${
|
||||
isSaas ? ' enrollment writefull completedTutorials aiErrorAssistant' : ''
|
||||
}`
|
||||
)
|
||||
@@ -533,6 +533,7 @@ async function projectListPage(req, res, next) {
|
||||
customerIoEnabled,
|
||||
aiBlocked,
|
||||
hasAiAssist,
|
||||
lastActive: user.lastActive,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ if(customerIoEnabled && ExposedSettings.cioWriteKey && ExposedSettings.cioSiteId
|
||||
function boolAttr(value) {
|
||||
return value !== undefined ? String(value) : null;
|
||||
}
|
||||
script(type="text/javascript", id="cio-loader", nonce=scriptNonce, data-best-subscription=(usersBestSubscription && usersBestSubscription.type), data-ai-blocked=boolAttr(aiBlocked), data-has-ai-assist=boolAttr(hasAiAssist), 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-ai-blocked=boolAttr(aiBlocked), data-has-ai-assist=boolAttr(hasAiAssist), data-cio-write-key=ExposedSettings.cioWriteKey, data-cio-site-id=ExposedSettings.cioSiteId, data-session-analytics-id=getSessionAnalyticsId(), data-user-id=getLoggedInUserId(), data-last-active=lastActive).
|
||||
|
||||
function parseBool(value) {
|
||||
return value === 'true' ? true : value === 'false' ? false : undefined;
|
||||
@@ -17,6 +17,7 @@ if(customerIoEnabled && ExposedSettings.cioWriteKey && ExposedSettings.cioSiteId
|
||||
var usersBestSubscription = cioSettings.bestSubscription;
|
||||
var aiBlocked = parseBool(cioSettings.aiBlocked);
|
||||
var hasAiAssist = parseBool(cioSettings.hasAiAssist);
|
||||
var lastActive = cioSettings.lastActive;
|
||||
|
||||
|
||||
!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";
|
||||
@@ -39,7 +40,7 @@ if(customerIoEnabled && ExposedSettings.cioWriteKey && ExposedSettings.cioSiteId
|
||||
if (typeof value !== 'undefined') obj[key] = value;
|
||||
}
|
||||
|
||||
var identifyData = {overleafId: userId};
|
||||
var identifyData = {overleafId: userId, lastActive};
|
||||
addIfDefined(identifyData, 'best-subscription-type', usersBestSubscription);
|
||||
addIfDefined(identifyData, 'aiBlocked', aiBlocked);
|
||||
addIfDefined(identifyData, 'hasAiAssist', hasAiAssist);
|
||||
|
||||
@@ -20,6 +20,7 @@ describe('ProjectListController', function () {
|
||||
first_name: 'bjkdsjfk',
|
||||
features: {},
|
||||
emails: [{ email: 'test@overleaf.com' }],
|
||||
lastActive: new Date(1),
|
||||
lastLoginIp: '111.111.111.112',
|
||||
}
|
||||
ctx.users = {
|
||||
|
||||
Reference in New Issue
Block a user