mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #32376 from overleaf/rh-cio-migrate-identifiers
Replace analytics id with user id as main identifier in customer.io GitOrigin-RevId: 780671a51b652c73a940bc152d8fd6916dd611ce
This commit is contained in:
@@ -6,7 +6,6 @@ import Settings from '@overleaf/settings'
|
||||
import AuthenticationController from '../Authentication/AuthenticationController.mjs'
|
||||
import SessionManager from '../Authentication/SessionManager.mjs'
|
||||
import SubscriptionLocator from '../Subscription/SubscriptionLocator.mjs'
|
||||
import UserAnalyticsIdCache from '../Analytics/UserAnalyticsIdCache.mjs'
|
||||
import _ from 'lodash'
|
||||
import { expressify } from '@overleaf/promise-utils'
|
||||
import Features from '../../infrastructure/Features.mjs'
|
||||
@@ -217,14 +216,15 @@ async function emailPreferencesPage(req, res) {
|
||||
|
||||
let subscribed = false
|
||||
|
||||
const analyticsId = await UserAnalyticsIdCache.get(userId)
|
||||
if (analyticsId) {
|
||||
try {
|
||||
const [preferences] = await Modules.promises.hooks.fire(
|
||||
'getSubscriptionPreferences',
|
||||
analyticsId
|
||||
userId
|
||||
)
|
||||
|
||||
subscribed = Boolean(preferences?.newsletter)
|
||||
} catch (err) {
|
||||
logger.error({ err, userId }, 'Error fetching newsletter subscription')
|
||||
}
|
||||
|
||||
res.render('user/email-preferences', {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
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()).
|
||||
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=((user && user._id) || '')).
|
||||
var cioSettings = document.querySelector('#cio-loader').dataset;
|
||||
var analyticsId = cioSettings.sessionAnalyticsId;
|
||||
var userId = cioSettings.userId;
|
||||
var siteId = cioSettings.cioSiteId;
|
||||
var writeKey = cioSettings.cioWriteKey;
|
||||
|
||||
@@ -19,6 +20,8 @@ if(customerIoEnabled && ExposedSettings.cioWriteKey && ExposedSettings.cioSiteId
|
||||
);
|
||||
if (analyticsId) {
|
||||
analytics.setAnonymousId(analyticsId);
|
||||
analytics.identify(analyticsId);
|
||||
}
|
||||
if (userId) {
|
||||
analytics.identify(userId);
|
||||
};
|
||||
}}();
|
||||
|
||||
Reference in New Issue
Block a user