Skip to content

JSON schema config won't work #960

@wcastand

Description

@wcastand

Describe the bug

Currently in vscode meta schema are not supported
microsoft/vscode#155379

meaning the datadog-configuration schema is not working properly i assume

in the meantime using file config seems to fail

Reproduction steps

make a datadog configuration file and try to use like the doc suggest in init before react-native

if i do it manually it works

SDK logs

 ERROR  Warning: Failed to parse the Datadog configuration file you provided.
Your configuration must validate the node_modules/@datadog/mobile-react-native/datadog-configuration.schema.json JSON schema.
You can use VSCode to check your configuration by adding the following line to your JSON file:
{
    "$schema": "./node_modules/@datadog/mobile-react-native/datadog-configuration.schema.json",
}

This is the schema i use that throw that error

(i replace app-id and client-id by placeholder but they are the correct values)

{"$schema": "./node_modules/@datadog/mobile-react-native/datadog-configuration.schema.json", "configuration": {"applicationId": "app-id", "batchSize": "SMALL", "clientToken": "client-id", "env": "development", "longTaskThresholdMs": 1000, "nativeCrashReportEnabled": true, "sessionSamplingRate": 100, "site": "EU1", "telemetrySampleRate": 20, "trackBackgroundEvents": false, "trackErrors": true, "trackInteractions": false, "trackResources": false, "trackingConsent": "GRANTED", "uploadFrequency": "FREQUENT", "verbosity": "WARN"}}

Expected behavior

to work properly when using file config

Affected SDK versions

all

Latest working SDK version

none

Did you confirm if the latest SDK version fixes the bug?

Yes

Integration Methods

Bun

React Native Version

don't matter

Package.json Contents

don't matter

iOS Setup

Expo CNG with custom plugin to init datadog native side

Android Setup

Expo CNG with custom plugin to init datadog native side

Device Information

don't matter

Other relevant information

if i do it by hand it seems to work

const configuration = require("../../datadog-configuration.json").configuration as DatadogProviderConfiguration
export const config = new DatadogProviderConfiguration(
	configuration.clientToken,
	configuration.env,
	configuration.applicationId,
	configuration.trackInteractions,
	configuration.trackResources,
	configuration.trackErrors,
	configuration.trackingConsent,
)

const ignoreKeys = [
	"clientToken",
	"env",
	"applicationId",
	"trackInteractions",
	"trackResources",
	"trackErrors",
	"trackingConsent",
]
for (const key of Object.keys(configuration).filter((k) => !ignoreKeys.includes(k))) {
	if (key in config) config[key] = configuration[key]
	else console.warn(`Unknown Datadog configuration key: ${key}`)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions