Skip to content

Commit 51ce137

Browse files
authored
chore: Remove heap, mixpanel, zendesk and dynatrace (#5802)
1 parent 57489b7 commit 51ce137

File tree

11 files changed

+22
-274
lines changed

11 files changed

+22
-274
lines changed

api/app/settings/common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,6 @@
10261026
GOOGLE_ANALYTICS_API_KEY = env("GOOGLE_ANALYTICS_API_KEY", default=None)
10271027
HEADWAY_API_KEY = env("HEADWAY_API_KEY", default=None)
10281028
CRISP_CHAT_API_KEY = env("CRISP_CHAT_API_KEY", default=None)
1029-
MIXPANEL_API_KEY = env("MIXPANEL_API_KEY", default=None)
10301029
SENTRY_API_KEY = env("SENTRY_API_KEY", default=None)
10311030
AMPLITUDE_API_KEY = env("AMPLITUDE_API_KEY", default=None)
10321031
REO_API_KEY = env("REO_API_KEY", default=None)

api/app/views.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def project_overrides(request: Request) -> HttpResponse:
4646
"hideInviteLinks": "DISABLE_INVITE_LINKS",
4747
"linkedinPartnerTracking": "LINKEDIN_PARTNER_TRACKING",
4848
"maintenance": "MAINTENANCE_MODE",
49-
"mixpanel": "MIXPANEL_API_KEY",
5049
"preventEmailPassword": "PREVENT_EMAIL_PASSWORD",
5150
"preventSignup": "PREVENT_SIGNUP",
5251
"reo": "REO_API_KEY",

docs/docs/deployment/hosting/locally-frontend.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ Current variables used between 'frontend/environment.js' and 'frontend/common/pr
9090
- `ENABLE_MAINTENANCE_MODE`: Puts the site into maintenance mode. Set it to any value to enable maintenance.
9191
- `AMPLITUDE_API_KEY`: The Amplitude key to use for behaviour tracking.
9292
- `REO_API_KEY`: The Reo key to use for behaviour tracking.
93-
- `MIXPANEL_API_KEY`: Mixpanel analytics key to use for behaviour tracking.
9493
- `SENTRY_API_KEY`: Sentry key for error reporting.
9594
- `ALBACROSS_CLIENT_ID`: Albacross client ID key for behaviour tracking.
9695
- `BASE_URL`: Used for specifying a base url path that's ignored during routing if serving from a subdirectory.

frontend/.eslintrc.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ module.exports = {
2929
'CodeHelp': true,
3030
'Column': true,
3131
'Cookies': true,
32-
'DYNATRACE_URL': true,
3332
'Dispatcher': true,
3433
'E2E': true,
3534
'ES6Component': true,
@@ -75,15 +74,13 @@ module.exports = {
7574
'closeModal2': true,
7675
'delighted': true,
7776
'describe': true,
78-
'dtrum': true,
7977
'em': true,
8078
'flagsmith': true,
8179
'ga': true,
8280
'heap': true,
8381
'hljs': true,
8482
'hot': true,
8583
'isMobile': true,
86-
'mixpanel': true,
8784
'moment': true,
8885
'oneOfType': true,
8986
'openConfirm': true,

frontend/api/index.js

Lines changed: 1 addition & 78 deletions
Large diffs are not rendered by default.

frontend/common/stores/config-store.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,12 @@ store.dispatcherIndex = Dispatcher.register(store, (payload) => {
4141
}
4242
})
4343

44-
const enableDynatrace = !!window.enableDynatrace && typeof dtrum !== 'undefined'
45-
4644
flagsmith
4745
.init({
4846
AsyncStorage,
4947
api: Project.flagsmithClientAPI,
5048
cacheFlags: true,
5149
enableAnalytics: Project.flagsmithAnalytics,
52-
enableDynatrace,
5350
environmentID: Project.flagsmith,
5451
onChange: controller.loaded,
5552
realtime: Project.flagsmithRealtime,

frontend/global.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ declare global {
4646
const Column: typeof Component
4747
const Loader: typeof Component
4848
const E2E: boolean
49-
const dtrum: undefined | { identifyUser: (id: string) => void }
5049
const closeModal: () => void
5150
const closeModal2: () => void
5251
const toast: (message: string) => void

frontend/web/main.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,3 @@ if (!E2E && Project.crispChat && !isWidget) {
110110
d.getElementsByTagName('head')[0].appendChild(s)
111111
})()
112112
}
113-
114-
if (!E2E && Project.zendesk && !isWidget) {
115-
const script = document.createElement('script')
116-
script.type = 'text/javascript'
117-
script.id = 'ze-snippet'
118-
script.async = true
119-
script.src = `https://static.zdassets.com/ekr/snippet.js?key=${Project.zendesk}`
120-
document.getElementsByTagName('head')[0].appendChild(script)
121-
}

frontend/web/project/api.js

Lines changed: 21 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ import * as amplitude from '@amplitude/analytics-browser'
22
import data from 'common/data/base/_data'
33
import isFreeEmailDomain from 'common/utils/isFreeEmailDomain'
44

5-
const enableDynatrace = !!window.enableDynatrace && typeof dtrum !== 'undefined'
65
import { loadReoScript } from 'reodotdev'
7-
8-
import freeEmailDomains from 'free-email-domains'
96
import { groupBy } from 'lodash'
107
import getUserDisplayName from 'common/utils/getUserDisplayName'
8+
119
global.API = {
1210
ajaxHandler(store, res) {
1311
switch (res.status) {
@@ -62,42 +60,7 @@ global.API = {
6260
},
6361
alias(id, user = {}) {
6462
if (Project.excludeAnalytics?.includes(id)) return
65-
if (Project.mixpanel) {
66-
mixpanel.alias(id)
67-
}
68-
69-
if (enableDynatrace && user?.id) {
70-
dtrum.identifyUser(`${user.id}`)
71-
}
7263
Utils.setupCrisp()
73-
if (Project.heap) {
74-
heap.identify(id)
75-
const user = AccountStore.model
76-
const orgs =
77-
(user &&
78-
user.organisations &&
79-
_.map(
80-
user.organisations,
81-
(o) => `${o.name} #${o.id}(${o.role})[${o.num_seats}]`,
82-
).join(',')) ||
83-
''
84-
const plans = AccountStore.getPlans()
85-
heap.addUserProperties({
86-
// use human-readable names
87-
'$first_name': user.first_name,
88-
89-
'$last_name': user.last_name,
90-
'USER_ID': id,
91-
email: id,
92-
'isCompanyEmail':
93-
!user.email.includes('@gmail') &&
94-
!user.email.includes('@yahoo') &&
95-
!user.email.includes('@hotmail') &&
96-
!user.email.includes('@icloud'),
97-
orgs,
98-
'plan': plans && plans.join(','),
99-
})
100-
}
10164
if (Project.reo) {
10265
const reoPromise = loadReoScript({ clientID: Project.reo })
10366
reoPromise.then((Reo) => {
@@ -128,8 +91,9 @@ global.API = {
12891
}
12992
if (Project.amplitude) {
13093
amplitude.setUserId(id)
131-
const identify = new amplitude.Identify().set('email', id)
132-
amplitude.identify(identify)
94+
API.trackTraits({
95+
email: id,
96+
})
13397
if (typeof window.engagement !== 'undefined') {
13498
window.engagement.boot({
13599
integrations: [
@@ -218,40 +182,6 @@ global.API = {
218182
identify(id, user = {}) {
219183
if (Project.excludeAnalytics?.includes(id)) return
220184
try {
221-
const orgs =
222-
(user &&
223-
user.organisations &&
224-
_.map(
225-
user.organisations,
226-
(o) => `${o.name} #${o.id}(${o.role})[${o.num_seats}]`,
227-
).join(',')) ||
228-
''
229-
if (Project.mixpanel) {
230-
mixpanel.identify(id)
231-
const plans = AccountStore.getPlans()
232-
233-
mixpanel.people.set({
234-
'$email': id,
235-
// use human-readable names
236-
'$first_name': user.first_name,
237-
238-
'$last_name': user.last_name,
239-
// only reserved properties need the $
240-
'USER_ID': id,
241-
'isCompanyEmail':
242-
!user.email.includes('@gmail') &&
243-
!user.email.includes('@yahoo') &&
244-
!user.email.includes('@hotmail') &&
245-
!user.email.includes('@icloud'),
246-
orgs,
247-
'plan': plans && plans.join(','),
248-
})
249-
}
250-
251-
if (enableDynatrace && user?.id) {
252-
dtrum.identifyUser(`${user.id}`)
253-
}
254-
255185
const planNames = {
256186
enterprise: 'Enterprise',
257187
free: 'Free',
@@ -297,41 +227,16 @@ global.API = {
297227
)
298228
const selectedRole = selectedOrg?.role //ADMIN | USER
299229
const selectedOrgName = selectedOrg?.name
300-
if (Project.heap) {
301-
const plans = AccountStore.getPlans()
302-
heap.identify(id)
303-
heap.addUserProperties({
304-
// use human-readable names
305-
'$first_name': user.first_name,
306-
'$last_name': user.last_name,
307-
'USER_ID': id,
308-
email: id,
309-
'isCompanyEmail':
310-
!user.email.includes('@gmail') &&
311-
!user.email.includes('@yahoo') &&
312-
!user.email.includes('@hotmail') &&
313-
!user.email.includes('@icloud'),
314-
orgs,
315-
'plan': plans && plans.join(','),
316-
})
317-
}
318230

319-
if (Project.amplitude) {
320-
amplitude.setUserId(id)
321-
const identify = new amplitude.Identify()
322-
.set('email', id)
323-
.set('name', { 'first': user.first_name, 'last': user.last_name })
324-
.set('organisation', selectedOrgName)
325-
.set('role', selectedRole)
326-
.set('plan', selectedPlanName)
327-
.set(
328-
'tasks',
329-
(user.onboarding?.tasks || [])?.map((v) => v.name),
330-
)
331-
.set('integrations', user.onboarding?.tools?.integrations || [])
332-
333-
amplitude.identify(identify)
334-
}
231+
API.trackTraits({
232+
email: id,
233+
integrations: user.onboarding?.tools?.integrations || [],
234+
name: { 'first': user.first_name, 'last': user.last_name },
235+
organisation: selectedOrgName,
236+
plan: selectedPlanName,
237+
role: selectedRole,
238+
tasks: (user.onboarding?.tasks || [])?.map((v) => v.name),
239+
})
335240
API.flagsmithIdentify()
336241
} catch (e) {
337242
console.error('Error identifying', e)
@@ -352,20 +257,7 @@ global.API = {
352257
tag,
353258
})
354259
},
355-
register(email, firstName, lastName) {
356-
if (Project.excludeAnalytics?.includes(email)) return
357-
if (Project.mixpanel) {
358-
mixpanel.register({
359-
'Email': email,
360-
'First Name': firstName,
361-
'Last Name': lastName,
362-
})
363-
}
364-
},
365260
reset() {
366-
if (Project.mixpanel) {
367-
mixpanel.reset()
368-
}
369261
return flagsmith.logout()
370262
},
371263
setCookie(key, v) {
@@ -432,11 +324,6 @@ global.API = {
432324
})
433325
}
434326

435-
if (Project.heap) {
436-
heap.track(data.event, {
437-
category: data.category,
438-
})
439-
}
440327
if (Project.amplitude) {
441328
const eventData = {
442329
category: data.category,
@@ -445,18 +332,6 @@ global.API = {
445332

446333
amplitude.track(data.event, eventData)
447334
}
448-
if (Project.mixpanel) {
449-
if (!data) {
450-
console.error('Passed null event data')
451-
}
452-
console.info('track', data)
453-
if (!data || !data.category || !data.event) {
454-
console.error('Invalid event provided', data)
455-
}
456-
mixpanel.track(data.event, {
457-
category: data.category,
458-
})
459-
}
460335
},
461336
trackPage(title) {
462337
if (Project.ga) {
@@ -467,19 +342,14 @@ global.API = {
467342
title,
468343
})
469344
}
470-
if (Project.heap) {
471-
heap.track(`Page View - ${title}`, {
472-
location: document.location.href,
473-
page: document.location.pathname,
474-
title,
475-
})
476-
}
477-
if (Project.mixpanel) {
478-
mixpanel.track(`Page View - ${title}`, {
479-
location: document.location.href,
480-
page: document.location.pathname,
481-
title,
482-
})
345+
},
346+
trackTraits(traits) {
347+
if (Project.amplitude && traits) {
348+
const identifyObj = new amplitude.Identify()
349+
for (const [key, value] of Object.entries(traits)) {
350+
identifyObj.set(key, value)
351+
}
352+
amplitude.identify(identifyObj)
483353
}
484354
},
485355
}

frontend/web/project/libs.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ window.RequiredElement = propTypes.node.isRequired;
5656
window.Link = require('react-router-dom').Link;
5757
window.NavLink = require('react-router-dom').NavLink;
5858

59-
if (Project.heap) {
60-
window.heap = window.heap || [], heap.load = function (e, t) { window.heap.appid = e, window.heap.config = t = t || {}; const r = document.createElement('script'); r.type = 'text/javascript', r.async = !0, r.src = `https://cdn.heapanalytics.com/js/heap-${e}.js`; const a = document.getElementsByTagName('script')[0]; a.parentNode.insertBefore(r, a); for (let n = function (e) { return function () { heap.push([e].concat(Array.prototype.slice.call(arguments, 0))); }; }, p = ['addEventProperties', 'addUserProperties', 'clearEventProperties', 'identify', 'resetIdentity', 'removeEventProperty', 'setEventProperties', 'track', 'unsetEventProperty'], o = 0; o<p.length; o++)heap[p[o]] = n(p[o]); };
61-
heap.load(Project.heap);
62-
}
6359
// Analytics
6460
if (Project.ga) {
6561
(function (i, s, o, g, r, a, m) {
@@ -71,27 +67,6 @@ if (Project.ga) {
7167
ga('create', Project.ga, 'auto');
7268
}
7369

74-
if (Project.mixpanel) {
75-
(function (e, a) {
76-
if (!a.__SV) {
77-
let b = window; try {
78-
var c; let l; let i; const j = b.location; const
79-
g = j.hash; c = function (a, b) { return (l = a.match(RegExp(`${b}=([^&]*)`))) ? l[1] : null; }; g && c(g, 'state') && (i = JSON.parse(decodeURIComponent(c(g, 'state'))), i.action === 'mpeditor' && (b.sessionStorage.setItem('_mpcehash', g), history.replaceState(i.desiredHash || '', e.title, j.pathname + j.search)));
80-
} catch (m) { } let k; let
81-
h; window.mixpanel = a; a._i = []; a.init = function (b, c, f) {
82-
function e(b, a) {
83-
const c = a.split('.'); c.length == 2 && (b = b[c[0]], a = c[1]); b[a] = function () {
84-
b.push([a].concat(Array.prototype.slice.call(arguments,
85-
0)));
86-
};
87-
} let d = a; typeof f !== 'undefined' ? d = a[f] = [] : f = 'mixpanel'; d.people = d.people || []; d.toString = function (b) { let a = 'mixpanel'; f !== 'mixpanel' && (a += `.${f}`); b || (a += ' (stub)'); return a; }; d.people.toString = function () { return `${d.toString(1)}.people (stub)`; }; k = 'disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user'.split(' ');
88-
for (h = 0; h < k.length; h++)e(d, k[h]); a._i.push([b, c, f]);
89-
}; a.__SV = 1.2; b = e.createElement('script'); b.type = 'text/javascript'; b.async = !0; b.src = typeof MIXPANEL_CUSTOM_LIB_URL !== 'undefined' ? MIXPANEL_CUSTOM_LIB_URL : e.location.protocol === 'file:' && 'https://cdn4.mxpnl.com/libs/mixpanel-2-latest.min.js'.match(/^\/\//) ? 'https://cdn4.mxpnl.com/libs/mixpanel-2-latest.min.js' : 'https://cdn4.mxpnl.com/libs/mixpanel-2-latest.min.js'; c = e.getElementsByTagName('script')[0]; c.parentNode.insertBefore(b, c);
90-
}
91-
}(document, window.mixpanel || []));
92-
mixpanel.init(Project.mixpanel);
93-
}
94-
9570
if (typeof SENTRY_RELEASE_VERSION !== 'undefined' && Project.sentry && typeof Sentry !== 'undefined') {
9671
Sentry.init({
9772
dsn: Project.sentry,

0 commit comments

Comments
 (0)