Skip to content

Commit

Permalink
chore(refactor): refactoring work
Browse files Browse the repository at this point in the history
Plugin, Flush, Event filtering,  Source config download, Networking, Application life cycle, Record screen views have been refactored.

Introduced count based flush policy.

Introduced exponential retry policy.

Bug Fixed:
- App tracking consent should be set irrespective of advertisementId.
- Message level options and global options should be merged.
- Last event timestamp should set to nil when reset is called.
  • Loading branch information
pallabmaiti committed Jan 30, 2024
1 parent cb223ee commit 72be93b
Show file tree
Hide file tree
Showing 161 changed files with 9,107 additions and 8,293 deletions.
5 changes: 4 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type_body_length:
- 400 # error
# or they can set both explicitly
file_length:
warning: 500
warning: 600
error: 1200
# naming rules can set warnings/errors for min_length and max_length
# additionally they can set excluded names
Expand All @@ -50,4 +50,7 @@ identifier_name:
- id
- URL
- GlobalAPIKey
function_body_length:
- 75 # warning
- 100 # error
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, codeclimate, junit, html, emoji, sonarqube, markdown, github-actions-logging)
2 changes: 2 additions & 0 deletions Examples/RudderConfig/RudderConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class RudderConfig: NSObject, Codable {
@objc let DEV_CONTROL_PLANE_URL: String
@objc let STORAGE_LOCATION: String
@objc let DOMAIN_IDENTIFIER: String
@objc let MOCK_DATA_PLANE_URL: String
@objc let MOCK_CONTROL_PLANE_URL: String

@objc
class func create(from url: URL) -> RudderConfig? {
Expand Down
6 changes: 3 additions & 3 deletions Examples/SampleObjC-iOS/SampleObjC-iOS/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ @implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
RSConfig *config = [[RSConfig alloc] initWithWriteKey:WRITE_KEY];
Config *config = [[Config alloc] initWithWriteKey:WRITE_KEY];
[config dataPlaneURL:DATA_PLANE_URL];
[config loglevel:RSLogLevelDebug];
[config trackLifecycleEvents:YES];
Expand All @@ -43,11 +43,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[client setAppTrackingConsent:RSAppTrackingConsentAuthorize];
[client setAnonymousId:@"example_anonymous_id"];
RSOption *defaultOption = [[RSOption alloc] init];
Option *defaultOption = [[Option alloc] init];
[defaultOption putIntegration:@"Amplitude" isEnabled:YES];
[client setOption:defaultOption];
RSOption *eventOption = [[RSOption alloc] init];
Option *eventOption = [[Option alloc] init];
[eventOption putIntegration:@"Amplitude" isEnabled:YES];
[eventOption putExternalId:@"brazeExternalId" withId:@"some_external_id_1"];
[client identify:@"user_id" traits:@{@"email": @"[email protected]"} option:eventOption];
Expand Down
4 changes: 2 additions & 2 deletions Examples/SampleObjC-tvOS/SampleObjC-tvOS/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ @implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
RSConfig *config = [[RSConfig alloc] initWithWriteKey:WRITE_KEY];
Config *config = [[Config alloc] initWithWriteKey:WRITE_KEY];
[config dataPlaneURL:DATA_PLANE_URL];
[config trackLifecycleEvents:YES];
[config recordScreenViews:YES];
Expand All @@ -35,7 +35,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}

- (void) identify {
RSOption *identifyOptions = [[RSOption alloc] init];
Option *identifyOptions = [[Option alloc] init];
[identifyOptions putExternalId:@"brazeExternalId1" withId:@"some_external_id_1"];

[client identify:@"test_user_id1" traits:@{@"foo1": @"bar1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ @implementation ExtensionDelegate

- (void)applicationDidFinishLaunching {
// Perform any final initialization of your application.
RSConfig *config = [[RSConfig alloc] initWithWriteKey:WRITE_KEY];
Config *config = [[Config alloc] initWithWriteKey:WRITE_KEY];
[config dataPlaneURL:DATA_PLANE_URL];
[config trackLifecycleEvents:YES];
[config recordScreenViews:YES];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let config: RSConfig = RSConfig(writeKey: "1wvsoF3Kx2SczQNlx1dvcqW9ODW")
let config: Config = Config(writeKey: "1wvsoF3Kx2SczQNlx1dvcqW9ODW")
.dataPlaneURL("https://rudderstacz.dataplane.rudderstack.com")
.loglevel(.debug)
.trackLifecycleEvents(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class RSCustomDestination: RSDestinationPlugin {
}
}

extension RSCustomDestination: RSPushNotifications {
extension RSCustomDestination: PushNotifications {
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

}
Expand Down
19 changes: 8 additions & 11 deletions Examples/SampleSwift-iOS/SampleSwift-iOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import UIKit
import Rudder
import AdSupport
import Network
import RudderFirebase
import RudderAmplitude

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var client: RSClient!

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

guard let path = Bundle.main.path(forResource: "RudderConfig", ofType: "plist"),
Expand All @@ -26,22 +26,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

print(NSHomeDirectory())

let config: RSConfig = RSConfig(writeKey: rudderConfig.WRITE_KEY, dataPlaneURL: rudderConfig.DEV_DATA_PLANE_URL)
if let config: Config = Config(writeKey: rudderConfig.WRITE_KEY, dataPlaneURL: rudderConfig.DEV_DATA_PLANE_URL)?
.controlPlaneURL(rudderConfig.DEV_CONTROL_PLANE_URL)
// .dataResidencyServer(.EU)
// .controlPlaneURL("https://e2e6fd4f-c24c-43d6-8ca3-11a11e7cc7d5.mock.pstmn.io") // disabled
// .controlPlaneURL("https://98e2b8de-9984-471b-a705-b1bcf3f9f6ba.mock.pstmn.io") // enabled
.loglevel(.verbose)
.trackLifecycleEvents(true)
.recordScreenViews(true)
.sleepTimeOut(20)
.gzipEnabled(false)

RSClient.sharedInstance().configure(with: config)


RSClient.sharedInstance().addDestination(RudderAmplitudeDestination())
RSClient.sharedInstance().addDestination(RudderFirebaseDestination())
// .sleepTimeOut(10)
.gzipEnabled(false) {

client = RSClient(config: config)
}

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation
import Rudder

/*
class RSCustomDestination: RSDestinationPlugin {
var key: String = "Custom"
var controller = RSController()
Expand Down Expand Up @@ -59,4 +59,4 @@ class CustomDestination: RudderDestination {
super.init()
plugin = RSCustomDestination()
}
}
}*/
Loading

0 comments on commit 72be93b

Please sign in to comment.