Compare commits
5 Commits
v0.76.0-ca
...
v0.76.0-cl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
256fbfc180 | ||
|
|
d362f5bce3 | ||
|
|
42f7511e06 | ||
|
|
819428ad09 | ||
|
|
29fa5c3cf0 |
@@ -1,13 +1,13 @@
|
||||
import { ConfigProvider } from 'antd';
|
||||
import getLocalStorageApi from 'api/browser/localstorage/get';
|
||||
import setLocalStorageApi from 'api/browser/localstorage/set';
|
||||
import logEvent from 'api/common/logEvent';
|
||||
import NotFound from 'components/NotFound';
|
||||
import Spinner from 'components/Spinner';
|
||||
import { FeatureKeys } from 'constants/features';
|
||||
import { LOCALSTORAGE } from 'constants/localStorage';
|
||||
import ROUTES from 'constants/routes';
|
||||
import AppLayout from 'container/AppLayout';
|
||||
import useAnalytics from 'hooks/analytics/useAnalytics';
|
||||
import { KeyboardHotkeysProvider } from 'hooks/hotkeys/useKeyboardHotkeys';
|
||||
import { useThemeConfig } from 'hooks/useDarkMode';
|
||||
import { useGetTenantLicense } from 'hooks/useGetTenantLicense';
|
||||
@@ -15,7 +15,6 @@ import { 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 posthog from 'posthog-js';
|
||||
import AlertRuleProvider from 'providers/Alert';
|
||||
import { useAppContext } from 'providers/App/App';
|
||||
@@ -51,8 +50,6 @@ function App(): JSX.Element {
|
||||
} = useAppContext();
|
||||
const [routes, setRoutes] = useState<AppRoutes[]>(defaultRoutes);
|
||||
|
||||
const { trackPageView } = useAnalytics();
|
||||
|
||||
const { hostname, pathname } = window.location;
|
||||
|
||||
const {
|
||||
@@ -69,18 +66,21 @@ function App(): JSX.Element {
|
||||
|
||||
const { name, email, role } = user;
|
||||
|
||||
const domain = extractDomain(email);
|
||||
const hostNameParts = hostname.split('.');
|
||||
|
||||
const identifyPayload = {
|
||||
email,
|
||||
name,
|
||||
company_name: orgName,
|
||||
role,
|
||||
tenant_id: hostNameParts[0],
|
||||
data_region: hostNameParts[1],
|
||||
tenant_url: hostname,
|
||||
company_domain: domain,
|
||||
source: 'signoz-ui',
|
||||
role,
|
||||
};
|
||||
|
||||
const sanitizedIdentifyPayload = pickBy(identifyPayload, identity);
|
||||
const domain = extractDomain(email);
|
||||
const hostNameParts = hostname.split('.');
|
||||
|
||||
const groupTraits = {
|
||||
name: orgName,
|
||||
tenant_id: hostNameParts[0],
|
||||
@@ -90,8 +90,13 @@ function App(): JSX.Element {
|
||||
source: 'signoz-ui',
|
||||
};
|
||||
|
||||
window.analytics.identify(email, sanitizedIdentifyPayload);
|
||||
window.analytics.group(domain, groupTraits);
|
||||
if (email) {
|
||||
logEvent('Email Identified', identifyPayload, 'identify');
|
||||
}
|
||||
|
||||
if (domain) {
|
||||
logEvent('Domain Identified', groupTraits, 'group');
|
||||
}
|
||||
|
||||
posthog?.identify(email, {
|
||||
email,
|
||||
@@ -192,9 +197,7 @@ function App(): JSX.Element {
|
||||
hide_default_launcher: false,
|
||||
});
|
||||
}
|
||||
|
||||
trackPageView(pathname);
|
||||
}, [pathname, trackPageView]);
|
||||
}, [pathname]);
|
||||
|
||||
useEffect(() => {
|
||||
// feature flag shouldn't be loading and featureFlags or fetchError any one of this should be true indicating that req is complete
|
||||
|
||||
@@ -7,11 +7,15 @@ import { EventSuccessPayloadProps } from 'types/api/events/types';
|
||||
const logEvent = async (
|
||||
eventName: string,
|
||||
attributes: Record<string, unknown>,
|
||||
eventType?: 'track' | 'group' | 'identify',
|
||||
rateLimited?: boolean,
|
||||
): Promise<SuccessResponse<EventSuccessPayloadProps> | ErrorResponse> => {
|
||||
try {
|
||||
const response = await axios.post('/event', {
|
||||
eventName,
|
||||
attributes,
|
||||
eventType: eventType || 'track',
|
||||
rateLimited: rateLimited || false, // TODO: Update this once we have a proper way to handle rate limiting
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@@ -392,11 +392,16 @@ function AppLayout(props: AppLayoutProps): JSX.Element {
|
||||
LOCALSTORAGE.DONT_SHOW_SLOW_API_WARNING,
|
||||
);
|
||||
|
||||
logEvent(`Slow API Warning`, {
|
||||
duration: `${data.duration}ms`,
|
||||
url: data.url,
|
||||
threshold: data.threshold,
|
||||
});
|
||||
logEvent(
|
||||
`Slow API Warning`,
|
||||
{
|
||||
durationMs: data.duration,
|
||||
url: data.url,
|
||||
thresholdMs: data.threshold,
|
||||
},
|
||||
'track',
|
||||
true, // rate limited - controlled by Backend
|
||||
);
|
||||
|
||||
const isDontShowSlowApiWarning = dontShowSlowApiWarning === 'true';
|
||||
|
||||
|
||||
@@ -19,10 +19,6 @@ jest.mock('hooks/useNotifications', () => ({
|
||||
})),
|
||||
}));
|
||||
|
||||
window.analytics = {
|
||||
track: jest.fn(),
|
||||
};
|
||||
|
||||
describe('Onboarding invite team member flow', () => {
|
||||
it('initial render and get started page', async () => {
|
||||
const { findByText } = render(
|
||||
|
||||
@@ -38,7 +38,7 @@ const useSampleLogs = ({
|
||||
filters: filter || initialFilters,
|
||||
aggregateOperator: LogsAggregatorOperator.NOOP,
|
||||
orderBy: [{ columnName: 'timestamp', order: 'desc' }],
|
||||
limit: count || DEFAULT_SAMPLE_LOGS_COUNT,
|
||||
pageSize: count || DEFAULT_SAMPLE_LOGS_COUNT,
|
||||
};
|
||||
return q;
|
||||
}, [count, filter]);
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
import { useAppContext } from 'providers/App/App';
|
||||
import { useCallback } from 'react';
|
||||
import { extractDomain } from 'utils/app';
|
||||
|
||||
const useAnalytics = (): any => {
|
||||
const { user } = useAppContext();
|
||||
|
||||
// Segment Page View - analytics.page([category], [name], [properties], [options], [callback]);
|
||||
const trackPageView = useCallback(
|
||||
(pageName: string): void => {
|
||||
if (user && user.email) {
|
||||
window.analytics.page(null, pageName, {
|
||||
userId: user.email,
|
||||
});
|
||||
}
|
||||
},
|
||||
[user],
|
||||
);
|
||||
|
||||
const trackEvent = (
|
||||
eventName: string,
|
||||
properties?: Record<string, unknown>,
|
||||
): void => {
|
||||
if (user && user.email) {
|
||||
const context = {
|
||||
context: {
|
||||
groupId: extractDomain(user?.email),
|
||||
},
|
||||
};
|
||||
|
||||
const updatedProperties = { ...properties };
|
||||
updatedProperties.userId = user.email;
|
||||
window.analytics.track(eventName, properties, context);
|
||||
}
|
||||
};
|
||||
|
||||
return { trackPageView, trackEvent };
|
||||
};
|
||||
|
||||
export default useAnalytics;
|
||||
@@ -49,12 +49,10 @@
|
||||
/>
|
||||
<meta data-react-helmet="true" name="docusaurus_locale" content="en" />
|
||||
<meta data-react-helmet="true" name="docusaurus_tag" content="default" />
|
||||
<meta name="robots" content="noindex">
|
||||
<meta name="robots" content="noindex" />
|
||||
<link data-react-helmet="true" rel="shortcut icon" href="/favicon.ico" />
|
||||
|
||||
<link rel="stylesheet" href="/css/uPlot.min.css" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
@@ -100,32 +98,16 @@
|
||||
</script>
|
||||
<script>
|
||||
const CUSTOMERIO_ID = '<%= htmlWebpackPlugin.options.CUSTOMERIO_ID %>';
|
||||
const CUSTOMERIO_SITE_ID = '<%= htmlWebpackPlugin.options.CUSTOMERIO_SITE_ID %>';
|
||||
!function(){var i="cioanalytics", analytics=(window[i]=window[i]||[]);if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.setAttribute('data-global-customerio-analytics-key', i);t.src="https://cdp.customer.io/v1/analytics-js/snippet/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._writeKey=key;analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.15.3";
|
||||
analytics.load(
|
||||
CUSTOMERIO_ID,
|
||||
{
|
||||
"integrations": {
|
||||
"Customer.io In-App Plugin": {
|
||||
siteId: CUSTOMERIO_SITE_ID
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
analytics.page();
|
||||
}}();
|
||||
</script>
|
||||
<script>
|
||||
//Set your SEGMENT_ID
|
||||
const SEGMENT_ID = '<%= htmlWebpackPlugin.options.SEGMENT_ID %>';
|
||||
|
||||
const CUSTOMERIO_SITE_ID =
|
||||
'<%= htmlWebpackPlugin.options.CUSTOMERIO_SITE_ID %>';
|
||||
!(function () {
|
||||
var analytics = (window.analytics = window.analytics || []);
|
||||
var i = 'cioanalytics',
|
||||
analytics = (window[i] = window[i] || []);
|
||||
if (!analytics.initialize)
|
||||
if (analytics.invoked)
|
||||
window.console &&
|
||||
console.error &&
|
||||
console.error('Segment snippet included twice.');
|
||||
console.error('Snippet included twice.');
|
||||
else {
|
||||
analytics.invoked = !0;
|
||||
analytics.methods = [
|
||||
@@ -152,35 +134,36 @@
|
||||
];
|
||||
analytics.factory = function (e) {
|
||||
return function () {
|
||||
if (window.analytics.initialized)
|
||||
return window.analytics[e].apply(window.analytics, arguments);
|
||||
var i = Array.prototype.slice.call(arguments);
|
||||
i.unshift(e);
|
||||
analytics.push(i);
|
||||
var t = Array.prototype.slice.call(arguments);
|
||||
t.unshift(e);
|
||||
analytics.push(t);
|
||||
return analytics;
|
||||
};
|
||||
};
|
||||
for (var i = 0; i < analytics.methods.length; i++) {
|
||||
var key = analytics.methods[i];
|
||||
for (var e = 0; e < analytics.methods.length; e++) {
|
||||
var key = analytics.methods[e];
|
||||
analytics[key] = analytics.factory(key);
|
||||
}
|
||||
analytics.load = function (key, i) {
|
||||
analytics.load = function (key, e) {
|
||||
var t = document.createElement('script');
|
||||
t.type = 'text/javascript';
|
||||
t.async = !0;
|
||||
t.setAttribute('data-global-customerio-analytics-key', i);
|
||||
t.src =
|
||||
'https://analytics-cdn.signoz.io/analytics.js/v1/' +
|
||||
'https://cdp.customer.io/v1/analytics-js/snippet/' +
|
||||
key +
|
||||
'/analytics.min.js';
|
||||
var n = document.getElementsByTagName('script')[0];
|
||||
n.parentNode.insertBefore(t, n);
|
||||
analytics._loadOptions = i;
|
||||
analytics._writeKey = key;
|
||||
analytics._loadOptions = e;
|
||||
};
|
||||
analytics._writeKey = SEGMENT_ID;
|
||||
analytics.SNIPPET_VERSION = '4.16.1';
|
||||
analytics.load(SEGMENT_ID, {
|
||||
analytics.SNIPPET_VERSION = '4.15.3';
|
||||
analytics.load(CUSTOMERIO_ID, {
|
||||
integrations: {
|
||||
'Segment.io': { apiHost: 'analytics-api.signoz.io/v1' },
|
||||
'Customer.io In-App Plugin': {
|
||||
siteId: CUSTOMERIO_SITE_ID,
|
||||
},
|
||||
},
|
||||
});
|
||||
analytics.page();
|
||||
|
||||
@@ -21,7 +21,6 @@ const plugins = [
|
||||
new HtmlWebpackPlugin({
|
||||
template: 'src/index.html.ejs',
|
||||
INTERCOM_APP_ID: process.env.INTERCOM_APP_ID,
|
||||
SEGMENT_ID: process.env.SEGMENT_ID,
|
||||
CUSTOMERIO_SITE_ID: process.env.CUSTOMERIO_SITE_ID,
|
||||
CUSTOMERIO_ID: process.env.CUSTOMERIO_ID,
|
||||
POSTHOG_KEY: process.env.POSTHOG_KEY,
|
||||
@@ -41,7 +40,6 @@ const plugins = [
|
||||
FRONTEND_API_ENDPOINT: process.env.FRONTEND_API_ENDPOINT,
|
||||
WEBSOCKET_API_ENDPOINT: process.env.WEBSOCKET_API_ENDPOINT,
|
||||
INTERCOM_APP_ID: process.env.INTERCOM_APP_ID,
|
||||
SEGMENT_ID: process.env.SEGMENT_ID,
|
||||
CUSTOMERIO_SITE_ID: process.env.CUSTOMERIO_SITE_ID,
|
||||
CUSTOMERIO_ID: process.env.CUSTOMERIO_ID,
|
||||
POSTHOG_KEY: process.env.POSTHOG_KEY,
|
||||
|
||||
@@ -26,7 +26,6 @@ const plugins = [
|
||||
new HtmlWebpackPlugin({
|
||||
template: 'src/index.html.ejs',
|
||||
INTERCOM_APP_ID: process.env.INTERCOM_APP_ID,
|
||||
SEGMENT_ID: process.env.SEGMENT_ID,
|
||||
CUSTOMERIO_SITE_ID: process.env.CUSTOMERIO_SITE_ID,
|
||||
CUSTOMERIO_ID: process.env.CUSTOMERIO_ID,
|
||||
POSTHOG_KEY: process.env.POSTHOG_KEY,
|
||||
@@ -51,7 +50,6 @@ const plugins = [
|
||||
FRONTEND_API_ENDPOINT: process.env.FRONTEND_API_ENDPOINT,
|
||||
WEBSOCKET_API_ENDPOINT: process.env.WEBSOCKET_API_ENDPOINT,
|
||||
INTERCOM_APP_ID: process.env.INTERCOM_APP_ID,
|
||||
SEGMENT_ID: process.env.SEGMENT_ID,
|
||||
CUSTOMERIO_SITE_ID: process.env.CUSTOMERIO_SITE_ID,
|
||||
CUSTOMERIO_ID: process.env.CUSTOMERIO_ID,
|
||||
POSTHOG_KEY: process.env.POSTHOG_KEY,
|
||||
|
||||
4
go.mod
4
go.mod
@@ -69,7 +69,7 @@ require (
|
||||
go.opentelemetry.io/otel/trace v1.34.0
|
||||
go.uber.org/multierr v1.11.0
|
||||
go.uber.org/zap v1.27.0
|
||||
golang.org/x/crypto v0.31.0
|
||||
golang.org/x/crypto v0.32.0
|
||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
|
||||
golang.org/x/net v0.33.0
|
||||
golang.org/x/oauth2 v0.24.0
|
||||
@@ -116,7 +116,7 @@ require (
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/go-faster/city v1.0.1 // indirect
|
||||
github.com/go-faster/errors v0.7.1 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
|
||||
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
|
||||
12
go.sum
12
go.sum
@@ -262,8 +262,8 @@ github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7F
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-jose/go-jose/v4 v4.0.2 h1:R3l3kkBds16bO7ZFAEEcofK0MkrAJt3jlJznWZG0nvk=
|
||||
github.com/go-jose/go-jose/v4 v4.0.2/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY=
|
||||
github.com/go-jose/go-jose/v4 v4.0.5 h1:M6T8+mKZl/+fNNuFHvGIzDz7BTLQPIounk/b9dw3AaE=
|
||||
github.com/go-jose/go-jose/v4 v4.0.5/go.mod h1:s3P1lRrkT8igV8D9OjyL4WRyHvjB6a4JSllnOrmmBOA=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
@@ -1108,8 +1108,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm
|
||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
||||
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@@ -1332,8 +1332,8 @@ golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
|
||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
|
||||
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
||||
@@ -1664,7 +1664,14 @@ func (aH *APIHandler) registerEvent(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
claims, ok := authtypes.ClaimsFromContext(r.Context())
|
||||
if ok {
|
||||
telemetry.GetInstance().SendEvent(request.EventName, request.Attributes, claims.Email, request.RateLimited, true)
|
||||
switch request.EventType {
|
||||
case model.TrackEvent:
|
||||
telemetry.GetInstance().SendEvent(request.EventName, request.Attributes, claims.Email, request.RateLimited, true)
|
||||
case model.GroupEvent:
|
||||
telemetry.GetInstance().SendGroupEvent(request.Attributes)
|
||||
case model.IdentifyEvent:
|
||||
telemetry.GetInstance().SendIdentifyEvent(request.Attributes)
|
||||
}
|
||||
aH.WriteJSON(w, r, map[string]string{"data": "Event Processed Successfully"})
|
||||
} else {
|
||||
RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: err}, nil)
|
||||
|
||||
@@ -68,7 +68,12 @@ func parseRegisterEventRequest(r *http.Request) (*model.RegisterEventParams, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if postData.EventName == "" {
|
||||
// Validate the event type
|
||||
if !postData.EventType.IsValid() {
|
||||
return nil, errors.New("eventType param missing/incorrect in query")
|
||||
}
|
||||
|
||||
if postData.EventType == model.TrackEvent && postData.EventName == "" {
|
||||
return nil, errors.New("eventName param missing in query")
|
||||
}
|
||||
|
||||
|
||||
@@ -11,4 +11,74 @@ var preferenceMap = map[string]Preference{
|
||||
IsDiscreteValues: true,
|
||||
AllowedScopes: []string{"org"},
|
||||
},
|
||||
"WELCOME_CHECKLIST_DO_LATER": {
|
||||
Key: "WELCOME_CHECKLIST_DO_LATER",
|
||||
Name: "Welcome Checklist Do Later",
|
||||
Description: "Welcome Checklist Do Later",
|
||||
ValueType: "boolean",
|
||||
DefaultValue: false,
|
||||
AllowedValues: []interface{}{true, false},
|
||||
IsDiscreteValues: true,
|
||||
AllowedScopes: []string{"user"},
|
||||
},
|
||||
"WELCOME_CHECKLIST_SEND_LOGS_SKIPPED": {
|
||||
Key: "WELCOME_CHECKLIST_SEND_LOGS_SKIPPED",
|
||||
Name: "Welcome Checklist Send Logs Skipped",
|
||||
Description: "Welcome Checklist Send Logs Skipped",
|
||||
ValueType: "boolean",
|
||||
DefaultValue: false,
|
||||
AllowedValues: []interface{}{true, false},
|
||||
IsDiscreteValues: true,
|
||||
AllowedScopes: []string{"user"},
|
||||
},
|
||||
"WELCOME_CHECKLIST_SEND_TRACES_SKIPPED": {
|
||||
Key: "WELCOME_CHECKLIST_SEND_TRACES_SKIPPED",
|
||||
Name: "Welcome Checklist Send Traces Skipped",
|
||||
Description: "Welcome Checklist Send Traces Skipped",
|
||||
ValueType: "boolean",
|
||||
DefaultValue: false,
|
||||
AllowedValues: []interface{}{true, false},
|
||||
IsDiscreteValues: true,
|
||||
AllowedScopes: []string{"user"},
|
||||
},
|
||||
"WELCOME_CHECKLIST_SEND_INFRA_METRICS_SKIPPED": {
|
||||
Key: "WELCOME_CHECKLIST_SEND_INFRA_METRICS_SKIPPED",
|
||||
Name: "Welcome Checklist Send Infra Metrics Skipped",
|
||||
Description: "Welcome Checklist Send Infra Metrics Skipped",
|
||||
ValueType: "boolean",
|
||||
DefaultValue: false,
|
||||
AllowedValues: []interface{}{true, false},
|
||||
IsDiscreteValues: true,
|
||||
AllowedScopes: []string{"user"},
|
||||
},
|
||||
"WELCOME_CHECKLIST_SETUP_DASHBOARDS_SKIPPED": {
|
||||
Key: "WELCOME_CHECKLIST_SETUP_DASHBOARDS_SKIPPED",
|
||||
Name: "Welcome Checklist Setup Dashboards Skipped",
|
||||
Description: "Welcome Checklist Setup Dashboards Skipped",
|
||||
ValueType: "boolean",
|
||||
DefaultValue: false,
|
||||
AllowedValues: []interface{}{true, false},
|
||||
IsDiscreteValues: true,
|
||||
AllowedScopes: []string{"user"},
|
||||
},
|
||||
"WELCOME_CHECKLIST_SETUP_ALERTS_SKIPPED": {
|
||||
Key: "WELCOME_CHECKLIST_SETUP_ALERTS_SKIPPED",
|
||||
Name: "Welcome Checklist Setup Alerts Skipped",
|
||||
Description: "Welcome Checklist Setup Alerts Skipped",
|
||||
ValueType: "boolean",
|
||||
DefaultValue: false,
|
||||
AllowedValues: []interface{}{true, false},
|
||||
IsDiscreteValues: true,
|
||||
AllowedScopes: []string{"user"},
|
||||
},
|
||||
"WELCOME_CHECKLIST_SETUP_SAVED_VIEW_SKIPPED": {
|
||||
Key: "WELCOME_CHECKLIST_SETUP_SAVED_VIEW_SKIPPED",
|
||||
Name: "Welcome Checklist Setup Saved View Skipped",
|
||||
Description: "Welcome Checklist Setup Saved View Skipped",
|
||||
ValueType: "boolean",
|
||||
DefaultValue: false,
|
||||
AllowedValues: []interface{}{true, false},
|
||||
IsDiscreteValues: true,
|
||||
AllowedScopes: []string{"user"},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -50,7 +50,21 @@ type GetTopOperationsParams struct {
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
type EventType string
|
||||
|
||||
const (
|
||||
TrackEvent EventType = "track"
|
||||
IdentifyEvent EventType = "identify"
|
||||
GroupEvent EventType = "group"
|
||||
)
|
||||
|
||||
// IsValid checks if the EventType is one of the valid values
|
||||
func (e EventType) IsValid() bool {
|
||||
return e == TrackEvent || e == IdentifyEvent || e == GroupEvent
|
||||
}
|
||||
|
||||
type RegisterEventParams struct {
|
||||
EventType EventType `json:"eventType"`
|
||||
EventName string `json:"eventName"`
|
||||
Attributes map[string]interface{} `json:"attributes"`
|
||||
RateLimited bool `json:"rateLimited"`
|
||||
|
||||
@@ -409,7 +409,24 @@ func createTelemetry() {
|
||||
telemetry.SendEvent(TELEMETRY_EVENT_DASHBOARDS_ALERTS, dashboardsAlertsData, user.Email, false, false)
|
||||
}
|
||||
}
|
||||
telemetry.SendIdentityEvent(map[string]interface{}{
|
||||
telemetry.SendIdentifyEvent(map[string]interface{}{
|
||||
"total_logs": totalLogs,
|
||||
"total_traces": totalSpans,
|
||||
"total_metrics": totalSamples,
|
||||
"total_users": userCount,
|
||||
"total_channels": alertsInfo.TotalChannels,
|
||||
"total_dashboards_with_panel": dashboardsInfo.TotalDashboardsWithPanelAndName,
|
||||
"total_saved_views": savedViewsInfo.TotalSavedViews,
|
||||
"total_active_alerts": alertsInfo.TotalActiveAlerts,
|
||||
"total_traces_based_alerts": alertsInfo.TracesBasedAlerts,
|
||||
"total_logs_based_alerts": alertsInfo.LogsBasedAlerts,
|
||||
"total_metric_based_alerts": alertsInfo.MetricBasedAlerts,
|
||||
"total_anomaly_based_alerts": alertsInfo.AnomalyBasedAlerts,
|
||||
"total_metrics_based_panels": dashboardsInfo.MetricBasedPanels,
|
||||
"total_logs_based_panels": dashboardsInfo.LogsBasedPanels,
|
||||
"total_traces_based_panels": dashboardsInfo.TracesBasedPanels,
|
||||
})
|
||||
telemetry.SendGroupEvent(map[string]interface{}{
|
||||
"total_logs": totalLogs,
|
||||
"total_traces": totalSpans,
|
||||
"total_metrics": totalSamples,
|
||||
@@ -434,13 +451,16 @@ func createTelemetry() {
|
||||
}
|
||||
|
||||
if totalLogs > 0 {
|
||||
telemetry.SendIdentityEvent(map[string]interface{}{"sent_logs": true})
|
||||
telemetry.SendIdentifyEvent(map[string]interface{}{"sent_logs": true})
|
||||
telemetry.SendGroupEvent(map[string]interface{}{"sent_logs": true})
|
||||
}
|
||||
if totalSpans > 0 {
|
||||
telemetry.SendIdentityEvent(map[string]interface{}{"sent_traces": true})
|
||||
telemetry.SendIdentifyEvent(map[string]interface{}{"sent_traces": true})
|
||||
telemetry.SendGroupEvent(map[string]interface{}{"sent_traces": true})
|
||||
}
|
||||
if totalSamples > 0 {
|
||||
telemetry.SendIdentityEvent(map[string]interface{}{"sent_metrics": true})
|
||||
telemetry.SendIdentifyEvent(map[string]interface{}{"sent_metrics": true})
|
||||
telemetry.SendGroupEvent(map[string]interface{}{"sent_metrics": true})
|
||||
}
|
||||
|
||||
getDistributedInfoInLastHeartBeatInterval, _ := telemetry.reader.GetDistributedInfoInLastHeartBeatInterval(ctx)
|
||||
@@ -571,7 +591,7 @@ func (a *Telemetry) IdentifyUser(user *types.User) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Telemetry) SendIdentityEvent(data map[string]interface{}) {
|
||||
func (a *Telemetry) SendIdentifyEvent(data map[string]interface{}) {
|
||||
|
||||
if !a.isTelemetryEnabled() || a.isTelemetryAnonymous() {
|
||||
return
|
||||
@@ -582,23 +602,37 @@ func (a *Telemetry) SendIdentityEvent(data map[string]interface{}) {
|
||||
traits.Set(k, v)
|
||||
}
|
||||
if a.saasOperator != nil {
|
||||
|
||||
a.saasOperator.Enqueue(analytics.Identify{
|
||||
UserId: a.GetUserEmail(),
|
||||
Traits: traits,
|
||||
})
|
||||
a.saasOperator.Enqueue(analytics.Group{
|
||||
UserId: a.userEmail,
|
||||
GroupId: a.getCompanyDomain(),
|
||||
Traits: traits,
|
||||
})
|
||||
}
|
||||
if a.ossOperator != nil {
|
||||
a.ossOperator.Enqueue(analytics.Identify{
|
||||
UserId: a.ipAddress,
|
||||
Traits: traits,
|
||||
})
|
||||
// Updating a groups properties
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Telemetry) SendGroupEvent(data map[string]interface{}) {
|
||||
|
||||
if !a.isTelemetryEnabled() || a.isTelemetryAnonymous() {
|
||||
return
|
||||
}
|
||||
traits := analytics.NewTraits()
|
||||
|
||||
for k, v := range data {
|
||||
traits.Set(k, v)
|
||||
}
|
||||
if a.saasOperator != nil {
|
||||
a.saasOperator.Enqueue(analytics.Group{
|
||||
UserId: a.GetUserEmail(),
|
||||
GroupId: a.getCompanyDomain(),
|
||||
Traits: traits,
|
||||
})
|
||||
}
|
||||
if a.ossOperator != nil {
|
||||
a.ossOperator.Enqueue(analytics.Group{
|
||||
UserId: a.ipAddress,
|
||||
GroupId: a.getCompanyDomain(),
|
||||
|
||||
Reference in New Issue
Block a user