-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from Giveth/feature/allow_admin_canceled_proj…
…ects Feature: Add admin canceled project status
- Loading branch information
Showing
5 changed files
with
124 additions
and
44 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
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,46 @@ | ||
import { User } from '../../entities/user'; | ||
import { Project } from '../../entities/project'; | ||
import { getAnalytics } from '../../analytics'; | ||
|
||
const analytics = getAnalytics() | ||
|
||
/** | ||
* Notifies Segment any event concerning the project | ||
*/ | ||
class ProjectTracker { | ||
project: Project | ||
eventName: string | ||
projectOwner?: User | ||
|
||
constructor(projectToUpdate: Project, eventTitle: string) { | ||
this.project = projectToUpdate | ||
this.eventName = eventTitle | ||
} | ||
|
||
async track() { | ||
this.projectOwner = await User.findOne({ id: Number(this.project.admin) }) | ||
|
||
if(this.projectOwner) { | ||
analytics.track( | ||
this.eventName, | ||
this.projectOwner.segmentUserId(), | ||
this.segmentProjectAttributes(), | ||
null | ||
) | ||
} | ||
} | ||
|
||
private segmentProjectAttributes() { | ||
return { | ||
email: this.projectOwner?.email, | ||
title: this.project.title, | ||
lastName: this.projectOwner?.lastName, | ||
firstName: this.projectOwner?.firstName, | ||
OwnerId: this.projectOwner?.id, | ||
slug: this.project.slug, | ||
walletAddress: this.project.walletAddress | ||
} | ||
} | ||
} | ||
|
||
export default ProjectTracker; |