1.1.4 • Published 3 months ago

clariloop-test-sdk v1.1.4

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

Clariloop Survey SDK

The Clariloop Survey SDK allows developers to easily embed surveys into their applications. It supports various display modes, including inline, popup, and overlay, providing flexibility for different UI/UX requirements.

Features

  • Multiple Display Modes: Inline, Popup, and Overlay.
  • Customizable Positioning for Popup mode.
  • Seamless Integration with React, Vanilla JavaScript, and Node.js.
  • Automatic Survey Lifecycle Handling (minimize, restore, close events).
  • Lightweight & Fast with optimized builds for CommonJS, ESM, and IIFE.

Installation

You can install the package via npm:

npm install clariloop-test-sdk

Or using yarn:

yarn add clariloop-test-sdk

Usage

Basic Initialization

import Clariloop from 'clariloop-test-sdk';

Clariloop.init({
  apiKey: 'your-api-key',
  orderId: '12345',
  customerId: 'user-123',
  email: 'user@example.com',
  displayMode: 'popup', // 'inline' | 'popup' | 'overlay'
  containerId: 'survey-container', // Required for 'inline'
});

Using in HTML (Browser Global)

<!DOCTYPE html>
<html lang="en">
  <head>
    <script src="https://cdn.example.com/clariloop.min.js"></script>
  </head>
  <body>
    <div id="survey-container"></div>
    <script>
      Clariloop.init({
        apiKey: 'your-api-key',
        orderId: '12345',
        customerId: 'user-123',
        email: 'user@example.com',
        displayMode: 'inline',
        containerId: 'survey-container',
      });
    </script>
  </body>
</html>

Configuration Options

PropertyTypeRequiredDescription
apiKeystringAPI key to authenticate survey requests.
orderIdstringThe order ID associated with the survey.
customerIdstringUnique customer identifier.
emailstringCustomer email address.
displayMode'inline' \| 'popup' \| 'overlay'Defines how the survey is displayed.
position'left' \| 'right'Required for popup mode to set position.
containerIdstring✅ for inlineThe div ID where the survey is mounted.

Advanced Features

Handling Events

You can listen for survey events using window.addEventListener('message').

window.addEventListener('message', (event) => {
  if (event.data?.type === 'CLOSE_SURVEY') {
    console.log('User closed the survey');
  }
});

Minimizing & Restoring Surveys

If using popup or overlay, the survey can be minimized and restored.

window.addEventListener('message', (event) => {
  if (event.data?.type === 'MINIMIZE_SURVEY') {
    console.log('Survey minimized');
  }
  if (event.data?.type === 'RESTORE_SURVEY') {
    console.log('Survey restored');
  }
});

Compatibility

The Clariloop Survey SDK supports the following environments:

  • Modern Browsers: Chrome, Firefox, Edge, Safari.
  • JavaScript Frameworks: React, Vue, Angular.
  • CDN Integration: Available for direct script inclusion.

Support

For any issues, please contact support at info@clariloop.com.

1.1.1

3 months ago

1.1.0

3 months ago

1.0.9

3 months ago

1.0.8

3 months ago

1.0.7

3 months ago

1.1.4

3 months ago

1.0.5

3 months ago

1.1.3

3 months ago

1.1.2

3 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.0

4 months ago

1.0.2

4 months ago