Skip to content

Commit dae5915

Browse files
committed
docs(feedback): Fix migration docs and document Actor methods
1 parent 1390402 commit dae5915

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

docs/migration/feedback.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ Below you can find a list of relevant feedback changes and issues that have been
1414
We have streamlined the interface for interacting with the Feedback widget. Below is a list of public functions that
1515
existed in 7.x and a description of how they have changed in v8.
1616

17-
| Method Name | Replacement | Notes |
18-
| ------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19-
| `Sentry.getClient<BrowserClient>()?.getIntegration(Feedback)` | `const feedback = Sentry.getFeedback()` | Get a type-safe reference to the configured feedbackIntegration instance. |
20-
| `feedback.getWidget()` | `const widget = feedback.createWidget(); widget.appendToDom()` | The SDK no longer maintains a stack of form instances. If you call `createWidget()` a new widget will be inserted into the DOM and an `ActorComponent` returned allows you control over the lifecycle of the widget. |
21-
| `feedback.openDialog()` | `widget.open()` | Make the form inside the widget visible. |
22-
| `feedback.closeDialog()` | `widget.close()` | Make the form inside the widget hidden in the page. Success/Error messages will still be rendered and will hide themselves if the form was recently submitted. |
23-
| `feedback.removeWidget()` | `widget.removeFromDom()` | Remove the form and widget instance from the page. After calling this `widget.el.parentNode` will be set to null. |
24-
| `feedback.attachTo()` | `const unsubscribe = feedback.attachTo(myButtonElem)` | The `attachTo()` method will create an onClick event listener to your html element that calls `appendToDom()` and `open()`. It returns a callback to remove the event listener. |
25-
| - | `const form = await feedback.createForm()` | A new method `createForm()`, used internally by `createWidget()` and `attachTo()`, returns a `Promise<FeedbackDialog>` so you can control showing and hiding of the feedback form directly. |
17+
| Method Name | Replacement | Notes |
18+
| ------------------------------------------------------------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19+
| `Sentry.getClient<BrowserClient>()?.getIntegration(Feedback)` | `const feedback = Sentry.getFeedback()` | Get a type-safe reference to the configured feedbackIntegration instance. |
20+
| `feedback.getWidget()` | `const actor = feedback.createWidget(); actor.appendToDom()` | The SDK no longer maintains a stack of form instances. If you call `createWidget()` a new widget will be inserted into the DOM and an `ActorComponent` returned allows you control over the lifecycle of the widget. |
21+
| `feedback.removeWidget()` | `actor.removeFromDom()` | Remove the form and widget instance from the page. After calling this `widget.el.parentNode` will be set to null. |
22+
| `feedback.attachTo()` | `const unsubscribe = feedback.attachTo(myButtonElem)` | The `attachTo()` method will create an onClick event listener to your html element that calls `appendToDom()` and `open()`. It returns a callback to remove the event listener. |
23+
| - | `const form = await feedback.createForm()` | A new method `createForm()`, used internally by `createWidget()` and `attachTo()`, returns a `Promise<FeedbackDialog>` so you can control showing and hiding of the feedback form directly. |
24+
| `feedback.openDialog()` | `form.open()` | Make the form inside the widget visible. |
25+
| `feedback.closeDialog()` | `form.close()` | Make the form inside the widget hidden in the page. Success/Error messages will still be rendered and will hide themselves if the form was recently submitted. |
2626

2727
### API Examples
2828

packages/feedback/src/core/components/Actor.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,37 @@ export interface ActorProps {
88
}
99

1010
export interface ActorComponent {
11+
/**
12+
* The HTMLButtonElement
13+
*/
1114
el: HTMLElement;
1215

16+
/**
17+
* Insert the button into the Shadow DOM.
18+
*
19+
* The button is visible by default and will hide itself when the form is open.
20+
*/
1321
appendToDom: () => void;
1422

23+
/**
24+
* Remove the button from the Shadow DOM.
25+
*
26+
* If the form has been opened by the user, but not submitted, it will remain open and in the DOM.
27+
*/
1528
removeFromDom: () => void;
1629

30+
/**
31+
* Show the button
32+
*
33+
* Called automatically when the dialog is submitted or closed.
34+
*/
1735
show: () => void;
1836

37+
/**
38+
* Hide the button
39+
*
40+
* Called automatically when the button is clicked and the dialog is revealed.
41+
*/
1942
hide: () => void;
2043
}
2144

packages/feedback/src/core/createMainStyles.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { FeedbackInternalOptions } from '@sentry/types';
22
import { DOCUMENT } from '../constants';
33

44
const PURPLE = 'rgba(88, 74, 192, 1)';
5+
const WHITE = '#ffffff';
56

67
interface InternalTheme extends NonNullable<FeedbackInternalOptions['themeLight']> {
78
border: string;
@@ -10,8 +11,8 @@ interface InternalTheme extends NonNullable<FeedbackInternalOptions['themeLight'
1011

1112
const DEFAULT_LIGHT: InternalTheme = {
1213
foreground: '#2b2233',
13-
background: '#ffffff',
14-
accentForeground: 'white',
14+
background: WHITE,
15+
accentForeground: WHITE,
1516
accentBackground: PURPLE,
1617
successColor: '#268d75',
1718
errorColor: '#df3338',
@@ -23,7 +24,7 @@ const DEFAULT_LIGHT: InternalTheme = {
2324
const DEFAULT_DARK: InternalTheme = {
2425
foreground: '#ebe6ef',
2526
background: '#29232f',
26-
accentForeground: 'white',
27+
accentForeground: WHITE,
2728
accentBackground: PURPLE,
2829
successColor: '#2da98c',
2930
errorColor: '#f55459',

packages/types/src/feedback/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface FeedbackInternalOptions
2525
type HTMLElement = unknown;
2626
export interface FeedbackDialog {
2727
/**
28-
* The HTMLElement that is containing all the form content
28+
* The HTMLElement that contains all the form content
2929
*/
3030
el: HTMLElement;
3131

0 commit comments

Comments
 (0)