const Client         = require('./../binary/base/client').Client;
const getLanguage    = require('./../binary/base/language').getLanguage;
const localize       = require('./../binary/base/localize').localize;
const url_for_static = require('./../binary/base/url').url_for_static;

class BinaryOneSignal {
    constructor() {
        this.OneSignal = window.OneSignal || [];
        this.options = {
            appId       : '8e2d0514-4c65-424e-b87e-4ffaaa61da21',
            // safari_web_id: 'YOUR_SAFARI_WEB_ID',
            path        : url_for_static('/'),
            autoRegister: true,
            notifyButton: {
                enable: false,
            },
            persistNotification: false,
            welcomeNotification: {
                title  : 'Binary.com',
                message: localize('Thank you for subscribing!'),
            },
            allowLocalhostAsSecureOrigin: true,
        };
        this.configure();
    }

    /*
     * Initializes OneSignal SDK
     * Notes:
     *  - do not call 'init' twice
     *  - 'init' call is required before any function can be used
     *  - log level can be set to 'trace/debug/info/warn/error' or 'silent' to disable all but in production
     *     - refer https://www.npmjs.com/package/loglevel
     */
    configure() {
        this.OneSignal.log.setLevel('silent'); // Disable all error logging
        this.OneSignal.push(() => {
            // Register the worker at root scope, pushed before 'init'
            this.OneSignal.SERVICE_WORKER_PARAM = { scope: url_for_static('/') };
        });
        this.OneSignal.push(['init', this.options]);
    }

    /*
     * Checks if a user has already accepted push notifications,
     * then send the user website language and Binary login_id to OneSignal
     */
    checkSubscription() {
        this.OneSignal.push(() => {
            if (window.location.hostname !== 'www.binary.com') return; // Use in production
            // If we're on an unsupported browser, do nothing
            if (!this.OneSignal.isPushNotificationsSupported()) {
                return;
            }
            this.OneSignal.isPushNotificationsEnabled()
                .then((isPushEnabled) => {
                    if (isPushEnabled) {
                        this.OneSignal.getTags((tags) => {
                            if (tags.language === undefined) {
                                this.OneSignal.sendTag('language', getLanguage().toLowerCase());
                            }
                            if (Client.is_logged_in() && tags.login_id === undefined) {
                                this.OneSignal.sendTag('login_id', Client.get('loginid'));
                            }
                        });
                    }
                });
        });
    }
}

export default new BinaryOneSignal();

@@ -314,24 +314,61 @@
 tructor() %7B%0A
+        if (!isApplicable()) return;%0A
         this
@@ -1865,127 +1865,72 @@
     
-this.OneSignal.push(() =%3E %7B%0A            if (window.location.hostname !== 'www.binary.com') return; // Use in production
+if (!isApplicable()) return;%0A        this.OneSignal.push(() =%3E %7B
 %0A   
@@ -2781,16 +2781,143 @@
    %7D%0A%7D%0A%0A
+const isApplicable = () =%3E (window.location.hostname === 'www.binary.com' && !/logged_inws/i.test(window.location.pathname));%0A%0A
 export d

Fix error in logged_in and limit to production