Skip to content

Commit 402f24c

Browse files
authored
Brie/updates sunset (#47)
* Add changes to stop crash and format event names and params * Add unit tests for event names and params separated by periods * Update dependencies of FirebaseCore and FirebaseAnalytics to most recent versions * Add circleci config * Update files for pod update' * Update xcode version for ci tests * Change xcode version * Remove IDEWorksapceChecks.plist * Account for leading and trailing whitespace * Add unit tests for leading and trailing whitespace
1 parent 00850a1 commit 402f24c

File tree

6 files changed

+168
-73
lines changed

6 files changed

+168
-73
lines changed

.circleci/config.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: 2
2+
3+
jobs:
4+
build_and_test:
5+
macos:
6+
xcode: "10.2.1"
7+
steps:
8+
- checkout
9+
- run: xcrun simctl list
10+
- run:
11+
name: Install build dependencies
12+
command: |
13+
sudo gem install xcpretty
14+
sudo gem install cocoapods -v 1.6.1
15+
# - run:
16+
# name: Fetch Cocoapods specs
17+
# command: curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
18+
19+
- run: make install
20+
- run: make build
21+
- run: make test
22+
- run: make lint
23+
24+
# - store_test_results:
25+
# # relies on xcpretty --report junit
26+
# path: build/reports
27+
# - run: bash <(curl -s https://codecov.io/bash)
28+
29+
workflows:
30+
version: 2
31+
build_and_test:
32+
jobs:
33+
- build_and_test

Example/Podfile.lock

Lines changed: 73 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,80 @@
11
PODS:
22
- Analytics (3.6.9)
33
- Expecta (1.0.6)
4-
- Firebase/Core (5.9.0):
4+
- Firebase/Core (6.7.0):
55
- Firebase/CoreOnly
6-
- FirebaseAnalytics (= 5.2.0)
7-
- Firebase/CoreOnly (5.9.0):
8-
- FirebaseCore (= 5.1.4)
9-
- FirebaseAnalytics (5.2.0):
10-
- FirebaseCore (~> 5.1)
11-
- FirebaseInstanceID (~> 3.2)
12-
- GoogleAppMeasurement (~> 5.2)
13-
- GoogleUtilities/AppDelegateSwizzler (~> 5.2)
14-
- GoogleUtilities/MethodSwizzler (~> 5.2)
15-
- GoogleUtilities/Network (~> 5.2)
16-
- "GoogleUtilities/NSData+zlib (~> 5.2)"
6+
- FirebaseAnalytics (= 6.1.1)
7+
- Firebase/CoreOnly (6.7.0):
8+
- FirebaseCore (= 6.2.1)
9+
- FirebaseAnalytics (6.1.1):
10+
- FirebaseCore (~> 6.2)
11+
- FirebaseInstanceID (~> 4.2)
12+
- GoogleAppMeasurement (= 6.1.1)
13+
- GoogleUtilities/AppDelegateSwizzler (~> 6.0)
14+
- GoogleUtilities/MethodSwizzler (~> 6.0)
15+
- GoogleUtilities/Network (~> 6.0)
16+
- "GoogleUtilities/NSData+zlib (~> 6.0)"
1717
- nanopb (~> 0.3)
18-
- FirebaseCore (5.1.4):
19-
- GoogleUtilities/Logger (~> 5.2)
20-
- FirebaseInstanceID (3.2.2):
21-
- FirebaseCore (~> 5.1)
22-
- GoogleUtilities/Environment (~> 5.3)
23-
- GoogleUtilities/UserDefaults (~> 5.3)
24-
- GoogleAppMeasurement (5.2.0):
25-
- GoogleUtilities/AppDelegateSwizzler (~> 5.2)
26-
- GoogleUtilities/MethodSwizzler (~> 5.2)
27-
- GoogleUtilities/Network (~> 5.2)
28-
- "GoogleUtilities/NSData+zlib (~> 5.2)"
18+
- FirebaseCore (6.2.1):
19+
- FirebaseCoreDiagnostics (~> 1.0)
20+
- FirebaseCoreDiagnosticsInterop (~> 1.0)
21+
- GoogleUtilities/Environment (~> 6.2)
22+
- GoogleUtilities/Logger (~> 6.2)
23+
- FirebaseCoreDiagnostics (1.0.1):
24+
- FirebaseCoreDiagnosticsInterop (~> 1.0)
25+
- GoogleDataTransportCCTSupport (~> 1.0)
26+
- GoogleUtilities/Environment (~> 6.2)
27+
- GoogleUtilities/Logger (~> 6.2)
28+
- FirebaseCoreDiagnosticsInterop (1.0.0)
29+
- FirebaseInstanceID (4.2.3):
30+
- FirebaseCore (~> 6.0)
31+
- GoogleUtilities/Environment (~> 6.0)
32+
- GoogleUtilities/UserDefaults (~> 6.0)
33+
- GoogleAppMeasurement (6.1.1):
34+
- GoogleUtilities/AppDelegateSwizzler (~> 6.0)
35+
- GoogleUtilities/MethodSwizzler (~> 6.0)
36+
- GoogleUtilities/Network (~> 6.0)
37+
- "GoogleUtilities/NSData+zlib (~> 6.0)"
2938
- nanopb (~> 0.3)
30-
- GoogleUtilities/AppDelegateSwizzler (5.3.0):
39+
- GoogleDataTransport (1.1.3)
40+
- GoogleDataTransportCCTSupport (1.0.2):
41+
- GoogleDataTransport (~> 1.1)
42+
- nanopb
43+
- GoogleUtilities/AppDelegateSwizzler (6.2.5):
3144
- GoogleUtilities/Environment
3245
- GoogleUtilities/Logger
3346
- GoogleUtilities/Network
34-
- GoogleUtilities/Environment (5.3.0)
35-
- GoogleUtilities/Logger (5.3.0):
47+
- GoogleUtilities/Environment (6.2.5)
48+
- GoogleUtilities/Logger (6.2.5):
3649
- GoogleUtilities/Environment
37-
- GoogleUtilities/MethodSwizzler (5.3.0):
50+
- GoogleUtilities/MethodSwizzler (6.2.5):
3851
- GoogleUtilities/Logger
39-
- GoogleUtilities/Network (5.3.0):
52+
- GoogleUtilities/Network (6.2.5):
4053
- GoogleUtilities/Logger
4154
- "GoogleUtilities/NSData+zlib"
4255
- GoogleUtilities/Reachability
43-
- "GoogleUtilities/NSData+zlib (5.3.0)"
44-
- GoogleUtilities/Reachability (5.3.0):
56+
- "GoogleUtilities/NSData+zlib (6.2.5)"
57+
- GoogleUtilities/Reachability (6.2.5):
4558
- GoogleUtilities/Logger
46-
- GoogleUtilities/UserDefaults (5.3.0):
59+
- GoogleUtilities/UserDefaults (6.2.5):
4760
- GoogleUtilities/Logger
48-
- nanopb (0.3.8):
49-
- nanopb/decode (= 0.3.8)
50-
- nanopb/encode (= 0.3.8)
51-
- nanopb/decode (0.3.8)
52-
- nanopb/encode (0.3.8)
61+
- nanopb (0.3.901):
62+
- nanopb/decode (= 0.3.901)
63+
- nanopb/encode (= 0.3.901)
64+
- nanopb/decode (0.3.901)
65+
- nanopb/encode (0.3.901)
5366
- OCHamcrest (7.0.1)
5467
- OCMockito (5.0.0):
5568
- OCHamcrest (~> 7.0)
56-
- Segment-Firebase (2.3.0):
69+
- Segment-Firebase (2.4.1):
5770
- Analytics (~> 3.2)
58-
- Firebase/Core (~> 5.0)
59-
- Segment-Firebase/Core (= 2.3.0)
60-
- Segment-Firebase/Core (2.3.0):
71+
- Firebase/Core (~> 6.2)
72+
- FirebaseAnalytics (~> 6.1)
73+
- Segment-Firebase/Core (= 2.4.1)
74+
- Segment-Firebase/Core (2.4.1):
6175
- Analytics (~> 3.2)
62-
- Firebase/Core (~> 5.0)
76+
- Firebase/Core (~> 6.2)
77+
- FirebaseAnalytics (~> 6.1)
6378
- Specta (1.0.7)
6479

6580
DEPENDENCIES:
@@ -75,8 +90,12 @@ SPEC REPOS:
7590
- Firebase
7691
- FirebaseAnalytics
7792
- FirebaseCore
93+
- FirebaseCoreDiagnostics
94+
- FirebaseCoreDiagnosticsInterop
7895
- FirebaseInstanceID
7996
- GoogleAppMeasurement
97+
- GoogleDataTransport
98+
- GoogleDataTransportCCTSupport
8099
- GoogleUtilities
81100
- nanopb
82101
- OCHamcrest
@@ -90,18 +109,22 @@ EXTERNAL SOURCES:
90109
SPEC CHECKSUMS:
91110
Analytics: 6541ce337e99d9f7a2240a8b3953940a7be5f998
92111
Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5
93-
Firebase: 383fa29aca93e371cab776b48a5c66544d3c2003
94-
FirebaseAnalytics: 831f1f127f4a75698e9875a87bf7e2668730d953
95-
FirebaseCore: 2a84b6b325792a4319ef71ee18819dcba08d2fd7
96-
FirebaseInstanceID: 78ba376fcd5b94c001f9999b2cbd3d1f1e56e78d
97-
GoogleAppMeasurement: 2b3a023a61239c8d002e6e4fcf4abce8eddce0e0
98-
GoogleUtilities: 760ccb53b7c7f40f9c02d8c241f76f841a7a6162
99-
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
112+
Firebase: 291d7b0a7b393f252358083b5d224884126fa46d
113+
FirebaseAnalytics: 843c7f64a8f9c79f0d03281197ebe7bb1d58d477
114+
FirebaseCore: 32b48f41c84a56fbde73b35ed01a830b3b6dc048
115+
FirebaseCoreDiagnostics: 4c04ae09d0ab027c30179828c6bb47764df1bd13
116+
FirebaseCoreDiagnosticsInterop: 6829da2b8d1fc795ff1bd99df751d3788035d2cb
117+
FirebaseInstanceID: 8b42755db950682e7de0d167bc6fb26a57b244af
118+
GoogleAppMeasurement: 86a82f0e1f20b8eedf8e20326530138fd71409de
119+
GoogleDataTransport: 91e682bd60a49d3f8f69f2e909a66efaed5a1e7a
120+
GoogleDataTransportCCTSupport: 6b545f7149111180763dc18c6f372c963de4a310
121+
GoogleUtilities: e7dc37039b19df7fe543479d3e4a02ac8d11bb69
122+
nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48
100123
OCHamcrest: 7c2229e7ea96eecd6e43dbef7c68e1dfbd6928b8
101124
OCMockito: 2598f5d43f6e74964d3ec3b9dea8b4fde3ea2c43
102-
Segment-Firebase: 804d7e63849ad42cc44dcbdb91ad080fa4edfb3c
125+
Segment-Firebase: d882b05c4fa34513f1f950623d876bc6acc02740
103126
Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66
104127

105128
PODFILE CHECKSUM: 256b940a1c5273be6ea8930b511feb0a3fb065f8
106129

107-
COCOAPODS: 1.5.3
130+
COCOAPODS: 1.7.3

Example/Tests/Tests.m

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,34 @@
6565
@"Starship_Type" : @"Death Star"
6666
}];
6767
});
68+
69+
it(@"track with event name and parmas separated by periods", ^{
70+
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@"Starship.Ordered"
71+
properties:@{
72+
@"Starship.Type" : @"Death Star"
73+
}
74+
context:@{}
75+
integrations:@{}];
76+
77+
[integration track:payload];
78+
[verify(mockFirebase) logEventWithName:@"Starship_Ordered" parameters:@{
79+
@"Starship_Type" : @"Death Star"
80+
}];
81+
});
82+
83+
it(@"track with leading and trailing spacing for event name", ^{
84+
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@" Starship Ordered "
85+
properties:@{
86+
@"Starship.Type" : @"Death Star"
87+
}
88+
context:@{}
89+
integrations:@{}];
90+
91+
[integration track:payload];
92+
[verify(mockFirebase) logEventWithName:@"Starship_Ordered" parameters:@{
93+
@"Starship_Type" : @"Death Star"
94+
}];
95+
});
6896

6997
it(@"track Order Completed", ^{
7098
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@"Order Completed" properties:@{

Segment-Firebase.podspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Pod::Spec.new do |s|
2424
s.static_framework = true
2525

2626
s.dependency 'Analytics', '~> 3.2'
27-
s.dependency 'Firebase/Core', '~> 5.0'
27+
s.dependency 'Firebase/Core', '~> 6.2'
28+
s.dependency 'FirebaseAnalytics','~> 6.1'
2829

2930
s.subspec 'Core' do |core|
3031
#For users who only want the core Firebase package

Segment-Firebase/Classes/SEGFirebaseIntegration.m

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ - (id)initWithSettings:(NSDictionary *)settings
1818
SEGLog(@"[FIROptions defaultOptions].deepLinkURLScheme = %@;", deepLinkURLScheme);
1919
}
2020

21+
if ([FIRApp defaultApp]) {
22+
SEGLog(@"[FIRApp Configure] already called, skipping");
23+
return self;
24+
}
25+
2126
[FIRApp configure];
2227
SEGLog(@"[FIRApp Configure]");
2328
}
@@ -87,11 +92,28 @@ - (NSString *)formatFirebaseEventNames:(NSString *)event
8792
kFIREventSearch, @"Products Searched", nil];
8893

8994
NSString *mappedEvent = [mapper objectForKey:event];
90-
95+
NSArray *periodSeparatedEvent = [event componentsSeparatedByString:@"."];
96+
NSString *regexString = @"^[a-zA-Z0-9_]+$";
97+
NSError *error = NULL;
98+
NSRegularExpression *regex =
99+
[NSRegularExpression regularExpressionWithPattern:regexString
100+
options:0
101+
error:&error];
102+
NSUInteger numberOfMatches = [regex numberOfMatchesInString:event
103+
options:0
104+
range:NSMakeRange(0, [event length])];
91105
if (mappedEvent) {
92106
return mappedEvent;
107+
} else if (numberOfMatches == 0) {
108+
NSString *trimmedEvent = [event stringByTrimmingCharactersInSet:
109+
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
110+
if ([periodSeparatedEvent count] > 1) {
111+
return [trimmedEvent stringByReplacingOccurrencesOfString:@"." withString:@"_"];
112+
} else {
113+
return [trimmedEvent stringByReplacingOccurrencesOfString:@" " withString:@"_"];
114+
}
93115
} else {
94-
return [event stringByReplacingOccurrencesOfString:@" " withString:@"_"];
116+
return event;
95117
}
96118
}
97119

@@ -141,7 +163,14 @@ + (NSDictionary *)mapToFirebaseParameters:(NSDictionary *)properties withMap:(NS
141163
NSMutableDictionary *output = [NSMutableDictionary dictionaryWithCapacity:dictionary.count];
142164
[dictionary enumerateKeysAndObjectsUsingBlock:^(id key, id data, BOOL *stop) {
143165
[output removeObjectForKey:key];
144-
key = [key stringByReplacingOccurrencesOfString:@" " withString:@"_"];
166+
NSArray *periodSeparatedKey = [key componentsSeparatedByString:@"."];
167+
NSString *trimmedKey = [key stringByTrimmingCharactersInSet:
168+
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
169+
if ([periodSeparatedKey count] > 1) {
170+
key = [trimmedKey stringByReplacingOccurrencesOfString:@"." withString:@"_"];
171+
} else {
172+
key = [trimmedKey stringByReplacingOccurrencesOfString:@" " withString:@"_"];
173+
}
145174
if ([data isKindOfClass:[NSNumber class]]) {
146175
data = [NSNumber numberWithDouble:[data doubleValue]];
147176
[output setObject:data forKey:key];

circle.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)