Skip to content

Commit

Permalink
Set OS in the form data based on the user agent.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed Sep 26, 2023
1 parent 0e7b264 commit 9cdf436
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/www/views/contact_view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {Radio} from '@material/mwc-radio';
import {SingleSelectedEvent} from '@material/mwc-list/mwc-list';

import './support_form';
import {IS_ANDROID, IS_IOS, IS_LINUX, IS_MACOS, IS_WINDOWS} from './os';
import {CardType} from '../shared/card';
import {IssueType} from './issue_type';
import {AppType} from './app_type';
Expand Down Expand Up @@ -203,6 +204,7 @@ export class ContactView extends LitElement {
}
const submitData = {
...this.formValues,
Operating_System: getOperatingSystemValue(),
Outline_Manager_Client_Version: this.version,
};
// TODO: Actually send the form data using the error reporter.
Expand Down Expand Up @@ -293,3 +295,12 @@ export class ContactView extends LitElement {
}
}
}

Check warning on line 298 in src/www/views/contact_view/index.ts

View check run for this annotation

Codecov / codecov/patch

src/www/views/contact_view/index.ts#L298

Added line #L298 was not covered by tests
function getOperatingSystemValue(): string | undefined {
if (IS_ANDROID) return 'android';
if (IS_IOS) return 'ios';
if (IS_LINUX) return 'linux';
if (IS_MACOS) return 'apple';
if (IS_WINDOWS) return 'windows';
return;

Check warning on line 305 in src/www/views/contact_view/index.ts

View check run for this annotation

Codecov / codecov/patch

src/www/views/contact_view/index.ts#L301-L305

Added lines #L301 - L305 were not covered by tests
}
22 changes: 22 additions & 0 deletions src/www/views/contact_view/os.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright 2023 The Outline Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export const IS_ANDROID = /android/i.test(navigator.userAgent);
export const IS_IOS = /iPad|iPhone|iPod/.test(navigator.userAgent);

export const IS_LINUX = /linux/i.test(navigator.userAgent);
export const IS_MACOS = /mac/i.test(navigator.userAgent);
export const IS_WINDOWS = /win/i.test(navigator.userAgent);
2 changes: 0 additions & 2 deletions src/www/views/contact_view/support_form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ export class SupportForm extends LitElement {
>
</mwc-textarea>
<input type="hidden" name="Operating_System" value="TODO" />
<p>* = Required field</p>
<span slot="card-actions">
Expand Down

0 comments on commit 9cdf436

Please sign in to comment.