From 91b030e6baf39d0c8bfe3145c74aedda10cfac25 Mon Sep 17 00:00:00 2001 From: Rui Nunes Date: Tue, 12 Sep 2023 17:39:48 +0100 Subject: [PATCH] fix(analytics): remove analytics API consent dependency --- .../integrations/AnalyticsApi/AnalyticsApi.ts | 11 +++++++++-- .../AnalyticsApi/__tests__/AnalyticsApi.test.ts | 13 +++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/react/src/analytics/integrations/AnalyticsApi/AnalyticsApi.ts b/packages/react/src/analytics/integrations/AnalyticsApi/AnalyticsApi.ts index 8e2a76351..ff915ed89 100644 --- a/packages/react/src/analytics/integrations/AnalyticsApi/AnalyticsApi.ts +++ b/packages/react/src/analytics/integrations/AnalyticsApi/AnalyticsApi.ts @@ -16,11 +16,18 @@ import { import { isArray, omit } from 'lodash-es'; export default class AnalyticsAPI extends integrations.Integration { - static override [utils.CONSENT_CATEGORIES_PROPERTY] = - utils.DefaultConsentKeys.Marketing; private debugMode: boolean | undefined; private whitelisted: Array | undefined; + /** + * Method to check if the integration is ready to be loaded. + * + * @returns If the integration is ready to be loaded. + */ + static override shouldLoad() { + return true; + } + /** * Creates an instance of Analytics Api integration. * diff --git a/packages/react/src/analytics/integrations/AnalyticsApi/__tests__/AnalyticsApi.test.ts b/packages/react/src/analytics/integrations/AnalyticsApi/__tests__/AnalyticsApi.test.ts index 73c76d31f..0a7d86063 100644 --- a/packages/react/src/analytics/integrations/AnalyticsApi/__tests__/AnalyticsApi.test.ts +++ b/packages/react/src/analytics/integrations/AnalyticsApi/__tests__/AnalyticsApi.test.ts @@ -69,13 +69,14 @@ describe('AnalyticsApi Integration', () => { expect(AnalyticsApi.prototype).toBeInstanceOf(integrations.Integration); }); - it('`shouldLoad` should return false if there is no user consent', () => { - expect(AnalyticsApi.shouldLoad({ marketing: false }, {})).toBe(false); - expect(AnalyticsApi.shouldLoad({}, {})).toBe(false); - }); - - it('`shouldLoad` should return true if there is user consent', () => { + it('`shouldLoad` should return always true', () => { + expect(AnalyticsApi.shouldLoad()).toBe(true); + // @ts-expect-error + expect(AnalyticsApi.shouldLoad({}, {})).toBe(true); + // @ts-expect-error expect(AnalyticsApi.shouldLoad({ marketing: true }, {})).toBe(true); + // @ts-expect-error + expect(AnalyticsApi.shouldLoad({ marketing: false }, {})).toBe(true); }); describe('AnalyticsApi Instance', () => {