Skip to content

Commit

Permalink
feat: santize identity payload and pass source to identity and group …
Browse files Browse the repository at this point in the history
…calls (SigNoz#3804)
  • Loading branch information
YounixM authored Oct 25, 2023
1 parent 9bad663 commit 6a8096b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions frontend/src/AppRoutes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import useLicense, { LICENSE_PLAN_KEY } from 'hooks/useLicense';
import { NotificationProvider } from 'hooks/useNotifications';
import { ResourceProvider } from 'hooks/useResourceAttribute';
import history from 'lib/history';
import { identity, pickBy } from 'lodash-es';
import { DashboardProvider } from 'providers/Dashboard/Dashboard';
import { QueryBuilderProvider } from 'providers/QueryBuilder';
import { Suspense, useEffect, useState } from 'react';
Expand Down Expand Up @@ -90,13 +91,19 @@ function App(): JSX.Element {
const orgName =
org && Array.isArray(org) && org.length > 0 ? org[0].name : '';

const { name, email } = user;

const identifyPayload = {
email: user?.email,
name: user?.name,
email,
name,
company_name: orgName,
role,
source: 'signoz-ui',
};
const domain = extractDomain(user?.email);

const sanitizedIdentifyPayload = pickBy(identifyPayload, identity);

const domain = extractDomain(email);

const hostNameParts = hostname.split('.');

Expand All @@ -106,13 +113,14 @@ function App(): JSX.Element {
data_region: hostNameParts[1],
tenant_url: hostname,
company_domain: domain,
source: 'signoz-ui',
};

window.analytics.identify(user?.email, identifyPayload);
window.analytics.identify(email, sanitizedIdentifyPayload);

window.analytics.group(domain, groupTraits);

window.clarity('identify', user.email, user.name);
window.clarity('identify', email, name);
};

useEffect(() => {
Expand Down

0 comments on commit 6a8096b

Please sign in to comment.