Skip to content

Commit

Permalink
♻️ [RUMF-1277] rename frustration types
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitZugmeyer committed May 23, 2022
1 parent de418d9 commit 0de509f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ describe('createRageClickChain', () => {
const clicks = [createFakeClick(), createFakeClick(), createFakeClick()]
createValidatedRageClickChain(clicks)
const expectedFrustrations = new Set()
expectedFrustrations.add(FrustrationType.RAGE)
expectedFrustrations.add(FrustrationType.RAGE_CLICK)
expect(clicks[0].clonedClick?.getFrustrations()).toEqual(expectedFrustrations)
})

it('the rage click should contains other clicks frustration', () => {
const clicks = [createFakeClick(), createFakeClick(), createFakeClick()]
clicks[1].addFrustration(FrustrationType.DEAD)
clicks[1].addFrustration(FrustrationType.DEAD_CLICK)
createValidatedRageClickChain(clicks)
expect(clicks[0].clonedClick?.getFrustrations().has(FrustrationType.RAGE)).toBe(true)
expect(clicks[0].clonedClick?.getFrustrations().has(FrustrationType.RAGE_CLICK)).toBe(true)
})

function createValidatedRageClickChain(clicks: Click[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function finalizeClicks(clicks: Click[], rageClick: Click) {
rageClick.addFrustration(frustration)
})
})
rageClick.addFrustration(FrustrationType.RAGE)
rageClick.addFrustration(FrustrationType.RAGE_CLICK)
rageClick.validate(timeStampNow())
} else {
rageClick.discard()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ describe('trackClickActions', () => {

clock.tick(EXPIRE_DELAY)
expect(events.length).toBe(1)
expect(events[0].frustrationTypes).toEqual([FrustrationType.DEAD])
expect(events[0].frustrationTypes).toEqual([FrustrationType.DEAD_CLICK])
expect(findActionId()).toEqual([])
})

Expand Down Expand Up @@ -288,7 +288,7 @@ describe('trackClickActions', () => {
clock.tick(EXPIRE_DELAY)
expect(events.length).toBe(1)
expect(events[0].startClocks.timeStamp).toBe(firstClickTimeStamp)
expect(events[0].frustrationTypes).toEqual([FrustrationType.RAGE])
expect(events[0].frustrationTypes).toEqual([FrustrationType.RAGE_CLICK])
expect(events[0].duration).toBe((MAX_DURATION_BETWEEN_CLICKS + 2 * actionDuration) as Duration)
})

Expand All @@ -310,7 +310,11 @@ describe('trackClickActions', () => {
clock.tick(EXPIRE_DELAY)
expect(events.length).toBe(1)
expect(events[0].frustrationTypes).toEqual(
jasmine.arrayWithExactContents([FrustrationType.DEAD, FrustrationType.ERROR, FrustrationType.RAGE])
jasmine.arrayWithExactContents([
FrustrationType.DEAD_CLICK,
FrustrationType.ERROR_CLICK,
FrustrationType.RAGE_CLICK,
])
)
})
})
Expand All @@ -325,7 +329,7 @@ describe('trackClickActions', () => {

clock.tick(EXPIRE_DELAY)
expect(events.length).toBe(1)
expect(events[0].frustrationTypes).toEqual([FrustrationType.ERROR])
expect(events[0].frustrationTypes).toEqual([FrustrationType.ERROR_CLICK])
})

// eslint-disable-next-line max-len
Expand All @@ -338,7 +342,7 @@ describe('trackClickActions', () => {
clock.tick(EXPIRE_DELAY)
expect(events.length).toBe(1)
expect(events[0].frustrationTypes).toEqual(
jasmine.arrayWithExactContents([FrustrationType.ERROR, FrustrationType.DEAD])
jasmine.arrayWithExactContents([FrustrationType.ERROR_CLICK, FrustrationType.DEAD_CLICK])
)
})
})
Expand All @@ -351,7 +355,7 @@ describe('trackClickActions', () => {

clock.tick(EXPIRE_DELAY)
expect(events.length).toBe(1)
expect(events[0].frustrationTypes).toEqual([FrustrationType.DEAD])
expect(events[0].frustrationTypes).toEqual([FrustrationType.DEAD_CLICK])
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function trackClickActions(
// If it has no activity, consider it as a dead click.
// TODO: this will yield a lot of false positive. We'll need to refine it in the future.
if (trackFrustrations) {
click.addFrustration(FrustrationType.DEAD)
click.addFrustration(FrustrationType.DEAD_CLICK)
click.stop()
} else {
click.discard()
Expand Down Expand Up @@ -240,7 +240,7 @@ function newClick(
}

if (eventCountsSubscription.eventCounts.errorCount > 0) {
addFrustration(FrustrationType.ERROR)
addFrustration(FrustrationType.ERROR_CLICK)
}

const { resourceCount, errorCount, longTaskCount } = eventCountsSubscription.eventCounts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe('rum track view metrics', () => {
action: {
type: 'click',
frustration: {
type: [FrustrationType.DEAD, FrustrationType.ERROR],
type: [FrustrationType.DEAD_CLICK, FrustrationType.ERROR_CLICK],
},
},
} as RumEvent & Context)
Expand Down
2 changes: 1 addition & 1 deletion packages/rum-core/src/domain/trackEventCounts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('trackEventCounts', () => {
action: {
type: 'click',
frustration: {
type: [FrustrationType.ERROR, FrustrationType.DEAD],
type: [FrustrationType.ERROR_CLICK, FrustrationType.DEAD_CLICK],
},
},
})
Expand Down
6 changes: 3 additions & 3 deletions packages/rum-core/src/rawRumEvent.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ export const enum ActionType {
}

export const enum FrustrationType {
RAGE = 'rage',
ERROR = 'error',
DEAD = 'dead',
RAGE_CLICK = 'rage_click',
ERROR_CLICK = 'error_click',
DEAD_CLICK = 'dead_click',
}

export type RawRumEvent =
Expand Down

0 comments on commit 0de509f

Please sign in to comment.