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

iOS: Expose builldBeacon and cancelBeacon hooks inside of BaseBeaconPlugin and make BeaconPlugin open class #536

Merged
merged 14 commits into from
Nov 20, 2024

Conversation

sakuntala-motukuri
Copy link
Contributor

@sakuntala-motukuri sakuntala-motukuri commented Nov 1, 2024

Change Type (required)

Indicate the type of change your pull request is:

iOS: Expose builldBeacon and cancelBeacon hooks inside of BaseBeaconPlugin and make BeaconPlugin open class

  • Changed return type of tap in Hook.swift to generic instead of void
  • Updated cancelBeacon and buildBeacon hooks accordingly in BaseBeaconPlugin class
  • Made BeaconPlugin open to extend the access for extending classes
  • Updated tests for above
  • patch
  • minor
  • major

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs
📦 Published PR as canary version: 0.9.2--canary.536.18200

Try this version out locally by upgrading relevant packages to 0.9.2--canary.536.18200

Version

Published prerelease version: 0.10.0-next.6

Changelog

Release Notes

Remove unneeded dependency on pubsub-js (#547)

Remove dead dependencies

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

Minor Docs Fixes (#538)

  • Fix search on next subdomain searching against and redirecting to latest
  • Update page description on the landing page

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

More Doc Fixes (#532)

  • Fix links for latest and next pages
  • Add package manager tabs for js install instructions
  • Fix version selector breaking on main page

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

Fix docs build visibility (#531)

Fix visibility of docs build

ios: enhance tapable logger to handle variadic args from the JS log (#524)

Prefixing message with the format [Player] [\(logLevel)]: moved out of the Tapable logger and moved to PrintLoggerPlugin. Any consumers using their own LoggerPlugin will need to append the logLevel if they want to print it

Before

public class CustomLoggingPlugin: NativePlugin {
    
    public let pluginName = "CustomLoggingPlugin"

    public func apply<P>(player: P) where P: HeadlessPlayer {
        guard let player = player as? SwiftUIPlayer else { return }
        player.logger.logLevel = .trace
        player.logger.hooks.trace.tap(name: pluginName, { print("Custom message")\(($0))" ) })
        ...
    }

After

public class CustomLoggingPlugin: NativePlugin {
    
    public let pluginName = "CustomLoggingPlugin"

    public func apply<P>(player: P) where P: HeadlessPlayer {
        guard let player = player as? SwiftUIPlayer else { return }
        player.logger.logLevel = .trace
        let prefixedMessage = "[Player] [trace]: "
        player.logger.hooks.trace.tap(name: pluginName, { print("\(prefixedMessage) Custom message \(($0))" ) })
        ...
    }

Breaking Changes

Any usage of the player.logger.hooks taps will have breaking changes in the callback because the calls have been changed to provide a [Any] type instead of String so it can be returned in the form of messages instead of a single message. Unless nothing is done in the callback to access the value but just to print it, there should be breaking changes

Example:

// this should be no breaking change
player.logger.hooks.trace.tap(name: "log", { print("\(($0))" ) })

// if `values` should be accessed in anyway, i.e want the first value, or want to seperate the values
 player.logger.hooks.debug.tap(name: "log") { values in
            // values is of type [Any], if you want to print only the first value
            print("\((message as? [String])?.first))" )
        }

🚀 Enhancement

  • ios: enhance tapable logger to handle variadic args from the JS log #524 (@nancywu1)

🐛 Bug Fix

🏠 Internal

📝 Documentation

Authors: 7

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

Attention: Patch coverage is 82.96296% with 23 lines in your changes missing coverage. Please review.

Project coverage is 89.54%. Comparing base (35f98d7) to head (cdb07d6).
Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
...ugins/beacon/ios/Tests/BaseBeaconPluginTests.swift 82.65% 17 Missing ⚠️
ios/core/Sources/Types/Hooks/Hook.swift 68.75% 5 Missing ⚠️
plugins/beacon/ios/Sources/BaseBeaconPlugin.swift 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #536      +/-   ##
==========================================
- Coverage   89.57%   89.54%   -0.04%     
==========================================
  Files         331      331              
  Lines       19718    19830     +112     
  Branches     1949     1949              
==========================================
+ Hits        17663    17757      +94     
- Misses       2041     2059      +18     
  Partials       14       14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@sakuntala-motukuri sakuntala-motukuri marked this pull request as ready for review November 5, 2024 02:34
@sakuntala-motukuri
Copy link
Contributor Author

/canary

@@ -18,20 +18,14 @@ import PlayerUIBaseBeaconPlugin
/**
Plugin used by `SwiftUIPlayer` for beaconing in a uniform format between platforms
*/
public class BeaconPlugin<BeaconStruct: Decodable>: BaseBeaconPlugin<BeaconStruct>, NativePlugin {
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like comments were removed by accident?

@sakuntala-motukuri sakuntala-motukuri merged commit cb18aac into main Nov 20, 2024
9 of 11 checks passed
@sakuntala-motukuri sakuntala-motukuri deleted the enhance-beacon-plugin-ios branch November 20, 2024 18:06
This was referenced Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants