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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ember-config-cat

v2.0.0

Published

Ember addon to wrap a ConfigCat client.

Readme

ember-config-cat

Build

This addon includes a service which wraps a ConfigCat client and aims at easing any feature flagging in your applications.

Compatibility

  • Ember.js v3.24 or above
  • Ember CLI v3.24 or above
  • Node.js v12 or above

Installation

ember install ember-config-cat

Usage

Options

# environment.js

module.exports = function (environment) {
  let ENV = {
    emberConfigCat: {
      // your options goes here
    }
  };
};

| Option | Default | Description | Links | | ------------------------ | ------------ | ----------------------------------------------------------------------- | ---------------------------------------------------------------------- | | mode | 'auto' | Polling mode: 'auto'/'lazy'/'manual' | 🔗 | | local | false | Enabling local mode: will only use default flag values | - | | flags | - | Default values for feature-flags | - | | sdkKey | – | Your SDK Key | 🔗 | | requestTimeoutMs | 30000 | Amount of time the SDK waits before returning cached values | 🔗 | | maxInitWaitTimeSeconds | 5 | Maximum waiting time between client init and config fetch | 🔗 | | pollIntervalSeconds | 60 | Polling interval | 🔗 | | cacheTimeToLiveSeconds | 60 | Cache TTL | 🔗 | | dataGovernance | 0 (Global) | Determine the CDN location of the data: 0 for Global / 1 for EuOnly | 🔗 | | logLevel | - | Set a custom log level | 🔗 |

  • requestTimeoutMs and dataGovernance are common polling options to the three available modes
  • All default values except mode, local and autoStart are defined in the ConfigCat SDK
  • You may define either local or sdkKey but the addon will fallback to local mode if no sdkKey is provided.

Content Security Policy (CSP)

If your app is using ember-cli-content-security-policy, you may need to add this into environment.js to allow ConfigCat requests.

module.exports = function (environment) {
  let ENV = {
    contentSecurityPolicy: {
      'connect-src': ['https://cdn-global.configcat.com'],
    },
  };
};

Initializing the client

Without user identification

import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class WhateverRoute extends Route {
  @service configCat;

  beforeModel() {
    return this.configCat.initClient();
  }
}

With user identification

A ConfigCat user object is made of four properties (identifier, email, country and custom): structure Calling .identifyUser() will initialize the client if needed.

import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class WhateverRoute extends Route {
  @service configCat;

  async model() {
    const user = this.authenticate();
    await this.configCat.identifyUser({
      identifier: user.id,
      email: user.email,
    });
  }
}

Using feature-flag values

import Component from '@glimmer/component';
import { inject as service } from '@ember/service';

export default class WhateverComponent extends Component {
  @service configCat;

  get isEnabled() {
    return this.configCat.flags.isAwesomeFeatureEnabled;
  }
}
{{#if this.isEnabled}}
  Enabled
{{else}}
  Disabled
{{/if}}

Template helpers

| Name | Parameters | Description | | ----------------- | ---------- | ------------------------------------------------------------- | | is-flag-enabled | key | Checks if the flag is enabled | | get-flag-value | key | Gets the current flag value | | has-flag-value | key, value | Compares the current flag value against a provided parameters |

Clearing data

import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';

export default class WhateverComponent extends Component {
  @service configCat;

  @action onClear() {
    this.configCat.dispose();
  }
}

Public methods and properties

| Name | Type | Description | | -------------- | ---------------- | --------------------------------------------------- | | flags | tracked property | Returns available feature-flags and values | | identifyUser | method | Identifies user and update feature-flags values | | update | method | Updates feature-flags values | | dispose | method | Releases everything related to the ConfigCat client |

Testing

ember-config-cat comes with a couple of test-helpers:

// ...
import { setupConfigCat, TestContext } from 'ember-config-cat/test-support';

module('...', function (hooks) {
  // ...
  setupConfigCat(hooks);

  test('...', async function (this: TestContext, assert) {
    // configuring one flag
    this.withFlag('featureA', true);

    // configuring several flags
    this.withFlags({ featureB: true, pricing: 10 });

    // ...
  });
});

Contributing

See the Contributing guide for details.

References

We draw our inspiration from the ember-launch-darkly addon

Docs

License

This project is licensed under the MIT License.