0.9.1 • Published 4 years ago

@prosperstack/survey v0.9.1

Weekly downloads
1
License
MPL-2.0
Repository
-
Last release
4 years ago

ProsperStack survey form

How to embed the survey form in your application

To ensure you collect the survey data from every cancellation, you can embed the survey form directly into your application.

IMPORANT: Note that you'll still need to process the Stripe cancellation after the survey is completed!

There are two options for including the ProsperStack JavaScript library in your application.

Install from npm

You can install the @prosperstack/survey package from npm.

npm install @prosperstack/survey

or, with yarn:

yarn add @prosperstack/survey

In you application, import the library:

import prosperStackSurvey from '@prosperstack/survey';

Load it via a script tag

If you don't want to use npm, you can load it with a script tag.

<script src="https://cdn.prosperstack.com/survey/0.9.1/survey.min.js"></script>

The library will be available at window.ProsperStackSurvey.

Usage

Call the imported prosperStackSurvey method or window.ProsperStackSurvey if loaded via script tag.

prosperStackSurvey({
  el: '#prosperstack-survey',
  surveyId: 'LBcbjt7Wbhw08oBK8PU3w',
  stripeSubscriptionId: 'sub_H6X0WYrAzq2iGk'
});

Options

The options argument accepts the following properties:

  • el - The element to load the survey into. Supply an HTMLElement or a string that can be used in document.querySelector().
  • surveyId - The unique ID of your survey. You can find this in your ProsperStack survey settings.
  • stripeSubscriptionId - The ID of the Stripe subscription that is being canceled.
  • replace - If true, replaces the supplied element with the survey, otherwise appends to it. Default is false.
  • completed - A callback that is called when the survey is completed. If not supplied, the method will return a Promise.

When the survey is complete

To be notified when the survey is complete, the library can accept a callback or return a Promise.

Using a callback

prosperStackSurvey({
  el: '#prosperstack-survey',
  surveyId: 'LBcbjt7Wbhw08oBK8PU3w',
  stripeSubscriptionId: 'sub_H6X0WYrAzq2iGk',
  completed: () => {
    console.log('Survey complete!')
  }
});

Using a Promise

prosperStackSurvey({
  el: '#prosperstack-survey',
  surveyId: 'LBcbjt7Wbhw08oBK8PU3w',
  stripeSubscriptionId: 'sub_H6X0WYrAzq2iGk'
}).then(() => {
  console.log('Survey complete!')
});
0.9.1

4 years ago

0.9.0

4 years ago