Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
feat: Add max config age option (#5)
Browse files Browse the repository at this point in the history
- Update iOS SDK to latest version 8.7.0
- Update Android SDK to latest version 5.36.2
- Expose the new ConfigMaxAgeSeconds option
  • Loading branch information
einsteinx2 authored Mar 23, 2022
1 parent 4372278 commit c5110f5
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 106 deletions.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<LibraryProjectZip Include="Jars\android-core-5.24.0.aar" />
<LibraryProjectZip Include="Jars\android-core-5.36.2.aar" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
117 changes: 13 additions & 104 deletions Bindings/mParticle.Xamarin.iOSBinding/ApiDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace mParticle.Xamarin.iOSBinding
{

[BaseType(typeof(NSObject))]
[Protocol]
interface MPTransactionAttributes : INSCopying, INSCoding
Expand Down Expand Up @@ -38,8 +37,6 @@ interface MPTransactionAttributes : INSCopying, INSCoding
string TransactionId { get; set; }
}



// @interface MPIHasher : NSObject
[BaseType(typeof(NSObject))]
[Protocol]
Expand All @@ -56,7 +53,6 @@ interface MPIHasher
string HashString(string stringToHash);
}


// @protocol MPExtensionProtocol <NSObject>
[Protocol, Model]
[BaseType(typeof(NSObject))]
Expand Down Expand Up @@ -333,8 +329,6 @@ interface MPCart : INSCoding
[Export("addAllProducts:shouldLogEvents:")]
void AddAllProducts(NSArray<MPProduct> products, bool shouldLogEvents);

// -(

// -(void)clear;
[Export("clear")]
void Clear();
Expand Down Expand Up @@ -443,7 +437,6 @@ interface MPIdentityApiResult
// @property(nonatomic, strong, readwrite, nonnull) MParticleUser* user;
[Export("user", ArgumentSemantic.Strong)]
MParticleUser User { get; set; }

}

//typedef void (^MPIdentityApiResultCallback)(MPIdentityApiResult* _Nullable apiResult, NSError * _Nullable error);
Expand All @@ -454,7 +447,6 @@ interface MPIdentityApiResult
[Protocol]
interface MPIdentityApi
{

// @property(nonatomic, strong, readonly, nullable) MParticleUser* currentUser;
[Export("currentUser")]
[return: NullAllowed]
Expand Down Expand Up @@ -610,93 +602,8 @@ interface MPPromotionContainer : INSCopying, INSCoding
void AddPromotion(MPPromotion promotion);
}

// @interface MPUserSegments : NSObject <NSCopying>
[BaseType(typeof(NSObject))]
interface MPUserSegments : INSCopying
{
// @property (readonly, nonatomic, strong) NSArray<MPSegment *> * _Nullable segmentsIds;
[NullAllowed, Export("segmentsIds", ArgumentSemantic.Strong)]
MPSegment[] SegmentsIds { get; }

// @property (readonly, nonatomic, strong) NSDate * _Nullable expiration;
[NullAllowed, Export("expiration", ArgumentSemantic.Strong)]
NSDate Expiration { get; }

// @property (readonly, nonatomic) BOOL expired;
[Export("expired")]
bool Expired { get; }

// -(NSString * _Nullable)commaSeparatedSegments;
[NullAllowed, Export("commaSeparatedSegments")]
string CommaSeparatedSegments { get; }
}

// This was added manually. For some reason, Sharpie didn't generate it.
// @interface MPDataModelAbstract : NSObject <NSCopying>
[BaseType(typeof(NSObject))]
interface MPDataModelAbstract : INSCopying
{

}

// This was added manually. For some reason, Sharpie didn't generate it.
// @interface MPSegment : MPDataModelAbstract <NSCopying>
[BaseType(typeof(MPDataModelAbstract))]
interface MPSegment : INSCopying
{
// @property (nonatomic, strong) NSNumber * segmentId;
[Export("segmentId", ArgumentSemantic.Strong)]
NSNumber SegmentId { get; }

//@property(nonatomic, strong) NSArray* endpointIds;
[Export("endpointIds")]
NSObject[] EndpointIds { get; }

//@property(nonatomic, strong, readonly) NSDate* expiration;
[Export("expiration")]
NSDate Expiration { get; }

//@property(nonatomic, strong) NSString* name;
[Export("name")]
NSString Name { get; }

//@property(nonatomic, strong) NSArray<MPSegmentMembership*>* memberships;
[Export("memberships")]
MPSegmentMembership[] Memberships { get; }

//@property(nonatomic, unsafe_unretained, readonly) BOOL expired;
[Export("expired")]
bool Expired { get; }
}

// This was added manually. For some reason, Sharpie didn't generate it.
// @interface MPSegmentMembership : NSObject<NSCopying>
[BaseType(typeof(NSObject))]
interface MPSegmentMembership : INSCopying
{

//@property(nonatomic, unsafe_unretained) int64_t segmentId;
[Export("segmentId")]
ulong SegmentId { get; }

//@property(nonatomic, unsafe_unretained) int64_t segmentMembershipId;
[Export("segmentMembershipId")]
ulong SegmentMembershipId { get; }

//@property(nonatomic, unsafe_unretained) NSTimeInterval timestamp;
[Export("timestamp")]
double Timestamp { get; }

//@property(nonatomic, unsafe_unretained) MPSegmentMembershipAction action;
[Export("action")]
MPSegmentMembership Action { get; set; }
}

// typedef void (^MPUserSegmentsHandler)(MPUserSegments * _Nullable, NSError * _Nullable);
delegate void MPUserSegmentsHandler([NullAllowed] MPUserSegments arg0, [NullAllowed] NSError arg1);

// @interface MPCaseInsensitive (NSArray)
[Category]
// @interface MPCaseInsensitive (NSArray)
[Category]
[BaseType(typeof(NSArray))]
interface NSArray_MPCaseInsensitive
{
Expand Down Expand Up @@ -764,11 +671,6 @@ interface MParticleUser
// - (void) removeUserAttribute:(NSString*) key;
[Export("removeUserAttribute:")]
void RemoveUserAttribute(NSString key);

// -(void)userSegments:(NSTimeInterval)timeout endpointId:(NSString * _Nonnull)endpointId completionHandler:(MPUserSegmentsHandler _Nonnull)completionHandler;
[Export("userSegments:endpointId:completionHandler:")]
void UserSegments(double timeout, string endpointId, MPUserSegmentsHandler completionHandler);

}

// @property(nonatomic, copy, nullable) void (^onUserAlias)(MParticleUser* previousUser, MParticleUser* newUser);
Expand Down Expand Up @@ -853,15 +755,18 @@ interface MParticleOptions
[Export("collectUserAgent", ArgumentSemantic.Assign)]
bool CollectUserAgent { get; set; }

// @property(nonatomic, copy) void (^onIdentifyComplete)(MPIdentityApiResult* _Nullable apiResult, NSError *_Nullable error);
[Export("onIdentifyComplete")]
// @property (nonatomic, strong, readwrite, nullable) NSNumber *configMaxAgeSeconds;
[NullAllowed, Export("configMaxAgeSeconds", ArgumentSemantic.Strong)]
NSNumber ConfigMaxAgeSeconds { get; set; }

// @property(nonatomic, copy) void (^onIdentifyComplete)(MPIdentityApiResult* _Nullable apiResult, NSError *_Nullable error);
[Export("onIdentifyComplete")]
OnIdentifyComplete OnIdentifyComplete { set; }

// @property(nonatomic, copy) void (^onAttributionComplete)(MPAttributionResult* _Nullable attributionResult, NSError *_Nullable error);
[Export("onAttributionComplete")]
OnAttributionCompleted OnAttributionCompleted { set; }

}
}

// void (^onIdentifyComplete)(MPIdentityApiResult* _Nullable apiResult, NSError *_Nullable error);
delegate void OnIdentifyComplete([NullAllowed] MPIdentityApiResult request, [NullAllowed] NSError error);
Expand Down Expand Up @@ -942,6 +847,10 @@ interface MParticle
[Export("version", ArgumentSemantic.Strong)]
string Version { get; }

// @property (nonatomic, readonly, nullable) NSNumber *configMaxAgeSeconds;
[NullAllowed, Export("configMaxAgeSeconds")]
NSNumber ConfigMaxAgeSeconds { get; }

// +(instancetype _Nonnull)sharedInstance;
[Static]
[Export("sharedInstance")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ typedef NS_ENUM(NSUInteger, MPKitInstance) {
MPKitInstancePilgrim = 211,
/** Kit code for Google Analytics for Firebase */
MPKitInstanceGoogleAnalyticsFirebase = 136,
/** Kit code for Google Analytics 4 for Firebase */
MPKitInstanceGoogleAnalyticsFirebaseGA4 = 160,
/** Kit code for Blueshift */
MPKitInstanceBlueshift = 1144
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, readonly) NSString *UUID;

/**
The session start time.
*/
@property (nonatomic, readonly) NSNumber *startTime;

@end

/**
Expand Down Expand Up @@ -291,6 +296,12 @@ Defaults to false. Prevents the eventsHost above from overwriting the alias endp
*/
@property (nonatomic, unsafe_unretained, readwrite) MPILogLevel logLevel;

/**
A custom handler callback for mParticle log messages. If set, this block will be invoked each time mParticle would normally log a message to the console.
N.B.: The format/wording of mParticle log messages may change between releases--please avoid using this programatically to detect SDK behavior unless absolutely necessary, and then only as a temporary workaround.
*/
@property (nonatomic, copy, readwrite) void (^customLogger)(NSString *message);

/**
Upload interval.
Expand Down Expand Up @@ -353,6 +364,20 @@ Defaults to false. Prevents the eventsHost above from overwriting the alias endp
*/
@property (nonatomic, strong, readwrite, nullable) NSNumber *attStatusTimestampMillis;

/**
Set a maximum threshold for stored configuration age, in seconds.
When the SDK starts, before we attempt to fetch a fresh config from the server, we
will load the most recent previous config from disk. when configMaxAgeSeconds is set, we will
check the timestamp on that config and, if its age is greater than the threshold, instead
of loading it we will delete it and wait for the fresh config to arrive.
This field is especially useful if your application often updates the kit/forwarding logic and
has a portion of user's who experience prolonged network interruptions. In these cases, a reasonable
configMaxAgeSeconds will prevent those users from potentially using very old forwarding logic.
*/
@property (nonatomic, strong, readwrite, nullable) NSNumber *configMaxAgeSeconds;

/**
Identify callback.
Expand Down Expand Up @@ -428,6 +453,13 @@ Defaults to false. Prevents the eventsHost above from overwriting the alias endp
*/
@property (nonatomic, unsafe_unretained) MPILogLevel logLevel;

/**
A custom handler callback for mParticle log messages. If set, this block will be invoked each time mParticle would normally log a message to the console.
N.B.: The format/wording of mParticle log messages may change between releases--please avoid using this programatically to detect SDK behavior unless absolutely necessary, and then only as a temporary workaround.
@see MParticleOptions
*/
@property (nonatomic, copy, readwrite) void (^customLogger)(NSString *message);

/**
Gets/Sets the opt-in/opt-out status for the application. Set it to YES to opt-out of event tracking. Set it to NO to opt-in of event tracking.
The default value is NO (opt-in of event tracking)
Expand Down Expand Up @@ -536,6 +568,12 @@ Defaults to false. Prevents the eventsHost above from overwriting the alias endp
*/
@property (nonatomic, readonly) MPDataPlanOptions *dataPlanOptions;

/**
Maximum threshold for stored configuration age, in seconds.
@see MParticleOptions
*/
@property (nonatomic, readonly, nullable) NSNumber *configMaxAgeSeconds;

#pragma mark - Initialization

/**
Expand Down Expand Up @@ -710,6 +748,18 @@ Defaults to false. Prevents the eventsHost above from overwriting the alias endp
*/
- (void)logScreen:(NSString *)screenName eventInfo:(nullable NSDictionary<NSString *, id> *)eventInfo;

/**
Logs a screen event and gives developer option to choose whether this screen event should be uploaded to mParticle when logged or only passed to kits. This is a convenience method for logging simple screen events; internally it creates an instance
of MPEvent and calls logScreenEvent:
@param screenName The name of the screen to be logged (required not nil and up to 255 characters)
@param eventInfo A dictionary containing further information about the screen. This dictionary is limited to 100 key
value pairs. Keys must be strings (up to 255 characters) and values can be strings (up to 4096 characters), numbers,
booleans, or dates
@param shouldUploadEvent A boolean flag that indicates whether this screen event should be uploaded to mParticle when logged or only passed to kits
@see logScreenEvent:
*/
- (void)logScreen:(NSString *)screenName eventInfo:(nullable NSDictionary<NSString *, id> *)eventInfo shouldUploadEvent:(BOOL)shouldUploadEvent;

/**
Sets the ATT Authorization state with the supplied timestamp, or uses the current time if none is supplied.
@param status The authorization state of ATT, determines whether the user has approved access to app-related data that can be used for tracking the user or the device.
Expand Down
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions Library/mParticle.Xamarin.Abstractions/MParticleSDK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public sealed class MParticleOptions
public Boolean IdDisabled = false;
public int UploadInterval = 600; //seconds
public int SessionTimeout = 60; //seconds
public int? ConfigMaxAgeSeconds; // defaults to unlimited
public Boolean UnCaughtExceptionLogging = false; // Android only
public LogLevel LogLevel = LogLevel.DEBUG;
public LocationTracking LocationTracking;
Expand Down
4 changes: 4 additions & 0 deletions Library/mParticle.Xamarin.Android/Utils/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ internal static AndroidBinding.MParticleOptions ConvertToMpOptions(MParticleOpti
builder.PushRegistration(options.PushRegistration.AndroidInstanceId, options.PushRegistration.AndroidSenderId);
}
builder.EnableUncaughtExceptionLogging(options.UnCaughtExceptionLogging);
if (options.ConfigMaxAgeSeconds != null)
{
builder.ConfigMaxAgeSeconds(options.ConfigMaxAgeSeconds.Value);
}
return builder.Build();
}

Expand Down
4 changes: 4 additions & 0 deletions Library/mParticle.Xamarin.iOS/Utils/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ internal static iOSBinding.MParticleOptions ConvertToMpOptions(MParticleOptions
mpOptions.Environment = ConvertToMpEnvironment(options.Environment);
mpOptions.ApiKey = options.ApiKey;
mpOptions.ApiSecret = options.ApiSecret;
if (options.ConfigMaxAgeSeconds != null)
{
mpOptions.ConfigMaxAgeSeconds = options.ConfigMaxAgeSeconds.Value;
}
if (options.IdentifyRequest != null)
{
mpOptions.IdentifyRequest = ConvertToMpIdentityRequest(options.IdentifyRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer: Wasi Haider (JECQAGRFCZ)</CodesignKey>
<CodesignKey>iPhone Developer</CodesignKey>
<DeviceSpecificBuild>true</DeviceSpecificBuild>
<MtouchDebug>true</MtouchDebug>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
Expand Down

0 comments on commit c5110f5

Please sign in to comment.