Skip to content

Commit 03699e5

Browse files
committed
Fix and lint
1 parent 4da8068 commit 03699e5

File tree

15 files changed

+90
-42
lines changed

15 files changed

+90
-42
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { expect } from '@playwright/test';
22
import { sentryTest } from '../../../../../../utils/fixtures';
3-
import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../../utils/helpers';
3+
import {
4+
envelopeRequestParser,
5+
shouldSkipFeatureFlagsTest,
6+
waitForErrorRequest,
7+
} from '../../../../../../utils/helpers';
48
import { FLAG_BUFFER_SIZE } from '../../../constants';
59

610
sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {

dev-packages/browser-integration-tests/suites/integrations/featureFlags/featureFlags/onError/withScope/test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { expect } from '@playwright/test';
22
import type { Scope } from '@sentry/browser';
33
import { sentryTest } from '../../../../../../utils/fixtures';
4-
import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../../utils/helpers';
4+
import {
5+
envelopeRequestParser,
6+
shouldSkipFeatureFlagsTest,
7+
waitForErrorRequest,
8+
} from '../../../../../../utils/helpers';
59

610
sentryTest('Flag evaluations in forked scopes are stored separately.', async ({ getLocalTestUrl, page }) => {
711
if (shouldSkipFeatureFlagsTest()) {

dev-packages/browser-integration-tests/suites/integrations/featureFlags/featureFlags/onSpan/subject.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,16 @@ const btnEndSpan = document.getElementById('btnEndSpan');
33
const btnStartNestedSpan = document.getElementById('btnStartNestedSpan');
44
const btnEndNestedSpan = document.getElementById('btnEndNestedSpan');
55

6-
window.withNestedSpans = (callback) => {
7-
window.Sentry.startSpan(
8-
{ name: 'test-root-span' },
9-
rootSpan => {
10-
window.traceId = rootSpan.spanContext().traceId;
6+
window.withNestedSpans = callback => {
7+
window.Sentry.startSpan({ name: 'test-root-span' }, rootSpan => {
8+
window.traceId = rootSpan.spanContext().traceId;
119

12-
window.Sentry.startSpan(
13-
{ name: 'test-span' },
14-
_span => {
15-
16-
window.Sentry.startSpan(
17-
{ name: 'test-nested-span' },
18-
_nestedSpan => {
19-
callback();
20-
}
21-
);
22-
},
23-
);
24-
},
25-
);
10+
window.Sentry.startSpan({ name: 'test-span' }, _span => {
11+
window.Sentry.startSpan({ name: 'test-nested-span' }, _nestedSpan => {
12+
callback();
13+
});
14+
});
15+
});
2616
};
2717

2818
// btnStartNestedSpan.addEventListener('click', () => {

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { expect } from '@playwright/test';
22
import { sentryTest } from '../../../../../utils/fixtures';
3-
import { shouldSkipFeatureFlagsTest, shouldSkipTracingTest, getMultipleSentryEnvelopeRequests, eventAndTraceHeaderRequestParser, type EventAndTraceHeader } from '../../../../../utils/helpers';
3+
import {
4+
type EventAndTraceHeader,
5+
eventAndTraceHeaderRequestParser,
6+
getMultipleSentryEnvelopeRequests,
7+
shouldSkipFeatureFlagsTest,
8+
shouldSkipTracingTest,
9+
} from '../../../../../utils/helpers';
410
import { MAX_FLAGS_PER_SPAN } from '../../constants';
511

612
sentryTest("Feature flags are added to active span's attributes on span end.", async ({ getLocalTestUrl, page }) => {
@@ -23,7 +29,7 @@ sentryTest("Feature flags are added to active span's attributes on span end.", a
2329
page,
2430
1,
2531
{}, // envelopeType: 'transaction' },
26-
eventAndTraceHeaderRequestParser, // properFullEnvelopeRequestParser
32+
eventAndTraceHeaderRequestParser, // properFullEnvelopeRequestParser
2733
);
2834

2935
// withNestedSpans is a util used to start 3 nested spans: root-span (not recorded in transaction_event.spans), span, and nested-span.
@@ -41,8 +47,12 @@ sentryTest("Feature flags are added to active span's attributes on span end.", a
4147
const event = (await envelopeRequestPromise)[0][0];
4248
const innerSpan = event.spans?.[0];
4349
const outerSpan = event.spans?.[1];
44-
const outerSpanFlags = Object.entries(outerSpan?.data ?? {}).filter(([key, _val]) => key.startsWith('flag.evaluation'));
45-
const innerSpanFlags = Object.entries(innerSpan?.data ?? {}).filter(([key, _val]) => key.startsWith('flag.evaluation'));
50+
const outerSpanFlags = Object.entries(outerSpan?.data ?? {}).filter(([key, _val]) =>
51+
key.startsWith('flag.evaluation'),
52+
);
53+
const innerSpanFlags = Object.entries(innerSpan?.data ?? {}).filter(([key, _val]) =>
54+
key.startsWith('flag.evaluation'),
55+
);
4656

4757
expect(innerSpanFlags).toEqual([]);
4858

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { expect } from '@playwright/test';
22
import { sentryTest } from '../../../../../../utils/fixtures';
3-
import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../../utils/helpers';
3+
import {
4+
envelopeRequestParser,
5+
shouldSkipFeatureFlagsTest,
6+
waitForErrorRequest,
7+
} from '../../../../../../utils/helpers';
48
import { FLAG_BUFFER_SIZE } from '../../../constants';
59

610
sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {

dev-packages/browser-integration-tests/suites/integrations/featureFlags/launchdarkly/onError/withScope/test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { expect } from '@playwright/test';
22
import type { Scope } from '@sentry/browser';
33
import { sentryTest } from '../../../../../../utils/fixtures';
4-
import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../../utils/helpers';
4+
import {
5+
envelopeRequestParser,
6+
shouldSkipFeatureFlagsTest,
7+
waitForErrorRequest,
8+
} from '../../../../../../utils/helpers';
59

610
sentryTest('Flag evaluations in forked scopes are stored separately.', async ({ getLocalTestUrl, page }) => {
711
if (shouldSkipFeatureFlagsTest()) {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { expect } from '@playwright/test';
22
import { sentryTest } from '../../../../../../utils/fixtures';
3-
import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../../utils/helpers';
3+
import {
4+
envelopeRequestParser,
5+
shouldSkipFeatureFlagsTest,
6+
waitForErrorRequest,
7+
} from '../../../../../../utils/helpers';
48
import { FLAG_BUFFER_SIZE } from '../../../constants';
59

610
sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {

dev-packages/browser-integration-tests/suites/integrations/featureFlags/openfeature/onError/errorHook/test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { expect } from '@playwright/test';
22
import { sentryTest } from '../../../../../../utils/fixtures';
3-
import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../../utils/helpers';
3+
import {
4+
envelopeRequestParser,
5+
shouldSkipFeatureFlagsTest,
6+
waitForErrorRequest,
7+
} from '../../../../../../utils/helpers';
48
import { FLAG_BUFFER_SIZE } from '../../../constants';
59

610
sentryTest('Flag evaluation error hook', async ({ getLocalTestUrl, page }) => {

dev-packages/browser-integration-tests/suites/integrations/featureFlags/openfeature/onError/withScope/test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { expect } from '@playwright/test';
22
import type { Scope } from '@sentry/browser';
33
import { sentryTest } from '../../../../../../utils/fixtures';
4-
import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../../utils/helpers';
4+
import {
5+
envelopeRequestParser,
6+
shouldSkipFeatureFlagsTest,
7+
waitForErrorRequest,
8+
} from '../../../../../../utils/helpers';
59

610
sentryTest('Flag evaluations in forked scopes are stored separately.', async ({ getLocalTestUrl, page }) => {
711
if (shouldSkipFeatureFlagsTest()) {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { expect } from '@playwright/test';
22
import { sentryTest } from '../../../../../../utils/fixtures';
3-
import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../../utils/helpers';
3+
import {
4+
envelopeRequestParser,
5+
shouldSkipFeatureFlagsTest,
6+
waitForErrorRequest,
7+
} from '../../../../../../utils/helpers';
48
import { FLAG_BUFFER_SIZE } from '../../../constants';
59

610
sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {

dev-packages/browser-integration-tests/suites/integrations/featureFlags/statsig/onError/withScope/test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { expect } from '@playwright/test';
22
import type { Scope } from '@sentry/browser';
33
import { sentryTest } from '../../../../../../utils/fixtures';
4-
import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../../utils/helpers';
4+
import {
5+
envelopeRequestParser,
6+
shouldSkipFeatureFlagsTest,
7+
waitForErrorRequest,
8+
} from '../../../../../../utils/helpers';
59

610
sentryTest('Flag evaluations in forked scopes are stored separately.', async ({ getLocalTestUrl, page }) => {
711
if (shouldSkipFeatureFlagsTest()) {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { expect } from '@playwright/test';
22
import { sentryTest } from '../../../../../../utils/fixtures';
3-
import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../../utils/helpers';
3+
import {
4+
envelopeRequestParser,
5+
shouldSkipFeatureFlagsTest,
6+
waitForErrorRequest,
7+
} from '../../../../../../utils/helpers';
48
import { FLAG_BUFFER_SIZE } from '../../../constants';
59

610
sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { expect } from '@playwright/test';
22
import type { Scope } from '@sentry/browser';
33
import { sentryTest } from '../../../../../../utils/fixtures';
4-
import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../../utils/helpers';
4+
import {
5+
envelopeRequestParser,
6+
shouldSkipFeatureFlagsTest,
7+
waitForErrorRequest,
8+
} from '../../../../../../utils/helpers';
59

610
sentryTest('Flag evaluations in forked scopes are stored separately.', async ({ getLocalTestUrl, page }) => {
711
if (shouldSkipFeatureFlagsTest()) {

packages/browser/src/utils/featureFlags.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function copyFlagsFromScopeToEvent(event: Event): Event {
5252
* @param name Name of the feature flag to insert.
5353
* @param value Value of the feature flag.
5454
* @param maxSize Max number of flags the buffer should store. Default value should always be used in production.
55-
*/
55+
*/
5656
export function insertFlagToScope(name: string, value: unknown, maxSize: number = FLAG_BUFFER_SIZE): void {
5757
const scopeContexts = getCurrentScope().getScopeData().contexts;
5858
if (!scopeContexts.flags) {
@@ -75,7 +75,13 @@ export function insertFlagToScope(name: string, value: unknown, maxSize: number
7575
* @param maxSize Max number of flags the buffer should store. Default value should always be used in production.
7676
* @param allowEviction If true, the oldest flag is evicted when the buffer is full. Otherwise the new flag is dropped.
7777
*/
78-
export function insertToFlagBuffer(flags: FeatureFlag[], name: string, value: unknown, maxSize: number, allowEviction: boolean = true): void {
78+
export function insertToFlagBuffer(
79+
flags: FeatureFlag[],
80+
name: string,
81+
value: unknown,
82+
maxSize: number,
83+
allowEviction: boolean = true,
84+
): void {
7985
if (typeof value !== 'boolean') {
8086
return;
8187
}
@@ -91,15 +97,13 @@ export function insertToFlagBuffer(flags: FeatureFlag[], name: string, value: un
9197
if (index !== -1) {
9298
// The flag was found, remove it from its current position - O(n)
9399
flags.splice(index, 1);
94-
console.log('dup flag', name);
95100
}
96101

97102
if (flags.length === maxSize) {
98103
if (allowEviction) {
99104
// If at capacity, pop the earliest flag - O(n)
100105
flags.shift();
101106
} else {
102-
console.log('dropping flag', name);
103107
return;
104108
}
105109
}
@@ -145,6 +149,8 @@ export function bufferSpanFeatureFlag(
145149
export function freezeSpanFeatureFlags(span: Span): void {
146150
const flags = GLOBAL_OBJ._spanToFlagBufferMap?.get(span);
147151
if (flags) {
148-
span.setAttributes(Object.fromEntries(flags.map(flag => [`${SPAN_FLAG_ATTRIBUTE_PREFIX}${flag.flag}`, flag.result])));
152+
span.setAttributes(
153+
Object.fromEntries(flags.map(flag => [`${SPAN_FLAG_ATTRIBUTE_PREFIX}${flag.flag}`, flag.result])),
154+
);
149155
}
150156
}

packages/browser/test/utils/featureFlags.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ describe('flags', () => {
7575
insertToFlagBuffer(buffer, 'feat1', false, maxSize, false);
7676
insertToFlagBuffer(buffer, 'feat1', true, maxSize, false);
7777

78-
expect(buffer).toEqual([
79-
{ flag: 'feat1', result: true },
80-
]);
78+
expect(buffer).toEqual([{ flag: 'feat1', result: true }]);
8179
});
8280

8381
it('does not allocate unnecessary space', () => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy