Merge remote-tracking branch 'github/master'

* github/master:
  Prepare fore release 2.6.0
  Add support for screen calls (#48)
  Prepare for releaae 2.5.0
  Brie/updates sunset (#47)
  Update CHANGELOG.md
  Prepare for release 2.4.1
  add promotion viewed event (#46)
This commit is contained in:
Zitao Xiong
2020-04-20 23:25:56 +08:00
7 changed files with 228 additions and 78 deletions

33
.circleci/config.yml Normal file
View File

@@ -0,0 +1,33 @@
version: 2
jobs:
build_and_test:
macos:
xcode: "10.2.1"
steps:
- checkout
- run: xcrun simctl list
- run:
name: Install build dependencies
command: |
sudo gem install xcpretty
sudo gem install cocoapods -v 1.6.1
# - run:
# name: Fetch Cocoapods specs
# command: curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
- run: make install
- run: make build
- run: make test
- run: make lint
# - store_test_results:
# # relies on xcpretty --report junit
# path: build/reports
# - run: bash <(curl -s https://codecov.io/bash)
workflows:
version: 2
build_and_test:
jobs:
- build_and_test

View File

@@ -1,5 +1,22 @@
Change Log
==========
Version 2.6.0 *(12th February, 2020)*
-------------------------------------------
* Adds support for calling `screen` calls explicitly.
Version 2.5.0 *(9th September, 2019)*
-------------------------------------------
* Updates to use the latest Firebase/Core SDK (6.2)
* Adds FirebaseAnalytics (6.1) as dependency as Firebase is migrating away from FirebaseCore
* Transforms event and property names to ^[a-zA-Z0-9_]+$
* Fixes crash when Firebase SDK is instantiated multiple times by not configuring the FIRApp if already done
* Adds CircleCI config
Version 2.4.1 *(28th August, 2019)*
-------------------------------------------
* Add mapping of Segment `"Promotion Viewed"` event to Firebase `kFIREventPresentOffer` event.
Version 2.4.0 *(26th September, 2018)*
-------------------------------------------

View File

@@ -1,65 +1,80 @@
PODS:
- Analytics (3.6.9)
- Expecta (1.0.6)
- Firebase/Core (5.9.0):
- Firebase/Core (6.7.0):
- Firebase/CoreOnly
- FirebaseAnalytics (= 5.2.0)
- Firebase/CoreOnly (5.9.0):
- FirebaseCore (= 5.1.4)
- FirebaseAnalytics (5.2.0):
- FirebaseCore (~> 5.1)
- FirebaseInstanceID (~> 3.2)
- GoogleAppMeasurement (~> 5.2)
- GoogleUtilities/AppDelegateSwizzler (~> 5.2)
- GoogleUtilities/MethodSwizzler (~> 5.2)
- GoogleUtilities/Network (~> 5.2)
- "GoogleUtilities/NSData+zlib (~> 5.2)"
- FirebaseAnalytics (= 6.1.1)
- Firebase/CoreOnly (6.7.0):
- FirebaseCore (= 6.2.1)
- FirebaseAnalytics (6.1.1):
- FirebaseCore (~> 6.2)
- FirebaseInstanceID (~> 4.2)
- GoogleAppMeasurement (= 6.1.1)
- GoogleUtilities/AppDelegateSwizzler (~> 6.0)
- GoogleUtilities/MethodSwizzler (~> 6.0)
- GoogleUtilities/Network (~> 6.0)
- "GoogleUtilities/NSData+zlib (~> 6.0)"
- nanopb (~> 0.3)
- FirebaseCore (5.1.4):
- GoogleUtilities/Logger (~> 5.2)
- FirebaseInstanceID (3.2.2):
- FirebaseCore (~> 5.1)
- GoogleUtilities/Environment (~> 5.3)
- GoogleUtilities/UserDefaults (~> 5.3)
- GoogleAppMeasurement (5.2.0):
- GoogleUtilities/AppDelegateSwizzler (~> 5.2)
- GoogleUtilities/MethodSwizzler (~> 5.2)
- GoogleUtilities/Network (~> 5.2)
- "GoogleUtilities/NSData+zlib (~> 5.2)"
- FirebaseCore (6.2.1):
- FirebaseCoreDiagnostics (~> 1.0)
- FirebaseCoreDiagnosticsInterop (~> 1.0)
- GoogleUtilities/Environment (~> 6.2)
- GoogleUtilities/Logger (~> 6.2)
- FirebaseCoreDiagnostics (1.0.1):
- FirebaseCoreDiagnosticsInterop (~> 1.0)
- GoogleDataTransportCCTSupport (~> 1.0)
- GoogleUtilities/Environment (~> 6.2)
- GoogleUtilities/Logger (~> 6.2)
- FirebaseCoreDiagnosticsInterop (1.0.0)
- FirebaseInstanceID (4.2.3):
- FirebaseCore (~> 6.0)
- GoogleUtilities/Environment (~> 6.0)
- GoogleUtilities/UserDefaults (~> 6.0)
- GoogleAppMeasurement (6.1.1):
- GoogleUtilities/AppDelegateSwizzler (~> 6.0)
- GoogleUtilities/MethodSwizzler (~> 6.0)
- GoogleUtilities/Network (~> 6.0)
- "GoogleUtilities/NSData+zlib (~> 6.0)"
- nanopb (~> 0.3)
- GoogleUtilities/AppDelegateSwizzler (5.3.0):
- GoogleDataTransport (1.1.3)
- GoogleDataTransportCCTSupport (1.0.2):
- GoogleDataTransport (~> 1.1)
- nanopb
- GoogleUtilities/AppDelegateSwizzler (6.2.5):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (5.3.0)
- GoogleUtilities/Logger (5.3.0):
- GoogleUtilities/Environment (6.2.5)
- GoogleUtilities/Logger (6.2.5):
- GoogleUtilities/Environment
- GoogleUtilities/MethodSwizzler (5.3.0):
- GoogleUtilities/MethodSwizzler (6.2.5):
- GoogleUtilities/Logger
- GoogleUtilities/Network (5.3.0):
- GoogleUtilities/Network (6.2.5):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (5.3.0)"
- GoogleUtilities/Reachability (5.3.0):
- "GoogleUtilities/NSData+zlib (6.2.5)"
- GoogleUtilities/Reachability (6.2.5):
- GoogleUtilities/Logger
- GoogleUtilities/UserDefaults (5.3.0):
- GoogleUtilities/UserDefaults (6.2.5):
- GoogleUtilities/Logger
- nanopb (0.3.8):
- nanopb/decode (= 0.3.8)
- nanopb/encode (= 0.3.8)
- nanopb/decode (0.3.8)
- nanopb/encode (0.3.8)
- nanopb (0.3.901):
- nanopb/decode (= 0.3.901)
- nanopb/encode (= 0.3.901)
- nanopb/decode (0.3.901)
- nanopb/encode (0.3.901)
- OCHamcrest (7.0.1)
- OCMockito (5.0.0):
- OCHamcrest (~> 7.0)
- Segment-Firebase (2.3.0):
- Segment-Firebase (2.4.1):
- Analytics (~> 3.2)
- Firebase/Core (~> 5.0)
- Segment-Firebase/Core (= 2.3.0)
- Segment-Firebase/Core (2.3.0):
- Firebase/Core (~> 6.2)
- FirebaseAnalytics (~> 6.1)
- Segment-Firebase/Core (= 2.4.1)
- Segment-Firebase/Core (2.4.1):
- Analytics (~> 3.2)
- Firebase/Core (~> 5.0)
- Firebase/Core (~> 6.2)
- FirebaseAnalytics (~> 6.1)
- Specta (1.0.7)
DEPENDENCIES:
@@ -75,8 +90,12 @@ SPEC REPOS:
- Firebase
- FirebaseAnalytics
- FirebaseCore
- FirebaseCoreDiagnostics
- FirebaseCoreDiagnosticsInterop
- FirebaseInstanceID
- GoogleAppMeasurement
- GoogleDataTransport
- GoogleDataTransportCCTSupport
- GoogleUtilities
- nanopb
- OCHamcrest
@@ -90,18 +109,22 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Analytics: 6541ce337e99d9f7a2240a8b3953940a7be5f998
Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5
Firebase: 383fa29aca93e371cab776b48a5c66544d3c2003
FirebaseAnalytics: 831f1f127f4a75698e9875a87bf7e2668730d953
FirebaseCore: 2a84b6b325792a4319ef71ee18819dcba08d2fd7
FirebaseInstanceID: 78ba376fcd5b94c001f9999b2cbd3d1f1e56e78d
GoogleAppMeasurement: 2b3a023a61239c8d002e6e4fcf4abce8eddce0e0
GoogleUtilities: 760ccb53b7c7f40f9c02d8c241f76f841a7a6162
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Firebase: 291d7b0a7b393f252358083b5d224884126fa46d
FirebaseAnalytics: 843c7f64a8f9c79f0d03281197ebe7bb1d58d477
FirebaseCore: 32b48f41c84a56fbde73b35ed01a830b3b6dc048
FirebaseCoreDiagnostics: 4c04ae09d0ab027c30179828c6bb47764df1bd13
FirebaseCoreDiagnosticsInterop: 6829da2b8d1fc795ff1bd99df751d3788035d2cb
FirebaseInstanceID: 8b42755db950682e7de0d167bc6fb26a57b244af
GoogleAppMeasurement: 86a82f0e1f20b8eedf8e20326530138fd71409de
GoogleDataTransport: 91e682bd60a49d3f8f69f2e909a66efaed5a1e7a
GoogleDataTransportCCTSupport: 6b545f7149111180763dc18c6f372c963de4a310
GoogleUtilities: e7dc37039b19df7fe543479d3e4a02ac8d11bb69
nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48
OCHamcrest: 7c2229e7ea96eecd6e43dbef7c68e1dfbd6928b8
OCMockito: 2598f5d43f6e74964d3ec3b9dea8b4fde3ea2c43
Segment-Firebase: 804d7e63849ad42cc44dcbdb91ad080fa4edfb3c
Segment-Firebase: d882b05c4fa34513f1f950623d876bc6acc02740
Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66
PODFILE CHECKSUM: 256b940a1c5273be6ea8930b511feb0a3fb065f8
COCOAPODS: 1.5.3
COCOAPODS: 1.7.3

View File

@@ -66,6 +66,34 @@ describe(@"Firebase Integration", ^{
}];
});
it(@"track with event name and parmas separated by periods", ^{
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@"Starship.Ordered"
properties:@{
@"Starship.Type" : @"Death Star"
}
context:@{}
integrations:@{}];
[integration track:payload];
[verify(mockFirebase) logEventWithName:@"Starship_Ordered" parameters:@{
@"Starship_Type" : @"Death Star"
}];
});
it(@"track with leading and trailing spacing for event name", ^{
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@" Starship Ordered "
properties:@{
@"Starship.Type" : @"Death Star"
}
context:@{}
integrations:@{}];
[integration track:payload];
[verify(mockFirebase) logEventWithName:@"Starship_Ordered" parameters:@{
@"Starship_Type" : @"Death Star"
}];
});
it(@"track Order Completed", ^{
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@"Order Completed" properties:@{
@"checkout_id" : @"9bcf000000000000",
@@ -306,6 +334,30 @@ describe(@"Firebase Integration", ^{
}];
});
it(@"track Promotion Viewed", ^{
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@"Promotion Viewed"
properties:@{
@"product_id" : @"507f1f77bcf86cd799439011",
@"category" : @"Games",
@"name" : @"Monopoly 3rd Edition",
@"price" : @18.99,
@"quantity" : @1,
@"currency" : @"usd",
}
context:@{}
integrations:@{}];
[integration track:payload];
[verify(mockFirebase) logEventWithName:@"present_offer" parameters:@{
@"item_id" : @"507f1f77bcf86cd799439011",
@"item_category" : @"Games",
@"item_name" : @"Monopoly 3rd Edition",
@"price" : @18.99,
@"quantity" : @1,
@"currency" : @"usd",
}];
});
it(@"track Payment Info Entered", ^{
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@"Payment Info Entered"
properties:@{
@@ -503,6 +555,15 @@ describe(@"Firebase Integration", ^{
}];
});
it(@"track screen with name", ^{
SEGScreenPayload *payload = [[SEGScreenPayload alloc] initWithName:@"Home screen"
properties:@{}
context:@{}
integrations:@{}];
[integration screen:payload];
[verify(mockFirebase) setScreenName:@"Home screen" screenClass:nil];
});
});
SpecEnd

View File

@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Segment-Firebase"
s.version = "2.4.0"
s.version = "2.6.0"
s.summary = "Firebase Integration for Segment's analytics-ios library."
s.description = <<-DESC
@@ -24,7 +24,8 @@ Pod::Spec.new do |s|
s.static_framework = true
s.dependency 'Analytics', '~> 3.2'
s.dependency 'Firebase/Core', '~> 5.0'
s.dependency 'Firebase/Core', '~> 6.2'
s.dependency 'FirebaseAnalytics','~> 6.1'
s.subspec 'Core' do |core|
#For users who only want the core Firebase package

View File

@@ -18,11 +18,13 @@
SEGLog(@"[FIROptions defaultOptions].deepLinkURLScheme = %@;", deepLinkURLScheme);
}
if (![FIRApp defaultApp]) {
[FIRApp configure];
SEGLog(@"[FIRApp Configure]");
if ([FIRApp defaultApp]) {
SEGLog(@"[FIRApp Configure] already called, skipping");
return self;
}
[FIRApp configure];
SEGLog(@"[FIRApp Configure]");
}
return self;
}
@@ -62,6 +64,13 @@
}
- (void)screen:(SEGScreenPayload *)payload
{
[self.firebaseClass setScreenName:payload.name screenClass:nil];
SEGLog(@"[FIRAnalytics setScreenName:%@]", payload.name);
}
#pragma mark - Utilities
// Event names can be up to 32 characters long, may only contain alphanumeric
@@ -79,6 +88,7 @@
kFIREventAddToCart, @"Product Added",
kFIREventRemoveFromCart, @"Product Removed",
kFIREventBeginCheckout, @"Checkout Started",
kFIREventPresentOffer, @"Promotion Viewed",
kFIREventAddPaymentInfo, @"Payment Info Entered",
kFIREventEcommercePurchase, @"Order Completed",
kFIREventPurchaseRefund, @"Order Refunded",
@@ -89,11 +99,28 @@
kFIREventSearch, @"Products Searched", nil];
NSString *mappedEvent = [mapper objectForKey:event];
NSArray *periodSeparatedEvent = [event componentsSeparatedByString:@"."];
NSString *regexString = @"^[a-zA-Z0-9_]+$";
NSError *error = NULL;
NSRegularExpression *regex =
[NSRegularExpression regularExpressionWithPattern:regexString
options:0
error:&error];
NSUInteger numberOfMatches = [regex numberOfMatchesInString:event
options:0
range:NSMakeRange(0, [event length])];
if (mappedEvent) {
return mappedEvent;
} else if (numberOfMatches == 0) {
NSString *trimmedEvent = [event stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([periodSeparatedEvent count] > 1) {
return [trimmedEvent stringByReplacingOccurrencesOfString:@"." withString:@"_"];
} else {
return [trimmedEvent stringByReplacingOccurrencesOfString:@" " withString:@"_"];
}
} else {
return [event stringByReplacingOccurrencesOfString:@" " withString:@"_"];
return event;
}
}
@@ -143,7 +170,14 @@ NSDictionary *formatEventProperties(NSDictionary *dictionary)
NSMutableDictionary *output = [NSMutableDictionary dictionaryWithCapacity:dictionary.count];
[dictionary enumerateKeysAndObjectsUsingBlock:^(id key, id data, BOOL *stop) {
[output removeObjectForKey:key];
key = [key stringByReplacingOccurrencesOfString:@" " withString:@"_"];
NSArray *periodSeparatedKey = [key componentsSeparatedByString:@"."];
NSString *trimmedKey = [key stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([periodSeparatedKey count] > 1) {
key = [trimmedKey stringByReplacingOccurrencesOfString:@"." withString:@"_"];
} else {
key = [trimmedKey stringByReplacingOccurrencesOfString:@" " withString:@"_"];
}
if ([data isKindOfClass:[NSNumber class]]) {
data = [NSNumber numberWithDouble:[data doubleValue]];
[output setObject:data forKey:key];

View File

@@ -1,19 +0,0 @@
machine:
xcode:
version: "9.0"
dependencies:
pre:
- gem install xcpretty
- gem install cocoapods -v 1.5.3
override:
- make install
cache_directories:
- Example/Pods
- ~/.cocoapods
test:
override:
- make build
- make test
- make lint