open-index/open-npm huggingface dataset:
npm package: @hypertrace/nodejsagent
Description: Hypertrace Node.js Agent
Author: Traceable Inc.
Latest version: 1.9.1

# Node.js Agent
[![codecov](https://codecov.io/gh/hypertrace/nodejsagent/branch/main/graph/badge.svg?token=Y4ZH7D6LE3)](https://codecov.io/gh/hypertrace/nodejsagent)

`nodejsagent` provides a set of complementary instrumentation features for collecting relevant data to be processed by [Hypertrace](https://hypertrace.org).


## Development

### Building
1.  Update protobuf definitions
    1. Update the `agent-config` submodule.
        ```
        git submodule update --init --recursive
        ```
    1. Generate protobbuf files: `./src/instrumentation/config/generated.js` and  `./src/instrumentation/config.generated.d.ts`.
        ```
        npm run generate_pb
        ```
1. Build.
    ```
    npm run build
    ```

You can then install the generated .tgz as a normal dependency.

_Note: Using npm link doesnt solve the local testing problem as it will use the hypertrace package dev-dependencies during instrumentation instead of the targetted node app_



### Testing
* Run the example application

    1. 
        ```
        cd ./examples/correlation
        ```
    1. Update `config.yaml` if needed.
    1. Install dependencies
        ```
        npm install
        ```
    1. Start application
        ```
        npm start
        ```

* Unit tests
    1. Start external services
        ```
        cd ./test/externalServices
        docker-compose up -d
        cd -
        ```
    1. 
        ```
        npm run test
        ```
    1. Stop external services if not needed.
        ```
        cd ./test/externalServices
        docker-compose down
        cd -
        ```

    Tests should be added to the `test` directory, in a structure that matches that of the file you are attempting to test.

    Ideally all functionality is testable in locally runnable unit-tests(as opposed to in a docker container), primarily for ease of debugging.

### Lambda layer
To build the layer & upload it to an AWS account:

1. Build using the steps above.
1. Run `./build_layer.sh <REGION>` where region is the region you want the layer to be available in
1. Add an environment variable to your lambda: `AWS_LAMBDA_EXEC_WRAPPER=/opt/hypertrace-instrument`
1. Configure reporting to a collector, you can set `HT_REPORTING_ENDPOINT` to a valid OTLP collector address. - If using with a collector layer, no need to specify an OTLP address as it will export to localhost:4317
npm package: @hypertune/openfeature-base-provider
Description: OpenFeature provider for Hypertune.
Latest version: 0.1.2

# Hypertune OpenFeature Base Provider
This package contains shared code for Hypertune server and client OpenFeature providers. This package is not indented for direct usage, use the relevant provider for your use case instead.

* [Server provider](https://www.npmjs.com/package/@hypertune/openfeature-server-provider)
* [Client provider](https://www.npmjs.com/package/@hypertune/openfeature-web-provider)


## Hypertune overview
[Hypertune](https://www.hypertune.com/) is the most flexible platform for feature flags, A/B testing, analytics and app configuration. Built with full end-to-end type-safety, Git-style version control and local, synchronous, in-memory flag evaluation. Optimized for TypeScript, React and Next.js.
npm package: @hypertune/openfeature-server-provider
Description: OpenFeature provider for Hypertune.
Latest version: 0.1.4

# Hypertune OpenFeature Server Provider

This package contains a provider for using Hypertune with the OpenFeature [JS Server SDK](https://www.npmjs.com/package/@openfeature/server-sdk). If you want to use Hypertune with OpenFeature in the client then checkout the [Hypertune OpenFeature Web Provider](https://www.npmjs.com/package/@hypertune/openfeature-web-provider).

## Hypertune overview

[Hypertune](https://www.hypertune.com/) is the most flexible platform for feature flags, A/B testing, analytics and app configuration. Built with full end-to-end type-safety, Git-style version control and local, synchronous, in-memory flag evaluation. Optimized for TypeScript, React and Next.js.

# Quick start

### 1. Installation

```sh
npm install @openfeature/server-sdk
npm install @hypertune/openfeature-server-provider
```

### 2. Usage

```ts
import { OpenFeature } from "@openfeature/server-sdk";
import { HypertuneProvider } from "@hypertune/openfeature-server-provider";

// Register Hypertune feature flag provider
await OpenFeature.setProviderAndWait(
  new HypertuneProvider({
    token: "YOUR_HYPERTUNE_TOKEN",
  })
);

// Create a new client
const client = OpenFeature.getClient();

// Define a context that matches schema of your Hypertune project
const context = {
  environment: "test",
  user: {
    id: "user_123",
    name: "Test User",
    email: "test@hypertune.com",
  },
};

// Set global context or pass it to each flag evaluation
await OpenFeature.setContext(context);

// Evaluate your feature flag
const exampleFlag = await client.getBooleanValue("exampleFlag", false);

if (exampleFlag) {
  console.log("exampleFlag is enabled");
}
```

## OpenFeature Specific Considerations

### Accessing nested flags

To access nested flags you can use a dot separated path to your flag e.g. `backend.exampleFlag`. Values in a list can only be accessed by first evaluating the list flag as an object using the `getObjectValue` method.

### Publishing events

To publish an event you can evaluate an event trigger flag using the `getBooleanValue` method.

### Flag-specific arguments

Flag-specific arguments are not supported for individual flags with this OpenFeature provider. Trying to evaluate a flag with arguments will result in an error and the default/fallback value will be used. The only way to pass inputs to Hypertune is via the top level context.
npm package: @hypertune/openfeature-web-provider
Description: OpenFeature provider for Hypertune.
Latest version: 0.1.4

# Hypertune OpenFeature Web Provider

This package contains a provider for using Hypertune with the OpenFeature [JS Web SDK](https://www.npmjs.com/package/@openfeature/web-sdk). If you want to use Hypertune with OpenFeature on the server then checkout the [Hypertune OpenFeature Server Provider](https://www.npmjs.com/package/@hypertune/openfeature-server-provider).

## Hypertune overview

[Hypertune](https://www.hypertune.com/) is the most flexible platform for feature flags, A/B testing, analytics and app configuration. Built with full end-to-end type-safety, Git-style version control and local, synchronous, in-memory flag evaluation. Optimized for TypeScript, React and Next.js.

# Quick start

### 1. Installation

```sh
npm install @openfeature/web-sdk
npm install @hypertune/openfeature-web-provider
```

### 2. Usage

```ts
import { OpenFeature } from "@openfeature/web-sdk";
import { HypertuneProvider } from "@hypertune/openfeature-web-provider";

// Register Hypertune feature flag provider
await OpenFeature.setProviderAndWait(
  new HypertuneProvider({
    token: "YOUR_HYPERTUNE_TOKEN",
  }),
  // Pass in a context that matches the schema of your Hypertune project
  {
    environment: "development",
    user: {
      id: "user_123",
      name: "Dev User",
      email: "test@hypertune.com",
    },
  }
);

// Create a new client
const client = OpenFeature.getClient();

// Evaluate your feature flag
const exampleFlag = client.getBooleanValue("exampleFlag", false);

if (exampleFlag) {
  console.log("exampleFlag is enabled");
}
```

## OpenFeature Specific Considerations

### Accessing nested flags

To access nested flags you can use a dot separated path to your flag e.g. `backend.exampleFlag`. Values in a list can only be accessed by first evaluating the list flag as an object using the `getObjectValue` method.

### Publishing events

To publish an event you can evaluate an event trigger flag using the `getBooleanValue` method.

### Flag-specific arguments

Flag-specific arguments are not supported for individual flags with this OpenFeature provider. Trying to evaluate a flag with arguments will result in an error and the default/fallback value will be used. The only way to pass inputs to Hypertune is via the top level context.