-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(release): pull release/3.54.0-SDK-2660 into main (#1932)
- Loading branch information
Showing
37 changed files
with
767 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,20 @@ | |
|
||
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). | ||
|
||
## [3.11.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected]...@rudderstack/[email protected]) (2024-11-21) | ||
|
||
|
||
### Features | ||
|
||
* snap extra parametrs pass ([#1921](https://github.com/rudderlabs/rudder-sdk-js/issues/1921)) ([0998d08](https://github.com/rudderlabs/rudder-sdk-js/commit/0998d081da3cfaaf0e999335384969ab77565230)) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* adroll bugsnag issue ([#1929](https://github.com/rudderlabs/rudder-sdk-js/issues/1929)) ([18589f2](https://github.com/rudderlabs/rudder-sdk-js/commit/18589f2367038cc8c144d07f7dc38abbf10c5a08)) | ||
* ga4 allow zero ([#1915](https://github.com/rudderlabs/rudder-sdk-js/issues/1915)) ([9ebbab9](https://github.com/rudderlabs/rudder-sdk-js/commit/9ebbab92cfdaf12067138e065d726da312c507a5)) | ||
* googleAds bugsnag issue ([#1930](https://github.com/rudderlabs/rudder-sdk-js/issues/1930)) ([4c8a652](https://github.com/rudderlabs/rudder-sdk-js/commit/4c8a652276882ab3dd982976763bff8c58e5db3d)) | ||
|
||
## [3.10.6](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected]...@rudderstack/[email protected]) (2024-11-19) | ||
|
||
### Dependency Updates | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
## [3.10.6](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected].5...@rudderstack/analytics-js-integrations@3.10.6) (2024-11-19) | ||
## [3.11.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected].6...@rudderstack/analytics-js-integrations@3.11.0) (2024-11-21) | ||
|
||
### Dependency Updates | ||
|
||
* `@rudderstack/analytics-js-common` updated to version `3.14.1` | ||
### Features | ||
|
||
* snap extra parametrs pass ([#1921](https://github.com/rudderlabs/rudder-sdk-js/issues/1921)) ([0998d08](https://github.com/rudderlabs/rudder-sdk-js/commit/0998d081da3cfaaf0e999335384969ab77565230)) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* adroll bugsnag issue ([#1929](https://github.com/rudderlabs/rudder-sdk-js/issues/1929)) ([18589f2](https://github.com/rudderlabs/rudder-sdk-js/commit/18589f2367038cc8c144d07f7dc38abbf10c5a08)) | ||
* ga4 allow zero ([#1915](https://github.com/rudderlabs/rudder-sdk-js/issues/1915)) ([9ebbab9](https://github.com/rudderlabs/rudder-sdk-js/commit/9ebbab92cfdaf12067138e065d726da312c507a5)) | ||
* googleAds bugsnag issue ([#1930](https://github.com/rudderlabs/rudder-sdk-js/issues/1930)) ([4c8a652](https://github.com/rudderlabs/rudder-sdk-js/commit/4c8a652276882ab3dd982976763bff8c58e5db3d)) | ||
|
235 changes: 235 additions & 0 deletions
235
packages/analytics-js-integrations/__tests__/integrations/Adroll/browser.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
/* eslint-disable no-underscore-dangle */ | ||
import { Adroll } from '../../../src/integrations/Adroll'; | ||
|
||
beforeEach(() => { | ||
window.__adroll = {}; | ||
// Add a dummy script as it is required by the init script | ||
const scriptElement = document.createElement('script'); | ||
scriptElement.type = 'text/javascript'; | ||
scriptElement.id = 'dummyScript'; | ||
const headElements = document.getElementsByTagName('head'); | ||
headElements[0].insertBefore(scriptElement, headElements[0].firstChild); | ||
}); | ||
afterEach(() => { | ||
// Reset DOM to original state | ||
document.getElementById('dummyScript')?.remove(); | ||
delete window.__adroll; | ||
delete window._adroll_email; | ||
}); | ||
|
||
describe('Init tests', () => { | ||
let adroll; | ||
|
||
test('Basic initialization', () => { | ||
adroll = new Adroll({ advId: 'TEST_ADV_ID', pixId: 'TEST_PIX_ID' }, { logLevel: 'debug' }); | ||
adroll.init(); | ||
expect(window.adroll_adv_id).toBe('TEST_ADV_ID'); | ||
expect(window.adroll_pix_id).toBe('TEST_PIX_ID'); | ||
}); | ||
}); | ||
|
||
describe('isLoaded and isReady tests', () => { | ||
let adroll; | ||
|
||
beforeEach(() => { | ||
adroll = new Adroll({ advId: 'TEST_ADV_ID', pixId: 'TEST_PIX_ID' }, { logLevel: 'debug' }); | ||
}); | ||
|
||
test('isLoaded should return true when window.__adroll is available', () => { | ||
window.__adroll = { record_user: jest.fn() }; | ||
expect(adroll.isLoaded()).toBe(true); | ||
}); | ||
|
||
test('isLoaded should return false when window.__adroll is not available', () => { | ||
window.__adroll = undefined; | ||
expect(adroll.isLoaded()).toBe(false); | ||
}); | ||
|
||
test('isReady should match isLoaded', () => { | ||
window.__adroll = { record_user: jest.fn() }; | ||
expect(adroll.isReady()).toBe(adroll.isLoaded()); | ||
}); | ||
}); | ||
|
||
describe('Identify tests', () => { | ||
let adroll; | ||
|
||
beforeEach(() => { | ||
adroll = new Adroll({ advId: 'TEST_ADV_ID', pixId: 'TEST_PIX_ID' }, { logLevel: 'debug' }); | ||
window.__adroll = { | ||
record_adroll_email: jest.fn(), | ||
}; | ||
}); | ||
|
||
test('should identify user with email from context.traits', () => { | ||
const email = '[email protected]'; | ||
adroll.identify({ | ||
message: { | ||
context: { | ||
traits: { email }, | ||
}, | ||
}, | ||
}); | ||
expect(window._adroll_email).toBe(email); | ||
expect(window.__adroll.record_adroll_email).toHaveBeenCalledWith('segment'); | ||
}); | ||
|
||
test('should identify user with email from traits', () => { | ||
const email = '[email protected]'; | ||
adroll.identify({ | ||
message: { | ||
traits: { email }, | ||
}, | ||
}); | ||
expect(window._adroll_email).toBe(email); | ||
expect(window.__adroll.record_adroll_email).toHaveBeenCalledWith('segment'); | ||
}); | ||
|
||
test('should not call record_adroll_email when email is missing', () => { | ||
adroll.identify({ | ||
message: { | ||
traits: {}, | ||
}, | ||
}); | ||
expect(window.__adroll.record_adroll_email).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe('Track tests', () => { | ||
let adroll; | ||
|
||
beforeEach(() => { | ||
adroll = new Adroll( | ||
{ | ||
advId: 'TEST_ADV_ID', | ||
pixId: 'TEST_PIX_ID', | ||
eventsMap: [ | ||
{ from: 'product viewed', to: 'abc123' }, | ||
{ from: 'order completed', to: 'def456' }, | ||
{ from: 'custom event', to: 'ghi789' }, | ||
], | ||
}, | ||
{ logLevel: 'debug' }, | ||
); | ||
window.__adroll = { | ||
record_user: jest.fn(), | ||
}; | ||
}); | ||
|
||
test('should track product events', () => { | ||
adroll.track({ | ||
message: { | ||
event: 'Product Viewed', | ||
properties: { | ||
product_id: '123', | ||
price: 99.99, | ||
}, | ||
}, | ||
}); | ||
expect(window.__adroll.record_user).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
adroll_segments: 'abc123', | ||
product_id: '123', | ||
}), | ||
); | ||
}); | ||
|
||
test('should track order events', () => { | ||
adroll.track({ | ||
message: { | ||
event: 'Order Completed', | ||
properties: { | ||
order_id: 'ORDER123', | ||
revenue: 199.99, | ||
}, | ||
}, | ||
}); | ||
expect(window.__adroll.record_user).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
adroll_segments: 'def456', | ||
order_id: 'ORDER123', | ||
}), | ||
); | ||
}); | ||
|
||
test('should not track unmapped events', () => { | ||
adroll.track({ | ||
message: { | ||
event: 'Unmapped Event', | ||
properties: {}, | ||
}, | ||
}); | ||
expect(window.__adroll.record_user).not.toHaveBeenCalled(); | ||
}); | ||
|
||
test('should handle non-string event names', () => { | ||
// Test number event | ||
adroll.track({ | ||
message: { | ||
event: 123, | ||
properties: {} | ||
} | ||
}); | ||
|
||
// Test object event | ||
adroll.track({ | ||
message: { | ||
event: { toString: () => 'custom event' }, | ||
properties: {} | ||
} | ||
}); | ||
|
||
expect(window.__adroll.record_user).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
adroll_segments: 'ghi789' | ||
}) | ||
); | ||
}); | ||
}); | ||
|
||
describe('Page tests', () => { | ||
let adroll; | ||
|
||
beforeEach(() => { | ||
adroll = new Adroll( | ||
{ | ||
advId: 'TEST_ADV_ID', | ||
pixId: 'TEST_PIX_ID', | ||
eventsMap: [ | ||
{ from: 'Viewed Landing Home Page', to: 'page123' }, // Updated mapping | ||
], | ||
}, | ||
{ logLevel: 'debug' }, | ||
); | ||
window.__adroll = { | ||
record_user: jest.fn(), | ||
}; | ||
// Mock window.location | ||
Object.defineProperty(window, 'location', { | ||
value: { | ||
pathname: '/', | ||
href: 'https://www.test-host.com/', | ||
}, | ||
writable: true, | ||
}); | ||
}); | ||
|
||
test('should track page view with category and name', () => { | ||
adroll.page({ | ||
message: { | ||
name: 'Home', | ||
category: 'Landing', | ||
properties: {}, | ||
}, | ||
}); | ||
expect(window.__adroll.record_user).toHaveBeenCalledWith({ | ||
name: 'Viewed Landing Home Page', | ||
path: '/', | ||
url: 'https://www.test-host.com/', | ||
adroll_segments: 'page123', | ||
referrer: '', | ||
search: undefined, | ||
title: '', | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.