Skip to content

missing var declaration on mixpanel-jslib-snippet.jsΒ #215

Closed

Description

@agustinhaller

Hi, this is a simple one to fix.
I noticed there are a couple var declarations missing in the mixpanel-jslib-snippet.js file.

call2_args = arguments;
call2 = [fn_name].concat(Array.prototype.slice.call(call2_args, 0));

As I'm using the snippet source code to load mixpanel lib from my Typescript code asynchronously. The Typescript compiler is complaining about those missing var declarations.

If you wonder why I'm using the snippet code directly in my Typescript files, it's because I don't want to include the snippet in my index.html as I want to keep scripts in the index.html file to a minimum to avoid blocking the UI thread.
I think this approach is a nice workaround for this issue.

Activity

  1. tdumitrescu commented on Apr 9, 2019

    @tdumitrescu
    Member

    Thanks for the catch! We'll get it in an upcoming release, though you can always expedite by submitting a PR.

    Re: bundling the async loader ("snippet"): that's a workable approach as long as you ensure you always run that JS bundle before you ever try to access window.mixpanel. The minified snippet is designed to be small enough to put in a page's <head> tag without any noticeable delay, and then you don't have to worry about loading order at all. The issue being discussed in #128 is different: the problem there is the size of the actual library code, which will only affect you when you try to put the entire lib in your bundles (i.e. bypassing the async loader altogether).

  2. tdumitrescu commented on Feb 18, 2022

    @tdumitrescu
    Member

    Sorry this slipped under the radar; it's been fixed in v2.45.0.

  3. added a commit that references this issue on Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions