Skip to content

Commit

Permalink
fix: update APSAnalytics (#12681)
Browse files Browse the repository at this point in the history
Fixes TIMOB-28403
  • Loading branch information
garymathews authored Apr 14, 2021
1 parent 36e779a commit 9bc150e
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ public final class TitaniumTestApplication extends TiApplication
@Override
public void onCreate()
{
super.onCreate();
appInfo = new TitaniumTestAppInfo(this);

// KrollAssetHelper.setAssetCrypt(new AssetCryptImpl());

// Load cache as soon as possible.
KrollAssetCache.init(this);

appInfo = new TitaniumTestAppInfo(this);
super.onCreate();

V8Runtime runtime = new V8Runtime();
KrollRuntime.init(this, runtime);
postAppInfo();
postOnCreate();
}
}
3 changes: 1 addition & 2 deletions android/templates/build/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public void onCreate()
KrollAssetCache.init(this);

super.onCreate();
postAppInfo();

V8Runtime runtime = new V8Runtime();

Expand Down Expand Up @@ -83,7 +82,7 @@ public void onCreate()
<% }); %>

KrollRuntime.init(this, runtime);

postAppInfo();
postOnCreate();

<% if (customModules.length) { %>
Expand Down
Binary file modified android/titanium/lib/aps-analytics.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@ public void postAppInfo()

if (isAnalyticsEnabled()) {
APSAnalytics.getInstance().initialize(getAppGUID(), this);

final int cacheSize = this.appProperties.getInt("ti.analytics.cacheSize", -1);
if (cacheSize > -1) {
APSAnalytics.getInstance().setCacheSize(cacheSize);
}
} else {
Log.i(TAG, "Analytics have been disabled");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ extern NSString *_Nonnull const APSDeployTypeProduction;
*/
@interface APSAnalytics : NSObject

/**
* Determine if EOL has passed. (March 1st 2022 GMT-8)
*/
+ (BOOL)IS_EOL;

/**
* Return the singleton instance to the real-time analytics service.
*/
Expand Down Expand Up @@ -67,6 +72,20 @@ extern NSString *_Nonnull const APSDeployTypeProduction;
*/
- (void)setOptedOut:(BOOL)optedOut;

/**
* Obtains number of events that will be cached.
*
* @return {NSInteger} number of events to cache
*/
- (NSInteger)getCacheSize;

/**
* Writes the cache size property in the SharedPreferences instance.
*
* @param {NSInteger} number of events to cache
*/
- (void)setCacheSize:(NSInteger)cacheSize;

/**
* Sends an application enroll event to indicate first launch.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-maccatalyst</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>libAPSAnalytics.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>maccatalyst</string>
</dict>
<dict>
<key>HeadersPath</key>
Expand All @@ -42,15 +39,18 @@
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-maccatalyst</string>
<key>LibraryPath</key>
<string>libAPSAnalytics.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>maccatalyst</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ extern NSString *_Nonnull const APSDeployTypeProduction;
*/
@interface APSAnalytics : NSObject

/**
* Determine if EOL has passed. (March 1st 2022 GMT-8)
*/
+ (BOOL)IS_EOL;

/**
* Return the singleton instance to the real-time analytics service.
*/
Expand Down Expand Up @@ -67,6 +72,20 @@ extern NSString *_Nonnull const APSDeployTypeProduction;
*/
- (void)setOptedOut:(BOOL)optedOut;

/**
* Obtains number of events that will be cached.
*
* @return {NSInteger} number of events to cache
*/
- (NSInteger)getCacheSize;

/**
* Writes the cache size property in the SharedPreferences instance.
*
* @param {NSInteger} number of events to cache
*/
- (void)setCacheSize:(NSInteger)cacheSize;

/**
* Sends an application enroll event to indicate first launch.
*
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ extern NSString *_Nonnull const APSDeployTypeProduction;
*/
@interface APSAnalytics : NSObject

/**
* Determine if EOL has passed. (March 1st 2022 GMT-8)
*/
+ (BOOL)IS_EOL;

/**
* Return the singleton instance to the real-time analytics service.
*/
Expand Down Expand Up @@ -67,6 +72,20 @@ extern NSString *_Nonnull const APSDeployTypeProduction;
*/
- (void)setOptedOut:(BOOL)optedOut;

/**
* Obtains number of events that will be cached.
*
* @return {NSInteger} number of events to cache
*/
- (NSInteger)getCacheSize;

/**
* Writes the cache size property in the SharedPreferences instance.
*
* @param {NSInteger} number of events to cache
*/
- (void)setCacheSize:(NSInteger)cacheSize;

/**
* Sends an application enroll event to indicate first launch.
*
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ extern NSString *_Nonnull const APSDeployTypeProduction;
*/
@interface APSAnalytics : NSObject

/**
* Determine if EOL has passed. (March 1st 2022 GMT-8)
*/
+ (BOOL)IS_EOL;

/**
* Return the singleton instance to the real-time analytics service.
*/
Expand Down Expand Up @@ -67,6 +72,20 @@ extern NSString *_Nonnull const APSDeployTypeProduction;
*/
- (void)setOptedOut:(BOOL)optedOut;

/**
* Obtains number of events that will be cached.
*
* @return {NSInteger} number of events to cache
*/
- (NSInteger)getCacheSize;

/**
* Writes the cache size property in the SharedPreferences instance.
*
* @param {NSInteger} number of events to cache
*/
- (void)setCacheSize:(NSInteger)cacheSize;

/**
* Sends an application enroll event to indicate first launch.
*
Expand Down
Binary file not shown.
9 changes: 9 additions & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/KrollBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,15 @@ - (void)didStartNewContext:(KrollContext *)kroll
NSString *deployType = TiSharedConfig.defaultConfig.applicationDeployType;
NSString *guid = TiSharedConfig.defaultConfig.applicationGUID;
[sharedAnalytics enableWithAppKey:guid andDeployType:deployType];

// Set analytics event cache size.
id cacheSizeObj = [[TiApp tiAppProperties] objectForKey:@"ti.analytics.cacheSize"];
if ([cacheSizeObj isKindOfClass:[NSNumber class]]) {
int cacheSize = [cacheSizeObj intValue];
if (cacheSize > -1) {
[sharedAnalytics setCacheSize:cacheSize];
}
}
}

NSURL *startURL = nil;
Expand Down

0 comments on commit 9bc150e

Please sign in to comment.