Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Improve error for sites using os.tc subdomain #1139

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

jkasten2
Copy link
Member

@jkasten2 jkasten2 commented Nov 17, 2023

Description

1 Line Summary

Replaces confusing "TypeError: Cannot read properties of undefined (reading 'message')" with a specific error that HTTP and the "My site is not fully HTTPS" option is no longer supported.

Details

Before this change the initialization process would get too far and would result a confusing undefined error.

Dead code will be cleaned up follow up PR.

Validation

Tests

Tested with Chrome 119 on Windows 11

  • Tested with a site with "My site is not fully HTTPS" enabled to ensure the new message would show in the JS console.
  • Tested with a normal HTTPS site to ensure it still works.

Info

Checklist

  • All the automated tests pass or I explained why that is not possible
  • I have personally tested this on my machine or explained why that is not possible
  • I have included test coverage for these changes or explained why they are not needed

Programming Checklist
Interfaces:

  • Don't use default export
  • New interfaces are in model files

Functions:

  • Don't use default export
  • All function signatures have return types
  • Helpers should not access any data but rather be given the data to operate on.

Typescript:

  • No Typescript warnings
  • Avoid silencing null/undefined warnings with the exclamation point

Other:

  • Iteration: refrain from using elem of array syntax. Prefer forEach or use map
  • Avoid using global OneSignal accessor for context if possible. Instead, we can pass it to function/constructor so that we don't call OneSignal.context

Screenshots

Before

TypeError: Cannot read properties of undefined (reading 'message')
    at Dev-OneSignalSDK.page.es6.js?v=160004:19230:46
    at new Promise (<anonymous>)
    at Database.<anonymous> (Dev-OneSignalSDK.page.es6.js?v=160004:19229:30)
    at Generator.next (<anonymous>)
    at Dev-OneSignalSDK.page.es6.js?v=160004:22237:71
    at new Promise (<anonymous>)
    at __awaiter (Dev-OneSignalSDK.page.es6.js?v=160004:22233:12)
    at Database.getAll (Dev-OneSignalSDK.page.es6.js?v=160004:19227:65)
    at Database.<anonymous> (Dev-OneSignalSDK.page.es6.js?v=160004:19863:53)
    at Generator.next (<anonymous>)

After

Uncaught (in promise) Error: OneSignalSDK: HTTP sites are no longer supported starting with version 16 (User Model), your public site must start with https://. Please visit the OneSignal dashboard's Settings > Web Configuration to find this option.
    at OneSignalUtils.internalIsUsingSubscriptionWorkaround (Dev-OneSignalSDK.page.es6.js?v=160004:21219:23)
    at ConfigHelper.getMergedConfig (Dev-OneSignalSDK.page.es6.js?v=160004:12008:109)
    at ConfigHelper.<anonymous> (Dev-OneSignalSDK.page.es6.js?v=160004:11956:40)
    at Generator.next (<anonymous>)
    at fulfilled (Dev-OneSignalSDK.page.es6.js?v=160004:22224:58)

Info

Checklist

  • I have included screenshots/recordings of the intended results or explained why they are not needed

Related Tickets



This change is Reviewable

Effects any sites with the "My site is not fully HTTPS" option enabled.

Before this change the initialization process would get too far and
would result a confusing undefined error.

Dead code will be cleaned up follow up commits.
@jkasten2 jkasten2 requested review from rgomezp and emawby November 17, 2023 23:01
Base automatically changed from feat/improve_logging_format to main November 21, 2023 23:09
@jkasten2 jkasten2 merged commit 1d5d116 into main Nov 21, 2023
2 checks passed
@jkasten2 jkasten2 deleted the fix/show_http_no_longer_supported_error branch November 21, 2023 23:11
@jkasten2 jkasten2 mentioned this pull request Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants