mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Add an endpoint for rails to record salesforce mappings
GitOrigin-RevId: fcca974a69217dc885c458543a82b4dcc338d98b
This commit is contained in:
parent
24b27e3863
commit
2486f893eb
3 changed files with 42 additions and 0 deletions
|
@ -28,8 +28,30 @@ export function extractAccountMappingsFromSubscription(
|
|||
}
|
||||
return accountMappings
|
||||
}
|
||||
|
||||
export function generateV1Mapping(v1Id, salesforceId, createdAt) {
|
||||
return {
|
||||
source: 'salesforce',
|
||||
sourceEntity: 'account',
|
||||
sourceEntityId: salesforceId,
|
||||
target: 'v1',
|
||||
targetEntity: 'university',
|
||||
targetEntityId: v1Id,
|
||||
createdAt,
|
||||
}
|
||||
}
|
||||
|
||||
function generateSubscriptionToV1Mapping(subscriptionId, v1Id) {
|
||||
return {
|
||||
source: 'v1',
|
||||
sourceEntity: 'university',
|
||||
sourceEntityId: v1Id,
|
||||
target: 'v2',
|
||||
targetEntity: 'subscription',
|
||||
targetEntityId: subscriptionId,
|
||||
createdAt: new Date().toISOString(),
|
||||
}
|
||||
}
|
||||
|
||||
function generateSubscriptionToSalesforceMapping(subscriptionId, salesforceId) {
|
||||
return {
|
||||
|
@ -45,4 +67,5 @@ function generateSubscriptionToSalesforceMapping(subscriptionId, salesforceId) {
|
|||
|
||||
export default {
|
||||
extractAccountMappingsFromSubscription,
|
||||
generateV1Mapping,
|
||||
}
|
||||
|
|
|
@ -4,6 +4,18 @@ import SessionManager from '../Authentication/SessionManager.js'
|
|||
import GeoIpLookup from '../../infrastructure/GeoIpLookup.js'
|
||||
import Features from '../../infrastructure/Features.js'
|
||||
import { expressify } from '@overleaf/promise-utils'
|
||||
import { generateV1Mapping } from './AccountMappingHelper.mjs'
|
||||
|
||||
async function registerSalesforceMapping(req, res, next) {
|
||||
if (!Features.hasFeature('analytics')) {
|
||||
return res.sendStatus(202)
|
||||
}
|
||||
const { createdAt, salesforceId, v1Id } = req.body
|
||||
AnalyticsManager.registerAccountMapping(
|
||||
generateV1Mapping(v1Id, salesforceId, createdAt)
|
||||
)
|
||||
res.sendStatus(202)
|
||||
}
|
||||
|
||||
async function updateEditingSession(req, res, next) {
|
||||
if (!Features.hasFeature('analytics')) {
|
||||
|
@ -47,6 +59,7 @@ function recordEvent(req, res, next) {
|
|||
}
|
||||
|
||||
export default {
|
||||
registerSalesforceMapping: expressify(registerSalesforceMapping),
|
||||
updateEditingSession: expressify(updateEditingSession),
|
||||
recordEvent,
|
||||
}
|
||||
|
|
|
@ -41,5 +41,11 @@ export default {
|
|||
RateLimiterMiddleware.rateLimit(rateLimiters.uniExternalCollabProxy),
|
||||
AnalyticsProxy.call('/uniExternalCollaboration')
|
||||
)
|
||||
|
||||
publicApiRouter.post(
|
||||
'/analytics/register-v-1-salesforce-mapping',
|
||||
AuthenticationController.requirePrivateApiAuth(),
|
||||
AnalyticsController.registerSalesforceMapping
|
||||
)
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue