From 5facec8ed20650bd22722f17e667db09902d8a63 Mon Sep 17 00:00:00 2001
From: Liangjun Song <146005915+adai26@users.noreply.github.com>
Date: Thu, 6 Feb 2025 12:49:56 +0000
Subject: [PATCH] Merge pull request #23238 from
overleaf/ls-analytic-events-for-flexible-licensing
Implement analytic events for flexible licensing
GitOrigin-RevId: 2ac0b471616d6e4f80ade18934d7240618195a8a
---
.../components/add-seats/add-seats.tsx | 55 +++++++++++++++++--
.../components/group-members.tsx | 2 +
.../upgrade-subscription.tsx | 34 ++++++++++--
.../dashboard/group-settings-button.tsx | 4 ++
.../dashboard/states/active/active-new.tsx | 10 +++-
5 files changed, 95 insertions(+), 10 deletions(-)
diff --git a/services/web/frontend/js/features/group-management/components/add-seats/add-seats.tsx b/services/web/frontend/js/features/group-management/components/add-seats/add-seats.tsx
index fc390f1962..e6b1c5ab82 100644
--- a/services/web/frontend/js/features/group-management/components/add-seats/add-seats.tsx
+++ b/services/web/frontend/js/features/group-management/components/add-seats/add-seats.tsx
@@ -28,6 +28,7 @@ import {
SubscriptionChangePreview,
} from '../../../../../../types/subscription/subscription-change-preview'
import { MergeAndOverride } from '../../../../../../types/utils'
+import { sendMB } from '../../../../infrastructure/event-tracking'
export const MAX_NUMBER_OF_USERS = 50
@@ -85,6 +86,17 @@ function AddSeats() {
[runAsyncCostSummary]
)
+ const debouncedTrackUserEnterSeatNumberEvent = useMemo(
+ () =>
+ debounce((value: number) => {
+ sendMB('flex-add-users-form', {
+ action: 'enter-seat-number',
+ seatNumber: value,
+ })
+ }, 500),
+ []
+ )
+
const validateSeats = async (value: string | undefined) => {
try {
await addSeatsValidationSchema.validate(value)
@@ -109,6 +121,7 @@ function AddSeats() {
if (isValidSeatsNumber) {
const seats = Number(value)
+ debouncedTrackUserEnterSeatNumberEvent(seats)
if (seats > MAX_NUMBER_OF_USERS) {
debouncedCostSummaryRequest.cancel()
@@ -117,6 +130,7 @@ function AddSeats() {
debouncedCostSummaryRequest(seats, controller.signal)
}
} else {
+ debouncedTrackUserEnterSeatNumberEvent.cancel()
debouncedCostSummaryRequest.cancel()
}
@@ -138,6 +152,9 @@ function AddSeats() {
}
if (shouldContactSales) {
+ sendMB('flex-add-users-form', {
+ action: 'click-send-request-button',
+ })
const post = postJSON(
'/user/subscription/group/add-users/sales-contact-form',
{
@@ -149,11 +166,21 @@ function AddSeats() {
)
runAsyncSendMailToSales(post).catch(debugConsole.error)
} else {
+ sendMB('flex-add-users-form', {
+ action: 'click-add-user-button',
+ })
const post = postJSON('/user/subscription/group/add-users/create', {
signal: addSeatsSignal,
body: { adding: Number(rawSeats) },
})
- runAsyncAddSeats(post).catch(debugConsole.error)
+ runAsyncAddSeats(post)
+ .then(() => {
+ sendMB('flex-add-users-success')
+ })
+ .catch(() => {
+ debugConsole.error()
+ sendMB('flex-add-users-error')
+ })
}
}
@@ -259,8 +286,17 @@ function AddSeats() {
@@ -313,11 +349,22 @@ function AddSeats() {
href="/user/subscription/group/upgrade-subscription"
rel="noreferrer noopener"
className="me-auto"
+ onClick={() => {
+ sendMB('flex-upgrade')
+ }}
>
{t('upgrade_my_plan')}
)}
-