Skip to content

Commit

Permalink
chore(release): pull release/3.54.0-SDK-2660 into main (#1932)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumarrs authored Nov 21, 2024
2 parents 78e9d9e + c9248cb commit 9d33769
Show file tree
Hide file tree
Showing 37 changed files with 767 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ permissions:

env:
NODE_OPTIONS: "--no-warnings"
CACHE_CONTROL: "\"no-store\""
CACHE_CONTROL: "\"max-age=3600\"" # "\"no-store\""

jobs:
deploy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
npm run test:ci
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rudderstack/analytics-js-monorepo",
"version": "3.53.0",
"version": "3.54.0",
"private": true,
"description": "Monorepo for RudderStack Analytics JS SDK",
"workspaces": [
Expand Down
14 changes: 14 additions & 0 deletions packages/analytics-js-integrations/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions packages/analytics-js-integrations/CHANGELOG_LATEST.md
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))

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: '',
});
});
});
Loading

0 comments on commit 9d33769

Please sign in to comment.