refactor(experiments): deprecate link method and update documentation to use runExperiment() instead#851
Conversation
… to use runExperiment() instead Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@claude review |
There was a problem hiding this comment.
LGTM — small, mechanical deprecation change adding @deprecated tags and a runtime warning.
Extended reasoning...
Overview
This PR touches a single file (packages/client/src/dataset/index.ts) to mark the dataset.items[].link() API as deprecated in favor of runExperiment(). The changes are limited to: (1) adding @deprecated JSDoc tags on FetchedDataset.items[].link and the LinkDatasetItemFunction type alias, (2) simplifying the JSDoc on LinkDatasetItemFunction by removing examples that promoted the deprecated path, and (3) adding a runtime logger.warn inside the link closure. No behavior changes to the actual linking logic.
Security risks
None. This is documentation and a logger.warn call — no auth, crypto, input validation, or data-handling code is touched. The deprecation warning is a pure side effect with no user-controllable content.
Level of scrutiny
Low. This is a deprecation-marking PR: zero runtime behavior change to the underlying API beyond an emitted warning string. The risk surface is essentially limited to whether the deprecation messaging is accurate, which it is.
Other factors
The two inline nits posted by the bug hunter — a couple of leftover item.link() references in JSDoc @example blocks and the per-call (rather than once-per-process) warning — are both polish items, not correctness issues. The author can address them at their discretion; neither blocks the deprecation signal from landing. No outstanding human reviewer comments to resolve.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Greptile Summary
This PR deprecates the
link()method onFetchedDatasetitems and redirects users to therunExperiment()API, removing the detailed JSDoc examples in favour of a deprecation notice and a runtimewarn()log.linkproperty on each dataset item is now marked@deprecatedin its JSDoc, andcreateDatasetItemLinkFunctionemits agetGlobalLogger().warn()on every invocation.LinkDatasetItemFunction's type-level documentation now points tolangfuse.experiment.run(), while the property-level JSDoc and runtime warning inconsistently referencerunExperiment()— two different API surfaces that will confuse migrating users.@deprecatedtag was also placed on theitemsarray property itself, not just on thelinkmethod inside each element, which will cause IDE tooling to strike throughdataset.itemseven for code that never callslink().Confidence Score: 4/5
The runtime behaviour of
link()is unchanged; the only additions are a deprecation warning and updated JSDoc. The inconsistency in the migration target affects developer guidance rather than runtime correctness.The
LinkDatasetItemFunctiontype doc and the runtimewarn()message both saylangfuse.experiment.run(), while theFetchedDataset.itemsJSDoc saysrunExperiment(). These are two distinct methods, so users reading different parts of the documentation will be directed to different APIs when migrating away fromlink(). Additionally, placing@deprecatedon theitemsarray itself will cause IDE tooling to strike through any access todataset.items, even for code that never toucheslink().packages/client/src/dataset/index.ts — the deprecation message in
LinkDatasetItemFunctionand the runtime warning should be reconciled with therunExperiment()references used everywhere else.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[User calls link on dataset item] --> B[createDatasetItemLinkFunction closure] B --> C[Emit deprecation warning via getGlobalLogger] C --> D[Extract traceId and spanId from otelSpan] D --> E[Call langfuseClient.api.datasetRunItems.create] E --> F[Return DatasetRunItem] G[Recommended migration path] --> H[dataset.runExperiment or langfuse.experiment.run] H --> I[ExperimentManager handles iteration and linking] I --> F%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD A[User calls link on dataset item] --> B[createDatasetItemLinkFunction closure] B --> C[Emit deprecation warning via getGlobalLogger] C --> D[Extract traceId and spanId from otelSpan] D --> E[Call langfuseClient.api.datasetRunItems.create] E --> F[Return DatasetRunItem] G[Recommended migration path] --> H[dataset.runExperiment or langfuse.experiment.run] H --> I[ExperimentManager handles iteration and linking] I --> FPrompt To Fix All With AI
Reviews (1): Last reviewed commit: "refactor(experiments): deprecate link me..." | Re-trigger Greptile