Skip to content

Commit

Permalink
chore(root): Release 2024-12-25 14:11 (#7381)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Dec 25, 2024
2 parents 5de4b92 + f2a6ba6 commit e6ff18e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
24 changes: 24 additions & 0 deletions apps/dashboard/src/components/auth/questionnaire-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { ROUTES } from '../../utils/routes';
import { useMutation } from '@tanstack/react-query';
import { useOrganization, useUser } from '@clerk/clerk-react';
import { useEnvironment, useFetchEnvironments } from '../../context/environment/hooks';
import { useSegment } from '../../context/segment';
import { useAuth } from '../../context/auth/hooks';

interface QuestionnaireFormData {
jobTitle: JobTitleEnum;
Expand Down Expand Up @@ -241,6 +243,8 @@ export function QuestionnaireForm() {
}

function useSubmitQuestionnaire() {
const { currentUser, currentOrganization } = useAuth();
const segment = useSegment();
const track = useTelemetry();
const navigate = useNavigate();
const { currentEnvironment } = useEnvironment();
Expand Down Expand Up @@ -271,6 +275,26 @@ function useSubmitQuestionnaire() {
companySize: data.companySize,
organizationType: data.organizationType,
});

if (currentUser && currentOrganization) {
segment.identify(currentUser, {
organizationType: data.organizationType,
jobTitle: data.jobTitle,
companySize: data.companySize,
});

segment.group(
{
id: currentOrganization?._id,
name: currentOrganization?.name,
createdAt: currentOrganization?.createdAt,
},
{
organizationType: data.organizationType,
companySize: data.companySize,
}
);
}
},
onSuccess: () => {
navigate(ROUTES.USECASE_SELECT);
Expand Down
15 changes: 14 additions & 1 deletion apps/dashboard/src/utils/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class SegmentService {
}
}

identify(user: IUserEntity) {
identify(user: IUserEntity, extraProperties?: Record<string, unknown>) {
if (!this.isSegmentEnabled()) {
return;
}
Expand All @@ -70,6 +70,19 @@ export class SegmentService {
firstName: user.firstName,
lastName: user.lastName,
avatar: user.profilePicture,
...(extraProperties || {}),
});
}

group(organization: { id: string; name: string; createdAt: string }, extraProperties?: Record<string, unknown>) {
if (!this.isSegmentEnabled()) {
return;
}

this._segment?.group(organization.id, {
name: organization.name,
createdAt: organization.createdAt,
...(extraProperties || {}),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export class SubscriberJobBound {
/**
* Due to Mixpanel HotSharding, we don't want to pass userId for production volume
*/
const segmentUserId = ['test-workflow', 'digest-playground'].includes(command.payload.__source) ? userId : '';
const segmentUserId = ['test-workflow', 'digest-playground', 'dashboard'].includes(command.payload.__source)
? userId
: '';

this.analyticsService.mixpanelTrack('Notification event trigger - [Triggers]', segmentUserId, {
name: template.name,
Expand Down

0 comments on commit e6ff18e

Please sign in to comment.