Skip to content

feat: Add support for multiple context event summaries. #821

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 26 commits into from

Conversation

kinyoklion
Copy link
Member

No description provided.

@@ -122,7 +122,7 @@ export class BrowserClient extends LDClientImpl implements LDClient {
clientSideId,
autoEnvAttributes,
platform,
filterToBaseOptions({ ...options, logger }),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated bug, will be fixed before this goes forward.

Copy link
Contributor

github-actions bot commented Apr 14, 2025

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Size: 15480 bytes
Size limit: 20000

@@ -12,16 +12,16 @@ describe('given an event summarizer', () => {
});

it('does nothing for an identify event.', () => {
const beforeSummary = summarizer.getSummary();
const beforeSummary = summarizer.getSummaries()[0];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are just updated to handle the API difference added by supporting multiple summaries.

@@ -1,14 +1,25 @@
import { Hasher } from '../src/api';

class MockHasher implements Hasher {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mock hasher implementation that was being used for client-side was not sufficiently representative of a real hash.

@@ -144,4 +144,8 @@ export default class AttributeReference {
this._components.every((value, index) => value === other.getComponent(index))
);
}

public get components() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only public to within the SDK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The event summarizer needed an interface to make it swappable for client/server.

@@ -143,6 +146,15 @@ export default class EventProcessor implements LDEventProcessor {
_config.privateAttributes.map((ref) => new AttributeReference(ref)),
);

if (summariesPerContext) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We theoretically may want to move this up the stack and use dependency injection instead. Though it will require some shuffling of things around.

Copy link
Contributor

github-actions bot commented Apr 16, 2025

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Size: 20099 bytes
Size limit: 21000

Copy link
Contributor

github-actions bot commented Apr 16, 2025

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Size: 20456 bytes
Size limit: 21000

})();
}

getSummaries(): SummarizedFlagsEvent[] {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving to a model where getting the summaries automatically clears. It makes it easier to validate there are no race conditions from async interactions.

@kinyoklion kinyoklion marked this pull request as ready for review April 22, 2025 16:32
@kinyoklion kinyoklion requested a review from a team as a code owner April 22, 2025 16:32
@@ -70,6 +70,7 @@
"packageManager": "yarn@3.4.1",
"//": "Pin jsonc-parser because v3.3.0 breaks rollup-plugin-esbuild",
"resolutions": {
"jsonc-parser": "3.2.0"
"jsonc-parser": "3.2.0",
"parse5": "7.2.1"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pin parse5 because it currently has a typescript problem.

@kinyoklion kinyoklion closed this Apr 24, 2025
@kinyoklion
Copy link
Member Author

Closed to improve hash.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants