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

Asynchronous loading on Chrome not working on mi Env #19

Open
ezubillaga opened this issue Dec 7, 2017 · 1 comment
Open

Asynchronous loading on Chrome not working on mi Env #19

ezubillaga opened this issue Dec 7, 2017 · 1 comment

Comments

@ezubillaga
Copy link

ezubillaga commented Dec 7, 2017

Hello:

I have been trying to test the Javascript error reporting (automatic or manually caught) using the async method suggested in the documentation, and although it works like charm in Firefox 57.0.1, I had to do a major tweak and disable the sync load to make it work in Chrome 62.0.3202.94.

Instead of the suggested method for loading the library, I had to do the following:

<script src="//cdn.jsdelivr.net/gh/AppEnlight/appenlight-client-js@0.5.1/appenlight-client.min.js"></script>
<script type="text/javascript">
    var initAppEnlight = function () {
        if(this.readyState!=='loading'){
            AppEnlight.init({
                apiKey: '{{ APPENLIGHT_KEY }}',
                windowOnError: 1 // enable to hook to window.onerror
            });
            // setting request info is completly optional
            AppEnlight.setRequestInfo({
                server: '{{ SERVER_HOSTNAME }}',
                username:'{{ request.user.username }}',
                {% if request.META.HTTP_X_FORWARDED_FOR %}
                ip: '{{ request.META.HTTP_X_FORWARDED_FOR }}',
                {% else %}
                ip: '{{ request.META.REMOTE_ADDR }}',
                {% endif %}
                // request_id:"server_generated_uuid"
            });
        }
    };

    initAppEnlight();
</script>

Previous to that each time I called the AppEnlight GrabError() or Log() functions I got 'AppEnlight is not defined" error on Chrome's debug console.

I'm not a JS developer so I'm not sure if the tweak I did is the right thing to do, or if there is a better way to overcome my issue with Chrome.

Thanks, and please keep going with the good work!

Erasmo

@ergo
Copy link
Member

ergo commented Dec 8, 2017

I think async was not supported in firefox so thats why it worked, and in chrome the rest of the code was executed before the library loaded. I'll take a look at this. Thanks.

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

No branches or pull requests

2 participants