Skip to content

Commit 85e994d

Browse files
authored
feat: hide and show pylon on user login events (#7383)
1 parent 937d09a commit 85e994d

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

frontend/common/loadChat.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,20 @@ function setupPylon() {
6262
}
6363
}
6464

65+
export function hidePylon() {
66+
if (typeof window.Pylon !== 'undefined') {
67+
window.Pylon('hideChatBubble')
68+
}
69+
}
70+
6571
export function identifyChatUser() {
6672
if (flagsmith.hasFeature('pylon_chat') && !isFreePlan()) {
6773
setupPylon()
74+
if (typeof window.Pylon !== 'undefined') {
75+
window.Pylon('showChatBubble')
76+
}
77+
} else {
78+
hidePylon()
6879
}
6980
}
7081

frontend/common/stores/account-store.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { sortBy } from 'lodash'
1313
import Project from 'common/project'
1414
import { getStore } from 'common/store'
1515
import { setSelectedOrganisationId } from 'common/selectedOrganisationSlice'
16+
import { hidePylon, identifyChatUser } from 'common/loadChat'
1617
import { service } from 'common/service'
1718
import { getBuildVersion } from 'common/services/useBuildVersion'
1819
import { createOnboardingSupportOptIn } from 'common/services/useOnboardingSupportOptIn'
@@ -312,6 +313,7 @@ const controller = {
312313
store.organisation = find(store.model.organisations, { id })
313314
getStore().dispatch(setSelectedOrganisationId(id))
314315
store.changed()
316+
identifyChatUser()
315317
},
316318

317319
setToken: (token) => {
@@ -373,6 +375,7 @@ const controller = {
373375
).finally(() => {
374376
API.setCookie('t', '')
375377
data.setToken(null)
378+
hidePylon()
376379
API.reset().finally(() => {
377380
store.model = user
378381
store.organisation = null

0 commit comments

Comments
 (0)