Skip to content

Commit a6dcfde

Browse files
committed
ref trigger user activity
1 parent 2787039 commit a6dcfde

File tree

4 files changed

+26
-44
lines changed

4 files changed

+26
-44
lines changed

packages/replay/src/coreHandlers/handleHistory.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ export function handleHistorySpanListener(replay: ReplayContainer): (handlerData
3939

4040
// Need to collect visited URLs
4141
replay.getContext().urls.push(result.name);
42-
replay.triggerUserActivity();
43-
44-
replay.addUpdate(() => {
45-
createPerformanceSpans(replay, [result]);
46-
// Returning false to flush
47-
return false;
42+
replay.updateUserActivity();
43+
44+
replay.checkSessionState(() => {
45+
replay.addUpdate(() => {
46+
createPerformanceSpans(replay, [result]);
47+
// Returning false to flush
48+
return false;
49+
});
4850
});
4951
};
5052
}

packages/replay/src/coreHandlers/util/addBreadcrumbEvent.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,25 @@ export function addBreadcrumbEvent(replay: ReplayContainer, breadcrumb: Breadcru
1313
}
1414

1515
if (['ui.click', 'ui.input'].includes(breadcrumb.category as string)) {
16-
replay.triggerUserActivity();
17-
} else {
18-
replay.checkSessionState(() => {
19-
// noop
20-
});
16+
replay.updateUserActivity();
2117
}
2218

23-
replay.addUpdate(() => {
24-
void replay.throttledAddEvent({
25-
type: EventType.Custom,
26-
// TODO: We were converting from ms to seconds for breadcrumbs, spans,
27-
// but maybe we should just keep them as milliseconds
28-
timestamp: (breadcrumb.timestamp || 0) * 1000,
29-
data: {
30-
tag: 'breadcrumb',
31-
// normalize to max. 10 depth and 1_000 properties per object
32-
payload: normalize(breadcrumb, 10, 1_000),
33-
},
34-
});
19+
replay.checkSessionState(() => {
20+
replay.addUpdate(() => {
21+
void replay.throttledAddEvent({
22+
type: EventType.Custom,
23+
// TODO: We were converting from ms to seconds for breadcrumbs, spans,
24+
// but maybe we should just keep them as milliseconds
25+
timestamp: (breadcrumb.timestamp || 0) * 1000,
26+
data: {
27+
tag: 'breadcrumb',
28+
// normalize to max. 10 depth and 1_000 properties per object
29+
payload: normalize(breadcrumb, 10, 1_000),
30+
},
31+
});
3532

36-
// Do not flush after console log messages
37-
return breadcrumb.category === 'console';
33+
// Do not flush after console log messages
34+
return breadcrumb.category === 'console';
35+
});
3836
});
3937
}

packages/replay/src/replay.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -437,24 +437,7 @@ export class ReplayContainer implements ReplayContainerInterface {
437437
}
438438

439439
/**
440-
* Updates the user activity timestamp and resumes recording. This should be
441-
* called in an event handler for a user action that we consider as the user
442-
* being "active" (e.g. a mouse click).
443-
*/
444-
public triggerUserActivity(): void {
445-
this._updateSessionActivity();
446-
447-
this.checkSessionState(() => {
448-
// noop
449-
});
450-
}
451-
452-
/**
453-
* Updates the user activity timestamp *without* resuming
454-
* recording. Some user events (e.g. keydown) can be create
455-
* low-value replays that only contain the keypress as a
456-
* breadcrumb. Instead this would require other events to
457-
* create a new replay after a session has expired.
440+
* Updates the user activity timestamp.
458441
*/
459442
public updateUserActivity(): void {
460443
this._updateSessionActivity();

packages/replay/src/types/replay.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ export interface ReplayContainer {
421421
flush(): Promise<void>;
422422
flushImmediate(): Promise<void>;
423423
cancelFlush(): void;
424-
triggerUserActivity(): void;
425424
updateUserActivity(): void;
426425
addUpdate(cb: AddUpdateCallback): void;
427426
getOptions(): ReplayPluginOptions;

0 commit comments

Comments
 (0)