Skip to content

Commit f1438be

Browse files
committed
add Feedback types
1 parent c17b008 commit f1438be

File tree

6 files changed

+35
-3
lines changed

6 files changed

+35
-3
lines changed

packages/types/src/datacategory.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ export type DataCategory =
2424
| 'profile'
2525
// Check-in event (monitor)
2626
| 'monitor'
27+
// Feedback type event (v2)
28+
| 'feedback'
2729
// Unknown data category
2830
| 'unknown';

packages/types/src/envelope.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { SerializedCheckIn } from './checkin';
22
import type { ClientReport } from './clientreport';
33
import type { DsnComponents } from './dsn';
44
import type { Event } from './event';
5+
import type { FeedbackEvent } from './feedback';
56
import type { ReplayEvent, ReplayRecordingData } from './replay';
67
import type { SdkInfo } from './sdkinfo';
78
import type { SerializedSession, Session, SessionAggregates } from './session';
@@ -26,6 +27,7 @@ export type DynamicSamplingContext = {
2627
export type EnvelopeItemType =
2728
| 'client_report'
2829
| 'user_report'
30+
| 'feedback'
2931
| 'session'
3032
| 'sessions'
3133
| 'transaction'
@@ -57,7 +59,7 @@ type BaseEnvelope<EnvelopeHeader, Item> = [
5759
];
5860

5961
type EventItemHeaders = {
60-
type: 'event' | 'transaction' | 'profile';
62+
type: 'event' | 'transaction' | 'profile' | 'feedback';
6163
};
6264
type AttachmentItemHeaders = {
6365
type: 'attachment';
@@ -67,6 +69,7 @@ type AttachmentItemHeaders = {
6769
attachment_type?: string;
6870
};
6971
type UserFeedbackItemHeaders = { type: 'user_report' };
72+
type FeedbackItemHeaders = { type: 'feedback' };
7073
type SessionItemHeaders = { type: 'session' };
7174
type SessionAggregatesItemHeaders = { type: 'sessions' };
7275
type ClientReportItemHeaders = { type: 'client_report' };
@@ -87,6 +90,7 @@ export type CheckInItem = BaseEnvelopeItem<CheckInItemHeaders, SerializedCheckIn
8790
type ReplayEventItem = BaseEnvelopeItem<ReplayEventItemHeaders, ReplayEvent>;
8891
type ReplayRecordingItem = BaseEnvelopeItem<ReplayRecordingItemHeaders, ReplayRecordingData>;
8992
export type StatsdItem = BaseEnvelopeItem<StatsdItemHeaders, string>;
93+
export type FeedbackItem = BaseEnvelopeItem<FeedbackItemHeaders, FeedbackEvent>;
9094

9195
export type EventEnvelopeHeaders = { event_id: string; sent_at: string; trace?: DynamicSamplingContext };
9296
type SessionEnvelopeHeaders = { sent_at: string };
@@ -95,7 +99,10 @@ type ClientReportEnvelopeHeaders = BaseEnvelopeHeaders;
9599
type ReplayEnvelopeHeaders = BaseEnvelopeHeaders;
96100
type StatsdEnvelopeHeaders = BaseEnvelopeHeaders;
97101

98-
export type EventEnvelope = BaseEnvelope<EventEnvelopeHeaders, EventItem | AttachmentItem | UserFeedbackItem>;
102+
export type EventEnvelope = BaseEnvelope<
103+
EventEnvelopeHeaders,
104+
EventItem | AttachmentItem | UserFeedbackItem | FeedbackItem
105+
>;
99106
export type SessionEnvelope = BaseEnvelope<SessionEnvelopeHeaders, SessionItem>;
100107
export type ClientReportEnvelope = BaseEnvelope<ClientReportEnvelopeHeaders, ClientReportItem>;
101108
export type ReplayEnvelope = [ReplayEnvelopeHeaders, [ReplayEventItem, ReplayRecordingItem]];

packages/types/src/event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface Event {
6161
* Note that `ErrorEvent`s do not have a type (hence its undefined),
6262
* while all other events are required to have one.
6363
*/
64-
export type EventType = 'transaction' | 'profile' | 'replay_event' | undefined;
64+
export type EventType = 'transaction' | 'profile' | 'replay_event' | 'feedback' | undefined;
6565

6666
export interface ErrorEvent extends Event {
6767
type: undefined;

packages/types/src/feedback.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { Event } from './event';
2+
3+
export interface FeedbackContext extends Record<string, unknown> {
4+
message: string;
5+
contact_email?: string;
6+
name?: string;
7+
replay_id?: string;
8+
url?: string;
9+
}
10+
11+
/**
12+
* NOTE: These types are still considered Alpha and subject to change.
13+
* @hidden
14+
*/
15+
export interface FeedbackEvent extends Event {
16+
type: 'feedback';
17+
contexts: Event['contexts'] & {
18+
feedback: FeedbackContext;
19+
};
20+
}

packages/types/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export type {
3636
EventEnvelopeHeaders,
3737
EventItem,
3838
ReplayEnvelope,
39+
FeedbackItem,
3940
SessionEnvelope,
4041
SessionItem,
4142
UserFeedbackItem,
@@ -69,6 +70,7 @@ export type {
6970
Profile,
7071
} from './profiling';
7172
export type { ReplayEvent, ReplayRecordingData, ReplayRecordingMode } from './replay';
73+
export type {FeedbackEvent} from './feedback';
7274
export type { QueryParams, Request, SanitizedRequestData } from './request';
7375
export type { Runtime } from './runtime';
7476
export type { CaptureContext, Scope, ScopeContext } from './scope';

packages/utils/src/envelope.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ const ITEM_TYPE_TO_DATA_CATEGORY_MAP: Record<EnvelopeItemType, DataCategory> = {
208208
replay_event: 'replay',
209209
replay_recording: 'replay',
210210
check_in: 'monitor',
211+
feedback: 'feedback',
211212
// TODO: This is a temporary workaround until we have a proper data category for metrics
212213
statsd: 'unknown',
213214
};

0 commit comments

Comments
 (0)