Skip to content

Commit

Permalink
feat(www): add a form field to distinguish new style form submissions…
Browse files Browse the repository at this point in the history
… in salesforce (#1748)

* feat(www): add a form field to distinguish legacy from new submitted forms in sentry and salesforce

* Add test for sending the values to error reporter.

* Use a version instead of a boolean on the app side.
  • Loading branch information
sbruens authored Oct 9, 2023
1 parent 742b6a5 commit baa7b01
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/www/shared/error_reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import * as Sentry from '@sentry/browser';
import {Integration as SentryIntegration} from '@sentry/types';

export type Tags = {[id: string]: string};
export type Tags = {[id: string]: string | boolean | number};

export interface OutlineErrorReporter {
report(userFeedback: string, feedbackCategory: string, userEmail?: string, tags?: Tags): Promise<void>;
Expand Down
17 changes: 17 additions & 0 deletions src/www/views/contact_view/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ describe('ContactView client variant', () => {
expect(supportForm).not.toBeNull();
});

it('reports correct values to error reporter on completion of support form', async () => {
const supportForm: SupportForm = el.shadowRoot!.querySelector('support-form')!;
supportForm.values.email = '[email protected]';
supportForm.values.subject = 'Test Subject';
supportForm.values.accessKeySource = 'a friend';
supportForm.values.description = 'Test Description';
supportForm.valid = true;
supportForm.dispatchEvent(new CustomEvent('submit'));
await nextFrame();

expect(mockErrorReporter.report).toHaveBeenCalledWith('Test Description', 'general', '[email protected]', {
subject: 'Test Subject',
accessKeySource: 'a friend',
formVersion: 2,
});
});

it('emits success event on completion of support form', async () => {
const listener = oneEvent(el, 'success');

Expand Down
5 changes: 4 additions & 1 deletion src/www/views/contact_view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ export class ContactView extends LitElement {

const {description, email, ...tags} = this.formValues as ValidFormValues;
try {
await this.errorReporter.report(description, this.selectedIssueType?.toString() ?? 'unknown', email, {...tags});
await this.errorReporter.report(description, this.selectedIssueType?.toString() ?? 'unknown', email, {
...tags,
formVersion: 2,
});
} catch (e) {
console.error(`Failed to send feedback report: ${e.message}`);
this.isFormSubmitting = false;
Expand Down

0 comments on commit baa7b01

Please sign in to comment.