0

Basically I am trying to use a profitWell script in my angular application this is the script

<script id="profitwell-js" data-pw-auth="XXX">
        (function(i,s,o,g,r,a,m){i[o]=i[o]||function(){(i[o].q=i[o].q||[]).push(arguments)};
        a=s.createElement(g);m=s.getElementsByTagName(g)[0];a.async=1;a.src=r+'?auth='+
        s.getElementById(o+'-js').getAttribute('data-pw-auth');m.parentNode.insertBefore(a,m);
        })(window,document,'profitwell','script','https://public.profitwell.com/js/profitwell.js');
        profitwell('start', { 'user_email': 'USER_EMAIL_HERE' });
</script>

now I have put this script in the <head> of my index.html and removed the profitWell('start') from it because I need to wait until a user authenticates before I can send in the emailAddress

so my index.html looks like this

<head>
<!-- ... -->
   <script id="profitwell-js" data-pw-auth="XXX">
        (function(i,s,o,g,r,a,m){i[o]=i[o]||function(){(i[o].q=i[o].q||[]).push(arguments)};
        a=s.createElement(g);m=s.getElementsByTagName(g)[0];a.async=1;a.src=r+'?auth='+
        s.getElementById(o+'-js').getAttribute('data-pw-auth');m.parentNode.insertBefore(a,m);
        })(window,document,'profitwell','script','https://public.profitwell.com/js/profitwell.js');
  </script>
</head>

now in my authentication component I have done the following

// ...

declare var profitWell: any;

// ...

authenticate() {
   // ...
   profitWell('start', {'user_email': this.email});
}

now I can see in my network that the profitWell script is being called but when I call the profitWell method I get the following

profitWell is not defined

now it is to my understanding when I add declare var profitWell: any that well let me use the global profitWell but I can't seem to get it to work.

3
  • Try to use window.profitwell and declare window as any. Commented Dec 10, 2019 at 4:35
  • @ShabbirDhangot same issue window.profitWell is not a function Commented Dec 10, 2019 at 4:41
  • Try w in small. check last line of js file. I checked public.profitwell.com/js/profitwell.js this js file there is no declaration of profitWell in the file. That is why you not able to use. Commented Dec 10, 2019 at 4:53

1 Answer 1

1

There is spell error on your usage. You need to use like profitwell and your used profitWell. Here profitWell is the issue.

declare var profitwell: any;

// ...

authenticate() {
   // ...
   profitwell('start', {'user_email': this.email});
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.