Permalink
Browse files

Add utilities

  • Loading branch information...
1 parent 3583ece commit e94d4a3016893f2c3230b56641ed253aa0cf0074 @soffes committed Mar 28, 2012
Showing with 60 additions and 12 deletions.
  1. +14 −0 LocalyticsUtilities.h
  2. +39 −0 LocalyticsUtilities.m
  3. +7 −12 Readme.markdown
View
@@ -0,0 +1,14 @@
+//
+// LocalyticsUtilities.h
+// Localytics
+//
+// Created by Sam Soffes on 3/27/12.
+// Copyright (c) 2012 Sam Soffes. All rights reserved.
+//
+
+#define ANALYTICS_ENABLED (!DEBUG && !TARGET_IPHONE_SIMULATOR)
+
+void LLStartSession(NSString *key);
+void LLTagEvent(NSString *name);
+void LLTagEventWithAttributes(NSString *name, NSDictionary *attributes);
+void LLTagScreen(NSString *name);
View
@@ -0,0 +1,39 @@
+//
+// LocalyticsUtilities.m
+// Localytics
+//
+// Created by Sam Soffes on 3/27/12.
+// Copyright (c) 2012 Sam Soffes. All rights reserved.
+//
+
+#import "LocalyticsUtilities.h"
+#if ANALYTICS_ENABLED
+#import "LocalyticsSession.h"
+#endif
+
+void LLStartSession(NSString *key) {
+#if ANALYTICS_ENABLED
+ [[LocalyticsSession sharedLocalyticsSession] startSession:(key)]
+#endif
+}
+
+
+void LLTagEvent(NSString *name) {
+#if ANALYTICS_ENABLED
+ [[LocalyticsSession sharedLocalyticsSession] tagEvent:name];
+#endif
+}
+
+
+void LLTagEventWithAttributes(NSString *name, NSDictionary *attributes) {
+#if ANALYTICS_ENABLED
+ [[LocalyticsSession sharedLocalyticsSession] tagEvent:name attributes:attributes];
+#endif
+}
+
+
+void LLTagScreen(NSString *name) {
+#if ANALYTICS_ENABLED
+ [[LocalyticsSession sharedLocalyticsSession] tagScreen:screen];
+#endif
+}
View
@@ -8,22 +8,17 @@ This is my fork of the [Localytics](http://www.localytics.com) iOS client. Mainl
* Add files to your project
* Disable ARC for those files if you're using ARC
* Add libSqlite3 to your target
+* Include `LocalyticsUtilities.h` for handy integration
+
+Here's the macro and functions provided:
``` objective-c
#define ANALYTICS_ENABLED (!DEBUG && !TARGET_IPHONE_SIMULATOR)
-#if ANALYTICS_ENABLED
- #import "LocalyticsSession.h"
- #define LLStartSession(key) [[LocalyticsSession sharedLocalyticsSession] startSession:(key)];
- #define LLLogEvent(name) [[LocalyticsSession sharedLocalyticsSession] tagEvent:(name)];
- #define LLLogEventWithAttributes(name, parameters) [[LocalyticsSession sharedLocalyticsSession] tagEvent:(name) attributes:(parameters)];
- #define LLLogScreen(screen) [[LocalyticsSession sharedLocalyticsSession] tagScreen:screen];
-#else
- #define LLStartSession(...)
- #define LLLogEvent(...)
- #define LLLogEventWithAttributes(...)
- #define LLLogScreen(...)
-#endif
+void LLStartSession(NSString *key);
+void LLTagEvent(NSString *name);
+void LLTagEventWithAttributes(NSString *name, NSDictionary *attributes);
+void LLTagScreen(NSString *name);
```
App delegate:

0 comments on commit e94d4a3

Please sign in to comment.