Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update analytics events (#6050)
- Loading branch information
1 parent
7dc790a
commit 6200559
Showing
17 changed files
with
1,108 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const EXECUTED_A_MACRO = 'Executed a macro'; | ||
export const SENT_MESSAGE = 'Sent a message'; | ||
export const SENT_PRIVATE_NOTE = 'Sent a private note'; | ||
export const INSERTED_A_CANNED_RESPONSE = 'Inserted a canned response'; | ||
export const USED_MENTIONS = 'Used mentions'; | ||
export const MERGED_CONTACTS = 'Used merge contact option'; | ||
export const ADDED_TO_CANNED_RESPONSE = 'Used added to canned response option'; | ||
export const ADDED_A_CUSTOM_ATTRIBUTE = 'Added a custom attribute'; | ||
export const ADDED_AN_INBOX = 'Added an inbox'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { AnalyticsBrowser } from '@june-so/analytics-next'; | ||
|
||
class AnalyticsHelper { | ||
constructor({ token: analyticsToken } = {}) { | ||
this.analyticsToken = analyticsToken; | ||
this.analytics = null; | ||
this.user = {}; | ||
} | ||
|
||
async init() { | ||
if (!this.analyticsToken) { | ||
return; | ||
} | ||
|
||
let [analytics] = await AnalyticsBrowser.load({ | ||
writeKey: this.analyticsToken, | ||
}); | ||
this.analytics = analytics; | ||
} | ||
|
||
identify(user) { | ||
if (!this.analytics) { | ||
return; | ||
} | ||
this.user = user; | ||
this.analytics.identify(this.user.email, { | ||
userId: this.user.id, | ||
email: this.user.email, | ||
name: this.user.name, | ||
avatar: this.user.avatar_url, | ||
}); | ||
|
||
const { accounts, account_id: accountId } = this.user; | ||
const [currentAccount] = accounts.filter( | ||
account => account.id === accountId | ||
); | ||
if (currentAccount) { | ||
this.analytics.group(currentAccount.id, this.user.id, { | ||
name: currentAccount.name, | ||
}); | ||
} | ||
} | ||
|
||
track(eventName, properties = {}) { | ||
if (!this.analytics) { | ||
return; | ||
} | ||
|
||
this.analytics.track({ | ||
userId: this.user.id, | ||
event: eventName, | ||
properties, | ||
}); | ||
} | ||
|
||
page(params) { | ||
if (!this.analytics) { | ||
return; | ||
} | ||
|
||
this.analytics.page(params); | ||
} | ||
} | ||
|
||
export * as ANALYTICS_EVENTS from './events'; | ||
|
||
export default new AnalyticsHelper(window.analyticsConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.