baxi hai 4 días
pai
achega
8cc31d8a61
Modificáronse 1 ficheiros con 24 adicións e 0 borrados
  1. 24 0
      assets/scripts/platform/FaceBook/FacebookImpl.ts

+ 24 - 0
assets/scripts/platform/FaceBook/FacebookImpl.ts

@@ -47,6 +47,20 @@ const FBEventNames = {
     ViewedContent: "fb_mobile_content_view",
 }
 
+const FBEventParameterName = {
+    ContentID: "fb_content_id",
+    ContentType: "fb_content_type",
+    Currency: "fb_currency",
+    Description: "fb_description",
+    Level: "fb_level",
+    MaxRatingValue: "fb_max_rating_value",
+    NumItems: "fb_num_items",
+    PaymentInfoAvailable: "fb_payment_info_available",
+    RegistrationMethod: "fb_registration_method",
+    SearchString: "fb_search_string",
+    Success: "fb_success",
+}
+
 const EventsMap = {
     [AppTracks.Registered]: FBEventNames.CompletedRegistration,
     [AppTracks.AddToWishlist]: FBEventNames.AddedToWishlist,
@@ -85,6 +99,16 @@ export abstract class FacebookImpl {
         if (!!fbEvent) {
             return this.onLogEvent(fbEvent, parameters, valueToSum);
         }
+
+        if (eventName === AppTracks.Purchased) {
+            let currency = parameters?.currency || "";
+            if (typeof currency === 'number') currency = currency.toString();
+
+            const value = Number(parameters?.value || valueToSum);
+            this.logPurchase(value, currency, {
+                [FBEventParameterName.Currency]: currency
+            })
+        }
     }
 
     abstract onLogEvent(eventName: string, parameters?: IFBEventParams, valueToSum?: number): Promise<boolean>;