Skip to content

Commit

Permalink
fix(ui): some t&w fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-delirium committed Jan 23, 2024
1 parent b22d943 commit 463ca8f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 27 deletions.
4 changes: 0 additions & 4 deletions frontend/app/components/Session/Player/TagWatch/TagWatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ function TagWatch() {
<div className={'text-disabled-text text-sm'}>
Create and filter sessions by ‘watch elements’ to determine if they rendered or not.
</div>
<div className={'w-full border border-b-light-gray'} />
<Button type={'link'} icon={<SearchOutlined />}>
Find session with selector
</Button>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ function CaptureRate(props: Props) {
updateCaptureConditions(projectId!, {
rate: parseInt(captureRate, 10),
conditionalCapture: conditionalCapture,
conditions: conditions.map((c) => c.toCaptureCondition()),
conditions: isEnterprise ? conditions.map((c) => c.toCaptureCondition()) : [],
}).finally(() => setChanged(false));
};

const updateDisabled = !changed || !isAdmin || (conditionalCapture && conditions.length === 0);
const updateDisabled = !changed || !isAdmin || (isEnterprise && (conditionalCapture && conditions.length === 0));
return (
<Drawer
size={'large'}
Expand Down Expand Up @@ -104,7 +104,7 @@ function CaptureRate(props: Props) {
<Switch
checked={conditionalCapture}
onChange={toggleRate}
checkedChildren={'Conditional'}
checkedChildren={isEnterprise ? 'All' : 'Conditional'}
disabled={!isAdmin}
unCheckedChildren={'Capture Rate'}
/>
Expand Down
2 changes: 1 addition & 1 deletion tracker/tracker-assist/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openreplay/tracker-assist",
"description": "Tracker plugin for screen assistance through the WebRTC",
"version": "8.0.0",
"version": "8.0.0-beta.9",
"keywords": [
"WebRTC",
"assistance",
Expand Down
2 changes: 1 addition & 1 deletion tracker/tracker-assist/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const pkgVersion = '7.0.4'
export const pkgVersion = '8.0.0-beta.9'
2 changes: 1 addition & 1 deletion tracker/tracker/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openreplay/tracker",
"description": "The OpenReplay tracker main package",
"version": "12.0.0",
"version": "12.0.0-beta.10",
"keywords": [
"logging",
"replay"
Expand Down
7 changes: 0 additions & 7 deletions tracker/tracker/src/main/modules/conditionsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,9 @@ export default class ConditionsManager {
customEvent(message: CustomEvent) {
// name - 1, payload - 2
const evConds = this.conditions.filter((c) => c.type === 'custom_event') as CommonCondition[]
console.log(message, evConds)
if (evConds.length) {
evConds.forEach((evCond) => {
const operator = operators[evCond.operator] as (a: string, b: string[]) => boolean
console.log(
operator,
evCond,
operator(message[1], evCond.value),
operator(message[2], evCond.value),
)
if (
operator &&
(operator(message[1], evCond.value) || operator(message[2], evCond.value))
Expand Down
3 changes: 2 additions & 1 deletion tracker/tracker/src/main/modules/tagWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class TagWatcher {
.then(({ tags }: { tags: { id: number; selector: string }[] }) => {
if (tags && tags.length) {
this.setTags(tags)
this.sessionStorage.setItem(WATCHED_TAGS_KEY, JSON.stringify(tags) || '')
const tagString = JSON.stringify(tags)
this.sessionStorage.setItem(WATCHED_TAGS_KEY, tagString || '')
}
})
.catch((e) => this.errLog(e))
Expand Down
37 changes: 28 additions & 9 deletions tracker/tracker/src/tests/tagWatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,43 @@ describe('TagWatcher', () => {

test('constructor initializes with tags from sessionStorage', () => {
// @ts-ignore
sessionStorageMock.getItem.mockReturnValue('div,span')
sessionStorageMock.getItem.mockReturnValue(
'[{"id":1,"selector":"div"},{"id":2,"selector":"span"}]',
)
const watcher = new TagWatcher(sessionStorageMock, errLogMock, onTag)
expect(watcher.tags).toEqual(['div', 'span'])
expect(watcher.intervals).toHaveProperty('div')
expect(watcher.intervals).toHaveProperty('span')
expect(watcher.tags).toEqual([
{ id: 1, selector: 'div' },
{ id: 2, selector: 'span' },
])
expect(watcher.intervals).toHaveProperty('1')
expect(watcher.intervals).toHaveProperty('2')
})

test('fetchTags sets tags and updates sessionStorage', async () => {
// @ts-ignore
global.fetch = jest.fn(() =>
Promise.resolve({
json: () => Promise.resolve(['div', 'span', 'p']),
json: () =>
Promise.resolve({
tags: [
{ id: 1, selector: 'div' },
{ id: 2, selector: 'span' },
{ id: 3, selector: 'p' },
],
}),
}),
)
const watcher = new TagWatcher(sessionStorageMock, errLogMock, onTag)
await watcher.fetchTags('https://localhost.com', '123')
expect(watcher.tags).toEqual(['div', 'span', 'p'])
expect(sessionStorageMock.setItem).toHaveBeenCalledWith(WATCHED_TAGS_KEY, 'div,span,p')
expect(watcher.tags).toEqual([
{ id: 1, selector: 'div' },
{ id: 2, selector: 'span' },
{ id: 3, selector: 'p' },
])
expect(sessionStorageMock.setItem).toHaveBeenCalledWith(
WATCHED_TAGS_KEY,
'[{"id":1,"selector":"div"},{"id":2,"selector":"span"},{"id":3,"selector":"p"}]',
)
})

test('setTags sets intervals for each tag', () => {
Expand All @@ -73,8 +92,8 @@ describe('TagWatcher', () => {
{ id: 1, selector: 'div' },
{ id: 2, selector: 'p' },
])
expect(watcher.intervals).toHaveProperty('div')
expect(watcher.intervals).toHaveProperty('p')
expect(watcher.intervals).toHaveProperty('1')
expect(watcher.intervals).toHaveProperty('2')
expect(mockObserve).not.toHaveBeenCalled() // No elements to observe initially
})

Expand Down

0 comments on commit 463ca8f

Please sign in to comment.