Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit 45e08aa

Browse files
Merge pull request #257 from wordpress-mobile/issue/extend_wpanalytics_to_descentralize_tracks
Extend WPAnalytics to decentralize tracks
2 parents e493684 + 9b8759d commit 45e08aa

File tree

5 files changed

+54
-4
lines changed

5 files changed

+54
-4
lines changed

WordPressShared.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressShared"
3-
s.version = "1.8.15"
3+
s.version = "1.8.16-beta.1"
44
s.summary = "Shared components used in building the WordPress iOS apps and other library components."
55

66
s.description = <<-DESC

WordPressShared/Core/Analytics/WPAnalytics.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ typedef NS_ENUM(NSUInteger, WPAnalyticsStat) {
201201
WPAnalyticsStatLoginSocialErrorUnknownUser,
202202
WPAnalyticsStatLogout,
203203
WPAnalyticsStatLowMemoryWarning,
204-
WPAnalyticsStatMediaEditorShown,
205-
WPAnalyticsStatMediaEditorUsed,
206204
WPAnalyticsStatMediaLibraryDeletedItems,
207205
WPAnalyticsStatMediaLibraryEditedItemMetadata,
208206
WPAnalyticsStatMediaLibraryPreviewedItem,
@@ -603,6 +601,8 @@ extern NSString *const WPAnalyticsStatEditorPublishedPostPropertyVideo;
603601
+ (void)endTimerForStat:(WPAnalyticsStat)stat withProperties:(NSDictionary *)properties;
604602
+ (void)track:(WPAnalyticsStat)stat;
605603
+ (void)track:(WPAnalyticsStat)stat withProperties:(NSDictionary *)properties;
604+
+ (void)trackString:(NSString *)event;
605+
+ (void)trackString:(NSString *)event withProperties:(NSDictionary *)properties;
606606
+ (void)endSession;
607607
+ (void)clearQueuedEvents;
608608

@@ -612,6 +612,8 @@ extern NSString *const WPAnalyticsStatEditorPublishedPostPropertyVideo;
612612

613613
- (void)track:(WPAnalyticsStat)stat;
614614
- (void)track:(WPAnalyticsStat)stat withProperties:(NSDictionary *)properties;
615+
- (void)trackString:(NSString *)event;
616+
- (void)trackString:(NSString *)event withProperties:(NSDictionary *)properties;
615617

616618
@optional
617619
- (void)beginSession;

WordPressShared/Core/Analytics/WPAnalytics.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ + (void)track:(WPAnalyticsStat)stat withProperties:(NSDictionary *)properties
6363
}
6464
}
6565

66+
+ (void)trackString:(NSString *)event
67+
{
68+
for (id<WPAnalyticsTracker> tracker in [self trackers]) {
69+
[tracker trackString:event];
70+
}
71+
}
72+
73+
+ (void)trackString:(NSString *)event withProperties:(NSDictionary *)properties
74+
{
75+
NSParameterAssert(properties != nil);
76+
for (id<WPAnalyticsTracker> tracker in [self trackers]) {
77+
[tracker trackString:event withProperties:properties];
78+
}
79+
}
80+
6681
+ (void)beginSession
6782
{
6883
for (id<WPAnalyticsTracker> tracker in [self trackers]) {

WordPressSharedTests/TestAnalyticsTracker.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,14 @@ - (void)refreshMetadata
2727
// No-op
2828
}
2929

30+
- (void)trackString:(NSString *)event {
31+
// No-op
32+
}
33+
34+
35+
- (void)trackString:(NSString *)event withProperties:(NSDictionary *)properties {
36+
// No-op
37+
}
38+
39+
3040
@end

WordPressSharedTests/WPAnalyticsTests.m

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,27 @@
117117
itShouldBehaveLike(@"a WPAnalyticsTracker method", @{@"invocation": invocation});
118118
});
119119

120-
SpecEnd
120+
describe(@"trackString:", ^{
121+
NSMethodSignature *signature = [TestAnalyticsTracker instanceMethodSignatureForSelector:@selector(trackString:)];
122+
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
123+
[invocation setSelector:@selector(trackString:)];
124+
NSString *event = @"my_event";
125+
[invocation setArgument:&event atIndex:2];
126+
127+
itShouldBehaveLike(@"a WPAnalyticsTracker method", @{@"invocation": invocation});
128+
});
129+
130+
describe(@"trackString:withProperties:", ^{
131+
NSMethodSignature *signature = [TestAnalyticsTracker instanceMethodSignatureForSelector:@selector(trackString:withProperties:)];
132+
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
133+
[invocation setSelector:@selector(trackString:withProperties:)];
134+
135+
NSString *event = @"my_event";
136+
NSDictionary *dict = @{};
137+
[invocation setArgument:&event atIndex:2];
138+
[invocation setArgument:&dict atIndex:3];
139+
140+
itShouldBehaveLike(@"a WPAnalyticsTracker method", @{@"invocation": invocation});
141+
});
142+
143+
SpecEnd

0 commit comments

Comments
 (0)