Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@optimizely/js-sdk-utils

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@optimizely/js-sdk-utils

Optimizely Full Stack Utils

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @optimizely/js-sdk-utils?

@optimizely/js-sdk-utils is a utility library for the Optimizely JavaScript SDK. It provides various helper functions and utilities to facilitate the implementation and management of Optimizely experiments and feature flags in JavaScript applications.

What are @optimizely/js-sdk-utils's main functionalities?

Event Dispatcher

The Event Dispatcher utility allows you to create and dispatch events to the Optimizely logging endpoint. This is useful for tracking user interactions and experiment data.

const { createEventDispatcher } = require('@optimizely/js-sdk-utils');

const dispatcher = createEventDispatcher();

const event = {
  url: 'https://logx.optimizely.com/v1/events',
  params: {
    account_id: '12345',
    project_id: '67890',
    visitors: [{
      visitor_id: 'visitor_1',
      attributes: [],
      snapshots: []
    }]
  }
};

dispatcher.dispatchEvent(event).then(response => {
  console.log('Event dispatched successfully:', response);
}).catch(error => {
  console.error('Error dispatching event:', error);
});

Logger

The Logger utility provides a simple logging mechanism that can be configured with different log levels. This helps in debugging and monitoring the SDK's behavior.

const { createLogger } = require('@optimizely/js-sdk-utils');

const logger = createLogger({ logLevel: 'info' });

logger.log('info', 'This is an info message');
logger.log('error', 'This is an error message');

Error Handler

The Error Handler utility provides a standardized way to handle errors within the Optimizely SDK. It can be used to catch and process errors, ensuring that they are logged and managed appropriately.

const { createErrorHandler } = require('@optimizely/js-sdk-utils');

const errorHandler = createErrorHandler();

try {
  throw new Error('Something went wrong');
} catch (error) {
  errorHandler.handleError(error);
}

Other packages similar to @optimizely/js-sdk-utils

Keywords

FAQs

Package last updated on 27 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc