Skip to content

Commit

Permalink
feat: Update Kochava to v8 and remove Cocoapods
Browse files Browse the repository at this point in the history
  • Loading branch information
einsteinx2 committed Apr 26, 2024
1 parent 7e84883 commit 488e574
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 68 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/ios-kit-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ jobs:
needs: create-release-branch
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Validate environment
run: |
env | grep -q '^GITHUB_ACCESS_TOKEN=' || (echo "Required environment variable GITHUB_ACCESS_TOKEN is not set" && exit 1)
env | grep -q '^COCOAPODS_TRUNK_TOKEN=' || (echo "Required environment variable COCOAPODS_TRUNK_TOKEN is not set" && exit 1)
- name: Setup git config
run: |
Expand Down Expand Up @@ -105,12 +103,6 @@ jobs:
git status
git push origin HEAD:release/${{ github.run_number }}
- name: Release to CocoaPods
if: ${{ github.event.inputs.dryRun == 'false'}}
run: |
sudo gem install xcodeproj
pod trunk push --allow-warnings
sync-repository:
name: Finalize release
needs: release
Expand Down
33 changes: 23 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,49 @@ import PackageDescription
let package = Package(
name: "mParticle-Kochava",
platforms: [
.iOS("12.4"),
.tvOS("12.4"),
.iOS("13.0"),
.tvOS("13.0"),
],
products: [
.library(
name: "mParticle-Kochava",
targets: ["mParticle-Kochava"]),
.library(
name: "mParticle-Kochava-NoTracking",
targets: ["mParticle-Kochava-NoTracking"]),
],
dependencies: [
.package(
name: "mParticle-Apple-SDK",
url: "https://github.com/mParticle/mparticle-apple-sdk",
.upToNextMajor(from: "8.3.0")
.upToNextMajor(from: "8.19.0")
),
.package(
name: "KochavaNetworking",
url: "https://github.com/Kochava/Apple-SwiftPackage-KochavaNetworking-XCFramework",
.upToNextMajor(from: "8.0.0")
),
.package(
name: "KochavaCore",
url: "https://github.com/Kochava/Apple-SwiftPackage-KochavaCore",
.upToNextMajor(from: "7.0.0")
name: "KochavaMeasurement",
url: "https://github.com/Kochava/Apple-SwiftPackage-KochavaMeasurement-XCFramework",
.upToNextMajor(from: "8.0.0")
),
.package(
name: "KochavaTracker",
url: "https://github.com/Kochava/Apple-SwiftPackage-KochavaTracker.git",
.upToNextMajor(from: "7.0.0")
name: "KochavaTracking",
url: "https://github.com/Kochava/Apple-SwiftPackage-KochavaTracking-XCFramework",
.upToNextMajor(from: "8.0.0")
),
],
targets: [
.target(
name: "mParticle-Kochava",
dependencies: ["mParticle-Apple-SDK", "KochavaCore", "KochavaTracker"],
dependencies: ["mParticle-Apple-SDK", "KochavaNetworking", "KochavaMeasurement", "KochavaTracking"],
path: "mParticle-Kochava",
publicHeadersPath: "."),
.target(
name: "mParticle-Kochava-NoTracking",
dependencies: ["mParticle-Apple-SDK", "KochavaNetworking", "KochavaMeasurement"],
path: "mParticle-Kochava-NoTracking",
publicHeadersPath: "."),
]
)
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ This repository contains the [Kochava](https://www.kochava.com) integration for

## Installation

KochavaTracker 4.0.0 and on is a Swift package. To install it, simply add this package as a dependency.
Kochava's SDK, as of version 8.0.0, no longer supports CocoaPods. As this version is the minimum required for App Store submission due to the iOS 17 privacy manifest changes, the mParticle Kochava Kit by association no longer supports CocoaPods either.

In Xcode, see File > Swift Packages > Add Package Dependency ... > and enter the URL for this package repository.

## Integration using CocoaPods
The mParticle Kochava Kit contains two build targets: `mParticle-Kochava` and `mParticle-Kochava-NoTracking`. The `mParticle-Kochava` retains all of the same functionality of the previous version of Kochava, while the `mParticle-Kochava-NoTracking` removes the parts that Apple defines as "tracking".

Prior to 4.0.0, KochavaTracker supported CocoaPods.
Specifically this means, `mParticle-Kochava` depends on the `KochavaNetworking`, `KochavaMeasurement`, and `KochavaTracking` packages, while the `mParticle-Kochava-NoTracking` target only depends on the `KochavaNetworking` and `KochavaMeasurement` packages.

### Adding the integration
You can read more about that in Kochava's documentation here: https://support.kochava.com/sdk-integration/ios-sdk-integration/ios-migrating-to-v8/

1. Add the kit dependency to your app's Podfile:
### Adding the integration

```
pod 'mParticle-Kochava', '~> 8.0'
```
1. Add this kit to your Xcode project using SPM, and choose either `mParticle-Kochava` or `mParticle-Kochava-NoTracking`

2. Follow the mParticle iOS SDK [quick-start](https://github.com/mParticle/mparticle-apple-sdk), then rebuild and launch your app, and verify that you see `"Included kits: { Kochava }"` in your Xcode console

Expand Down
6 changes: 3 additions & 3 deletions Scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ NOTES="$2"
# Update version number
#

# Update CocoaPods podspec file
sed -i '' 's/\(^ s.version[^=]*= \).*/\1"'"$VERSION"'"/' mParticle-Kochava.podspec
# Update VERSION file
echo $PREFIXED_VERSION > VERSION

# Make the release commit in git
#

git add mParticle-Kochava.podspec
git add VERSION
git commit -m "chore(release): $VERSION [skip ci]
$NOTES"
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v8.4.0
1 change: 1 addition & 0 deletions mParticle-Kochava-NoTracking
20 changes: 0 additions & 20 deletions mParticle-Kochava.podspec

This file was deleted.

36 changes: 17 additions & 19 deletions mParticle-Kochava/MPKitKochava.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#import "MPKitKochava.h"
#import "MPKochavaSpatialCoordinate.h"
#if defined(__has_include) && __has_include(<KochavaTracker/KochavaTracker.h>)
#import <KochavaTracker/KochavaTracker.h>
#if defined(__has_include) && __has_include(<KochavaMeasurement/KochavaMeasurement.h>)
#import <KochavaMeasurement/KochavaMeasurement.h>
#else
#import "KochavaTracker.h"
#import "KochavaMeasurement.h"
#endif

NSString *const MPKitKochavaErrorKey = @"mParticle-Kochava Error";
Expand Down Expand Up @@ -136,8 +136,7 @@ - (NSError *)errorWithMessage:(NSString *)message {
}

- (void)retrieveAttributionWithCompletionHandler:(void(^)(NSDictionary *attribution))completionHandler {
[KVATracker.shared.attribution retrieveResultWithCompletionHandler:^(KVAAttributionResult * _Nonnull attributionResult)
{
[KVAMeasurement.shared.attribution retrieveResultWithClosure_didComplete:^(KVAMeasurement_Attribution_Result * _Nonnull attributionResult) {
if (!attributionResult.rawDictionary) {
[self->_kitApi onAttributionCompleteWithResult:nil error:[self errorWithMessage:@"Received nil attributionData from Kochava"]];
} else {
Expand Down Expand Up @@ -252,24 +251,24 @@ - (MPKitExecStatus *)didFinishLaunchingWithConfiguration:(NSDictionary *)configu

- (void)start {
if (self.configuration[kvEnableATT]) {
KVATracker.shared.appTrackingTransparency.enabledBool = [self.configuration[kvEnableATT] boolValue] ? TRUE : FALSE;
KVAMeasurement.shared.appTrackingTransparency.enabledBool = [self.configuration[kvEnableATT] boolValue] ? TRUE : FALSE;
}

if (self.configuration[kvEnableATTPrompt]) {
KVATracker.shared.appTrackingTransparency.autoRequestTrackingAuthorizationBool = [self.configuration[kvEnableATTPrompt] boolValue] ? TRUE : FALSE;
KVAMeasurement.shared.appTrackingTransparency.autoRequestTrackingAuthorizationBool = [self.configuration[kvEnableATTPrompt] boolValue] ? TRUE : FALSE;
if (self.configuration[kvWaitIntervalATT] && [self.configuration[kvEnableATTPrompt] boolValue]) {
KVATracker.shared.appTrackingTransparency.authorizationStatusWaitTimeInterval = [self.configuration[kvWaitIntervalATT] integerValue];
KVAMeasurement.shared.appTrackingTransparency.authorizationStatusWaitTimeInterval = [self.configuration[kvWaitIntervalATT] integerValue];
}
}

[KVATracker.shared startWithAppGUIDString:self.configuration[kvAppId]];
[KVAMeasurement.shared startWithAppGUIDString:self.configuration[kvAppId]];

if (self.configuration[kvLimitAdTracking]) {
KVATracker.shared.appLimitAdTracking.boolean = [self.configuration[kvLimitAdTracking] boolValue];
KVAMeasurement.shared.appLimitAdTracking.boolean = [self.configuration[kvLimitAdTracking] boolValue];
}

if (self.configuration[kvEnableLogging]) {
KVALog.shared.level = [self.configuration[kvEnableLogging] boolValue] ? KVALogLevel.debug : KVALogLevel.never;
KVALog.shared.level = [self.configuration[kvEnableLogging] boolValue] ? KVALog_Level.debug : KVALog_Level.never;
}

if (self.configuration[kvUserIdentificationType] || self.configuration[kvEmailIdentificationType] ) {
Expand All @@ -279,8 +278,7 @@ - (void)start {
NSDictionary *userActivityDictionary = self.launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey];
if (userActivityDictionary == nil)
{
[KVADeeplink processWithURL:nil closure_didComplete:^(KVADeeplink * _Nonnull deeplink)
{
[KVADeeplink processWithURL:nil closure_didComplete:^(KVADeeplink * _Nonnull deeplink) {
NSString *destinationString = deeplink.destinationString;
if (destinationString.length == 0) {
[self->_kitApi onAttributionCompleteWithResult:nil error:[self errorWithMessage:@"Received nil deeplink from Kochava"]];
Expand Down Expand Up @@ -318,7 +316,7 @@ - (void)start {
}

- (id const)providerKitInstance {
return [self started] ? KVATracker.shared : nil;
return [self started] ? KVAMeasurement.shared : nil;
}

- (MPKitAPI *)kitApi {
Expand All @@ -330,7 +328,7 @@ - (MPKitAPI *)kitApi {
}

- (MPKitExecStatus *)setOptOut:(BOOL)optOut {
KVATracker.shared.appLimitAdTracking.boolean = optOut;
KVAMeasurement.shared.appLimitAdTracking.boolean = optOut;

MPKitExecStatus *execStatus = [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceKochava) returnCode:MPKitReturnCodeSuccess];
return execStatus;
Expand All @@ -347,7 +345,7 @@ - (nonnull MPKitExecStatus *)logBaseEvent:(nonnull MPBaseEvent *)event {
}

- (MPKitExecStatus *)routeEvent:(MPEvent *)event {
KVAEvent *kochavaEvent = [[KVAEvent alloc] initWithType:KVAEventType.custom];
KVAEvent *kochavaEvent = [[KVAEvent alloc] initWithType:KVAEvent_Type.custom];
kochavaEvent.customEventName = event.name;
kochavaEvent.infoDictionary = event.customAttributes;
[kochavaEvent send];
Expand All @@ -356,7 +354,7 @@ - (MPKitExecStatus *)routeEvent:(MPEvent *)event {
}

- (MPKitExecStatus *)routeCommerceEvent:(MPCommerceEvent *)commerceEvent {
KVAEvent *kochavaEvent = [[KVAEvent alloc] initWithType:KVAEventType.custom];
KVAEvent *kochavaEvent = [[KVAEvent alloc] initWithType:KVAEvent_Type.custom];
NSString *eventName;
if (commerceEvent.promotionContainer) {
eventName = [NSString stringWithFormat:@"eCommerce - %@", KVNSStringFromPromotionAction(commerceEvent.promotionContainer.action)];
Expand Down Expand Up @@ -408,7 +406,7 @@ - (MPKitExecStatus *)routeCommerceEvent:(MPCommerceEvent *)commerceEvent {
}

- (MPKitExecStatus *)logScreen:(MPEvent *)event {
KVAEvent *kochavaEvent = [[KVAEvent alloc] initWithType:KVAEventType.custom];
KVAEvent *kochavaEvent = [[KVAEvent alloc] initWithType:KVAEvent_Type.custom];
kochavaEvent.customEventName = [NSString stringWithFormat:@"Viewed %@", event.name];
kochavaEvent.infoDictionary = event.customAttributes;
[kochavaEvent send];
Expand Down Expand Up @@ -465,7 +463,7 @@ - (MPKitExecStatus *)continueUserActivity:(NSUserActivity *)userActivity restora
}

- (MPKitExecStatus *)setATTStatus:(MPATTAuthorizationStatus)status withATTStatusTimestampMillis:(NSNumber *)attStatusTimestampMillis API_AVAILABLE(ios(14)){
KVATracker.shared.appTrackingTransparency.enabledBool = YES;
KVAMeasurement.shared.appTrackingTransparency.enabledBool = YES;

return [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceKochava) returnCode:MPKitReturnCodeSuccess];
}
Expand Down

0 comments on commit 488e574

Please sign in to comment.