Code Monkey home page Code Monkey logo

Comments (1)

dosubot avatar dosubot commented on June 27, 2024 2

Hey @vikashrajgupta! I'm here to help you out with any bugs, questions, or contributions you have. Let's work together to resolve your issue.

To add custom JavaScript code or integrate an analytics tool like PostHog into Apache Superset, follow these steps:

  1. Create a Custom HTML File:

    • Create a file named tail_js_custom_extra.html in the superset/templates/superset/ directory.
    • Add your custom JavaScript code or PostHog integration script to this file. For example:
    <script>
      console.log('PostHog script loaded');
      !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(o=t.createElement("script")).type="text/javascript",o.async=!0,o.src=s.api_host+"/static/array.js",(n=t.getElementsByTagName("script")[0]).parentNode.insertBefore(o,n),r=e;var c=function(t){return function(){r.push([t].concat(Array.prototype.slice.call(arguments,0)))}},u=["capture","identify","alias","people.set","people.set_once","people.unset","people.increment","people.append","people.union","people.track_charge","people.clear_charges","people.delete_user"];for(p=0;p<u.length;p++)g(r,u[p]);e._i.push([i,s,a])},e.__SV=1.0)}(document,window.posthog||[]);
      posthog.init('YOUR_API_KEY', {api_host: 'https://app.posthog.com'});
    </script>
  2. Include the Custom HTML File:

    • Ensure that tail_js_custom_extra.html is included in the tail_js block of spa.html:
    {% block tail_js %}
      {{ js_bundle(entry) }}
      {% include "tail_js_custom_extra.html" %}
    {% endblock %}
  3. Build the Frontend:

    • Navigate to the superset-frontend directory and run the following commands:
    cd superset-frontend
    npm install
    npm run build
  4. Restart Docker Containers:

    • Restart your Docker containers to apply the changes:
    docker-compose down
    docker-compose up

By following these steps, your custom JavaScript code should be executed, and the PostHog analytics tool should be integrated into Apache Superset [1][2][3].

To continue talking to Dosu, mention @dosu.

from superset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.