Skip to content

Commit cf53bb2

Browse files
committed
ref: fix onDialogOpened, add option for host id
1 parent d1c2038 commit cf53bb2

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

packages/feedback/src/integration.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export class Feedback implements Integration {
8181
private hasDialogEverOpened: boolean;
8282

8383
public constructor({
84+
id = 'sentry-feedback',
8485
attachTo = null,
8586
autoInject = true,
8687
showEmail = true,
@@ -123,6 +124,7 @@ export class Feedback implements Integration {
123124
this.hasDialogEverOpened = false;
124125

125126
this.options = {
127+
id,
126128
attachTo,
127129
autoInject,
128130
isAnonymous,
@@ -174,7 +176,7 @@ export class Feedback implements Integration {
174176
if (this._host) {
175177
this.remove();
176178
}
177-
const existingFeedback = document.querySelector('#sentry-feedback');
179+
const existingFeedback = document.querySelector(`#${this.options.id}`);
178180
if (existingFeedback) {
179181
existingFeedback.remove();
180182
}
@@ -237,8 +239,8 @@ export class Feedback implements Integration {
237239
if (this._dialog) {
238240
this._dialog.open();
239241
this._isDialogOpen = true;
240-
if (this.options.onDialogOpened) {
241-
this.options.onDialogOpened();
242+
if (this.options.onDialogOpen) {
243+
this.options.onDialogOpen();
242244
}
243245
return;
244246
}
@@ -278,8 +280,8 @@ export class Feedback implements Integration {
278280
this._actor && this._actor.hide();
279281

280282
this.hasDialogEverOpened = true;
281-
if (this.options.onDialogOpened) {
282-
this.options.onDialogOpened();
283+
if (this.options.onDialogOpen) {
284+
this.options.onDialogOpen();
283285
}
284286
} catch (err) {
285287
// TODO: Error handling?
@@ -334,7 +336,7 @@ export class Feedback implements Integration {
334336

335337
// Create the host
336338
this._host = document.createElement('div');
337-
this._host.id = 'sentry-feedback';
339+
this._host.id = this.options.id;
338340

339341
// Create the shadow root
340342
const shadow = this._host.attachShadow({ mode: 'open' });

packages/feedback/src/types/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ export interface FeedbackFormData {
3535
}
3636

3737
export interface FeedbackConfigurationWithDefaults {
38+
/**
39+
* id to use for the main widget container (this will host the shadow DOM)
40+
*/
41+
id: string;
42+
3843
/**
3944
* DOM Selector to attach click listener to, for opening Feedback dialog.
4045
*/

0 commit comments

Comments
 (0)