diff --git a/packages/core/src/js/scopeSync.ts b/packages/core/src/js/scopeSync.ts index 1fe6b65265..0bfd05186a 100644 --- a/packages/core/src/js/scopeSync.ts +++ b/packages/core/src/js/scopeSync.ts @@ -1,4 +1,5 @@ import type { Breadcrumb, Scope } from '@sentry/core'; +import { debug } from '@sentry/core'; import { logger } from '@sentry/react'; import { DEFAULT_BREADCRUMB_LEVEL } from './breadcrumb'; import { fillTyped } from './utils/fill'; @@ -81,26 +82,30 @@ export function enableSyncToNative(scope: Scope): void { }); fillTyped(scope, 'setAttribute', original => (key: string, value: unknown): Scope => { + debug.warn('This feature is currently not supported.'); // Only sync primitive types - if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { - NATIVE.setAttribute(key, value); - } + // Native layer still not supported + // if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { + // NATIVE.setAttribute(key, value); + // } return original.call(scope, key, value); }); fillTyped(scope, 'setAttributes', original => (attributes: Record): Scope => { + // Native layer not supported + debug.warn('This feature is currently not supported.'); // Filter to only primitive types - const primitiveAttrs: Record = {}; - Object.keys(attributes).forEach(key => { - const value = attributes[key]; - if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { - primitiveAttrs[key] = value; - } - }); - - if (Object.keys(primitiveAttrs).length > 0) { - NATIVE.setAttributes(primitiveAttrs); - } + // const primitiveAttrs: Record = {}; + // Object.keys(attributes).forEach(key => { + // const value = attributes[key]; + // if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { + // primitiveAttrs[key] = value; + // } + // }); + // + // if (Object.keys(primitiveAttrs).length > 0) { + // NATIVE.setAttributes(primitiveAttrs); + // } return original.call(scope, attributes); }); } diff --git a/packages/core/test/scopeSync.test.ts b/packages/core/test/scopeSync.test.ts index 43a8146648..c1da1841ba 100644 --- a/packages/core/test/scopeSync.test.ts +++ b/packages/core/test/scopeSync.test.ts @@ -116,8 +116,11 @@ describe('ScopeSync', () => { let setExtrasScopeSpy: jest.SpyInstance; let addBreadcrumbScopeSpy: jest.SpyInstance; let setContextScopeSpy: jest.SpyInstance; + /* + TODO: Uncomment once Native setattribute is implemented. let setAttributeScopeSpy: jest.SpyInstance; let setAttributesScopeSpy: jest.SpyInstance; + */ beforeAll(() => { const testScope = SentryCore.getIsolationScope(); @@ -219,6 +222,8 @@ describe('ScopeSync', () => { expect(setContextScopeSpy).toHaveBeenCalledExactlyOnceWith('key', { key: 'value' }); }); + /* + TODO: uncomment tests once native implementation is done. it('setAttribute', () => { expect(SentryCore.getIsolationScope().setAttribute).not.toBe(setAttributeScopeSpy); @@ -283,5 +288,6 @@ describe('ScopeSync', () => { }); expect(NATIVE.setAttributes).not.toHaveBeenCalled(); }); + */ }); });