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

[ECO-5204] Wrapper SDK proxy #2014

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

lawrence-forooghian
Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian commented Jan 15, 2025

This implements as much of ADR-117: Tracking wrapper SDK usage, continued as is needed for the Chat SDK. That is:

  • it adds a -createWrapperSDKProxyWithOptions: method to ARTRealtime
  • this method takes a set of agents that describe the wrapper SDK which is using the ARTRealtime instance
  • the method returns a proxy object that calls through to the underlying ARTRealtime instance
  • when you make a REST request by calling -request:… on the proxy instance, it adds the wrapper SDK's agents to the Ably-Agent header
  • when you fetch a Realtime channel by calling -get:… on the proxy instance, it sets an agent channel param containing the wrapper SDK's agents

ably/ably-chat-swift#211 demonstrates this new API being used in the Chat SDK.

I'm putting this up for review to get opinions on it; remaining work includes:

  • writing a spec for this
  • specifying and implementing the functionality that's not needed for Chat right now (i.e. doing the same for ARTRest, adding to the Ably-Agent header for all of the other REST methods that ADR-117 says we should cover)

Summary by CodeRabbit

  • New Features

    • Introduced a new Wrapper SDK Proxy that lets developers create proxy client instances for improved connectivity. These proxy clients share connection and channel states with underlying Realtime clients and offer enhanced configuration options (via options, key, or token) along with integrated SDK agent tracking in HTTP requests.
  • Documentation

    • Updated guidelines for public header inclusion and module imports to streamline development.
  • Tests

    • Added comprehensive tests to validate connection, channel state handling, and proxy request processing.
    • New test suite WrapperSDKProxyTests to ensure correct behavior of the wrapper SDK proxy client.

Copy link

coderabbitai bot commented Jan 15, 2025

Walkthrough

The changes implement a Wrapper SDK Proxy feature. New public and private headers and implementation files have been added to define proxy classes (e.g., ARTWrapperSDKProxyRealtime, ARTWrapperSDKProxyRealtimeChannel, ARTWrapperSDKProxyRealtimeChannels, ARTWrapperSDKProxyOptions) and to extend ARTRealtime with proxy creation methods. Multiple existing methods across the SDK have been updated to accept an extra wrapperSDKAgents parameter for enhanced request handling. Documentation instructions and build scripts have been adjusted accordingly, and test cases have been added or updated to validate the new proxy behavior.

Changes

Files Change Summary
Source/include/Ably/ARTRealtime+WrapperSDKProxy.h, Source/include/Ably/ARTWrapperSDKProxyOptions.h, Source/include/Ably/ARTWrapperSDKProxyRealtime.h, Source/include/Ably/ARTWrapperSDKProxyRealtimeChannel.h, Source/include/Ably/ARTWrapperSDKProxyRealtimeChannels.h
Source/ARTWrapperSDKProxyRealtime.m, Source/ARTWrapperSDKProxyRealtimeChannel.m, Source/ARTWrapperSDKProxyRealtimeChannels.m, Source/ARTWrapperSDKProxyOptions.m
Added new interfaces and implementations to support the wrapper SDK proxy feature with dedicated options and proxy behavior for real-time operations.
Source/ARTAuth.m, Source/ARTHTTPPaginatedResponse.m, Source/ARTPaginatedResult.m, Source/ARTPushActivationStateMachine.m, Source/ARTPushAdmin.m, Source/ARTPushChannel.m, Source/ARTPushChannelSubscriptions.m, Source/ARTPushDeviceRegistrations.m, Source/ARTRealtime.m, Source/ARTRest.m, Source/ARTRestChannel.m
Source/PrivateHeaders/...
Updated multiple method signatures to include a new wrapperSDKAgents parameter to carry SDK agent information during network request execution.
CONTRIBUTING.md, Scripts/jazzy.sh, Source/include/Ably/Ably.h, Source/include/Ably/AblyInternal.h, Source/include/Ably/AblyPublic.h, Source/Ably.modulemap Revised documentation instructions and umbrella header imports to reflect the modular reorganization and proxy interfaces.
Test/Tests/RealtimeClientConnectionTests.swift, Test/Tests/RestClientTests.swift, Test/Tests/WrapperSDKProxyTests.swift Modified and added tests to use the updated method signature with wrapperSDKAgents and to validate proper proxy functionality and state sharing.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Wrapper SDK Client
    participant RT as ARTRealtime
    participant Proxy as ARTWrapperSDKProxyRealtime
    participant Rest as ARTRest

    Client->>RT: createWrapperSDKProxyWithOptions(options)
    RT-->>Client: returns Proxy instance
    Client->>Proxy: request(method, path, params, body,\nheaders, wrapperSDKAgents)
    Proxy->>Rest: executeRequest(request, wrapperSDKAgents)
    Rest-->>Proxy: response
    Proxy-->>Client: returns response
Loading

Assessment against linked issues

Objective ([ECO-5204]) Addressed Explanation
Implement wrapper SDK proxy

Possibly related issues

Possibly related PRs

Suggested reviewers

  • umair-ably
  • maratal

Poem

I’m a rabbit hopping through the code,
With wrappers and proxies in joyful mode.
Each method updated, a carrot to munch,
With wrapperSDKAgents adding a crunchy bunch.
My burrow is neat, my code is bright—
Hoppy changes keep our framework light!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0ee8a5 and 58bbd14.

📒 Files selected for processing (35)
  • Ably.xcodeproj/project.pbxproj (37 hunks)
  • Source/ARTAuth.m (2 hunks)
  • Source/ARTHTTPPaginatedResponse.m (4 hunks)
  • Source/ARTPaginatedResult.m (1 hunks)
  • Source/ARTPushActivationStateMachine.m (4 hunks)
  • Source/ARTPushAdmin.m (1 hunks)
  • Source/ARTPushChannel.m (4 hunks)
  • Source/ARTPushChannelSubscriptions.m (2 hunks)
  • Source/ARTPushDeviceRegistrations.m (4 hunks)
  • Source/ARTRealtime.m (5 hunks)
  • Source/ARTRest.m (11 hunks)
  • Source/ARTRestChannel.m (2 hunks)
  • Source/ARTWrapperSDKProxyOptions.m (1 hunks)
  • Source/ARTWrapperSDKProxyRealtime.m (1 hunks)
  • Source/ARTWrapperSDKProxyRealtimeChannel.m (1 hunks)
  • Source/ARTWrapperSDKProxyRealtimeChannels.m (1 hunks)
  • Source/Ably.modulemap (1 hunks)
  • Source/PrivateHeaders/Ably/ARTClientInformation+Private.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTHTTPPaginatedResponse+Private.h (3 hunks)
  • Source/PrivateHeaders/Ably/ARTHttp.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTRealtime+Private.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTRest+Private.h (2 hunks)
  • Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtime+Private.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtimeChannel+Private.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtimeChannels+Private.h (1 hunks)
  • Source/include/Ably.modulemap (1 hunks)
  • Source/include/Ably/ARTRealtime+WrapperSDKProxy.h (1 hunks)
  • Source/include/Ably/ARTWrapperSDKProxyOptions.h (1 hunks)
  • Source/include/Ably/ARTWrapperSDKProxyRealtime.h (1 hunks)
  • Source/include/Ably/ARTWrapperSDKProxyRealtimeChannel.h (1 hunks)
  • Source/include/Ably/ARTWrapperSDKProxyRealtimeChannels.h (1 hunks)
  • Source/include/Ably/AblyInternal.h (1 hunks)
  • Test/Tests/RealtimeClientConnectionTests.swift (4 hunks)
  • Test/Tests/RestClientTests.swift (1 hunks)
  • Test/Tests/WrapperSDKProxyTests.swift (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (29)
  • Source/ARTWrapperSDKProxyOptions.m
  • Source/PrivateHeaders/Ably/ARTClientInformation+Private.h
  • Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtimeChannels+Private.h
  • Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtime+Private.h
  • Source/include/Ably/ARTRealtime+WrapperSDKProxy.h
  • Source/ARTPushActivationStateMachine.m
  • Source/Ably.modulemap
  • Source/include/Ably/AblyInternal.h
  • Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtimeChannel+Private.h
  • Source/PrivateHeaders/Ably/ARTHttp.h
  • Source/ARTPaginatedResult.m
  • Source/PrivateHeaders/Ably/ARTRealtime+Private.h
  • Source/include/Ably.modulemap
  • Source/ARTPushAdmin.m
  • Source/ARTPushChannelSubscriptions.m
  • Test/Tests/RestClientTests.swift
  • Source/ARTPushChannel.m
  • Source/include/Ably/ARTWrapperSDKProxyRealtime.h
  • Source/ARTAuth.m
  • Source/ARTHTTPPaginatedResponse.m
  • Source/ARTRestChannel.m
  • Test/Tests/WrapperSDKProxyTests.swift
  • Source/PrivateHeaders/Ably/ARTHTTPPaginatedResponse+Private.h
  • Source/ARTWrapperSDKProxyRealtimeChannels.m
  • Source/ARTPushDeviceRegistrations.m
  • Source/include/Ably/ARTWrapperSDKProxyOptions.h
  • Source/PrivateHeaders/Ably/ARTRest+Private.h
  • Source/ARTWrapperSDKProxyRealtime.m
  • Source/ARTWrapperSDKProxyRealtimeChannel.m
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: check (macOS, test_macOS)
  • GitHub Check: check (tvOS, test_tvOS17_2)
  • GitHub Check: build
  • GitHub Check: check
  • GitHub Check: check
  • GitHub Check: check (iOS, test_iOS17_2)
🔇 Additional comments (45)
Ably.xcodeproj/project.pbxproj (37)

79-88: Check for potential duplication
It appears these headers are referenced multiple times with identical settings. If this is not intentional (e.g., for multiple platforms), consider removing duplicates to reduce confusion.


178-201: Check for potential duplication
It appears these headers and sources are referenced multiple times within the same build phase. Confirm if each duplication is necessary for different build configurations or remove duplicates.


296-317: Check for potential duplication
Multiple entries for the same headers and source files can lead to maintenance overhead. Ensure all references are needed; otherwise, consider cleaning them up.


1195-1203: Check for potential duplication
These newly added file references look correct, but please verify that repeated references to the same headers are intentional for all targets.


1229-1240: Check for potential duplication
Adding these new wrapper files is appropriate, but verify that listing them multiple times (e.g., as public headers and sources) is required for each target.


1287-1298: Check for potential duplication
Multiple references to the same wrapper proxy channel headers and sources may cause confusion. Double-check that each reference is required for your build setup.


1650-1670: Check for potential duplication
The “Wrapper SDK Proxy” group includes repeated references to the same files. Confirm that you need these entries for each configuration or remove duplicates.


1813-1819: Check for potential duplication
The reference to WrapperSDKProxyTests.swift is repeated. If you only need one reference per test target, you can safely remove extras.


1897-1903: Check for potential duplication
References to AblyPublic.h and AblyInternal.h appear again. Verify no duplication is taking place beyond what’s needed for each compilation phase.


1911-1917: Check for potential duplication
Files under “Source” are repeated in multiple sections. Confirm whether these references are needed across multiple build phases or can be consolidated.


2124-2131: Check for potential duplication
ARTWrapperSDKProxyOptions.h and ARTWrapperSDKProxyOptions.m have multiple references. Confirm if each reference is truly necessary for your targets.


2335-2350: Check for potential duplication
Several references to ARTWrapperSDKProxyOptions.h and ARTWrapperSDKProxyRealtime.h exist in the “Headers” section. Make sure you aren’t unintentionally duplicating them.


2382-2389: Check for potential duplication
ARTWrapperSDKProxyRealtimeChannel+Private.h and ARTWrapperSDKProxyRealtimeChannels+Private.h are repeated under “Headers.” Validate each entry.


2438-2448: Check for potential duplication
ARTWrapperSDKProxyRealtimeChannel.h and ARTWrapperSDKProxyRealtimeChannels.h appear multiple times. Ensure this is necessary or remove duplicates.


2463-2469: Check for potential duplication
Confirm that the repeated addition of these wrapper headers under different sections is intentional for platform variants.


2542-2550: Check for potential duplication
ARTWrapperSDKProxyOptions.h references appear again. Validate that the Public vs. Private assignment here is correct and not duplicated accidentally.


2575-2590: Check for potential duplication
ARTWrapperSDKProxyRealtime.h references are included multiple times. Confirm they’re not accidentally duplicated across build phases.


2593-2599: Check for potential duplication
ARTWrapperSDKProxyRealtime+Private.h might be listed repeatedly. Confirm if each listing is needed for your build scheme.


2615-2622: Check for potential duplication
Repeated file references for AblyInternal.h and AblyPublic.h can cause confusion. Confirm or remove duplicates.


2656-2662: Check for potential duplication
ARTRealtime+WrapperSDKProxy.h is seen across multiple headings. Ensure it’s structured properly for your multi-platform approach.


2722-2730: Check for potential duplication
Duplicated references to ARTWrapperSDKProxyOptions.h and other new files might exist. Validate if each reference truly belongs under “Headers.”


2755-2770: Check for potential duplication
ARTWrapperSDKProxyRealtimeChannel+Private.h is appearing again. Confirm the repeated references are intentional for test or platform splits.


2773-2779: Check for potential duplication
ARTWrapperSDKProxyRealtime+Private.h references can be consolidated unless they serve different build configurations.


2795-2802: Check for potential duplication
AblyInternal.h and AblyPublic.h reappear. Review whether they must be repeated in this portion of the project file.


2836-2842: Check for potential duplication
References to ARTRealtime+WrapperSDKProxy.h reoccur. If you only need a single reference within a single target, eliminate duplicates.


3174-3180: Check for potential duplication
WrapperSDKProxyTests.swift repeated in “Sources.” This often happens if multiple test targets share the same file. Confirm that’s desired.


3264-3271: Check for potential duplication
ARTWrapperSDKProxyRealtimeChannel.m and ARTWrapperSDKProxyRealtimeChannels.m are registered repeatedly. Validate each reference.


3277-3283: Check for potential duplication
ARTWrapperSDKProxyOptions.m listed multiple times can lead to confusion about which target uses it. Please verify it’s configured properly.


3291-3297: Check for potential duplication
ARTWrapperSDKProxyRealtime.m references may be duplicated. Ensure you only declare it once per build configuration to avoid confusion.


3390-3396: Check for potential duplication
WrapperSDKProxyTests.swift is cited again. Confirm if multiple references are necessary for parallel test targets or remove redundancy.


3450-3456: Check for potential duplication
WrapperSDKProxyTests.swift might be referenced under multiple groups. Confirm if it’s truly required or unify references.


3512-3519: Check for potential duplication
ARTWrapperSDKProxyRealtimeChannel.m and ARTWrapperSDKProxyRealtimeChannels.m are registered again. Validate the necessity to avoid confusion.


3525-3531: Check for potential duplication
ARTWrapperSDKProxyOptions.m appears in multiple places. This might be intentional for platform builds, but please verify.


3539-3545: Check for potential duplication
ARTWrapperSDKProxyRealtime.m references reappear here. Confirm each listing or remove duplicates if they aren’t needed.


3640-3647: Check for potential duplication
ARTWrapperSDKProxyRealtimeChannel.m and ARTWrapperSDKProxyRealtimeChannels.m are declared again. Ensure this is on purpose.


3653-3660: Check for potential duplication
ARTWrapperSDKProxyOptions.m is appearing repeatedly as a source file. Confirm if separate references are needed for each build scheme.


3667-3673: Check for potential duplication
ARTWrapperSDKProxyRealtime.m reappears one more time. Carefully verify your project structure and remove any extraneous references.

Source/include/Ably/ARTWrapperSDKProxyRealtimeChannel.h (1)

14-24: Add initialization methods and underlying channel property.

The interface is missing:

  • A designated initializer that takes the underlying ARTRealtimeChannel
  • A property to access the underlying channel instance
  • Making the default initializer unavailable
@interface ARTWrapperSDKProxyRealtimeChannel : NSObject <ARTRealtimeChannelProtocol>

+ @property (nonatomic, readonly) ARTRealtimeChannel *underlyingChannel;
+
+ - (instancetype)initWithUnderlyingChannel:(ARTRealtimeChannel *)channel NS_DESIGNATED_INITIALIZER;
+ - (instancetype)init NS_UNAVAILABLE;
+
@property (readonly) ARTRealtimePresence *presence;
Source/include/Ably/ARTWrapperSDKProxyRealtimeChannels.h (1)

14-21: Add initialization methods and underlying channels property.

The interface is missing:

  • A designated initializer that takes the underlying ARTRealtimeChannels
  • A property to access the underlying channels instance
  • Making the default initializer unavailable
@interface ARTWrapperSDKProxyRealtimeChannels : NSObject <ARTRealtimeChannelsProtocol>

+ @property (nonatomic, readonly) ARTRealtimeChannels *underlyingChannels;
+
+ - (instancetype)initWithUnderlyingChannels:(ARTRealtimeChannels *)channels NS_DESIGNATED_INITIALIZER;
+ - (instancetype)init NS_UNAVAILABLE;
+
- (ARTWrapperSDKProxyRealtimeChannel *)get:(NSString *)name;
Source/ARTRest.m (1)

322-334: LGTM! Well-implemented agent identifier handling.

The implementation correctly merges agents from both the client options and wrapper SDK agents, ensuring proper tracking of wrapper SDK usage.

Source/ARTRealtime.m (1)

187-195: LGTM! Well-implemented proxy creation.

The WrapperSDKProxy category cleanly implements the proxy creation functionality, properly initializing the proxy with the realtime instance and options.

Test/Tests/RealtimeClientConnectionTests.swift (4)

252-253: LGTM!

The execute method signature has been correctly updated to include the wrapperSDKAgents parameter.


276-277: LGTM!

The execute method signature has been correctly updated to include the wrapperSDKAgents parameter.


338-339: LGTM!

The execute method signature has been correctly updated to include the wrapperSDKAgents parameter.


383-384: LGTM!

The execute method signature has been correctly updated to include the wrapperSDKAgents parameter.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 15, 2025 12:51 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 15, 2025 12:54 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 15, 2025 14:09 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 15, 2025 14:12 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 15, 2025 14:30 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 15, 2025 14:34 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 15, 2025 14:51 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 15, 2025 14:54 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 15, 2025 17:39 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 15, 2025 17:41 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 15, 2025 19:40 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 15, 2025 19:43 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 15, 2025 20:01 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 15, 2025 20:03 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 16, 2025 19:15 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 16, 2025 19:18 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 16, 2025 19:37 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 16, 2025 19:38 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 16, 2025 20:22 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 16, 2025 20:26 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 20, 2025 17:16 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 20, 2025 17:18 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 30, 2025 16:36 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 30, 2025 17:07 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 30, 2025 17:09 Inactive
@lawrence-forooghian lawrence-forooghian changed the title [WIP] Wrapper sdk proxy [WIP, ECO-5204] Wrapper sdk proxy Jan 30, 2025
@lawrence-forooghian lawrence-forooghian changed the title [WIP, ECO-5204] Wrapper sdk proxy [WIP, ECO-5204] Wrapper SDK proxy Jan 30, 2025
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 30, 2025 19:08 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 30, 2025 19:14 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features January 30, 2025 19:59 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc January 30, 2025 20:00 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/features February 3, 2025 18:21 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/2014/jazzydoc February 3, 2025 18:25 Inactive
@lawrence-forooghian lawrence-forooghian marked this pull request as ready for review February 3, 2025 18:33
@lawrence-forooghian lawrence-forooghian changed the title [WIP, ECO-5204] Wrapper SDK proxy [ECO-5204] Wrapper SDK proxy Feb 3, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🔭 Outside diff range comments (1)
Test/Tests/RestClientTests.swift (1)

785-785: Test coverage for non-nil wrapperSDKAgents is missing.

The output confirms that all tests using the wrapperSDKAgents parameter (in both RestClientTests.swift and RealtimeClientConnectionTests.swift) pass nil. There are no test cases that provide non-nil values to exercise the wrapper SDK agents behavior. Consider adding additional tests to confirm that providing a non-nil value triggers the correct functionality.

🔗 Analysis chain

Verify test coverage for the new parameter.

The test case test__014__RestClient__client_should_handle_error_messages_in_plaintext_and_HTML_format has been updated to include the new wrapperSDKAgents parameter, but it's passing nil. Consider adding additional test cases to verify the behavior when non-nil wrapper SDK agents are provided.

Run this script to check for existing test coverage of the wrapperSDKAgents parameter:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for test cases that verify wrapperSDKAgents parameter behavior
# Test: Look for test cases that pass non-nil wrapperSDKAgents. Expect: Test cases that verify the parameter's functionality.

echo "Searching for test cases using wrapperSDKAgents..."
rg -A 5 "wrapperSDKAgents" Test/Tests/

Length of output: 3068

🧹 Nitpick comments (22)
Source/ARTRest.m (3)

115-115: Consider allowing user-specified agents here.
Currently, wrapperSDKAgents is hard-coded as nil when invoking _internal request:. If there's a use case for passing custom agents from public ARTRest calls, consider adding a parameter here rather than defaulting to nil.


322-333: Be aware of agent name collisions.
When merging _options.agents with wrapperSDKAgents, the wrapper agents overwrite any duplicates in _options.agents. Confirm that overwriting is intended or consider a different merge strategy.


549-549: Time request always uses ARTAuthenticationOff.
Currently, this omits wrapperSDKAgents. If you intend to collect usage data or track agent info for time requests, consider making the parameter configurable here. Otherwise, this is fine.

Ably.xcodeproj/project.pbxproj (11)

1900-1901: Repeated references for AblyPublic.h and AblyInternal.h.
Double-check whether these are required for separate build targets or are unintentional duplicates.


2466-2466: ARTWrapperSDKProxyRealtime+Private.h references.
Ensure Private headers are not accidentally exposed through a bridging header or combined frameworks.


2578-2579: Check ARTWrapperSDKProxyRealtime.h references for multiple build phases.
Duplication might be intentional for multiple platform targets, but remove if unneeded.

Also applies to: 2587-2587


2725-2727: Check references for ARTWrapperSDKProxyOptions.h, ARTWrapperSDKProxyRealtimeChannel/Channels.h.
Ensure you’re not duplicating references across different PBXGroups.


2776-2776: ARTWrapperSDKProxyRealtime+Private.h reference again.
Ensure that test and internal builds rely on this private header if needed, but it isn’t exposed in distribution.


2839-2839: Another reference for ARTRealtime+WrapperSDKProxy.h.
Confirm that you need to declare it again in this section.


3267-3268: Multiple references for ARTWrapperSDKProxyRealtimeChannel.m and ARTWrapperSDKProxyRealtimeChannels.m.
Potential duplication for multiple build phases. Confirm or remove.


3393-3393: Additional reference for WrapperSDKProxyTests.swift.
Ensure your test plan or schemes pick up these tests.


3528-3528: One more insertion for ARTWrapperSDKProxyOptions.m.
Ensure you’re not overshadowing or conflicting with prior references.


3643-3644: Repeated references for ARTWrapperSDKProxyRealtimeChannel.m and .m for Channels.
Verify you only need them once per platform or build configuration.


3670-3670: Extra reference to ARTWrapperSDKProxyRealtime.m.
Looks consistent with the rest, but double-check for unneeded duplicates.

Source/include/Ably/AblyInternal.h (1)

1-2: Consider enhancing the documentation comment.

While the comment clearly states these APIs are for Ably-authored SDKs, it could be more specific about which SDKs (e.g., Chat SDK, other wrapper SDKs) are intended to use these APIs and provide examples.

Source/include/Ably/ARTRealtime+WrapperSDKProxy.h (1)

10-17: Enhance method documentation.

While the current documentation is good, consider adding:

  • Example usage code
  • Description of what analytics information is collected
  • Link to ADR-117 for reference

Here's a suggested documentation enhancement:

 /**
  Creates a proxy client to be used to supply analytics information for Ably-authored SDKs.

  The proxy client shares the state of the `ARTRealtime` instance on which this method is called.

  - Important: This method should only be called by Ably-authored SDKs.
+ 
+ This proxy client enables tracking of wrapper SDK usage by appending the wrapper SDK's agents
+ to the `Ably-Agent` header in REST requests and including them as channel parameters.
+ 
+ For more information, see ADR-117.
+ 
+ @param options The options containing the wrapper SDK's agents.
+ @return A proxy client that shares state with this instance.
+ 
+ @code
+ ARTWrapperSDKProxyOptions *options = [[ARTWrapperSDKProxyOptions alloc] 
+     initWithAgents:@{@"chat": @"1.0.0"}];
+ ARTWrapperSDKProxyRealtime *proxy = [realtime createWrapperSDKProxyWithOptions:options];
+ @endcode
  */
Source/include/Ably/ARTWrapperSDKProxyOptions.h (1)

12-17: Enhance documentation for agents property.

The documentation should:

  • Include example usage showing how to specify agents with and without versions
  • Document the format and structure of the agents dictionary
  • Reference where ARTClientInformationAgentNotVersioned is defined
/**
 * A set of additional entries for the Ably agent header and the `agent` realtime channel param.
 *
 * If an agent does not have a version, represent this by using the `ARTClientInformationAgentNotVersioned` pointer as the version.
+ *
+ * Example usage:
+ * ```objc
+ * NSDictionary *agents = @{
+ *   @"chat-sdk": @"1.0.0",                                    // Agent with version
+ *   @"wrapper-sdk": ARTClientInformationAgentNotVersioned     // Agent without version
+ * };
+ * ARTWrapperSDKProxyOptions *options = [[ARTWrapperSDKProxyOptions alloc] initWithAgents:agents];
+ * ```
 */
Source/ARTWrapperSDKProxyRealtimeChannels.m (1)

41-54: Consider adding nil check for required parameters.

The method should validate that both name and channel are non-nil before proceeding.

 - (ARTWrapperSDKProxyRealtimeChannel *)get:(NSString *)name maybeOptions:(nullable ARTRealtimeChannelOptions *)options {
+    if (!name) {
+        return nil;
+    }
     ARTRealtimeChannelOptions *resolvedOptions = [self addingAgentToOptions:options];
     ARTRealtimeChannel *channel;
     if (resolvedOptions) {
         channel = [self.underlyingChannels get:name options:resolvedOptions];
     } else {
         channel = [self.underlyingChannels get:name];
     }
+    if (!channel) {
+        return nil;
+    }
Source/ARTWrapperSDKProxyRealtime.m (1)

19-29: Consider adding nil checks in initializer.

The initializer should validate that neither realtime nor proxyOptions are nil.

 - (instancetype)initWithRealtime:(ARTRealtime *)realtime
                     proxyOptions:(ARTWrapperSDKProxyOptions *)proxyOptions {
+    if (!realtime || !proxyOptions) {
+        return nil;
+    }
     if (self = [super init]) {
         _underlyingRealtime = realtime;
         _proxyOptions = proxyOptions;
Source/PrivateHeaders/Ably/ARTRest+Private.h (1)

73-75: Consider adding documentation for the wrapperSDKAgents parameter.

Adding documentation would help developers understand the purpose and expected format of the wrapperSDKAgents dictionary.

 - (nullable NSObject<ARTCancellable> *)executeRequest:(NSURLRequest *)request
+                                     /** Dictionary of wrapper SDK agent information to be included in requests.
+                                         Keys and values should be strings identifying the wrapper SDK details. */
                                      wrapperSDKAgents:(nullable NSDictionary<NSString *, NSString *> *)wrapperSDKAgents
                                           completion:(nullable ARTURLRequestCallback)callback;
Source/PrivateHeaders/Ably/ARTRealtime+Private.h (1)

55-55: Consider adding documentation for the wrapperSDKAgents parameter.

Adding documentation would help developers understand the purpose and expected format of the wrapperSDKAgents dictionary.

+        /** Dictionary of wrapper SDK agent information to be included in requests.
+            Keys and values should be strings identifying the wrapper SDK details. */
         wrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents
Test/Tests/WrapperSDKProxyTests.swift (1)

208-208: Replace unused parameter with underscore.

The headers parameter in the closure is unused. Replace it with _ to address the SwiftLint warning.

-                ) { response, error in
+                ) { response, _ in
🧰 Tools
🪛 SwiftLint (0.57.0)

[Warning] 208-208: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 870c8a6 and d0ee8a5.

📒 Files selected for processing (39)
  • Ably.xcodeproj/project.pbxproj (37 hunks)
  • CONTRIBUTING.md (1 hunks)
  • Scripts/jazzy.sh (1 hunks)
  • Source/ARTAuth.m (2 hunks)
  • Source/ARTHTTPPaginatedResponse.m (4 hunks)
  • Source/ARTPaginatedResult.m (1 hunks)
  • Source/ARTPushActivationStateMachine.m (4 hunks)
  • Source/ARTPushAdmin.m (1 hunks)
  • Source/ARTPushChannel.m (4 hunks)
  • Source/ARTPushChannelSubscriptions.m (2 hunks)
  • Source/ARTPushDeviceRegistrations.m (4 hunks)
  • Source/ARTRealtime.m (5 hunks)
  • Source/ARTRest.m (11 hunks)
  • Source/ARTRestChannel.m (2 hunks)
  • Source/ARTWrapperSDKProxyOptions.m (1 hunks)
  • Source/ARTWrapperSDKProxyRealtime.m (1 hunks)
  • Source/ARTWrapperSDKProxyRealtimeChannel.m (1 hunks)
  • Source/ARTWrapperSDKProxyRealtimeChannels.m (1 hunks)
  • Source/Ably.modulemap (1 hunks)
  • Source/PrivateHeaders/Ably/ARTClientInformation+Private.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTHTTPPaginatedResponse+Private.h (3 hunks)
  • Source/PrivateHeaders/Ably/ARTHttp.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTRealtime+Private.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTRest+Private.h (2 hunks)
  • Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtime+Private.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtimeChannel+Private.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtimeChannels+Private.h (1 hunks)
  • Source/include/Ably.modulemap (1 hunks)
  • Source/include/Ably/ARTRealtime+WrapperSDKProxy.h (1 hunks)
  • Source/include/Ably/ARTWrapperSDKProxyOptions.h (1 hunks)
  • Source/include/Ably/ARTWrapperSDKProxyRealtime.h (1 hunks)
  • Source/include/Ably/ARTWrapperSDKProxyRealtimeChannel.h (1 hunks)
  • Source/include/Ably/ARTWrapperSDKProxyRealtimeChannels.h (1 hunks)
  • Source/include/Ably/Ably.h (1 hunks)
  • Source/include/Ably/AblyInternal.h (1 hunks)
  • Source/include/Ably/AblyPublic.h (1 hunks)
  • Test/Tests/RealtimeClientConnectionTests.swift (4 hunks)
  • Test/Tests/RestClientTests.swift (1 hunks)
  • Test/Tests/WrapperSDKProxyTests.swift (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • Scripts/jazzy.sh
  • Source/PrivateHeaders/Ably/ARTHttp.h
  • Test/Tests/RealtimeClientConnectionTests.swift
🧰 Additional context used
📓 Learnings (1)
Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtimeChannel+Private.h (1)
Learnt from: maratal
PR: ably/ably-cocoa#1973
File: Source/include/Ably/ARTRealtimeChannelOptions.h:33-33
Timestamp: 2024-11-12T07:31:53.691Z
Learning: `ARTChannelOptions` is already marked with `NS_SWIFT_SENDABLE`.
🪛 LanguageTool
CONTRIBUTING.md

[uncategorized] ~40-~40: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...this header is intended for use only by Ably-authored SDKs and should not be included in the ...

(HYPHENATED_LY_ADVERB_ADJECTIVE)

🪛 SwiftLint (0.57.0)
Test/Tests/WrapperSDKProxyTests.swift

[Warning] 208-208: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: check (macOS, test_macOS)
  • GitHub Check: check (tvOS, test_tvOS17_2)
  • GitHub Check: check (iOS, test_iOS17_2)
🔇 Additional comments (80)
Source/ARTRest.m (7)

245-265: Consistent propagation of wrapperSDKAgents.
All branches of executeRequest:withAuthOption: properly forward wrapperSDKAgents to the underlying request methods, ensuring consistent agent handling.


268-273: Straightforward pass-through logic.
This overload simply calls the more complex version of the same method, neatly passing along wrapperSDKAgents.


278-314: Verify concurrency on updating request headers.
Although everything appears correct, these methods dispatch different requests based on token renewal paths. Verify no race conditions occur when multiple threads invoke these methods concurrently.


316-321: Consistent delegation to fallback-based method.
Using executeRequest with a fresh fallback context ensures robust error handling while supporting the new wrapperSDKAgents parameter.


343-463: Good handling of fallback logic plus wrapper agents.
Passing wrapperSDKAgents through fallback retry logic is consistent, and preceding code sets the “Ably-Agent” header via agentIdentifierWithWrapperSDKAgents:. Implementation looks solid.


570-570: New parameter aligns method signature with internal usage.
This addition to the public request: method mirrors the internal structure for wrapperSDKAgents. No issues found.


659-660: Agent handling in paginated responses looks correct.
Propagating wrapperSDKAgents to ARTHTTPPaginatedResponse ensures the same agent context is preserved.

Ably.xcodeproj/project.pbxproj (26)

79-87: Check for duplicate build file entries for AblyInternal/AblyPublic headers.
These repeated references (all marked as Public) may be intentional for multi-target builds, but if not, consider consolidating them to avoid confusion.


181-195: Validate new entries for ARTWrapperSDKProxyOptions and related files.
Ensure that making them all Public is intentional, since these options might be for internal use only.


299-316: Confirm ARTWrapperSDKProxyRealtimeChannel and ARTWrapperSDKProxyRealtimeChannels references.
They appear multiple times as Public. If you only need them in certain targets, you might scope them accordingly.


1198-1200: Check the file references for AblyInternal.h, AblyPublic.h, and ARTRealtime+WrapperSDKProxy.h.
Redundant entries can cause project file bloat and potential build inconsistencies.


1232-1237: Review new file references for ARTWrapperSDKProxyOptions and ARTWrapperSDKProxyRealtime.
All references are Public; confirm whether they need to be exposed externally.


1290-1295: Confirm the new references for ARTWrapperSDKProxyRealtimeChannel[+Private].h and .m.
If these headers are meant to be private, switching their attribute to Private can reduce external exposure.


1653-1669: New PBXGroup “Wrapper SDK Proxy” creation.
This grouping is a good organizational step. Just ensure that all relevant header and source references are correctly placed within it.


1816-1816: Added WrapperSDKProxyTests.swift to the test group.
No obvious issues, but confirm that your test target references this file.


1914-1914: Added "Wrapper SDK Proxy" group reference.
Seems fine. Ensure the group’s path is correct for all supported platforms (iOS, macOS, tvOS).


2127-2128: File references for ARTWrapperSDKProxyOptions.h/.m.
Both are marked as Public in the “Types” group. Verify that public exposure is needed or switch to Private if only used internally.


2338-2338: Added new public headers for ARTWrapperSDKProxyOptions and ARTWrapperSDKProxyRealtime.
Check that the public scope matches your distribution strategy and that these are included in the final build artifact properly.

Also applies to: 2343-2343, 2347-2347


2385-2386: Private headers for ARTWrapperSDKProxyRealtimeChannel/Channels.
Marking them Private is consistent with an internal usage pattern; just confirm all bridging to the public API is covered.


2441-2442: Multiple references for ARTWrapperSDKProxyRealtimeChannel.h/.h.
These files are listed as Public multiple times. If you only intend one reference per target, remove duplicates.

Also applies to: 2444-2445


2545-2547: Confirm the addition of ARTWrapperSDKProxyOptions.h as Public.
If this is purely for advanced usage, consider making it Private or documenting it thoroughly.


2596-2596: Reference to private header in line 2596.
No immediate concerns, just confirm that your test or internal builds include this correctly.


2618-2619: Repeated references to AblyInternal.h and AblyPublic.h.
As before, verify that each is necessary.


2659-2659: Added new reference for ARTRealtime+WrapperSDKProxy.h.
If this extension should be widely available, Public is correct. Otherwise, consider scoping it to internal usage only.


2758-2759: Check multiple references for ARTWrapperSDKProxyRealtime.h.
Consolidate if possible, or confirm multiple target requirements.

Also applies to: 2767-2767


2798-2799: Repeated references for AblyInternal.h and AblyPublic.h.
Check if your specific build phases or target conditions genuinely require duplication.


3177-3177: WrapperSDKProxyTests.swift in Sources.
Looks fine; confirm that the test target includes this file or if it belongs in a dedicated test group.


3280-3280: Check reference for ARTWrapperSDKProxyOptions.m.
No immediate issues; confirm that build phases have this properly assigned.


3294-3294: One more reference for ARTWrapperSDKProxyRealtime.m.
Stay consistent across all references. Consider combining them if they belong to the same build configuration.


3453-3453: WrapperSDKProxyTests.swift in another PBXGroup.
Double-check that you don’t have conflicting references for the same file.


3515-3516: Check references for ARTWrapperSDKProxyRealtimeChannel.m and ARTWrapperSDKProxyRealtimeChannels.m.
Likely repeated for a different build configuration. If so, keep them; otherwise, remove duplicates.


3542-3542: Reference for ARTWrapperSDKProxyRealtime.m.
Confirm you are listing it only under the relevant build phases (e.g., iOS/macOS).


3656-3656: ARTWrapperSDKProxyOptions.m reference again.
If you intend each build variant to include it, keep it. Otherwise, consolidate.

Source/ARTWrapperSDKProxyOptions.m (1)

5-11: LGTM! Well-structured initialization with proper copy semantics.

The implementation correctly:

  • Follows the two-stage initialization pattern
  • Uses copy semantics for the agents dictionary to prevent external mutations
  • Handles nullable input appropriately
Source/include/Ably/Ably.h (1)

15-16: LGTM! Clean separation of public and internal APIs.

The consolidation of imports into AblyPublic.h and AblyInternal.h improves the organization and maintainability of the SDK's API surface.

Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtime+Private.h (1)

7-13: LGTM! Well-designed private interface with proper initialization constraints.

The interface correctly:

  • Declares a designated initializer with required dependencies
  • Prevents incorrect initialization by marking default init as unavailable
  • Uses proper nullability annotations
Source/include/Ably/AblyInternal.h (1)

3-7: LGTM! Comprehensive inclusion of wrapper SDK proxy components.

The imports include all necessary components for implementing wrapper SDK tracking as outlined in ADR-117.

Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtimeChannel+Private.h (1)

1-16: LGTM! Well-structured initialization pattern.

The implementation follows best practices:

  • Proper use of forward declarations
  • Correct nullability annotations
  • Well-defined initialization pattern with unavailable default initializer and designated initializer
Source/PrivateHeaders/Ably/ARTWrapperSDKProxyRealtimeChannels+Private.h (1)

1-16: LGTM! Consistent implementation pattern.

The implementation maintains consistency with ARTWrapperSDKProxyRealtimeChannel+Private.h and follows the same best practices.

Source/PrivateHeaders/Ably/ARTClientInformation+Private.h (1)

12-13: LGTM! Clear and well-documented API addition.

The new method is well-documented and follows consistent naming patterns with existing methods in the class.

Source/include/Ably/ARTWrapperSDKProxyRealtimeChannel.h (1)

8-12: LGTM! Clear documentation of purpose and usage restrictions.

The documentation clearly states the purpose of the class and correctly emphasizes that it's for Ably-authored SDKs only.

Source/include/Ably/ARTWrapperSDKProxyRealtimeChannels.h (1)

8-12: LGTM! Clear documentation of purpose and usage restrictions.

The documentation clearly states the purpose of the class and correctly emphasizes that it's for Ably-authored SDKs only.

Source/include/Ably/ARTWrapperSDKProxyRealtime.h (1)

11-15: LGTM! Clear documentation of purpose and usage restrictions.

The documentation clearly states the purpose of the class and correctly emphasizes that it's for Ably-authored SDKs only.

Source/PrivateHeaders/Ably/ARTHTTPPaginatedResponse+Private.h (3)

12-12: LGTM! Property declaration looks good.

The property is correctly declared as nullable and readonly, with appropriate type specification.


14-22: LGTM! Method signature update is well-structured.

The initializer method signature is updated correctly to include the wrapperSDKAgents parameter while maintaining proper nullability annotations.


29-33: LGTM! Method signature replacement is appropriate.

The new method signature correctly replaces the deprecated one and includes proper parameter annotations.

Source/include/Ably/AblyPublic.h (1)

1-49: LGTM! Comprehensive and well-organized public header imports.

The imports are logically grouped and include all necessary components for the SDK's public interface.

Source/ARTWrapperSDKProxyRealtimeChannels.m (2)

11-12: LGTM! Properties are properly declared.

Properties are correctly declared as readonly with appropriate memory management semantics.


56-68: LGTM! Robust options handling.

The method properly handles both nil and non-nil cases for options and agents, with clean parameter resolution.

Source/ARTWrapperSDKProxyRealtime.m (1)

65-80: LGTM! Request method properly handles wrapper SDK agents.

The implementation correctly forwards the agents from proxy options to the underlying request.

Source/ARTPushAdmin.m (1)

85-86: LGTM!

The addition of wrapperSDKAgents:nil parameter aligns with the broader SDK changes for wrapper SDK tracking.

Source/Ably.modulemap (1)

115-117: LGTM!

The new private headers for wrapper SDK proxy functionality are correctly placed and follow the existing naming conventions.

Source/PrivateHeaders/Ably/ARTRest+Private.h (1)

73-75: LGTM!

The addition of wrapperSDKAgents parameter is consistent across methods and uses appropriate types.

Also applies to: 79-82

Source/PrivateHeaders/Ably/ARTRealtime+Private.h (1)

50-57: LGTM!

The addition of wrapperSDKAgents parameter is consistent with other files and uses appropriate types.

Source/include/Ably.modulemap (1)

113-115: LGTM!

The new private headers for the wrapper SDK proxy feature are correctly placed in the Private module and follow the existing naming convention.

Source/ARTHTTPPaginatedResponse.m (2)

23-28: LGTM!

The wrapper SDK agents parameter is correctly added to the initializer and stored as a copy, maintaining immutability.


65-65: LGTM!

The wrapper SDK agents are correctly propagated through the pagination chain, ensuring consistent behavior across paginated requests.

Also applies to: 86-86, 96-96

Source/ARTWrapperSDKProxyRealtimeChannel.m (1)

16-23: LGTM!

The initialization is well-implemented with proper property initialization and immutability.

Source/ARTPushChannelSubscriptions.m (2)

93-93: LGTM!

The addition of wrapperSDKAgents:nil parameter is consistent with the API changes for wrapper SDK support.


210-210: LGTM!

The addition of wrapperSDKAgents:nil parameter is consistent with the API changes for wrapper SDK support.

Source/ARTPushChannel.m (4)

132-132: LGTM!

The addition of wrapperSDKAgents:nil parameter is consistent with the API changes for wrapper SDK support.


166-166: LGTM!

The addition of wrapperSDKAgents:nil parameter is consistent with the API changes for wrapper SDK support.


203-203: LGTM!

The addition of wrapperSDKAgents:nil parameter is consistent with the API changes for wrapper SDK support.


238-238: LGTM!

The addition of wrapperSDKAgents:nil parameter is consistent with the API changes for wrapper SDK support.

Source/ARTPushDeviceRegistrations.m (4)

94-94: LGTM!

The addition of wrapperSDKAgents:nil parameter is consistent with the API changes for wrapper SDK support.


142-142: LGTM!

The addition of wrapperSDKAgents:nil parameter is consistent with the API changes for wrapper SDK support.


215-215: LGTM!

The addition of wrapperSDKAgents:nil parameter is consistent with the API changes for wrapper SDK support.


260-260: LGTM!

The addition of wrapperSDKAgents:nil parameter is consistent with the API changes for wrapper SDK support.

Test/Tests/WrapperSDKProxyTests.swift (4)

8-73: Well-structured connection state tests!

The test cases effectively validate the connection state sharing and subscription management between the proxy and underlying client. Good use of cleanup and clear documentation of test flow.


77-181: Comprehensive channel state and subscription tests!

The test cases thoroughly validate the channel state sharing and subscription management between the proxy and underlying channel. Good coverage of both state changes and message handling.


185-320: Well-implemented request handling tests!

The test cases effectively validate the addition of wrapper SDK agent information to request headers, including proper handling in paginated requests.

🧰 Tools
🪛 SwiftLint (0.57.0)

[Warning] 208-208: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)


324-404: Well-designed agent channel parameter tests!

The test cases effectively validate the agent parameter handling in various scenarios using a clean parameterized test approach. Good coverage of different channel option combinations.

Source/ARTRestChannel.m (1)

234-234: LGTM!

The addition of wrapperSDKAgents:nil parameter to the executeRequest calls is consistent with the PR objectives and maintains proper request handling.

Also applies to: 364-364

Source/ARTPushActivationStateMachine.m (1)

199-199: LGTM!

The addition of wrapperSDKAgents:nil parameter to the executeRequest calls in push-related methods is consistent with the PR objectives and maintains proper request handling.

Also applies to: 265-265, 313-313, 368-368

Source/ARTAuth.m (1)

373-373: LGTM!

The addition of wrapperSDKAgents:nil parameter to the executeRequest calls in authentication methods is consistent with the PR objectives and maintains proper request handling.

Also applies to: 511-511

Source/ARTRealtime.m (3)

7-7: LGTM!

The addition of imports for wrapper SDK proxy functionality is appropriate and necessary for the new feature.

Also applies to: 56-56


187-195: LGTM!

The new category implementation cleanly extends ARTRealtime with wrapper SDK proxy functionality, following good Objective-C practices.


507-516: LGTM!

The addition of wrapperSDKAgents parameter to the request method is consistent with the PR objectives and maintains proper request handling.

Test/Tests/RestClientTests.swift (1)

785-785: LGTM! Test updated for new method signature.

The test has been correctly updated to include the new wrapperSDKAgents parameter, appropriately set to nil as this test case doesn't involve wrapper SDK functionality.

CONTRIBUTING.md (1)

38-40: LGTM! Clear guidance for header organization.

The updated instructions provide clear guidance on organizing public headers based on their intended usage:

  • AblyPublic.h for general-use APIs
  • AblyInternal.h for Ably-authored SDK-only APIs

This separation helps maintain clear boundaries between public and internal interfaces.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~40-~40: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...this header is intended for use only by Ably-authored SDKs and should not be included in the ...

(HYPHENATED_LY_ADVERB_ADJECTIVE)

Source/include/Ably/ARTWrapperSDKProxyRealtimeChannel.h Outdated Show resolved Hide resolved
Source/include/Ably/ARTWrapperSDKProxyRealtimeChannels.h Outdated Show resolved Hide resolved
Source/include/Ably/ARTWrapperSDKProxyRealtime.h Outdated Show resolved Hide resolved
Source/ARTWrapperSDKProxyRealtimeChannel.m Outdated Show resolved Hide resolved
Source/ARTPaginatedResult.m Show resolved Hide resolved
Part of #2020; that is, implementing ADR-117 [1]. This adds a
-createWrapperSDKProxyWithOptions: method to ARTRealtime. This method is
only to be called by Ably-authored wrapper SDKs and accepts a set of
agents describing the wrapper SDK. It returns a proxy object that wraps
the underlying ARTRealtime instance.

The intention is that when certain methods are called on this proxy, the
proxy will insert information that allows us to track the usage of the
wrapper SDK. I'll implement this behaviour in subsequent commits.

[1] https://ably.atlassian.net/wiki/spaces/ENG/pages/3413016589/ADR-117+Tracking+wrapper+SDK+usage+continued
Part of #2020; that is, implementing ADR-117 [1]. When -request is
called on an ARTWrapperSDKProxyRealtime, add the wrapper SDK's agents to
the Ably-Agent header.

[1] https://ably.atlassian.net/wiki/spaces/ENG/pages/3413016589/ADR-117+Tracking+wrapper+SDK+usage+continued
This extends the change in b006650 to also apply to loading subsequent
pages.
Part of #2020; that is, implementing ADR-117 [1]. There are no
functional changes here; it's preparation for adding the `agent` channel
param when a channel is fetched via an ARTWrapperSDKProxyRealtime.

I initially implemented this with internal storage of proxy instances to
ensure that there be only one proxy instance per underlying channel.
However, it wasn't really clear to me _why_ I did this, other than for
some sort of symmetry with the underlying ARTRealtimeChannels behaviour.
So it didn't really seem worth the time of trying to figure out the
right behaviour. So I decided to not implement this behaviour in the
end, instead creating a new proxy instance each time -get:… is called.

[1] https://ably.atlassian.net/wiki/spaces/ENG/pages/3413016589/ADR-117+Tracking+wrapper+SDK+usage+continued
Part of #2020; that is, implementing ADR-117 [1]. When a realtime
channel is fetched via an ARTWrapperSDKProxyRealtime, add the `agent`
channel param so that the channel attach analytics event gets attributed
to the wrapper SDK.

[1] https://ably.atlassian.net/wiki/spaces/ENG/pages/3413016589/ADR-117+Tracking+wrapper+SDK+usage+continued
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant