Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion api/app/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,6 @@
GOOGLE_ANALYTICS_API_KEY = env("GOOGLE_ANALYTICS_API_KEY", default=None)
HEADWAY_API_KEY = env("HEADWAY_API_KEY", default=None)
CRISP_CHAT_API_KEY = env("CRISP_CHAT_API_KEY", default=None)
MIXPANEL_API_KEY = env("MIXPANEL_API_KEY", default=None)
SENTRY_API_KEY = env("SENTRY_API_KEY", default=None)
AMPLITUDE_API_KEY = env("AMPLITUDE_API_KEY", default=None)
REO_API_KEY = env("REO_API_KEY", default=None)
Expand Down
1 change: 0 additions & 1 deletion api/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def project_overrides(request: Request) -> HttpResponse:
"hideInviteLinks": "DISABLE_INVITE_LINKS",
"linkedinPartnerTracking": "LINKEDIN_PARTNER_TRACKING",
"maintenance": "MAINTENANCE_MODE",
"mixpanel": "MIXPANEL_API_KEY",
"preventEmailPassword": "PREVENT_EMAIL_PASSWORD",
"preventSignup": "PREVENT_SIGNUP",
"reo": "REO_API_KEY",
Expand Down
1 change: 0 additions & 1 deletion docs/docs/deployment/hosting/locally-frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ Current variables used between 'frontend/environment.js' and 'frontend/common/pr
- `ENABLE_MAINTENANCE_MODE`: Puts the site into maintenance mode. Set it to any value to enable maintenance.
- `AMPLITUDE_API_KEY`: The Amplitude key to use for behaviour tracking.
- `REO_API_KEY`: The Reo key to use for behaviour tracking.
- `MIXPANEL_API_KEY`: Mixpanel analytics key to use for behaviour tracking.
- `SENTRY_API_KEY`: Sentry key for error reporting.
- `ALBACROSS_CLIENT_ID`: Albacross client ID key for behaviour tracking.
- `BASE_URL`: Used for specifying a base url path that's ignored during routing if serving from a subdirectory.
Expand Down
3 changes: 0 additions & 3 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ module.exports = {
'CodeHelp': true,
'Column': true,
'Cookies': true,
'DYNATRACE_URL': true,
'Dispatcher': true,
'E2E': true,
'ES6Component': true,
Expand Down Expand Up @@ -75,15 +74,13 @@ module.exports = {
'closeModal2': true,
'delighted': true,
'describe': true,
'dtrum': true,
'em': true,
'flagsmith': true,
'ga': true,
'heap': true,
'hljs': true,
'hot': true,
'isMobile': true,
'mixpanel': true,
'moment': true,
'oneOfType': true,
'openConfirm': true,
Expand Down
79 changes: 1 addition & 78 deletions frontend/api/index.js

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions frontend/common/stores/config-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@ store.dispatcherIndex = Dispatcher.register(store, (payload) => {
}
})

const enableDynatrace = !!window.enableDynatrace && typeof dtrum !== 'undefined'

flagsmith
.init({
AsyncStorage,
api: Project.flagsmithClientAPI,
cacheFlags: true,
enableAnalytics: Project.flagsmithAnalytics,
enableDynatrace,
environmentID: Project.flagsmith,
onChange: controller.loaded,
realtime: Project.flagsmithRealtime,
Expand Down
1 change: 0 additions & 1 deletion frontend/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ declare global {
const Column: typeof Component
const Loader: typeof Component
const E2E: boolean
const dtrum: undefined | { identifyUser: (id: string) => void }
const closeModal: () => void
const closeModal2: () => void
const toast: (message: string) => void
Expand Down
9 changes: 0 additions & 9 deletions frontend/web/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,3 @@ if (!E2E && Project.crispChat && !isWidget) {
d.getElementsByTagName('head')[0].appendChild(s)
})()
}

if (!E2E && Project.zendesk && !isWidget) {
const script = document.createElement('script')
script.type = 'text/javascript'
script.id = 'ze-snippet'
script.async = true
script.src = `https://static.zdassets.com/ekr/snippet.js?key=${Project.zendesk}`
document.getElementsByTagName('head')[0].appendChild(script)
}
172 changes: 21 additions & 151 deletions frontend/web/project/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import * as amplitude from '@amplitude/analytics-browser'
import data from 'common/data/base/_data'
import isFreeEmailDomain from 'common/utils/isFreeEmailDomain'

const enableDynatrace = !!window.enableDynatrace && typeof dtrum !== 'undefined'
import { loadReoScript } from 'reodotdev'

import freeEmailDomains from 'free-email-domains'
import { groupBy } from 'lodash'
import getUserDisplayName from 'common/utils/getUserDisplayName'

global.API = {
ajaxHandler(store, res) {
switch (res.status) {
Expand Down Expand Up @@ -62,42 +60,7 @@ global.API = {
},
alias(id, user = {}) {
if (Project.excludeAnalytics?.includes(id)) return
if (Project.mixpanel) {
mixpanel.alias(id)
}

if (enableDynatrace && user?.id) {
dtrum.identifyUser(`${user.id}`)
}
Utils.setupCrisp()
if (Project.heap) {
heap.identify(id)
const user = AccountStore.model
const orgs =
(user &&
user.organisations &&
_.map(
user.organisations,
(o) => `${o.name} #${o.id}(${o.role})[${o.num_seats}]`,
).join(',')) ||
''
const plans = AccountStore.getPlans()
heap.addUserProperties({
// use human-readable names
'$first_name': user.first_name,

'$last_name': user.last_name,
'USER_ID': id,
email: id,
'isCompanyEmail':
!user.email.includes('@gmail') &&
!user.email.includes('@yahoo') &&
!user.email.includes('@hotmail') &&
!user.email.includes('@icloud'),
orgs,
'plan': plans && plans.join(','),
})
}
if (Project.reo) {
const reoPromise = loadReoScript({ clientID: Project.reo })
reoPromise.then((Reo) => {
Expand Down Expand Up @@ -128,8 +91,9 @@ global.API = {
}
if (Project.amplitude) {
amplitude.setUserId(id)
const identify = new amplitude.Identify().set('email', id)
amplitude.identify(identify)
API.trackTraits({
email: id,
})
if (typeof window.engagement !== 'undefined') {
window.engagement.boot({
integrations: [
Expand Down Expand Up @@ -218,40 +182,6 @@ global.API = {
identify(id, user = {}) {
if (Project.excludeAnalytics?.includes(id)) return
try {
const orgs =
(user &&
user.organisations &&
_.map(
user.organisations,
(o) => `${o.name} #${o.id}(${o.role})[${o.num_seats}]`,
).join(',')) ||
''
if (Project.mixpanel) {
mixpanel.identify(id)
const plans = AccountStore.getPlans()

mixpanel.people.set({
'$email': id,
// use human-readable names
'$first_name': user.first_name,

'$last_name': user.last_name,
// only reserved properties need the $
'USER_ID': id,
'isCompanyEmail':
!user.email.includes('@gmail') &&
!user.email.includes('@yahoo') &&
!user.email.includes('@hotmail') &&
!user.email.includes('@icloud'),
orgs,
'plan': plans && plans.join(','),
})
}

if (enableDynatrace && user?.id) {
dtrum.identifyUser(`${user.id}`)
}

const planNames = {
enterprise: 'Enterprise',
free: 'Free',
Expand Down Expand Up @@ -297,41 +227,16 @@ global.API = {
)
const selectedRole = selectedOrg?.role //ADMIN | USER
const selectedOrgName = selectedOrg?.name
if (Project.heap) {
const plans = AccountStore.getPlans()
heap.identify(id)
heap.addUserProperties({
// use human-readable names
'$first_name': user.first_name,
'$last_name': user.last_name,
'USER_ID': id,
email: id,
'isCompanyEmail':
!user.email.includes('@gmail') &&
!user.email.includes('@yahoo') &&
!user.email.includes('@hotmail') &&
!user.email.includes('@icloud'),
orgs,
'plan': plans && plans.join(','),
})
}

if (Project.amplitude) {
amplitude.setUserId(id)
const identify = new amplitude.Identify()
.set('email', id)
.set('name', { 'first': user.first_name, 'last': user.last_name })
.set('organisation', selectedOrgName)
.set('role', selectedRole)
.set('plan', selectedPlanName)
.set(
'tasks',
(user.onboarding?.tasks || [])?.map((v) => v.name),
)
.set('integrations', user.onboarding?.tools?.integrations || [])

amplitude.identify(identify)
}
API.trackTraits({
email: id,
integrations: user.onboarding?.tools?.integrations || [],
name: { 'first': user.first_name, 'last': user.last_name },
organisation: selectedOrgName,
plan: selectedPlanName,
role: selectedRole,
tasks: (user.onboarding?.tasks || [])?.map((v) => v.name),
})
API.flagsmithIdentify()
} catch (e) {
console.error('Error identifying', e)
Expand All @@ -352,20 +257,7 @@ global.API = {
tag,
})
},
register(email, firstName, lastName) {
if (Project.excludeAnalytics?.includes(email)) return
if (Project.mixpanel) {
mixpanel.register({
'Email': email,
'First Name': firstName,
'Last Name': lastName,
})
}
},
reset() {
if (Project.mixpanel) {
mixpanel.reset()
}
return flagsmith.logout()
},
setCookie(key, v) {
Expand Down Expand Up @@ -432,11 +324,6 @@ global.API = {
})
}

if (Project.heap) {
heap.track(data.event, {
category: data.category,
})
}
if (Project.amplitude) {
const eventData = {
category: data.category,
Expand All @@ -445,18 +332,6 @@ global.API = {

amplitude.track(data.event, eventData)
}
if (Project.mixpanel) {
if (!data) {
console.error('Passed null event data')
}
console.info('track', data)
if (!data || !data.category || !data.event) {
console.error('Invalid event provided', data)
}
mixpanel.track(data.event, {
category: data.category,
})
}
},
trackPage(title) {
if (Project.ga) {
Expand All @@ -467,19 +342,14 @@ global.API = {
title,
})
}
if (Project.heap) {
heap.track(`Page View - ${title}`, {
location: document.location.href,
page: document.location.pathname,
title,
})
}
if (Project.mixpanel) {
mixpanel.track(`Page View - ${title}`, {
location: document.location.href,
page: document.location.pathname,
title,
})
},
trackTraits(traits) {
if (Project.amplitude && traits) {
const identifyObj = new amplitude.Identify()
for (const [key, value] of Object.entries(traits)) {
identifyObj.set(key, value)
}
amplitude.identify(identifyObj)
}
},
}
Expand Down
25 changes: 0 additions & 25 deletions frontend/web/project/libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ window.RequiredElement = propTypes.node.isRequired;
window.Link = require('react-router-dom').Link;
window.NavLink = require('react-router-dom').NavLink;

if (Project.heap) {
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]); };
heap.load(Project.heap);
}
// Analytics
if (Project.ga) {
(function (i, s, o, g, r, a, m) {
Expand All @@ -71,27 +67,6 @@ if (Project.ga) {
ga('create', Project.ga, 'auto');
}

if (Project.mixpanel) {
(function (e, a) {
if (!a.__SV) {
let b = window; try {
var c; let l; let i; const j = b.location; const
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)));
} catch (m) { } let k; let
h; window.mixpanel = a; a._i = []; a.init = function (b, c, f) {
function e(b, a) {
const c = a.split('.'); c.length == 2 && (b = b[c[0]], a = c[1]); b[a] = function () {
b.push([a].concat(Array.prototype.slice.call(arguments,
0)));
};
} 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(' ');
for (h = 0; h < k.length; h++)e(d, k[h]); a._i.push([b, c, f]);
}; 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);
}
}(document, window.mixpanel || []));
mixpanel.init(Project.mixpanel);
}

if (typeof SENTRY_RELEASE_VERSION !== 'undefined' && Project.sentry && typeof Sentry !== 'undefined') {
Sentry.init({
dsn: Project.sentry,
Expand Down
1 change: 0 additions & 1 deletion frontend/webpack/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = [
new webpack.DefinePlugin({
E2E: process.env.E2E,
SENTRY_RELEASE_VERSION: true,
DYNATRACE_URL: !!process.env.DYNATRACE_URL && JSON.stringify(process.env.DYNATRACE_URL),
}),
// // Fixes warning in moment-with-locales.min.js
// // Module not found: Error: Can't resolve './locale' in ...
Expand Down
Loading