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

Browser SDK 2 initialization error "null is not an object" #955

Open
dhruvg opened this issue Feb 10, 2025 · 4 comments
Open

Browser SDK 2 initialization error "null is not an object" #955

dhruvg opened this issue Feb 10, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@dhruvg
Copy link

dhruvg commented Feb 10, 2025

Expected Behavior

The Browser SDK should load reliably on Safari.

Current Behavior

When loading my site with Amplitude's Browser SDK 2 on Safari, I get the error:

null is not an object (evaluating 'a.args[f]._STUBBED_PLUGIN_NAME')

Image

Image

This prevents all events from being sent for that session. This seems to be happen most often in Safari, and it happens at random. It also happens more often if I use the Safari browser cache between refreshes.

I've yet to be able to reproduce this on Chrome.

Steps to Reproduce

I am using the following code to load Amplitude SDK:

<head>
...
<!-- Start Amplitude -->
  <script type="text/javascript" src="https://cdn.amplitude.com/script/<%= amplitudeAppId %>.js"></script>
  <script type="text/javascript">
    window.amplitude.init(
      "<%= amplitudeAppId %>",
      {
        optOut: true,
        minIdLength: 1,
        autocapture: {
          attribution: true,
          sessions: true,
          pageViews: false,
          formInteractions: false,
          fileDownloads: false,
          elementInteractions: false,
        },
      },
    );
  </script>
  <!-- End Amplitude -->
...
</head>

NOTE: the optOut true is intentional as it is set manually later after cookie consent. The main issue here is that the SDK itself fails to load.

Environment

  • JS SDK Version: latest (i.e. <script type="text/javascript" src="https://cdn.amplitude.com/script/<%= amplitudeAppId %>.js"></script>)
  • Installation Method: script
  • Browser and Version: Safari 14.0.2
@dhruvg dhruvg added the bug Something isn't working label Feb 10, 2025
@Mercy811
Copy link
Contributor

@dhruvg, it should be fixed. Could you check again?

@dhruvg
Copy link
Author

dhruvg commented Feb 11, 2025

Still happening. If I open my site on Safari and refresh 10 times with console open. One or two times, this error will be thrown. Probably some race condition. Please advise.

@Mercy811
Copy link
Contributor

Could you provide the url of your website so that I can reproduce?

@Mercy811
Copy link
Contributor

Could you clear cache and try again? Scripts are stored in cache as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants