Skip to content

Commit ded833f

Browse files
committed
fix(ping-protect): handle behavioralDataCollection as string value
1 parent 3d45f13 commit ded833f

5 files changed

Lines changed: 22 additions & 6 deletions

File tree

packages/javascript-sdk/src/fr-auth/callbacks/ping-protect-initialize-callback.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* ping-protect-intitialize-callback.test.ts
55
*
6-
* Copyright (c) 2024 - 2025 Ping Identity Corporation. All rights reserved.
6+
* Copyright (c) 2024 - 2026 Ping Identity Corporation. All rights reserved.
77
* This software may be modified and distributed under the terms
88
* of the MIT license. See the LICENSE file for details.
99
*/

packages/javascript-sdk/src/fr-auth/callbacks/ping-protect-initialize-callback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* ping-protect-initialize-callback.ts
55
*
6-
* Copyright (c) 2024 - 2025 Ping Identity Corporation. All rights reserved.
6+
* Copyright (c) 2024 - 2026 Ping Identity Corporation. All rights reserved.
77
* This software may be modified and distributed under the terms
88
* of the MIT license. See the LICENSE file for details.
99
*/

packages/ping-protect/src/lib/ping-protect.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
*
3-
* Copyright (c) 2024 - 2025 Ping Identity Corporation. All right reserved.
3+
* Copyright (c) 2024 - 2026 Ping Identity Corporation. All right reserved.
44
*
55
* This software may be modified and distributed under the terms
66
* of the MIT license. See the LICENSE file for details.
@@ -41,6 +41,22 @@ describe('PIProtect', () => {
4141
await PIProtect.start(config);
4242
expect(protectMock).toHaveBeenCalledWith(config);
4343
});
44+
it('should resume behavioralData when behavioralDataCollection is string true', async () => {
45+
await PIProtect.start({ envId: '12345', behavioralDataCollection: false });
46+
const resumeSpy = vi.spyOn(window._pingOneSignals, 'resumeBehavioralData');
47+
48+
await PIProtect.start({ envId: '12345', behavioralDataCollection: 'true' });
49+
50+
expect(resumeSpy).toHaveBeenCalledTimes(1);
51+
});
52+
it('should not resume behavioralData when behavioralDataCollection is string false', async () => {
53+
await PIProtect.start({ envId: '12345', behavioralDataCollection: false });
54+
const resumeSpy = vi.spyOn(window._pingOneSignals, 'resumeBehavioralData');
55+
56+
await PIProtect.start({ envId: '12345', behavioralDataCollection: 'false' });
57+
58+
expect(resumeSpy).not.toHaveBeenCalled();
59+
});
4460
it('should call pause behavioralData', () => {
4561
const protectMock = vi.spyOn(PIProtect, 'pauseBehavioralData');
4662
PIProtect.pauseBehavioralData();

packages/ping-protect/src/lib/ping-protect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
*
3-
* Copyright (c) 2024 - 2025 Ping Identity Corporation. All right reserved.
3+
* Copyright (c) 2024 - 2026 Ping Identity Corporation. All right reserved.
44
*
55
* This software may be modified and distributed under the terms
66
* of the MIT license. See the LICENSE file for details.
@@ -76,7 +76,7 @@ export abstract class PIProtect {
7676
}
7777
await window._pingOneSignals.init(options);
7878

79-
if (options.behavioralDataCollection === true) {
79+
if (options.behavioralDataCollection === true || options.behavioralDataCollection === 'true') {
8080
window._pingOneSignals.resumeBehavioralData();
8181
}
8282
}

packages/ping-protect/src/lib/ping-protect.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
*
3-
* Copyright (c) 2024 - 2025 Ping Identity Corporation. All right reserved.
3+
* Copyright (c) 2024 - 2026 Ping Identity Corporation. All right reserved.
44
*
55
* This software may be modified and distributed under the terms
66
* of the MIT license. See the LICENSE file for details.

0 commit comments

Comments
 (0)