Skip to content

aliu/unleash #15035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 78 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
0f6ef9a
ci(v8): Ensure CI runs on v8 & v9 branches (#14604) (#14727)
mydea Dec 16, 2024
323a38c
meta(changelog): Update changelog for 8.45.1 (#14722)
andreiborza Dec 16, 2024
3690d62
release: 8.45.1
getsentry-bot Dec 16, 2024
f6ef5a1
Merge branch 'release/8.45.1' into v8
Dec 16, 2024
85952db
chore(craft): Publish only aws v8 layer (#14703)
andreiborza Dec 16, 2024
c698ad9
feat: Allow capture of more than 1 ANR event [v8] (#14713)
timfish Dec 16, 2024
6e682c4
fix: Normalise ANR debug image file paths if appRoot was supplied [v8…
timfish Dec 16, 2024
9527563
feat(node): Detect Railway release name [v8] (#14714)
AbhiPrasad Dec 16, 2024
d32bf15
fix(nuxt): Remove build config from tsconfig (#14737)
s1gr1d Dec 16, 2024
dcc5742
ref(flags): don't export FeatureFlagContext in types-hoist/context.ts…
aliu39 Dec 16, 2024
0e5e77a
meta(changelog): Update changelog for 8.46.0
s1gr1d Dec 16, 2024
ea72950
Merge pull request #14739 from getsentry/changelog-8.46.0
s1gr1d Dec 17, 2024
5387fde
release: 8.46.0
getsentry-bot Dec 17, 2024
e80eefe
Merge branch 'release/8.46.0' into v8
Dec 17, 2024
3a7743c
feat(core): Add `updateSpanName` helper function [v8] (#14736)
Lms24 Dec 17, 2024
9c53d48
feat(v8/node/deps): Bump @prisma/instrumentation from 5.19.1 to 5.22.…
mydea Dec 17, 2024
8e0db86
chore(docs): Add docs for how to publish a release for previous major…
andreiborza Dec 18, 2024
37fbd75
feat(v8/node): Do not overwrite prisma `db.system` in newer Prisma ve…
mydea Dec 18, 2024
b1d393e
ref(v8/nextjs): Fix typo in source maps deletion warning (#14776)
Lms24 Dec 18, 2024
8107512
feat(v8/replay): Mask srcdoc iframe contents per default (#14779)
chargome Dec 18, 2024
8a7b29e
meta: Update changelog for 8.47.0 (#14777)
Lms24 Dec 18, 2024
eac1a88
release: 8.47.0
getsentry-bot Dec 18, 2024
b6c84fa
Merge branch 'release/8.47.0' into v8
Dec 18, 2024
01a2571
fix(nestjs/v8): Use correct main/module path in package.json (#14791)
AbhiPrasad Dec 19, 2024
d3f52cf
feat(v8/core): Deprecate `getDomElement` method (#14799)
mydea Dec 19, 2024
e7b3530
fix(v8/node): Ensure `NODE_OPTIONS` is not passed to worker threads (…
timfish Dec 23, 2024
bc7e87f
fix(v8/node): Correctly resolve debug IDs for ANR events with custom …
timfish Dec 23, 2024
3693a5d
fix(v8/angular): Fall back to element `tagName` when name is not prov…
Lms24 Dec 23, 2024
b578a71
fix(aws-lambda): Remove version suffix from lambda layer (#14843)
andreiborza Dec 27, 2024
75ca8b9
meta(changelog): Update changelog for 8.48.0 (#14844)
andreiborza Dec 27, 2024
90714e1
Init[WIP]
aliu39 Dec 30, 2024
576a1ad
fix(v8/core): Use consistent `continueTrace` implementation in core (…
s1gr1d Dec 30, 2024
960dd9b
fix(v8/node): Ensure express requests are properly handled (#14851)
mydea Dec 30, 2024
dbd3296
feat(v8/node): Add `openTelemetrySpanProcessors` option (#14853)
mydea Dec 30, 2024
845b7aa
fix(v8/react): Improve handling of routes nested under path="/" (#14897)
onurtemizkan Jan 3, 2025
6fa3797
feat(v8/core): Add `normalizedRequest` to `samplingContext` (#14903)
s1gr1d Jan 7, 2025
77cabfb
fix(v8/react): Use `Set` as the `allRoutes` container. (#14878) (#14884)
chargome Jan 7, 2025
8b03e0b
fix(v8/feedback): Avoid lazy loading code for `syncFeedbackIntegratio…
mydea Jan 7, 2025
8e2ed6f
meta(changelog): Update changelog for 8.48.0 (#14919)
andreiborza Jan 7, 2025
405ceb4
release: 8.48.0
getsentry-bot Jan 7, 2025
e31e1c5
Merge branch 'release/8.48.0' into v8
Jan 7, 2025
29f5bac
Merge branch 'v8' into aliu/unleash
aliu39 Jan 8, 2025
e714b9e
Working patch and basic test for isEnabled
aliu39 Jan 9, 2025
e02b91b
Biome check
aliu39 Jan 9, 2025
785aab3
fix(profiling/v8): Don't put `require`, `__filename` and `__dirname` …
lforst Jan 9, 2025
8926cb7
fix(v8/vue): Re-throw error when no errorHandler exists (#14943)
s1gr1d Jan 9, 2025
af00c8f
fix(v8/sveltekit): Ensure source maps deletion is called after source…
Lms24 Jan 9, 2025
e464187
Merge branch 'v8' into aliu/unleash
aliu39 Jan 9, 2025
7ec8d02
Working patch and test for getVariant
aliu39 Jan 9, 2025
f1a5574
Fix docstr sample code
aliu39 Jan 9, 2025
34af880
Fix patching for correct access to
aliu39 Jan 9, 2025
c8b0078
ini.js format
aliu39 Jan 9, 2025
2543733
init.js format2
aliu39 Jan 10, 2025
5182853
chore(v8/repo): Add missing v7 changelog entries (#14961)
Lms24 Jan 10, 2025
211a1ab
Disable eslint/unbound-method
aliu39 Jan 10, 2025
fda1aee
feat(v8/react): Add a `handled` prop to ErrorBoundary (#14978)
Lms24 Jan 10, 2025
0c3b2a4
fix(v8/replay): Disable mousemove sampling in rrweb for iOS browsers …
chargome Jan 10, 2025
2898386
Rm getVariant code
aliu39 Jan 10, 2025
b972f6e
Add withScope test
aliu39 Jan 10, 2025
798a932
feat(v8/browser): Flush offline queue on flush and browser online eve…
timfish Jan 13, 2025
286f6b0
test(v8/e2e): Fix node-express test transitive dependency (#15004)
mydea Jan 14, 2025
dd64f14
Merge branch 'v8' into aliu/unleash
aliu39 Jan 14, 2025
f5ac627
fix(v8/node): Enforce that ContextLines integration does not leave op…
AbhiPrasad Jan 14, 2025
8c07c27
Merge branch 'v8' into aliu/unleash
aliu39 Jan 15, 2025
629fba2
meta(changelog): Update CHANGELOG for 8.49.0 (#15019)
AbhiPrasad Jan 15, 2025
db51933
release: 8.49.0
getsentry-bot Jan 15, 2025
5144754
Merge branch 'release/8.49.0' into v8
Jan 15, 2025
6f9bc8b
feat(v8/react): Add support for React Router `createMemoryRouter` (#1…
onurtemizkan Jan 15, 2025
b93864e
meta(changelog): Update changelog for 8.50.0 (#15025)
lforst Jan 15, 2025
70efdde
release: 8.50.0
getsentry-bot Jan 15, 2025
9ccf2bf
Merge branch 'release/8.50.0' into v8
Jan 15, 2025
dbf0f64
Rewrite patching with fill()
aliu39 Jan 15, 2025
ba090a2
Change integration input to an options dict
aliu39 Jan 15, 2025
bba93f7
Update wrapper docstr
aliu39 Jan 15, 2025
776bb58
Add badSignature test
aliu39 Jan 15, 2025
fae120b
Fix formatting (yarn run biome check --apply)
aliu39 Jan 15, 2025
6160f07
Merge branch 'v8' into aliu/unleash
aliu39 Jan 15, 2025
bcc0b86
Only log/test if debug build
aliu39 Jan 16, 2025
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
17 changes: 1 addition & 16 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,11 @@ targets:
id: '@sentry-internal/eslint-config-sdk'
includeNames: /^sentry-internal-eslint-config-sdk-\d.*\.tgz$/

# TODO(v9): Remove this target
# NOTE: We publish the v8 layer under its own name so people on v8 can still get patches
# whenever we release a new v8 version—otherwise we would overwrite the current major lambda layer.
- name: aws-lambda-layer
includeNames: /^sentry-node-serverless-\d+.\d+.\d+(-(beta|alpha|rc)\.\d+)?\.zip$/
layerName: SentryNodeServerlessSDKv8
compatibleRuntimes:
- name: node
versions:
- nodejs10.x
- nodejs12.x
- nodejs14.x
- nodejs16.x
- nodejs18.x
- nodejs20.x
license: MIT

# AWS Lambda Layer target
- name: aws-lambda-layer
includeNames: /^sentry-node-serverless-\d+.\d+.\d+(-(beta|alpha|rc)\.\d+)?\.zip$/
# TODO(v9): change to `SentryNodeServerlessSDKv8` once v9 is released
layerName: SentryNodeServerlessSDK
compatibleRuntimes:
- name: node
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
branches:
- develop
- master
- v9
- v8
- release/**
pull_request:
merge_group:
Expand Down Expand Up @@ -105,7 +107,7 @@ jobs:
outputs:
commit_label: '${{ env.COMMIT_SHA }}: ${{ env.COMMIT_MESSAGE }}'
# Note: These next three have to be checked as strings ('true'/'false')!
is_develop: ${{ github.ref == 'refs/heads/develop' }}
is_base_branch: ${{ github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/v9' || github.ref == 'refs/heads/v8'}}
is_release: ${{ startsWith(github.ref, 'refs/heads/release/') }}
changed_profiling_node: ${{ steps.changed.outputs.profiling_node == 'true' }}
changed_ci: ${{ steps.changed.outputs.workflow == 'true' }}
Expand All @@ -126,7 +128,7 @@ jobs:
timeout-minutes: 15
if: |
needs.job_get_metadata.outputs.changed_any_code == 'true' ||
needs.job_get_metadata.outputs.is_develop == 'true' ||
needs.job_get_metadata.outputs.is_base_branch == 'true' ||
needs.job_get_metadata.outputs.is_release == 'true' ||
(needs.job_get_metadata.outputs.is_gitflow_sync == 'false' && needs.job_get_metadata.outputs.has_gitflow_label == 'false')
steps:
Expand Down Expand Up @@ -171,7 +173,7 @@ jobs:
key: nx-Linux-${{ github.ref }}-${{ env.HEAD_COMMIT || github.sha }}
# On develop branch, we want to _store_ the cache (so it can be used by other branches), but never _restore_ from it
restore-keys:
${{needs.job_get_metadata.outputs.is_develop == 'false' && env.NX_CACHE_RESTORE_KEYS || 'nx-never-restore'}}
${{needs.job_get_metadata.outputs.is_base_branch == 'false' && env.NX_CACHE_RESTORE_KEYS || 'nx-never-restore'}}

- name: Build packages
# Set the CODECOV_TOKEN for Bundle Analysis
Expand Down Expand Up @@ -219,7 +221,7 @@ jobs:
timeout-minutes: 15
runs-on: ubuntu-20.04
if:
github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_develop == 'true' ||
github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_base_branch == 'true' ||
needs.job_get_metadata.outputs.is_release == 'true'
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
Expand Down Expand Up @@ -1207,7 +1209,8 @@ jobs:
- name: Run E2E test
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
timeout-minutes: 10
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:assert
run: |
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:assert

job_required_jobs_passed:
name: All required jobs passed or were skipped
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/enforce-license-compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@ name: "CI: Enforce License Compliance"

on:
push:
branches: [master, develop, release/*]
branches:
- develop
- master
- v9
- v8
- release/**
pull_request:
branches: [master, develop]
branches:
- develop
- master
- v9
- v8

jobs:
enforce-license-compliance:
Expand Down
2 changes: 1 addition & 1 deletion .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = [
path: 'packages/browser/build/npm/esm/index.js',
import: createImport('init', 'browserTracingIntegration', 'replayIntegration'),
gzip: true,
limit: '75 KB',
limit: '76 KB',
},
{
name: '@sentry/browser (incl. Tracing, Replay) - with treeshaking flags',
Expand Down
66 changes: 66 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,72 @@

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

## 8.50.0

- feat(v8/react): Add support for React Router `createMemoryRouter` ([#14985](https://github.com/getsentry/sentry-javascript/pull/14985))

## 8.49.0

- feat(v8/browser): Flush offline queue on flush and browser online event ([#14969](https://github.com/getsentry/sentry-javascript/pull/14969))
- feat(v8/react): Add a `handled` prop to ErrorBoundary ([#14978](https://github.com/getsentry/sentry-javascript/pull/14978))
- fix(profiling/v8): Don't put `require`, `__filename` and `__dirname` on global object ([#14952](https://github.com/getsentry/sentry-javascript/pull/14952))
- fix(v8/node): Enforce that ContextLines integration does not leave open file handles ([#14997](https://github.com/getsentry/sentry-javascript/pull/14997))
- fix(v8/replay): Disable mousemove sampling in rrweb for iOS browsers ([#14944](https://github.com/getsentry/sentry-javascript/pull/14944))
- fix(v8/sveltekit): Ensure source maps deletion is called after source ma… ([#14963](https://github.com/getsentry/sentry-javascript/pull/14963))
- fix(v8/vue): Re-throw error when no errorHandler exists ([#14943](https://github.com/getsentry/sentry-javascript/pull/14943))

Work in this release was contributed by @HHK1 and @mstrokin. Thank you for your contribution!

## 8.48.0

### Deprecations

- **feat(v8/core): Deprecate `getDomElement` method ([#14799](https://github.com/getsentry/sentry-javascript/pull/14799))**

Deprecates `getDomElement`. There is no replacement.

### Other changes

- fix(nestjs/v8): Use correct main/module path in package.json ([#14791](https://github.com/getsentry/sentry-javascript/pull/14791))
- fix(v8/core): Use consistent `continueTrace` implementation in core ([#14819](https://github.com/getsentry/sentry-javascript/pull/14819))
- fix(v8/node): Correctly resolve debug IDs for ANR events with custom appRoot ([#14823](https://github.com/getsentry/sentry-javascript/pull/14823))
- fix(v8/node): Ensure `NODE_OPTIONS` is not passed to worker threads ([#14825](https://github.com/getsentry/sentry-javascript/pull/14825))
- fix(v8/angular): Fall back to element `tagName` when name is not provided to `TraceDirective` ([#14828](https://github.com/getsentry/sentry-javascript/pull/14828))
- fix(aws-lambda): Remove version suffix from lambda layer ([#14843](https://github.com/getsentry/sentry-javascript/pull/14843))
- fix(v8/node): Ensure express requests are properly handled ([#14851](https://github.com/getsentry/sentry-javascript/pull/14851))
- feat(v8/node): Add `openTelemetrySpanProcessors` option ([#14853](https://github.com/getsentry/sentry-javascript/pull/14853))
- fix(v8/react): Use `Set` as the `allRoutes` container. ([#14878](https://github.com/getsentry/sentry-javascript/pull/14878)) (#14884)
- fix(v8/react): Improve handling of routes nested under path="/" ([#14897](https://github.com/getsentry/sentry-javascript/pull/14897))
- feat(v8/core): Add `normalizedRequest` to `samplingContext` ([#14903](https://github.com/getsentry/sentry-javascript/pull/14903))
- fix(v8/feedback): Avoid lazy loading code for `syncFeedbackIntegration` ([#14918](https://github.com/getsentry/sentry-javascript/pull/14918))

Work in this release was contributed by @arturovt. Thank you for your contribution!

## 8.47.0

- feat(v8/core): Add `updateSpanName` helper function (#14736)
- feat(v8/node): Do not overwrite prisma `db.system` in newer Prisma versions (#14772)
- feat(v8/node/deps): Bump @prisma/instrumentation from 5.19.1 to 5.22.0 (#14755)
- feat(v8/replay): Mask srcdoc iframe contents per default (#14779)
- ref(v8/nextjs): Fix typo in source maps deletion warning (#14776)

Work in this release was contributed by @aloisklink and @benjick. Thank you for your contributions!

## 8.46.0

- feat: Allow capture of more than 1 ANR event [v8] ([#14713](https://github.com/getsentry/sentry-javascript/pull/14713))
- feat(node): Detect Railway release name [v8] ([#14714](https://github.com/getsentry/sentry-javascript/pull/14714))
- fix: Normalise ANR debug image file paths if appRoot was supplied [v8] ([#14709](https://github.com/getsentry/sentry-javascript/pull/14709))
- fix(nuxt): Remove build config from tsconfig ([#14737](https://github.com/getsentry/sentry-javascript/pull/14737))

Work in this release was contributed by @conor-ob. Thank you for your contribution!

## 8.45.1

- fix(feedback): Return when the `sendFeedback` promise resolves ([#14683](https://github.com/getsentry/sentry-javascript/pull/14683))

Work in this release was contributed by @antonis. Thank you for your contribution!

## 8.45.0

- feat(core): Add `handled` option to `captureConsoleIntegration` ([#14664](https://github.com/getsentry/sentry-javascript/pull/14664))
Expand Down
4 changes: 2 additions & 2 deletions dev-packages/browser-integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry-internal/browser-integration-tests",
"version": "8.45.0",
"version": "8.50.0",
"main": "index.js",
"license": "MIT",
"engines": {
Expand Down Expand Up @@ -43,7 +43,7 @@
"@babel/preset-typescript": "^7.16.7",
"@playwright/test": "^1.44.1",
"@sentry-internal/rrweb": "2.31.0",
"@sentry/browser": "8.45.0",
"@sentry/browser": "8.50.0",
"axios": "1.7.7",
"babel-loader": "^8.2.2",
"html-webpack-plugin": "^5.5.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as Sentry from '@sentry/browser';

window.UnleashClient = class {
isEnabled(x) {
return x;
}
};

window.Sentry = Sentry;
window.sentryUnleashIntegration = Sentry.unleashIntegration({ unleashClientClass: window.UnleashClient });

Sentry.init({
dsn: 'https://[email protected]/1337',
sampleRate: 1.0,
integrations: [window.sentryUnleashIntegration],
debug: true, // Required to test logging.
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../../utils/fixtures';

import { shouldSkipFeatureFlagsTest } from '../../../../../utils/helpers';

sentryTest('Logs and returns if isEnabled does not match expected signature', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
sentryTest.skip();
}
const bundleKey = process.env.PW_BUNDLE || '';
const hasDebug = !bundleKey.includes('_min');

await page.route('https://dsn.ingest.sentry.io/**/*', route => {
return route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ id: 'test-id' }),
});
});

const url = await getLocalTestUrl({ testDir: __dirname, skipDsnRouteHandler: true });
await page.goto(url);

const errorLogs: string[] = [];
page.on('console', msg => {
if (msg.type() == 'error') {
errorLogs.push(msg.text());
}
});

const results = await page.evaluate(() => {
const unleash = new (window as any).UnleashClient();
const res1 = unleash.isEnabled('my-feature');
const res2 = unleash.isEnabled(999);
const res3 = unleash.isEnabled({});
return [res1, res2, res3];
});

// Test that the expected results are still returned. Note isEnabled is identity function for this test.
expect(results).toEqual(['my-feature', 999, {}]);

// Expected error logs.
if (hasDebug) {
expect(errorLogs).toEqual(
expect.arrayContaining([
expect.stringContaining(
'[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: my-feature (string), result: my-feature (string)',
),
expect.stringContaining(
'[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: 999 (number), result: 999 (number)',
),
expect.stringContaining(
'[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: [object Object] (object), result: [object Object] (object)',
),
]),
);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.

sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
sentryTest.skip();
}

await page.route('https://dsn.ingest.sentry.io/**/*', route => {
return route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ id: 'test-id' }),
});
});

const url = await getLocalTestUrl({ testDir: __dirname, skipDsnRouteHandler: true });
await page.goto(url);

await page.evaluate(bufferSize => {
const client = new (window as any).UnleashClient();

client.isEnabled('feat1');
client.isEnabled('strFeat');
client.isEnabled('noPayloadFeat');
client.isEnabled('jsonFeat');
client.isEnabled('noVariantFeat');
client.isEnabled('disabledFeat');

for (let i = 7; i <= bufferSize; i++) {
client.isEnabled(`feat${i}`);
}
client.isEnabled(`feat${bufferSize + 1}`); // eviction
client.isEnabled('noPayloadFeat'); // update (move to tail)
}, FLAG_BUFFER_SIZE);

const reqPromise = waitForErrorRequest(page);
await page.locator('#error').click();
const req = await reqPromise;
const event = envelopeRequestParser(req);

const expectedFlags = [{ flag: 'strFeat', result: true }];
expectedFlags.push({ flag: 'jsonFeat', result: true });
expectedFlags.push({ flag: 'noVariantFeat', result: true });
expectedFlags.push({ flag: 'disabledFeat', result: false });
for (let i = 7; i <= FLAG_BUFFER_SIZE; i++) {
expectedFlags.push({ flag: `feat${i}`, result: false });
}
expectedFlags.push({ flag: `feat${FLAG_BUFFER_SIZE + 1}`, result: false });
expectedFlags.push({ flag: 'noPayloadFeat', result: true });

expect(event.contexts?.flags?.values).toEqual(expectedFlags);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as Sentry from '@sentry/browser';

window.UnleashClient = class {
constructor() {
this._featureToVariant = {
strFeat: { name: 'variant1', enabled: true, feature_enabled: true, payload: { type: 'string', value: 'test' } },
noPayloadFeat: { name: 'eu-west', enabled: true, feature_enabled: true },
jsonFeat: {
name: 'paid-orgs',
enabled: true,
feature_enabled: true,
payload: {
type: 'json',
value: '{"foo": {"bar": "baz"}, "hello": [1, 2, 3]}',
},
},

// Enabled feature with no configured variants.
noVariantFeat: { name: 'disabled', enabled: false, feature_enabled: true },

// Disabled feature.
disabledFeat: { name: 'disabled', enabled: false, feature_enabled: false },
};

// Variant returned for features that don't exist.
// `feature_enabled` may be defined in prod, but we want to test the undefined case.
this._fallbackVariant = {
name: 'disabled',
enabled: false,
};
}

isEnabled(toggleName) {
const variant = this._featureToVariant[toggleName] || this._fallbackVariant;
return variant.feature_enabled || false;
}

getVariant(toggleName) {
return this._featureToVariant[toggleName] || this._fallbackVariant;
}
};

window.Sentry = Sentry;
window.sentryUnleashIntegration = Sentry.unleashIntegration({ unleashClientClass: window.UnleashClient });

Sentry.init({
dsn: 'https://[email protected]/1337',
sampleRate: 1.0,
integrations: [window.sentryUnleashIntegration],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
document.getElementById('error').addEventListener('click', () => {
throw new Error('Button triggered error');
});
Loading
Loading