Skip to content
This repository was archived by the owner on Feb 11, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions GAJavaScriptTracker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* Begin PBXBuildFile section */
B41129571598A17E00FAC856 /* GAJavaScriptTracker.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B431A386159893FC00277663 /* GAJavaScriptTracker.framework */; };
B411295A1598A18B00FAC856 /* GAJavaScriptTracker.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = B431A386159893FC00277663 /* GAJavaScriptTracker.framework */; };
B411295A1598A18B00FAC856 /* GAJavaScriptTracker.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = B431A386159893FC00277663 /* GAJavaScriptTracker.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
B411295B1598A1E200FAC856 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B431A388159893FC00277663 /* Cocoa.framework */; };
B411295D1598B19000FAC856 /* GAJavaScriptTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = B431A395159893FC00277663 /* GAJavaScriptTracker.h */; settings = {ATTRIBUTES = (Public, ); }; };
B411295F1598B3E600FAC856 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B411295E1598B3E600FAC856 /* WebKit.framework */; };
Expand Down Expand Up @@ -221,7 +221,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = QR;
LastUpgradeCheck = 0450;
LastUpgradeCheck = 0610;
ORGANIZATIONNAME = net.doo;
};
buildConfigurationList = B431A35A1598939500277663 /* Build configuration list for PBXProject "GAJavaScriptTracker" */;
Expand Down Expand Up @@ -294,7 +294,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -315,15 +314,14 @@
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx10.7;
SDKROOT = macosx;
};
name = Debug;
};
B431A37D1598939500277663 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -337,7 +335,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
SDKROOT = macosx10.7;
SDKROOT = macosx;
};
name = Release;
};
Expand All @@ -349,6 +347,7 @@
INFOPLIST_FILE = "GAJavaScriptTrackerApp/GAJavaScriptTracker-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@executable_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
WRAPPER_EXTENSION = app;
};
name = Debug;
Expand All @@ -361,13 +360,15 @@
INFOPLIST_FILE = "GAJavaScriptTrackerApp/GAJavaScriptTracker-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@executable_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
WRAPPER_EXTENSION = app;
};
name = Release;
};
B431A399159893FC00277663 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
Expand All @@ -376,13 +377,16 @@
INFOPLIST_FILE = "GAJavaScriptTracker/GAJavaScriptTracker-Info.plist";
INSTALL_PATH = "@executable_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SDKROOT = macosx;
WRAPPER_EXTENSION = framework;
};
name = Debug;
};
B431A39A159893FC00277663 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
Expand All @@ -391,6 +395,8 @@
INFOPLIST_FILE = "GAJavaScriptTracker/GAJavaScriptTracker-Info.plist";
INSTALL_PATH = "@executable_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SDKROOT = macosx;
WRAPPER_EXTENSION = framework;
};
name = Release;
Expand Down
16 changes: 7 additions & 9 deletions GAJavaScriptTracker/GAJSWebViewEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#import "GAJSWebViewEngine.h"

#define ELog(x,...) /* NSLog */

@interface GAJSWebViewEngine ()
@property(nonatomic, readwrite) WebView *webView;
@end
Expand Down Expand Up @@ -123,10 +121,10 @@ - (void)sendOffBatchedJS {
if(_webviewLoaded) {
for(id aJSString in _webViewPendingScripts) {
//run it
NSLog(@"[JSC] Evaluate JS: %@ %@ %@", aJSString, _webView.customUserAgent, _webView.applicationNameForUserAgent);
DLog(@"[JSC] Evaluate JS: %@ %@ %@", aJSString, _webView.customUserAgent, _webView.applicationNameForUserAgent);
NSString *result = [_webView stringByEvaluatingJavaScriptFromString:aJSString];
if (!result) {
ELog(@"[JSC] No result returned");
DLog(@"[JSC] No result returned");
}
}
[_webViewPendingScripts removeAllObjects];
Expand Down Expand Up @@ -195,7 +193,7 @@ - (void)loadJSLibraryFromURL:(NSURL*)url {
userInfo:nil];
}

ELog(@"[JSC] loading library %@...", url.lastPathComponent);
DLog(@"[JSC] loading library %@...", url.lastPathComponent);
[self runJS:library];
}

Expand All @@ -208,7 +206,7 @@ - (void)flushJS {
#pragma mark -

- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
ELog(@"did load webview");
DLog(@"did load webview");
_webviewLoaded = YES;

if(_webViewPendingScripts.count >= _batchSize) {
Expand All @@ -218,16 +216,16 @@ - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {

#if DEBUG_WEBVIEW_ENGINE
- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
ELog(@"[javascript-alert] %@", message);
DLog(@"[javascript-alert] %@", message);
}

- (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource {
ELog(@"[request] %@", request);
DLog(@"[request] %@", request);
return request;
}

- (void)webView:(WebView *)sender resource:(id)identifier didReceiveResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)dataSource {
ELog(@"[response] %@", response);
DLog(@"[response] %@", response);
}
#endif

Expand Down
7 changes: 7 additions & 0 deletions GAJavaScriptTracker/GAJavaScriptTracker-Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

#ifdef DEBUG
# define DLog(...) NSLog(__VA_ARGS__)
#else
# define DLog(...) /* */
#endif
#define ALog(...) NSLog(__VA_ARGS__)
12 changes: 6 additions & 6 deletions GAJavaScriptTracker/GAJavaScriptTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ -(void)start {
assert(!_JSEngine);

if(self.debug)
NSLog(@"[GAJST] allocate engine");
DLog(@"[GAJST] allocate engine");

_JSEngine = [[GAJSWebViewEngine alloc] init];
if(!_JSEngine) {
Expand All @@ -100,7 +100,7 @@ -(void)start {
%@", _accountID, _anonymizeIp ? anonymize : @""];

if(self.debug)
NSLog(@"[GAJST] Load html and set INITIAL_GA: %@", str);
DLog(@"[GAJST] Load html and set INITIAL_GA: %@", str);

_JSEngine.htmlName = @"main";
_JSEngine.htmlVariables = [NSDictionary dictionaryWithObject:str forKey:@"INITIAL_GA"];
Expand All @@ -118,19 +118,19 @@ -(void)stop {
assert(_JSEngine);

if(self.debug)
NSLog(@"[GAJST] flush the engine [if the webview is not loaded, this may loose a batch.]");
DLog(@"[GAJST] flush the engine [if the webview is not loaded, this may loose a batch.]");
[_JSEngine flushJS];

if(self.debug)
NSLog(@"[GAJST] release engine");
DLog(@"[GAJST] release engine");

_JSEngine = nil;
}

//is it running?
- (BOOL)isRunning {
if(self.debug)
NSLog(@"[GAJST] checking for engine");
DLog(@"[GAJST] checking for engine");

return (_JSEngine!=NULL);
}
Expand All @@ -153,7 +153,7 @@ - (void)setBatchInterval:(NSTimeInterval)batchInterval {

- (BOOL)executeScript:(NSString*)js {
if(self.debug)
NSLog(@"[GAJST] execute %@", js);
DLog(@"[GAJST] execute %@", js);

if(!self.dryRun) {
[_JSEngine runJS:js];
Expand Down