Skip to content

Commit 2898386

Browse files
committed
Rm getVariant code
1 parent 211a1ab commit 2898386

File tree

2 files changed

+2
-60
lines changed
  • dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/basic
  • packages/browser/src/integrations/featureFlags/unleash

2 files changed

+2
-60
lines changed

dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/basic/test.ts

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest
66

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

9-
sentryTest('Basic isEnabled test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
9+
sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
1010
if (shouldSkipFeatureFlagsTest()) {
1111
sentryTest.skip();
1212
}
@@ -47,45 +47,3 @@ sentryTest('Basic isEnabled test with eviction, update, and no async tasks', asy
4747

4848
expect(event.contexts?.flags?.values).toEqual(expectedFlags);
4949
});
50-
51-
sentryTest('Basic getVariant test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
52-
if (shouldSkipFeatureFlagsTest()) {
53-
sentryTest.skip();
54-
}
55-
56-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
57-
return route.fulfill({
58-
status: 200,
59-
contentType: 'application/json',
60-
body: JSON.stringify({ id: 'test-id' }),
61-
});
62-
});
63-
64-
const url = await getLocalTestUrl({ testDir: __dirname, skipDsnRouteHandler: true });
65-
await page.goto(url);
66-
67-
await page.evaluate(bufferSize => {
68-
const client = new (window as any).UnleashClient();
69-
for (let i = 1; i <= bufferSize; i++) {
70-
client.getVariant(`feat${i}`);
71-
}
72-
client.getVariant(`feat${bufferSize + 1}`); // eviction
73-
client.getVariant('feat3'); // update
74-
}, FLAG_BUFFER_SIZE);
75-
76-
const reqPromise = waitForErrorRequest(page);
77-
await page.locator('#error').click();
78-
const req = await reqPromise;
79-
const event = envelopeRequestParser(req);
80-
81-
const expectedFlags = [{ flag: 'feat2', result: true }];
82-
expectedFlags.push({ flag: 'feat4', result: true });
83-
expectedFlags.push({ flag: 'feat5', result: true });
84-
for (let i = 6; i <= FLAG_BUFFER_SIZE; i++) {
85-
expectedFlags.push({ flag: `feat${i}`, result: false });
86-
}
87-
expectedFlags.push({ flag: `feat${FLAG_BUFFER_SIZE + 1}`, result: false });
88-
expectedFlags.push({ flag: 'feat3', result: true });
89-
90-
expect(event.contexts?.flags?.values).toEqual(expectedFlags);
91-
});

packages/browser/src/integrations/featureFlags/unleash/integration.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Client, Event, EventHint, IntegrationFn } from '@sentry/core';
22

33
import { defineIntegration } from '@sentry/core';
44
import { copyFlagsFromScopeToEvent, insertFlagToScope } from '../../../utils/featureFlags';
5-
import type { IVariant, UnleashClient, UnleashClientClass } from './types';
5+
import type { UnleashClient, UnleashClientClass } from './types';
66

77
/**
88
* Sentry integration for capturing feature flag evaluations from the Unleash SDK.
@@ -54,22 +54,6 @@ export const unleashIntegration = defineIntegration((unleashClientClass: Unleash
5454
// eslint-disable-next-line @typescript-eslint/unbound-method
5555
const originalIsEnabled = unleashClientPrototype.isEnabled;
5656
unleashClientPrototype.isEnabled = new Proxy(originalIsEnabled, sentryIsEnabled);
57-
58-
const sentryGetVariant = {
59-
apply: (
60-
target: (this: UnleashClient, toggleName: string) => IVariant,
61-
thisArg: UnleashClient,
62-
args: [toggleName: string],
63-
) => {
64-
const variant = Reflect.apply(target, thisArg, args);
65-
const result = variant.feature_enabled || false; // undefined means the feature does not exist.
66-
insertFlagToScope(args[0], result);
67-
return variant;
68-
},
69-
};
70-
// eslint-disable-next-line @typescript-eslint/unbound-method
71-
const originalGetVariant = unleashClientPrototype.getVariant;
72-
unleashClientPrototype.getVariant = new Proxy(originalGetVariant, sentryGetVariant);
7357
},
7458
};
7559
}) satisfies IntegrationFn;

0 commit comments

Comments
 (0)