Skip to content

Commit 29cd72a

Browse files
committed
Merge branch 'main' into rlamb/sdk-10/support-event-urls
2 parents fdf4a43 + 9d93d2d commit 29cd72a

File tree

6 files changed

+32
-11
lines changed

6 files changed

+32
-11
lines changed

packages/sdk/browser/__tests__/goals/LocationWatcher.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { jest } from '@jest/globals';
22

3-
import { DefaultLocationWatcher, LOCATION_WATCHER_INTERVAL } from '../../src/goals/LocationWatcher';
3+
import {
4+
DefaultLocationWatcher,
5+
LOCATION_WATCHER_INTERVAL_MS,
6+
} from '../../src/goals/LocationWatcher';
47

58
let mockCallback: jest.Mock;
69

@@ -25,7 +28,7 @@ it('should call callback when URL changes', () => {
2528
value: { href: 'https://example.com/new-page' },
2629
writable: true,
2730
});
28-
jest.advanceTimersByTime(LOCATION_WATCHER_INTERVAL);
31+
jest.advanceTimersByTime(LOCATION_WATCHER_INTERVAL_MS);
2932

3033
expect(mockCallback).toHaveBeenCalledTimes(1);
3134

@@ -40,7 +43,7 @@ it('should not call callback when URL remains the same', () => {
4043

4144
const watcher = new DefaultLocationWatcher(mockCallback);
4245

43-
jest.advanceTimersByTime(LOCATION_WATCHER_INTERVAL * 2);
46+
jest.advanceTimersByTime(LOCATION_WATCHER_INTERVAL_MS * 2);
4447

4548
expect(mockCallback).not.toHaveBeenCalled();
4649

@@ -80,7 +83,7 @@ it('should stop watching when close is called', () => {
8083
value: { href: 'https://example.com/new-page' },
8184
writable: true,
8285
});
83-
jest.advanceTimersByTime(LOCATION_WATCHER_INTERVAL);
86+
jest.advanceTimersByTime(LOCATION_WATCHER_INTERVAL_MS);
8487
window.dispatchEvent(new Event('popstate'));
8588

8689
expect(mockCallback).not.toHaveBeenCalled();

packages/sdk/browser/src/goals/GoalTracker.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ export default class GoalTracker {
7575
const pageviewGoals = goalsMatchingUrl.filter((goal) => goal.kind === 'pageview');
7676
const clickGoals = goalsMatchingUrl.filter((goal) => goal.kind === 'click');
7777

78-
pageviewGoals.forEach((event) => {
79-
onEvent(event);
80-
});
78+
pageviewGoals.forEach((event) => onEvent(event));
8179

8280
if (clickGoals.length) {
8381
// Click handler is not a member function in order to avoid having to bind it for the event

packages/sdk/browser/src/goals/LocationWatcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const LOCATION_WATCHER_INTERVAL = 300;
1+
export const LOCATION_WATCHER_INTERVAL_MS = 300;
22

33
// Using any for the timer handle because the type is not the same for all
44
// platforms and we only need to use it opaquely.
@@ -39,7 +39,7 @@ export class DefaultLocationWatcher {
3939
* Details on when popstate is called:
4040
* https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event#when_popstate_is_sent
4141
*/
42-
this.watcherHandle = setInterval(checkUrl, LOCATION_WATCHER_INTERVAL);
42+
this.watcherHandle = setInterval(checkUrl, LOCATION_WATCHER_INTERVAL_MS);
4343

4444
window.addEventListener('popstate', checkUrl);
4545

packages/sdk/browser/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
import { BrowserClient, LDClient } from './BrowserClient';
1919
import { BrowserOptions as LDOptions } from './options';
2020

21-
// TODO: Export and use browser specific options.
2221
export {
2322
LDClient,
2423
LDFlagSet,

packages/sdk/vercel/examples/route-handler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"@launchdarkly/vercel-server-sdk": "workspace:^",
1313
"@vercel/edge-config": "^1.1.0",
14-
"next": "14.1.2",
14+
"next": "14.2.10",
1515
"react": "^18.2.0",
1616
"react-dom": "18.2.0"
1717
},

packages/shared/common/src/internal/events/EventProcessor.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,27 @@ export default class EventProcessor implements LDEventProcessor {
372372
};
373373
return out;
374374
}
375+
case 'click': {
376+
const out: ClickOutputEvent = {
377+
kind: 'click',
378+
creationDate: event.creationDate,
379+
contextKeys: event.context.kindsAndKeys,
380+
key: event.key,
381+
url: event.url,
382+
selector: event.selector,
383+
};
384+
return out;
385+
}
386+
case 'pageview': {
387+
const out: PageviewOutputEvent = {
388+
kind: 'pageview',
389+
creationDate: event.creationDate,
390+
contextKeys: event.context.kindsAndKeys,
391+
key: event.key,
392+
url: event.url,
393+
};
394+
return out;
395+
}
375396
default:
376397
// This would happen during the addition of a new event type to the SDK.
377398
return event;

0 commit comments

Comments
 (0)