Skip to content

Commit

Permalink
feat: Add tracking to the UserInformation component (#1337)
Browse files Browse the repository at this point in the history
* feat: Add tracking to the UserInformation component

* feat: Upgrade decentraland-gatsby package

* fix: Remove uuid usage

* feat: Remove @types/uuid package

---------

Co-authored-by: Gabriel Diaz <[email protected]>
  • Loading branch information
LautaroPetaccio and cyaiox committed Oct 16, 2023
1 parent 89f2fdd commit aa2e709
Show file tree
Hide file tree
Showing 10 changed files with 3,038 additions and 471 deletions.
3,467 changes: 3,018 additions & 449 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"dayjs": "^1.11.9",
"dayjs-precise-range": "^1.0.1",
"dcl-catalyst-client": "^21.5.0",
"decentraland-gatsby": "^5.86.3",
"decentraland-gatsby": "^5.92.0",
"decentraland-ui": "^4.1.0",
"discord.js": "^14.7.1",
"dompurify": "^2.3.3",
Expand Down
6 changes: 3 additions & 3 deletions src/components/Layout/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useLocation } from '@reach/router'
import UserInformation, { UserInformationProps } from 'decentraland-gatsby/dist/components/User/UserInformation'
import UserInformation from 'decentraland-gatsby/dist/components/User/UserInformation'
import { Mobile, NotMobile } from 'decentraland-ui/dist/components/Media/Media'

import BurgerMenu from './BurgerMenu/BurgerMenu'

const BURGER_MENU_LOCATIONS = ['/', '/proposals/', '/transparency/', '/projects/', '/profile/']

function Navbar(props: UserInformationProps) {
function Navbar() {
const location = useLocation()
const showBurgerMenu = BURGER_MENU_LOCATIONS.some((burgerLocation) => burgerLocation === location.pathname)

Expand All @@ -18,7 +18,7 @@ function Navbar(props: UserInformationProps) {
</Mobile>
)}
<NotMobile>
<UserInformation {...props} />
<UserInformation />
</NotMobile>
</>
)
Expand Down
4 changes: 2 additions & 2 deletions src/entities/Proposal/testHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// eslint-disable @typescript-eslint/no-explicit-any
import crypto from 'crypto'
import JobContext from 'decentraland-gatsby/dist/entities/Job/context'
import { v1 as uuid } from 'uuid'

import Time from '../../utils/date/Time'
import { Budget } from '../Budget/types'
Expand Down Expand Up @@ -103,7 +103,7 @@ export function createTestProposal(
grantCategory?: NewGrantCategory
): ProposalAttributes {
const testProposalConfiguration = getTestProposalConfiguration(proposalType, grantSize, grantCategory)
const id = uuid()
const id = crypto.randomUUID()
return {
...BASIC_ATTRIBUTES,
id: `id-${proposalType.toString()}-${proposalStatus.toString()}-${id}`,
Expand Down
4 changes: 2 additions & 2 deletions src/entities/QuarterBudget/model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import crypto from 'crypto'
import { Model } from 'decentraland-gatsby/dist/entities/Database/model'
import { SQL, table } from 'decentraland-gatsby/dist/entities/Database/utils'
import snakeCase from 'lodash/snakeCase'
import { v1 as uuid } from 'uuid'

import { TransparencyBudget } from '../../clients/DclData'
import Time from '../../utils/date/Time'
Expand Down Expand Up @@ -61,7 +61,7 @@ export default class QuarterBudgetModel extends Model<QuarterBudgetAttributes> {

private static getNewQuarterBudget(transparencyBudget: TransparencyBudget, startAt: Date, finishAt: Date, now: Date) {
const newQuarterBudget: QuarterBudgetAttributes = {
id: uuid(),
id: crypto.randomUUID(),
total: transparencyBudget.total,
start_at: startAt,
finish_at: finishAt,
Expand Down
6 changes: 2 additions & 4 deletions src/entities/Updates/model.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { def } from 'bdd-lazy-var/getter'
import * as uuid from 'uuid'
import crypto from 'crypto'

import Time from '../../utils/date/Time'
import { getMonthsBetweenDates } from '../../utils/date/getMonthsBetweenDates'
Expand All @@ -8,8 +8,6 @@ import { VestingStartDate } from '../Grant/types'
import UpdateModel from './model'
import { UpdateStatus } from './types'

jest.mock('uuid')

const PROPOSAL_ID = '123'
const UUID = '00000000-0000-0000-0000-000000000000'

Expand All @@ -20,7 +18,7 @@ describe('UpdateModel', () => {
jest.clearAllMocks()
jest.spyOn(UpdateModel, 'createMany').mockImplementation((list: any) => list)
jest.spyOn(UpdateModel, 'delete').mockResolvedValue([] as any)
jest.spyOn(uuid, 'v1').mockReturnValue(UUID)
jest.spyOn(crypto, 'randomUUID').mockReturnValue(UUID)
jest.useFakeTimers('modern')
jest.setSystemTime(FAKE_NOW)
})
Expand Down
6 changes: 3 additions & 3 deletions src/entities/Updates/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import crypto from 'crypto'
import { Model } from 'decentraland-gatsby/dist/entities/Database/model'
import { v1 as uuid } from 'uuid'

import { VestingDates } from '../../clients/VestingData'
import Time from '../../utils/date/Time'
Expand Down Expand Up @@ -31,7 +31,7 @@ export default class UpdateModel extends Model<UpdateAttributes> {

const updates = Array.from(Array(updatesQuantity), (_, index) => {
const update: UpdateAttributes = {
id: uuid(),
id: crypto.randomUUID(),
proposal_id: proposalId,
status: UpdateStatus.Pending,
due_date: this.getDueDate(firstUpdateStartingDate, index),
Expand Down Expand Up @@ -68,7 +68,7 @@ export default class UpdateModel extends Model<UpdateAttributes> {
const now = new Date()

return await this.create({
id: uuid(),
id: crypto.randomUUID(),
status: UpdateStatus.Done,
due_date: undefined,
completion_date: now,
Expand Down
6 changes: 3 additions & 3 deletions src/entities/Updates/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { v1 as uuid } from 'uuid'
import crypto from 'crypto'

import Time from '../../utils/date/Time'

Expand All @@ -20,8 +20,8 @@ type GenerateUpdate = Pick<
| 'completion_date'
>
const generateUpdate = (update: GenerateUpdate): UpdateAttributes => ({
id: uuid(),
proposal_id: uuid(),
id: crypto.randomUUID(),
proposal_id: crypto.randomUUID(),
health: update.health,
introduction: update.introduction,
highlights: update.highlights,
Expand Down
4 changes: 2 additions & 2 deletions src/services/BadgesService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import crypto from 'crypto'
import logger from 'decentraland-gatsby/dist/entities/Development/logger'
import { v1 as uuid } from 'uuid'

import AirdropJobModel from '../back/models/AirdropJob'
import { VoteService } from '../back/services/vote'
Expand Down Expand Up @@ -177,7 +177,7 @@ export class BadgesService {
private static async queueAirdropJob(badgeSpec: string, recipients: string[]) {
logger.log(`Enqueueing airdrop job`, { badgeSpec, recipients })
try {
await AirdropJobModel.create({ id: uuid(), badge_spec: badgeSpec, recipients })
await AirdropJobModel.create({ id: crypto.randomUUID(), badge_spec: badgeSpec, recipients })
} catch (error) {
ErrorService.report('Unable to create AirdropJob', {
error,
Expand Down
4 changes: 2 additions & 2 deletions src/services/ProposalService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import crypto from 'crypto'
import logger from 'decentraland-gatsby/dist/entities/Development/logger'
import RequestError from 'decentraland-gatsby/dist/entities/Route/error'
import { v1 as uuid } from 'uuid'

import { VoteService } from '../back/services/vote'
import { Discourse, DiscourseComment, DiscoursePost } from '../clients/Discourse'
Expand Down Expand Up @@ -44,7 +44,7 @@ export class ProposalService {
throw new Error('Decentraland DAO Grants Program has been put on hold')
}

const proposalId = uuid()
const proposalId = crypto.randomUUID()
const proposalLifespan = this.getLifespan(proposalInCreation)
const coAuthors = this.getCoAuthors(proposalInCreation)

Expand Down

0 comments on commit aa2e709

Please sign in to comment.