Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(release): 1.17.2 #535

Merged
merged 15 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [1.17.2](https://github.com/aws-observability/aws-rum-web/compare/v1.17.1...v1.17.2) (2024-04-03)

### Bug Fixes

* Record resources with invalid names ([#532](https://github.com/aws-observability/aws-rum-web/issues/532)) ([1da86e7](https://github.com/aws-observability/aws-rum-web/commit/1da86e7b42aa9545f623a5d55ca7859481b81e54))

### [1.17.1](https://github.com/aws-observability/aws-rum-web/compare/v1.17.0...v1.17.1) (2024-02-26)


Expand Down
4 changes: 2 additions & 2 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": "aws-rum-web",
"version": "1.17.1",
"version": "1.17.2",
"sideEffects": false,
"description": "The Amazon CloudWatch RUM web client.",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/event-cache/EventCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '../dispatch/dataplane';
import EventBus, { Topic } from '../event-bus/EventBus';

const webClientVersion = '1.17.1';
const webClientVersion = '1.17.2';

/**
* A cache which stores events generated by telemetry plugins.
Expand Down
2 changes: 1 addition & 1 deletion src/event-cache/__tests__/EventCache.integ.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DEFAULT_CONFIG, mockFetch } from '../../test-utils/test-utils';
import { SESSION_START_EVENT_TYPE } from '../../sessions/SessionManager';
import { INSTALL_MODULE } from '../../utils/constants';

const WEB_CLIENT_VERSION = '1.17.1';
const WEB_CLIENT_VERSION = '1.17.2';

global.fetch = mockFetch;
describe('EventCache tests', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/event-cache/__tests__/EventCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jest.mock('../../sessions/SessionManager', () => ({
}))
}));

const WEB_CLIENT_VERSION = '1.17.1';
const WEB_CLIENT_VERSION = '1.17.2';

describe('EventCache tests', () => {
beforeAll(() => {
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/event-plugins/ResourcePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { InternalPlugin } from '../InternalPlugin';
import { getResourceFileType, shuffle } from '../../utils/common-utils';
import {
getResourceFileType,
isPutRumEventsCall,
shuffle
} from '../../utils/common-utils';
import { ResourceEvent } from '../../events/resource-event';
import { PERFORMANCE_RESOURCE_EVENT_TYPE } from '../utils/constant';
import {
Expand Down Expand Up @@ -88,12 +92,8 @@ export class ResourcePlugin extends InternalPlugin {
duration,
transferSize
}: PerformanceResourceTiming): void => {
const pathRegex =
/.*\/application\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/events/;
const entryUrl = new URL(name);
if (
entryUrl.host === this.context.config.endpointUrl.host &&
pathRegex.test(entryUrl.pathname)
isPutRumEventsCall(name, this.context.config.endpointUrl.hostname)
) {
// Ignore calls to PutRumEvents (i.e., the CloudWatch RUM data
// plane), otherwise we end up in an infinite loop of recording
Expand Down
52 changes: 24 additions & 28 deletions src/plugins/event-plugins/__tests__/ResourcePlugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
resourceTiming,
putRumEventsDocument,
putRumEventsGammaDocument,
dataPlaneDocument,
imageResourceEventA,
imageResourceEventB,
navigationEvent,
Expand Down Expand Up @@ -95,32 +93,6 @@ describe('ResourcePlugin tests', () => {
expect(record).not.toHaveBeenCalled();
});

test('when resource is a PutRumEvents request with a path prefix then resource event is not recorded', async () => {
// Setup
doMockPerformanceObserver([putRumEventsGammaDocument]);

const plugin: ResourcePlugin = buildResourcePlugin();

// Run
plugin.load(context);

// Assert
expect(record).not.toHaveBeenCalled();
});

test('when resource is not a PutRumEvents request but has the same host then the resource event is recorded', async () => {
// Setup
doMockPerformanceObserver([dataPlaneDocument]);

const plugin: ResourcePlugin = buildResourcePlugin();

// Run
plugin.load(context);

// Assert
expect(record).toHaveBeenCalled();
});

test('when enabled then events are recorded', async () => {
// Setup
const plugin: ResourcePlugin = buildResourcePlugin();
Expand Down Expand Up @@ -235,4 +207,28 @@ describe('ResourcePlugin tests', () => {

expect(record).not.toHaveBeenCalled();
});

test('when entry name is an invalid url then resource event is recorded', async () => {
// setup
const invalidEntry = {
name: 'invalid.com',
startTime: 0,
duration: 10,
entryType: 'resource'
} as PerformanceEntry;
doMockPerformanceObserver([invalidEntry]);

// run
const plugin = buildResourcePlugin();
plugin.load(context);

// assert
expect(() => new URL(invalidEntry.name)).toThrowError();
expect(() =>
plugin.recordResourceEvent(
invalidEntry as PerformanceResourceTiming
)
).not.toThrowError();
expect(record).toHaveBeenCalled();
});
});
29 changes: 29 additions & 0 deletions src/utils/__tests__/common-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,33 @@ describe('Common utils tests', () => {
utils.getResourceFileType(resourceUrl, utils.InitiatorType.CSS)
).toEqual(utils.ResourceType.STYLESHEET);
});

test('when url is has endpoint host and path then it is a PutRumEvents call', async () => {
const endpointHost = 'dataplane.rum.us-west-2.amazonaws.com';
const resourceUrl =
'https://dataplane.rum.us-west-2.amazonaws.com/gamma/application/aa17a42c-e737-48f7-adaf-2e0905f48073/events';
expect(utils.isPutRumEventsCall(resourceUrl, endpointHost)).toBe(true);
});

test('when url has endpoint host but wrong path then it is not a PutRumEvents call', async () => {
const endpointHost = 'dataplane.rum.us-west-2.amazonaws.com';
const resourceUrl =
'https://dataplane.rum.us-west-2.amazonaws.com/user';
expect(utils.isPutRumEventsCall(resourceUrl, endpointHost)).toBe(false);
});

test('when url has wrong host and wrong path then it is not a PutRumEvents call', async () => {
const endpointHost = 'example.com';
const resourceUrl =
'https://dataplane.rum.us-west-2.amazonaws.com/user';
expect(utils.isPutRumEventsCall(resourceUrl, endpointHost)).toBe(false);
});

test('when url is invalid then it is not a PutRumEvents call', async () => {
const endpointHost = 'dataplane.rum.us-west-2.amazonaws.com';
const resourceUrl =
'dataplane.rum.us-west-2.amazonaws.com/gamma/application/aa17a42c-e737-48f7-adaf-2e0905f48073/events';
expect(() => new URL(endpointHost)).toThrowError();
expect(utils.isPutRumEventsCall(resourceUrl, endpointHost)).toBe(false);
});
});
19 changes: 19 additions & 0 deletions src/utils/common-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,22 @@ export const isFCPSupported = () => {
export const isLongTaskSupported = () => {
return PerformanceObserver.supportedEntryTypes.includes('longtask');
};

/** PutRumEvents regex pattern */
const putRumEventsPattern =
/.*\/application\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/events/;

export const isPutRumEventsCall = (
url: string,
endpointHost: string
): boolean => {
try {
return (
new URL(url).hostname === endpointHost &&
putRumEventsPattern.test(url)
);
} catch (_) {
// Ignore invalid URLs
return false;
}
};
Loading