Skip to content

Commit 75c6557

Browse files
committed
fix: Remove ROKT_DOMAIN gate from logging
1 parent 7878862 commit 75c6557

2 files changed

Lines changed: 10 additions & 25 deletions

File tree

src/Rokt-Kit.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ declare global {
214214
Rokt?: RoktGlobal;
215215
__rokt_li_guid__?: string;
216216
optimizely?: OptimizelyGlobal;
217-
ROKT_DOMAIN?: string;
218217
// mParticle is declared as any to avoid conflicts with @mparticle/web-sdk type declarations.
219218
// We use the typed mp() accessor for all internal accesses.
220219
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -511,10 +510,6 @@ function sendAdBlockMeasurementSignals(domain: string | undefined, version: stri
511510
// Reporting helpers
512511
// ============================================================
513512

514-
function _isRoktDomainPresent(): boolean {
515-
return typeof window !== 'undefined' && Boolean(window.ROKT_DOMAIN);
516-
}
517-
518513
function _isDebugModeEnabled(): boolean {
519514
return typeof window !== 'undefined' && !!window.location?.search?.toLowerCase().includes('mp_enable_logging=true');
520515
}
@@ -558,7 +553,7 @@ class ReportingTransport {
558553
this._launcherInstanceGuid = launcherInstanceGuid;
559554
this._accountId = accountId || null;
560555
this._rateLimiter = rateLimiter || new RateLimiter();
561-
this._isEnabled = _isDebugModeEnabled() || (_isRoktDomainPresent() && isLoggingEnabled);
556+
this._isEnabled = _isDebugModeEnabled() || isLoggingEnabled;
562557
}
563558

564559
send(

test/src/tests.spec.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6227,7 +6227,6 @@ describe('Rokt Forwarder', () => {
62276227
describe('ErrorReportingService', () => {
62286228
let originalFetch: typeof window.fetch;
62296229
let fetchCalls: Array<{ url: string; options: any }>;
6230-
const originalROKT_DOMAIN_ref = { value: (window as any).ROKT_DOMAIN };
62316230

62326231
beforeEach(() => {
62336232
fetchCalls = [];
@@ -6236,13 +6235,10 @@ describe('Rokt Forwarder', () => {
62366235
fetchCalls.push({ url, options });
62376236
return Promise.resolve({ ok: true });
62386237
};
6239-
originalROKT_DOMAIN_ref.value = (window as any).ROKT_DOMAIN;
6240-
(window as any).ROKT_DOMAIN = 'set';
62416238
});
62426239

62436240
afterEach(() => {
62446241
window.fetch = originalFetch;
6245-
(window as any).ROKT_DOMAIN = originalROKT_DOMAIN_ref.value;
62466242
});
62476243

62486244
it('should send error reports to the errors endpoint', () => {
@@ -6298,21 +6294,26 @@ describe('Rokt Forwarder', () => {
62986294
expect(body.severity).toBe('INFO');
62996295
});
63006296

6301-
it('should not send when ROKT_DOMAIN is missing and feature flag is off', () => {
6297+
it('should send when logging flag is enabled without ROKT_DOMAIN', () => {
63026298
(window as any).ROKT_DOMAIN = undefined;
6299+
const service = new ErrorReportingServiceClass({ isLoggingEnabled: true }, '1.0.0', 'test-guid');
6300+
service.report({ message: 'should send', severity: WSDKErrorSeverityConst.ERROR });
6301+
expect(fetchCalls.length).toBe(1);
6302+
});
6303+
6304+
it('should not send when logging flag is off', () => {
63036305
const service = new ErrorReportingServiceClass({ isLoggingEnabled: false }, '1.0.0', 'test-guid');
63046306
service.report({ message: 'should not send', severity: WSDKErrorSeverityConst.ERROR });
63056307
expect(fetchCalls.length).toBe(0);
63066308
});
63076309

6308-
it('should not send when feature flag is off and debug mode is off', () => {
6310+
it('should not send when logging flag is off and debug mode is off', () => {
63096311
const service = new ErrorReportingServiceClass({ isLoggingEnabled: false }, '1.0.0', 'test-guid');
63106312
service.report({ message: 'should not send', severity: WSDKErrorSeverityConst.ERROR });
63116313
expect(fetchCalls.length).toBe(0);
63126314
});
63136315

6314-
it('should send when debug mode is enabled even without ROKT_DOMAIN', () => {
6315-
(window as any).ROKT_DOMAIN = undefined;
6316+
it('should send when debug mode is enabled even when logging flag is off', () => {
63166317
const originalSearch = window.location.search;
63176318
window.history.pushState({}, '', window.location.pathname + '?mp_enable_logging=true');
63186319
const service = new ErrorReportingServiceClass({ isLoggingEnabled: false }, '1.0.0', 'test-guid');
@@ -6425,7 +6426,6 @@ describe('Rokt Forwarder', () => {
64256426
describe('LoggingService', () => {
64266427
let originalFetch: typeof window.fetch;
64276428
let fetchCalls: Array<{ url: string; options: any }>;
6428-
const originalROKT_DOMAIN_ref = { value: (window as any).ROKT_DOMAIN };
64296429

64306430
beforeEach(() => {
64316431
fetchCalls = [];
@@ -6434,13 +6434,10 @@ describe('Rokt Forwarder', () => {
64346434
fetchCalls.push({ url, options });
64356435
return Promise.resolve({ ok: true });
64366436
};
6437-
originalROKT_DOMAIN_ref.value = (window as any).ROKT_DOMAIN;
6438-
(window as any).ROKT_DOMAIN = 'set';
64396437
});
64406438

64416439
afterEach(() => {
64426440
window.fetch = originalFetch;
6443-
(window as any).ROKT_DOMAIN = originalROKT_DOMAIN_ref.value;
64446441
});
64456442

64466443
it('should always send to the logging endpoint with severity INFO', () => {
@@ -6527,7 +6524,6 @@ describe('Rokt Forwarder', () => {
65276524
describe('ErrorReportingService rate limiting', () => {
65286525
let originalFetch: typeof window.fetch;
65296526
let fetchCalls: Array<{ url: string; options: any }>;
6530-
const originalROKT_DOMAIN_ref = { value: (window as any).ROKT_DOMAIN };
65316527

65326528
beforeEach(() => {
65336529
fetchCalls = [];
@@ -6536,13 +6532,10 @@ describe('Rokt Forwarder', () => {
65366532
fetchCalls.push({ url, options });
65376533
return Promise.resolve({ ok: true });
65386534
};
6539-
originalROKT_DOMAIN_ref.value = (window as any).ROKT_DOMAIN;
6540-
(window as any).ROKT_DOMAIN = 'set';
65416535
});
65426536

65436537
afterEach(() => {
65446538
window.fetch = originalFetch;
6545-
(window as any).ROKT_DOMAIN = originalROKT_DOMAIN_ref.value;
65466539
});
65476540

65486541
it('should rate limit after 10 errors', () => {
@@ -6610,15 +6603,13 @@ describe('Rokt Forwarder', () => {
66106603
let registeredLoggingService: any = null;
66116604
const fetchCalls: Array<{ url: string; options: any }> = [];
66126605
const originalFetch = window.fetch;
6613-
const originalRoktDomain = (window as any).ROKT_DOMAIN;
66146606
const originalConfig = (window as any).mParticle.config;
66156607

66166608
try {
66176609
(window as any).fetch = (url: string, options: any) => {
66186610
fetchCalls.push({ url, options });
66196611
return Promise.resolve({ ok: true });
66206612
};
6621-
(window as any).ROKT_DOMAIN = 'set';
66226613
(window as any).mParticle.config = {
66236614
...originalConfig,
66246615
isLoggingEnabled: true,
@@ -6662,7 +6653,6 @@ describe('Rokt Forwarder', () => {
66626653
expect(body.code).toBe(ErrorCodesConst.UNKNOWN_ERROR);
66636654
} finally {
66646655
window.fetch = originalFetch;
6665-
(window as any).ROKT_DOMAIN = originalRoktDomain;
66666656
(window as any).mParticle.config = originalConfig;
66676657
delete (window as any).mParticle._registerErrorReportingService;
66686658
delete (window as any).mParticle._registerLoggingService;

0 commit comments

Comments
 (0)