npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@usesummit/global

v0.3.2

Published

Summit powers engaging apps for sales, marketing, and product teams to deploy and use anywhere.

Downloads

398

Readme

Summit JS SDK - Browser global (CDN-hosted)

Summit powers engaging apps for sales, marketing, and product teams to deploy and use anywhere.

You can use this SDK to call your Summit apps over API from your website or apps. The SDK isn't mandatory but ensures a correct configuration for Summit's analytics and CRM integration features.

🌱 The Summit SDK is fresh out of the oven and in an alpha state. Things might change at any time, but we're happy to collaborate on your implementation and make sure we don't break things going forward. You can reach me at [email protected] if you're planning on rolling out your own implementation and have questions or concerns.

Usage

If you're not building your scripts and are working with a site builder like Wix or Webflow, there's a global build available. We'll host this from our own CDN soon, but for now, we recommend using unpkg. Given our alpha release stage, make sure you pin a specific version that you can verify is working with your implementation.

<script src="https://unpkg.com/@usesummit/[email protected]/dist/index.global.js">

Including this script in your HTML will add a window.Summit global to your website with an initialized browser client.

You can then configure that client with your API key or cookie settings by calling window.Summit.configure(). This method supports the same options as the constructor.

Other than that, all methods supported by the browser client are callable on the global window.Summit instance: window.Summit.run(), window.Summit.embed(), and window.Summit.identify().

Example: Webflow

<script
    src="https://unpkg.com/@usesummit/[email protected]/dist/index.global.js"
>

    <script>
        window.Summit.configure('my-app-api-key');

        // Fancy number formatting is a browser built-in nowadays
        const formatter = new Intl.NumberFormat('en-US', {
            style: 'currency',
            currency: 'USD',
            maximumFractionDigits: 0,
        });

        function initCalculator() {
            const form = document.getElementsByClassName('js-rev-share-form')[0];
            const runway = document.getElementsByClassName(
                'js-rev-share-output-runway'
            )[0];
            const repaymentCap = document.getElementsByClassName(
                'js-rev-share-output-repayment-cap'
            )[0];

            // Set initial values, you can't do that directly in Webflow for some reason
            form.querySelector('[name=cash_balance]').value = '50k';
            form.querySelector('[name=mrr]').value = '25k';
            form.querySelector('[name=mrr_growth_rate]').value = '8';
            form.querySelector('[name=monthly_burn]').value = '50k';
            form.querySelector('[name=loan_amount]').value = '100k';
            form.querySelector('[name=rev_share_pct]').value = '7.5';

            form.addEventListener('submit', function (e) {
                e.preventDefault();
                e.stopPropagation();

                // Basic input validation
                let isValid = true;

                Array.from(
                    form.querySelectorAll('input:not([type=submit])')
                ).forEach(function (input) {
                    if (!input.value) {
                        input.classList.add('has-error');
                        isValid = false;
                    } else {
                        input.classList.remove('has-error');
                    }
                });

                if (!isValid) {
                    return false;
                }

                const formData = new FormData(form);

                // Show a loading state on the button
                const button = form.querySelector('[type=submit]');

                const initialButtonLabel = button.value;

                button.value = 'Simulating…';
                button.setAttribute('disabled', 'disabled');
                button.style.opacity = 0.6;

                window.Summit.run('my-org/31159e/my-app', formData).then(function (
                    response
                ) {
                    // Undo loading state on the button
                    button.value = initialButtonLabel;
                    button.removeAttribute('disabled');
                    button.style.opacity = 1;

                    // This is where you process your results
                    // In this example, we find the month where `checking_account` (an output value in Summit)
                    // goes below zero
                    const negativeIndex = response.results.findIndex(function (
                        result
                    ) {
                        const checkingBalance = result.values.checking_account;
                        return (
                            typeof checkingBalance === 'number' &&
                            checkingBalance <= 0
                        );
                    });

                    // Show number of months before the checking account goes below zero
                    runway.textContent =
                        negativeIndex === -1
                            ? '∞'
                            : negativeIndex === 0
                            ? 'One month'
                            : `${negativeIndex + 1} months`;

                    // Show another value
                    repaymentCap.textContent = formatter.format(
                        response.results[0].values.repayment_cap
                    );

                    runway.style.display = 'block';
                    repaymentCap.style.display = 'block';
                });

                return false;
            });
        }

        if (['loaded', 'interactive', 'complete'].includes(document.readyState)) {
            initCalculator();
        } else {
            document.addEventListener('DOMContentLoaded', initCalculator);
        }
</script>