react-native-mparticle 3.1.3 → 3.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -120,7 +120,7 @@ dependencies {
120
120
  //
121
121
  // Bounded upper bound prevents resolving to 6.0.0-rc.1+ on Maven Central.
122
122
  // 6.x removed deprecated symbols (e.g. UserAttributeListener); see #710.
123
- api 'com.mparticle:android-core:[5.79.0, 6.0)'
123
+ api 'com.mparticle:android-core:[5.79.2, 6.0)'
124
124
 
125
125
  //
126
126
  // And, if you want to include kits, you can do so as follows:
@@ -136,6 +136,6 @@ dependencies {
136
136
  testImplementation 'junit:junit:4.13.2'
137
137
  testImplementation files('libs/java-json.jar')
138
138
 
139
- testImplementation 'com.mparticle:android-core:5.79.0'
139
+ testImplementation 'com.mparticle:android-core:5.79.2'
140
140
  testImplementation("com.facebook.react:react-android:+")
141
141
  }
@@ -19,6 +19,13 @@
19
19
  - (void)setUserId:(NSNumber *)userId;
20
20
  @end
21
21
 
22
+ // Forward declare so New Arch `logCommerceEvent` can use the same JS→native
23
+ // mappings as `RCTConvert (MPCommerceEvent)` (defined later in this file).
24
+ @interface RCTConvert (MPCommerceEvent)
25
+ + (MPCommerceEventAction)MPCommerceEventAction:(id)json;
26
+ + (MPPromotionAction)MPPromotionAction:(id)json;
27
+ @end
28
+
22
29
  @implementation RNMParticle
23
30
 
24
31
  RCT_EXTERN void RCTRegisterModule(Class);
@@ -447,11 +454,14 @@ RCT_EXPORT_METHOD(getSession:(RCTResponseSenderBlock)completion)
447
454
  MPCommerceEvent *mpCommerceEvent = [[MPCommerceEvent alloc] init];
448
455
 
449
456
  if (commerceEvent.productActionType().has_value()) {
450
- mpCommerceEvent.action = (MPCommerceEventAction)commerceEvent.productActionType().value();
457
+ mpCommerceEvent.action = [RCTConvert MPCommerceEventAction:@(commerceEvent.productActionType().value())];
451
458
  }
452
459
 
453
460
  if (commerceEvent.promotionActionType().has_value()) {
454
- mpCommerceEvent.promotionContainer = [[MPPromotionContainer alloc] initWithAction:(MPPromotionAction)commerceEvent.promotionActionType().value() promotion:nil];
461
+ MPPromotionAction promotionAction =
462
+ [RCTConvert MPPromotionAction:@(commerceEvent.promotionActionType().value())];
463
+ mpCommerceEvent.promotionContainer =
464
+ [[MPPromotionContainer alloc] initWithAction:promotionAction promotion:nil];
455
465
  }
456
466
 
457
467
  if (commerceEvent.products().has_value()) {
@@ -778,7 +788,7 @@ RCT_EXPORT_METHOD(setCCPAConsentState:(MPCCPAConsent *)consent)
778
788
  MPCommerceEvent *commerceEvent = [[MPCommerceEvent alloc] init];
779
789
 
780
790
  if (dict[@"productActionType"] && dict[@"productActionType"] != [NSNull null]) {
781
- commerceEvent.action = (MPCommerceEventAction)[dict[@"productActionType"] integerValue];
791
+ commerceEvent.action = [RCTConvert MPCommerceEventAction:dict[@"productActionType"]];
782
792
  }
783
793
 
784
794
  if (dict[@"products"] && dict[@"products"] != [NSNull null]) {
@@ -920,6 +930,7 @@ typedef NS_ENUM(NSUInteger, MPReactCommerceEventAction) {
920
930
  + (MPTransactionAttributes *)MPTransactionAttributes:(id)json;
921
931
  + (MPProduct *)MPProduct:(id)json;
922
932
  + (MPCommerceEventAction)MPCommerceEventAction:(id)json;
933
+ + (MPPromotionAction)MPPromotionAction:(id)json;
923
934
  + (MPIdentityApiRequest *)MPIdentityApiRequest:(id)json;
924
935
  + (MPIdentityApiResult *)MPIdentityApiResult:(id)json;
925
936
  + (MPAliasRequest *)MPAliasRequest:(id)json;
@@ -989,7 +1000,7 @@ typedef NS_ENUM(NSUInteger, MPReactCommerceEventAction) {
989
1000
  }
990
1001
 
991
1002
  + (MPPromotionContainer *)MPPromotionContainer:(id)json {
992
- MPPromotionAction promotionAction = (MPPromotionAction)[json[@"promotionActionType"] intValue];
1003
+ MPPromotionAction promotionAction = [RCTConvert MPPromotionAction:json[@"promotionActionType"]];
993
1004
  MPPromotionContainer *promotionContainer = [[MPPromotionContainer alloc] initWithAction:promotionAction promotion:nil];
994
1005
  NSArray *jsonPromotions = json[@"promotions"];
995
1006
  [jsonPromotions enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
@@ -1039,6 +1050,20 @@ typedef NS_ENUM(NSUInteger, MPReactCommerceEventAction) {
1039
1050
  return product;
1040
1051
  }
1041
1052
 
1053
+ + (MPPromotionAction)MPPromotionAction:(NSNumber *)json {
1054
+ // JS `PromotionActionType`: View = 0, Click = 1 (js/index.tsx).
1055
+ // Apple `MPPromotionAction`: Click = 0, View = 1 (MPPromotion.h).
1056
+ switch ([json intValue]) {
1057
+ case 0:
1058
+ return MPPromotionActionView;
1059
+ case 1:
1060
+ return MPPromotionActionClick;
1061
+ default:
1062
+ // Match Android `convertPromotionActionType`: non-zero → Click
1063
+ return MPPromotionActionClick;
1064
+ }
1065
+ }
1066
+
1042
1067
  + (MPCommerceEventAction)MPCommerceEventAction:(NSNumber *)json {
1043
1068
  int actionInt = [json intValue];
1044
1069
  MPCommerceEventAction action;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "homepage": "https://www.mparticle.com",
5
5
  "license": "Apache-2.0",
6
6
  "repository": "mParticle/react-native-mparticle",
7
- "version": "3.1.3",
7
+ "version": "3.1.5",
8
8
  "main": "lib/index.js",
9
9
  "types": "lib/index.d.ts",
10
10
  "react-native": "js/index",
@@ -287,7 +287,7 @@ const withMParticleAppBuildGradle = (config, props) => {
287
287
  // to a pre-release (e.g. 6.0.0-rc.1) and transitively drag the core past
288
288
  // the bridge's compiled-against API surface.
289
289
  const kitDependencies = props.androidKits
290
- .map(kit => ` implementation "com.mparticle:${kit}:[5.79.0, 6.0)"`)
290
+ .map(kit => ` implementation "com.mparticle:${kit}:[5.79.2, 6.0)"`)
291
291
  .join('\n');
292
292
  // Use mergeContents for idempotent injection
293
293
  const withKits = (0, generateCode_1.mergeContents)({
@@ -385,7 +385,7 @@ const withMParticleAppBuildGradle: ConfigPlugin<MParticlePluginProps> = (
385
385
  // to a pre-release (e.g. 6.0.0-rc.1) and transitively drag the core past
386
386
  // the bridge's compiled-against API surface.
387
387
  const kitDependencies = props.androidKits
388
- .map(kit => ` implementation "com.mparticle:${kit}:[5.79.0, 6.0)"`)
388
+ .map(kit => ` implementation "com.mparticle:${kit}:[5.79.2, 6.0)"`)
389
389
  .join('\n');
390
390
 
391
391
  // Use mergeContents for idempotent injection