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 API key sign up load problem #4538

Closed
5 tasks done
jason-upchurch opened this issue Aug 5, 2020 · 6 comments
Closed
5 tasks done

Fix API key sign up load problem #4538

jason-upchurch opened this issue Aug 5, 2020 · 6 comments

Comments

@jason-upchurch
Copy link
Contributor

jason-upchurch commented Aug 5, 2020

User story

As a user of the api key signup page, I want the page to sign up form to load consistently so that I can sign up for an api key on the first page load.

Background

Both @johnnyporkchops and @jason-upchurch have observed the form not loading on the first try. This doesn't seem to happen often, but we've both seen it. We'd like to try to ensure the form loads with the page every time.

Technical considerations

  • Timeboxed to handle by Monday and address with the form consistently loading, or the data.gov form link is included
  • Do we need to remove the feature flag?
  • Is there really a form load lag?
  • If so, can we fix this and make sure the page waits for the form?

Completion criteria:

  • The form loads consistently each time
@jason-upchurch jason-upchurch added this to the Sprint 13.3 milestone Aug 5, 2020
@johnnyporkchops
Copy link
Contributor

johnnyporkchops commented Aug 6, 2020

@rfultz Do you think if we add defer to to script instead of async this would help? It is a bit hard to reproduce the intermittent error consistently to test. (cc: @patphongs )

var apiUmbrella = document.createElement('script'); 
        apiUmbrella.type = 'text/javascript'; 
        apiUmbrella.async = true;
        apiUmbrella.src = 'https://api.data.gov/static/javascripts/signup_embed.js';
        (document.getElementsByTagName('head')[0] || 
         document.getElementsByTagName('body')[0])
        .appendChild(apiUmbrella);

Also I wonder if feature flag logic is intermittently slowing down page load. The logic wrapping the js could be simplified like this:

<script>
    window.onload = function() {
      SwaggerLayout(
        "{{ specs_url }}",
        document.getElementById("swagger-ui")
      );
 {% if api_key_signup_feature_flag %}     
       var apiUmbrella = document.createElement('script'); 
       apiUmbrella.type = 'text/javascript'; 
       apiUmbrella.async = true;
       apiUmbrella.src = 'https://api.data.gov/static/javascripts/signup_embed.js';
       (document.getElementsByTagName('head')[0] || 
        document.getElementsByTagName('body')[0])
       .appendChild(apiUmbrella);
  {% endif %}
    };
</script>

Also we can remove

          document.getElementsByTagName('body')[0])

@jason-upchurch
Copy link
Contributor Author

@johnnyporkchops @rfultz thanks for the discussion! Based on the possibility that the feature flag is involved, and the fact that it didn't work as intended, I also opened issue #4545 to remove it.

I also see that it's not always failing to load, so hopefully simplifying the logic will help.

cc @patphongs

@JonellaCulmer JonellaCulmer changed the title Determine if api key signup form not consistently loading and fix Fix API key sign up load problem Aug 13, 2020
@jason-upchurch jason-upchurch self-assigned this Aug 13, 2020
@jason-upchurch
Copy link
Contributor Author

@johnnyporkchops I'm going to start by removing the feature flag.

@jason-upchurch
Copy link
Contributor Author

@johnnyporkchops I wanted to document your leadership role in this issue. The ideas that I was able to implement here all came from your comments. You also sat with me as we paired on the implementation and spent equal time and were an equal leader in the solution. Thank you!! 👍 cc @patphongs

@johnnyporkchops
Copy link
Contributor

@jason-upchurch. Thanks for keeping this in the pipeline and knocking it out this sprint. Good call!

@JonellaCulmer
Copy link
Contributor

Closing, the work is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants