Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- library_config
- datadog-js-zstd
- pipeline
- sketches
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: 'Use composite action'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- library_config
- datadog-js-zstd
- pipeline
- sketches
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: 'Use composite action'
Expand Down
124 changes: 82 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions crates/capabilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ http = "1"
bytes = "1.4"
futures-core = "0.3"
anyhow = "1"
# TODO: Replace this temporary libdatadog PR rev with the official release/tag
# that contains DataDog/libdatadog#2235, then regenerate Cargo.lock.
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", rev = "6356aee4c69b51f27e7e82e43b1797f60b74905a" }
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", rev = "3081603d3c74f209be4e3be951f78a1a7469397f" }

[dev-dependencies]
wasm-bindgen-test = "0.3"
28 changes: 28 additions & 0 deletions crates/capabilities/src/env.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2026-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0

//! Wasm implementation of [`EnvCapability`] backed by Node.js `process.env`.

use wasm_bindgen::prelude::*;

use libdd_capabilities::env::{EnvCapability, EnvError};

#[wasm_bindgen(module = "/src/env_transport.js")]
extern "C" {
#[wasm_bindgen(js_name = "get")]
fn js_env_get(name: &str) -> JsValue;
}

#[derive(Debug, Clone)]
pub struct WasmEnvCapability;

impl EnvCapability for WasmEnvCapability {
fn new() -> Self {
Self
}

fn get(&self, name: &str) -> Result<Option<String>, EnvError> {
// Node coerces every process.env value to a string, so NotUnicode is unreachable here.
Ok(js_env_get(name).as_string())
}
}
7 changes: 7 additions & 0 deletions crates/capabilities/src/env_transport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'

const { env } = process

module.exports.get = (name) => {
return env[name]
}
Loading
Loading