Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
26722d7
Init package files
aliu39 Oct 29, 2024
72f9cc0
Merge branch 'develop' into aliu/launch-darkly
aliu39 Oct 29, 2024
419cd83
Revert changelog and move types file
aliu39 Oct 29, 2024
610da4d
Add ld to dependencies and skeleton code. Get rid of core/
aliu39 Oct 29, 2024
5b2e5ec
Fix readme, rename types file, bring back core/
aliu39 Oct 29, 2024
66b1253
Fix readme 2
aliu39 Oct 30, 2024
023604a
Merge branch 'develop' into aliu/launch-darkly
aliu39 Oct 30, 2024
1f99c28
Merge branch 'aliu/launch-darkly' of https://github.com/getsentry/sen…
aliu39 Oct 30, 2024
85acc6d
Finish implementing, minus scope.flags
aliu39 Oct 30, 2024
3b3a767
Implement flag buffer in sentry scope
aliu39 Oct 30, 2024
ab3181d
Revert changelog
aliu39 Oct 30, 2024
22684ea
fix types
michellewzhang Oct 30, 2024
79e5b24
docstring
michellewzhang Oct 30, 2024
63649c5
Export FeatureFlag type in index.ts
aliu39 Oct 30, 2024
923500f
Merge branch 'aliu/launch-darkly' of https://github.com/getsentry/sen…
aliu39 Oct 30, 2024
bd04755
Clean up comments
aliu39 Oct 30, 2024
91a4db9
Fix build (uses yalc for scope changes) and use LRUMap util
aliu39 Oct 31, 2024
1849673
Merge branch 'develop' into aliu/launch-darkly
aliu39 Nov 5, 2024
1ca9d53
Tweak hook name and docs
aliu39 Nov 5, 2024
893cd62
FlagBuffer class and interface, add to scope._contexts. Remove old fl…
aliu39 Nov 6, 2024
f172683
Call clone in scope.clone()
aliu39 Nov 6, 2024
b96c17f
Rewrite as a util fx instead of class. Use in LD integration
aliu39 Nov 6, 2024
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
50 changes: 0 additions & 50 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,6 @@

- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott

## 8.36.0

### Important Changes

- **feat(nuxt): Add Sentry Pinia plugin ([#14047](https://github.com/getsentry/sentry-javascript/pull/14047))**

The Nuxt SDK now allows you to track Pinia state for captured errors. To enable the Pinia plugin, set the `trackPinia` option to `true` in your client config:

```ts
// sentry.client.config.ts

Sentry.init({
trackPinia: true,
});
```

Read more about the Pinia plugin in the [Sentry Pinia Documentation](https://docs.sentry.io/platforms/javascript/guides/nuxt/features/pinia/).

- **feat(nextjs/vercel-edge/cloudflare): Switch to OTEL for performance monitoring ([#13889](https://github.com/getsentry/sentry-javascript/pull/13889))**

With this release, the Sentry Next.js, and Cloudflare SDKs will now capture performance data based on OpenTelemetry.
Some exceptions apply in cases where Next.js captures inaccurate data itself.

NOTE: You may experience minor differences in transaction names in Sentry.
Most importantly transactions for serverside pages router invocations will now be named `GET /[param]/my/route` instead of `/[param]/my/route`.
This means that those transactions are now better aligned with the OpenTelemetry semantic conventions.

### Other Changes

- deps: Bump bundler plugins and CLI to 2.22.6 and 2.37.0 respectively ([#14050](https://github.com/getsentry/sentry-javascript/pull/14050))
- feat(deps): bump @opentelemetry/instrumentation-aws-sdk from 0.44.0 to 0.45.0 ([#14099](https://github.com/getsentry/sentry-javascript/pull/14099))
- feat(deps): bump @opentelemetry/instrumentation-connect from 0.39.0 to 0.40.0 ([#14101](https://github.com/getsentry/sentry-javascript/pull/14101))
- feat(deps): bump @opentelemetry/instrumentation-express from 0.43.0 to 0.44.0 ([#14102](https://github.com/getsentry/sentry-javascript/pull/14102))
- feat(deps): bump @opentelemetry/instrumentation-fs from 0.15.0 to 0.16.0 ([#14098](https://github.com/getsentry/sentry-javascript/pull/14098))
- feat(deps): bump @opentelemetry/instrumentation-kafkajs from 0.3.0 to 0.4.0 ([#14100](https://github.com/getsentry/sentry-javascript/pull/14100))
- feat(nextjs): Add method and url to route handler request data ([#14084](https://github.com/getsentry/sentry-javascript/pull/14084))
- feat(node): Add breadcrumbs for `child_process` and `worker_thread` ([#13896](https://github.com/getsentry/sentry-javascript/pull/13896))
- fix(core): Ensure standalone spans are not sent if SDK is disabled ([#14088](https://github.com/getsentry/sentry-javascript/pull/14088))
- fix(nextjs): Await flush in api handlers ([#14023](https://github.com/getsentry/sentry-javascript/pull/14023))
- fix(nextjs): Don't leak webpack types into exports ([#14116](https://github.com/getsentry/sentry-javascript/pull/14116))
- fix(nextjs): Fix matching logic for file convention type for root level components ([#14038](https://github.com/getsentry/sentry-javascript/pull/14038))
- fix(nextjs): Respect directives in value injection loader ([#14083](https://github.com/getsentry/sentry-javascript/pull/14083))
- fix(nuxt): Only wrap `.mjs` entry files in rollup ([#14060](https://github.com/getsentry/sentry-javascript/pull/14060))
- fix(nuxt): Re-export all exported bindings ([#14086](https://github.com/getsentry/sentry-javascript/pull/14086))
- fix(nuxt): Server-side setup in readme ([#14049](https://github.com/getsentry/sentry-javascript/pull/14049))
- fix(profiling-node): Always warn when running on incompatible major version of Node.js ([#14043](https://github.com/getsentry/sentry-javascript/pull/14043))
- fix(replay): Fix `onError` callback ([#14002](https://github.com/getsentry/sentry-javascript/pull/14002))
- perf(otel): Only calculate current timestamp once ([#14094](https://github.com/getsentry/sentry-javascript/pull/14094))
- test(browser-integration): Add sentry DSN route handler by default ([#14095](https://github.com/getsentry/sentry-javascript/pull/14095))

## 8.35.0

### Beta release of the official Nuxt Sentry SDK
Expand Down
6 changes: 6 additions & 0 deletions packages/aws-serverless/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ export function tryPatchHandler(taskRoot: string, handlerPath: string): void {
return;
}

// Check for prototype pollution
if (functionName === '__proto__' || functionName === 'constructor' || functionName === 'prototype') {
DEBUG_BUILD && logger.error(`Invalid handler name: ${functionName}`);
return;
}

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
(mod as HandlerModule)[functionName!] = wrapHandler(obj);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/launchdarkly/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
build/
39 changes: 39 additions & 0 deletions packages/launchdarkly/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Note: All paths are relative to the directory in which eslint is being run, rather than the directory where this file
// lives

// ESLint config docs: https://eslint.org/docs/user-guide/configuring/

module.exports = {
extends: ['../../.eslintrc.js'],
overrides: [
{
files: ['src/**/*.ts'],
},
{
files: ['test.setup.ts', 'vitest.config.ts'],
parserOptions: {
project: ['tsconfig.test.json'],
},
rules: {
'no-console': 'off',
},
},
{
files: ['test/**/*.ts'],

rules: {
// most of these errors come from `new Promise(process.nextTick)`
'@typescript-eslint/unbound-method': 'off',
// TODO: decide if we want to enable this again after the migration
// We can take the freedom to be a bit more lenient with tests
'@typescript-eslint/no-floating-promises': 'off',
},
},
{
files: ['src/types/deprecated.ts'],
rules: {
'@typescript-eslint/naming-convention': 'off',
},
},
],
};
4 changes: 4 additions & 0 deletions packages/launchdarkly/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
/*.tgz
.eslintcache
build
21 changes: 21 additions & 0 deletions packages/launchdarkly/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023-2024 Functional Software, Inc. dba Sentry

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
25 changes: 25 additions & 0 deletions packages/launchdarkly/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<p align="center">
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
</a>
</p>

# Sentry Integration for Feedback

This SDK is **considered experimental and in a beta state**. It may experience breaking changes, and may be discontinued
at any time. Please reach out on [GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) if you have
any feedback/concerns.

To view Feedback in Sentry, your
[Sentry organization must be an early adopter](https://docs.sentry.io/product/accounts/early-adopter-features/).

## Installation

Please read the [offical integration documentation](https://docs.sentry.io/platforms/javascript/user-feedback/) for
installation instructions.

## Configuration

The Feedback integration is highly customizable, please read the
[official integration documentation](https://docs.sentry.io/platforms/javascript/user-feedback/configuration/) for the
most up-to-date configuration options.
73 changes: 73 additions & 0 deletions packages/launchdarkly/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"name": "@sentry-internal/launchdarkly",
"version": "8.35.0",
"description": "Sentry SDK integration for user launchdarkly",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/launchdarkly",
"author": "Sentry",
"license": "MIT",
"engines": {
"node": ">=14.18"
},
"files": [
"/build/npm"
],
"main": "build/npm/cjs/index.js",
"module": "build/npm/esm/index.js",
"types": "build/npm/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./build/npm/types/index.d.ts",
"default": "./build/npm/esm/index.js"
},
"require": {
"types": "./build/npm/types/index.d.ts",
"default": "./build/npm/cjs/index.js"
}
}
},
"typesVersions": {
"<4.9": {
"build/npm/types/index.d.ts": [
"build/npm/types-ts3.8/index.d.ts"
]
}
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@sentry/core": "8.35.0",
"@sentry/types": "8.35.0",
"@sentry/utils": "8.35.0",
"launchdarkly-js-client-sdk": "^3.5.0"
},
"scripts": {
"build": "run-p build:transpile build:types build:bundle",
"build:transpile": "rollup -c rollup.npm.config.mjs",
"build:bundle": "rollup -c rollup.bundle.config.mjs",
"build:dev": "run-p build:transpile build:types",
"build:types": "run-s build:types:core build:types:downlevel",
"build:types:core": "tsc -p tsconfig.types.json",
"build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8 && yarn node ./scripts/shim-preact-export.js",
"build:watch": "run-p build:transpile:watch build:bundle:watch build:types:watch",
"build:dev:watch": "run-p build:transpile:watch build:types:watch",
"build:transpile:watch": "yarn build:transpile --watch",
"build:bundle:watch": "yarn build:bundle --watch",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:tarball": "npm pack",
"circularDepCheck": "madge --circular src/index.ts",
"clean": "rimraf build sentry-internal-launchdarkly-*.tgz",
"fix": "eslint . --format stylish --fix",
"lint": "eslint . --format stylish",
"test": "jest",
"test:watch": "jest --watch",
"yalc:publish": "yalc publish --push --sig"
},
"volta": {
"extends": "../../package.json"
},
"sideEffects": false
}
12 changes: 12 additions & 0 deletions packages/launchdarkly/rollup.bundle.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { makeBaseBundleConfig, makeBundleConfigVariants } from '@sentry-internal/rollup-utils';

const baseBundleConfig = makeBaseBundleConfig({
bundleType: 'addon',
entrypoints: ['src/index.ts'],
licenseTitle: '@sentry-internal/launchdarkly',
outputFileBase: () => 'bundles/launchdarkly',
});

const builds = makeBundleConfigVariants(baseBundleConfig);

export default builds;
19 changes: 19 additions & 0 deletions packages/launchdarkly/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils';

export default makeNPMConfigVariants(
makeBaseNPMConfig({
hasBundles: true,
packageSpecificConfig: {
output: {
// set exports to 'named' or 'auto' so that rollup doesn't warn
exports: 'named',
// set preserveModules to false because for Replay we actually want
// to bundle everything into one file.
preserveModules:
process.env.SENTRY_BUILD_PRESERVE_MODULES === undefined
? false
: Boolean(process.env.SENTRY_BUILD_PRESERVE_MODULES),
},
},
}),
);
75 changes: 75 additions & 0 deletions packages/launchdarkly/scripts/shim-preact-export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// preact does not support more modern TypeScript versions, which breaks our users that depend on older
// TypeScript versions. To fix this, we shim the types from preact to be any and remove the dependency on preact
// for types directly. This script is meant to be run after the build/npm/types-ts3.8 directory is created.

// Path: build/npm/types-ts3.8/global.d.ts

const fs = require('fs');
const path = require('path');

/**
* This regex looks for preact imports we can replace and shim out.
*
* Example:
* import { ComponentChildren, VNode } from 'preact';
*/
const preactImportRegex = /import\s*{\s*([\w\s,]+)\s*}\s*from\s*'preact'\s*;?/;

function walk(dir) {
const files = fs.readdirSync(dir);
files.forEach(file => {
const filePath = path.join(dir, file);
const stat = fs.lstatSync(filePath);
if (stat.isDirectory()) {
walk(filePath);
} else {
if (filePath.endsWith('.d.ts')) {
const content = fs.readFileSync(filePath, 'utf8');

Check failure

Code scanning / CodeQL

Potential file system race condition High

The file may have changed since it
was checked
.
const capture = preactImportRegex.exec(content);
if (capture) {
const groups = capture[1].split(',').map(s => s.trim());

// This generates a shim snippet to replace the type imports from preact
// It generates a snippet based on the capture groups of preactImportRegex.
//
// Example:
//
// import type { ComponentChildren, VNode } from 'preact';
// becomes
// type ComponentChildren: any;
// type VNode: any;
const snippet = groups.reduce((acc, curr) => {
const searchableValue = curr.includes(' as ') ? curr.split(' as ')[1] : curr;

// look to see if imported as value, then we have to use declare const
if (content.includes(`typeof ${searchableValue}`)) {
return `${acc}declare const ${searchableValue}: any;\n`;
}

// look to see if generic type like Foo<T>
if (content.includes(`${searchableValue}<`)) {
return `${acc}type ${searchableValue}<T> = any;\n`;
}

// otherwise we can just leave as type
return `${acc}type ${searchableValue} = any;\n`;
}, '');

// we then can remove the import from preact
const newContent = content.replace(preactImportRegex, '// replaced import from preact');

// and write the new content to the file
fs.writeFileSync(filePath, snippet + newContent, 'utf8');

Check failure

Code scanning / CodeQL

Potential file system race condition High

The file may have changed since it
was checked
.
}
}
}
});
}

function run() {
// recurse through build/npm/types-ts3.8 directory
const dir = path.join('build', 'npm', 'types-ts3.8');
walk(dir);
}

run();
6 changes: 6 additions & 0 deletions packages/launchdarkly/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is used as entry point to generate the npm package and CDN bundles.

export { launchDarklyIntegration } from './integration';

// export type {
// } from './types';
43 changes: 43 additions & 0 deletions packages/launchdarkly/src/integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { IntegrationFn } from '@sentry/types';
import type { LDInspectionFlagUsedHandler } from 'launchdarkly-js-client-sdk';
import type { LaunchDarklyOptions } from './types';

/**
* Sentry integration for capturing feature flags from LaunchDarkly.
*
* See the [feature flag documentation](TODO:) for more information.
*
* @example
*
* ```
* Sentry.init({
* dsn: '__DSN__',
* integrations: [Sentry.replayIntegration()],
* });
* ```
*/
export const launchDarklyIntegration = ((options?: LaunchDarklyOptions) => {
const { ldClient } = options;

return {
name: 'launchdarkly',

setup(client) {
// type is Sentry SDK client

// pseudo-code
ldClient.addHandler(FlagUsedHandler());
},
};
}) satisfies IntegrationFn;

// https://launchdarkly.github.io/js-client-sdk/interfaces/LDInspectionFlagUsedHandler.html //TODO: rm this link
class FlagUsedHandler implements LDInspectionFlagUsedHandler {
public name = 'sentry-feature-flag-monitor'; // eslint-disable-line @sentry-internal/sdk/no-class-field-initializers
public synchronous?: boolean;
public type = 'flag-used' as const; // eslint-disable-line @sentry-internal/sdk/no-class-field-initializers
public method(flagKey, flagDetail, context) {
//TODO:
return;
}
}
Loading
Loading