satellite/analytics: Track events generated from navigation and dashboard (#4795)

satellite/analytics: Track events generated from navigation and dashboard
This commit is contained in:
prerna-parashar 2022-05-18 12:49:10 -07:00 committed by GitHub
parent 0e0437cc9f
commit 14ebba0d77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 83 additions and 29 deletions

View File

@ -15,22 +15,34 @@ import (
)
const (
eventAccountCreated = "Account Created"
eventSignedIn = "Signed In"
eventProjectCreated = "Project Created"
eventAccessGrantCreated = "Access Grant Created"
eventAccountVerified = "Account Verified"
eventGatewayCredentialsCreated = "Credentials Created"
eventPassphraseCreated = "Passphrase Created"
eventExternalLinkClicked = "External Link Clicked"
eventPathSelected = "Path Selected"
eventLinkShared = "Link Shared"
eventObjectUploaded = "Object Uploaded"
eventAPIKeyGenerated = "API Key Generated"
eventCreditCardAdded = "Credit Card Added"
eventUpgradeBannerClicked = "Upgrade Banner Clicked"
eventModalAddCard = "Credit Card Added In Modal"
eventModalAddTokens = "Storj Token Added In Modal"
eventAccountCreated = "Account Created"
eventSignedIn = "Signed In"
eventProjectCreated = "Project Created"
eventAccessGrantCreated = "Access Grant Created"
eventAccountVerified = "Account Verified"
eventGatewayCredentialsCreated = "Credentials Created"
eventPassphraseCreated = "Passphrase Created"
eventExternalLinkClicked = "External Link Clicked"
eventPathSelected = "Path Selected"
eventLinkShared = "Link Shared"
eventObjectUploaded = "Object Uploaded"
eventAPIKeyGenerated = "API Key Generated"
eventCreditCardAdded = "Credit Card Added"
eventUpgradeBannerClicked = "Upgrade Banner Clicked"
eventModalAddCard = "Credit Card Added In Modal"
eventModalAddTokens = "Storj Token Added In Modal"
eventSearchBuckets = "Search Buckets"
eventNavigateProjects = "Navigate Projects"
eventManageProjectsClicked = "Manage Projects Clicked"
eventCreateNewClicked = "Create New Clicked"
eventViewDocsClicked = "View Docs Clicked"
eventViewForumClicked = "View Forum Clicked"
eventViewSupportClicked = "View Support Clicked"
eventCreateAnAccessGrantClicked = "Create an Access Grant Clicked"
eventUploadUsingCliClicked = "Upload Using CLI Clicked"
eventUploadInWebClicked = "Upload In Web Clicked"
eventNewProjectClicked = "New Project Clicked"
eventLogoutClicked = "Logout Clicked"
)
var (
@ -72,7 +84,9 @@ func NewService(log *zap.Logger, config Config, satelliteName string) *Service {
}
for _, name := range []string{eventGatewayCredentialsCreated, eventPassphraseCreated, eventExternalLinkClicked,
eventPathSelected, eventLinkShared, eventObjectUploaded, eventAPIKeyGenerated, eventUpgradeBannerClicked,
eventModalAddCard, eventModalAddTokens} {
eventModalAddCard, eventModalAddTokens, eventSearchBuckets, eventNavigateProjects, eventManageProjectsClicked,
eventCreateNewClicked, eventViewDocsClicked, eventViewForumClicked, eventViewSupportClicked, eventCreateAnAccessGrantClicked,
eventUploadUsingCliClicked, eventUploadInWebClicked, eventNewProjectClicked, eventLogoutClicked} {
service.clientEvents[name] = true
}

View File

@ -61,6 +61,9 @@ import ArrowImage from '@/../static/images/navigation/arrowExpandRight.svg';
import SettingsIcon from '@/../static/images/navigation/settings.svg';
import LogoutIcon from '@/../static/images/navigation/logout.svg';
import { AnalyticsHttpApi } from '@/api/analytics';
import { AnalyticsEvent } from '@/utils/constants/analyticsEventNames';
// @vue/component
@Component({
components: {
@ -77,6 +80,8 @@ export default class AccountArea extends Vue {
private dropdownYPos = 0;
private dropdownXPos = 0;
private readonly analytics: AnalyticsHttpApi = new AnalyticsHttpApi();
public $refs!: {
accountArea: HTMLDivElement,
}
@ -96,6 +101,7 @@ export default class AccountArea extends Vue {
await this.$router.push(RouteConfig.Login.path);
try {
this.analytics.eventTriggered(AnalyticsEvent.LOGOUT_CLICKED);
await this.auth.logout();
} catch (error) {
await this.$notify.error(error.message);

View File

@ -48,7 +48,7 @@
href="https://docs.storj.io/"
target="_blank"
rel="noopener noreferrer"
@click.prevent="trackExternalLinkClickEvent('https://docs.storj.io/')"
@click.prevent="trackViewDocsEvent('https://docs.storj.io/')"
>
<DocsIcon class="dropdown-item__icon" />
<div class="dropdown-item__text">
@ -62,7 +62,7 @@
href="https://forum.storj.io/"
target="_blank"
rel="noopener noreferrer"
@click.prevent="trackExternalLinkClickEvent('https://forum.storj.io/')"
@click.prevent="trackViewForumEvent('https://forum.storj.io/')"
>
<ForumIcon class="dropdown-item__icon" />
<div class="dropdown-item__text">
@ -76,7 +76,7 @@
href="https://supportdcs.storj.io/hc/en-us"
target="_blank"
rel="noopener noreferrer"
@click.prevent="trackExternalLinkClickEvent('https://supportdcs.storj.io/hc/en-us')"
@click.prevent="trackViewSupportEvent('https://supportdcs.storj.io/hc/en-us')"
>
<SupportIcon class="dropdown-item__icon" />
<div class="dropdown-item__text">
@ -244,7 +244,7 @@ export default class NewNavigationArea extends Vue {
* Redirects to create project screen.
*/
public navigateToCreateAG(): void {
this.analytics.linkEventTriggered(AnalyticsEvent.PATH_SELECTED, "Create an Access Grant");
this.analytics.eventTriggered(AnalyticsEvent.CREATE_AN_ACCESS_GRANT_CLICKED);
this.closeDropdowns();
this.$router.push(RouteConfig.AccessGrants.with(RouteConfig.CreateAccessGrant).path).catch(() => {return;});
}
@ -253,7 +253,7 @@ export default class NewNavigationArea extends Vue {
* Redirects to objects screen.
*/
public navigateToBuckets(): void {
this.analytics.linkEventTriggered(AnalyticsEvent.PATH_SELECTED, "Buckets");
this.analytics.eventTriggered(AnalyticsEvent.UPLOAD_IN_WEB_CLICKED);
this.closeDropdowns();
this.$router.push(RouteConfig.Buckets.path).catch(() => {return;});
}
@ -262,7 +262,7 @@ export default class NewNavigationArea extends Vue {
* Redirects to onboarding CLI flow screen.
*/
public navigateToCLIFlow(): void {
this.analytics.linkEventTriggered(AnalyticsEvent.PATH_SELECTED, "Upload using CLI");
this.analytics.eventTriggered(AnalyticsEvent.UPLOAD_USING_CLI_CLICKED);
this.closeDropdowns();
this.$store.commit(APP_STATE_MUTATIONS.SET_ONB_AG_NAME_STEP_BACK_ROUTE, this.$route.path);
this.$router.push({name: RouteConfig.AGName.name});
@ -272,7 +272,7 @@ export default class NewNavigationArea extends Vue {
* Redirects to create access grant screen.
*/
public navigateToNewProject(): void {
this.analytics.linkEventTriggered(AnalyticsEvent.PATH_SELECTED, "New Project");
this.analytics.eventTriggered(AnalyticsEvent.NEW_PROJECT_CLICKED);
this.closeDropdowns();
this.$router.push(RouteConfig.CreateProject.path);
}
@ -358,10 +358,26 @@ export default class NewNavigationArea extends Vue {
}
/**
* Sends external link click event to segment and opens link.
* Sends "View Docs" event to segment and opens link.
*/
public trackExternalLinkClickEvent(link: string): void {
this.analytics.linkEventTriggered(AnalyticsEvent.EXTERNAL_LINK_CLICKED, link);
public trackViewDocsEvent(link: string): void {
this.analytics.eventTriggered(AnalyticsEvent.VIEW_DOCS_CLICKED);
window.open(link)
}
/**
* Sends "View Forum" event to segment and opens link.
*/
public trackViewForumEvent(link: string): void {
this.analytics.eventTriggered(AnalyticsEvent.VIEW_FORUM_CLICKED);
window.open(link)
}
/**
* Sends "View Support" event to segment and opens link.
*/
public trackViewSupportEvent(link: string): void {
this.analytics.eventTriggered(AnalyticsEvent.VIEW_SUPPORT_CLICKED);
window.open(link)
}

View File

@ -137,6 +137,7 @@ export default class NewProjectSelection extends Vue {
* @param projectID
*/
public async onProjectSelected(projectID: string): Promise<void> {
await this.analytics.eventTriggered(AnalyticsEvent.NAVIGATE_PROJECTS);
await this.$store.dispatch(PROJECTS_ACTIONS.SELECT, projectID);
LocalData.setSelectedProjectId(projectID);
await this.$store.dispatch(PM_ACTIONS.SET_SEARCH_QUERY, '');
@ -212,7 +213,7 @@ export default class NewProjectSelection extends Vue {
*/
public onProjectsLinkClick(): void {
if (this.$route.name !== RouteConfig.ProjectsList.name) {
this.analytics.linkEventTriggered(AnalyticsEvent.PATH_SELECTED, "Manage Projects");
this.analytics.eventTriggered(AnalyticsEvent.MANAGE_PROJECTS_CLICKED);
this.$router.push(RouteConfig.ProjectsList.path);
}
@ -224,7 +225,7 @@ export default class NewProjectSelection extends Vue {
*/
public onCreateLinkClick(): void {
if (this.$route.name !== RouteConfig.CreateProject.name) {
this.analytics.linkEventTriggered(AnalyticsEvent.PATH_SELECTED, "Create New Project");
this.analytics.eventTriggered(AnalyticsEvent.CREATE_NEW_CLICKED);
const user: User = this.$store.getters.user;
const ownProjectsCount: number = this.$store.getters.projectsCount;

View File

@ -48,6 +48,9 @@ import SortingHeader from '@/components/project/buckets/SortingHeader.vue';
import { BUCKET_ACTIONS } from '@/store/modules/buckets';
import { Bucket } from '@/types/buckets';
import { AnalyticsHttpApi } from '@/api/analytics';
import { AnalyticsEvent } from '@/utils/constants/analyticsEventNames';
const {FETCH, SET_SEARCH} = BUCKET_ACTIONS;
// @vue/component
@ -61,6 +64,7 @@ const {FETCH, SET_SEARCH} = BUCKET_ACTIONS;
},
})
export default class BucketArea extends Vue {
private readonly analytics: AnalyticsHttpApi = new AnalyticsHttpApi();
/**
* Lifecycle hook before component destruction where buckets search query is cleared.
*/
@ -136,6 +140,7 @@ export default class BucketArea extends Vue {
*/
public async fetch(searchQuery: string): Promise<void> {
await this.$store.dispatch(SET_SEARCH, searchQuery);
await this.analytics.eventTriggered(AnalyticsEvent.SEARCH_BUCKETS);
try {
await this.$store.dispatch(FETCH, 1);

View File

@ -13,4 +13,16 @@ export enum AnalyticsEvent {
UPGRADE_BANNER_CLICKED = 'Upgrade Banner Clicked',
MODAL_ADD_CARD = 'Credit Card Added In Modal',
MODAL_ADD_TOKENS = 'Storj Token Added In Modal',
SEARCH_BUCKETS = 'Search Buckets',
NAVIGATE_PROJECTS = 'Navigate Projects',
MANAGE_PROJECTS_CLICKED = 'Manage Projects Clicked',
CREATE_NEW_CLICKED = 'Create New Clicked',
VIEW_DOCS_CLICKED = 'View Docs Clicked',
VIEW_FORUM_CLICKED = 'View Forum Clicked',
VIEW_SUPPORT_CLICKED = 'View Support Clicked',
CREATE_AN_ACCESS_GRANT_CLICKED = 'Create an Access Grant Clicked',
UPLOAD_USING_CLI_CLICKED = 'Upload Using CLI Clicked',
UPLOAD_IN_WEB_CLICKED = 'Upload In Web Clicked',
NEW_PROJECT_CLICKED = 'New Project Clicked',
LOGOUT_CLICKED = 'Logout Clicked',
}