|
@@ -1,3 +1,5 @@
|
|
|
|
|
+import { AppTracks } from "@scripts/app/AppTrack";
|
|
|
|
|
+
|
|
|
export interface IFBLoginRes {
|
|
export interface IFBLoginRes {
|
|
|
accessToken: string;
|
|
accessToken: string;
|
|
|
/** SDK 返回的用户资料,仅用于展示;服务端仍需验证登录凭证。 */
|
|
/** SDK 返回的用户资料,仅用于展示;服务端仍需验证登录凭证。 */
|
|
@@ -28,6 +30,29 @@ export interface IFBShareRes {
|
|
|
reason?: string;
|
|
reason?: string;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const FBEventNames = {
|
|
|
|
|
+ AchievedLevel: "fb_mobile_level_achieved",
|
|
|
|
|
+ ActivatedApp: "fb_mobile_activate_app",
|
|
|
|
|
+ AddedPaymentInfo: "fb_mobile_add_payment_info",
|
|
|
|
|
+ AddedToCart: "fb_mobile_add_to_cart",
|
|
|
|
|
+ AddedToWishlist: "fb_mobile_add_to_wishlist",
|
|
|
|
|
+ CompletedRegistration: "fb_mobile_complete_registration",
|
|
|
|
|
+ CompletedTutorial: "fb_mobile_tutorial_completion",
|
|
|
|
|
+ InitiatedCheckout: "fb_mobile_initiated_checkout",
|
|
|
|
|
+ Purchased: "fb_mobile_purchase",
|
|
|
|
|
+ Rated: "fb_mobile_rate",
|
|
|
|
|
+ Searched: "fb_mobile_search",
|
|
|
|
|
+ SpentCredits: "fb_mobile_spent_credits",
|
|
|
|
|
+ UnlockedAchievement: "fb_mobile_achievement_unlocked",
|
|
|
|
|
+ ViewedContent: "fb_mobile_content_view",
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const EventsMap = {
|
|
|
|
|
+ [AppTracks.Registered]: FBEventNames.CompletedRegistration,
|
|
|
|
|
+ [AppTracks.AddToWishlist]: FBEventNames.AddedToWishlist,
|
|
|
|
|
+ [AppTracks.Addtocart]: FBEventNames.AddedToCart,
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export abstract class FacebookImpl {
|
|
export abstract class FacebookImpl {
|
|
|
private _isInitialized = false;
|
|
private _isInitialized = false;
|
|
|
|
|
|
|
@@ -37,6 +62,7 @@ export abstract class FacebookImpl {
|
|
|
|
|
|
|
|
protected onInited() {
|
|
protected onInited() {
|
|
|
this._isInitialized = true;
|
|
this._isInitialized = true;
|
|
|
|
|
+ this.activeApp();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async login(): Promise<IFBLoginRes> {
|
|
async login(): Promise<IFBLoginRes> {
|
|
@@ -50,11 +76,18 @@ export abstract class FacebookImpl {
|
|
|
|
|
|
|
|
abstract share(options: IFBShareOptions): Promise<IFBShareRes>;
|
|
abstract share(options: IFBShareOptions): Promise<IFBShareRes>;
|
|
|
|
|
|
|
|
- abstract logEvent(
|
|
|
|
|
- eventName: string,
|
|
|
|
|
- parameters?: IFBEventParams,
|
|
|
|
|
- valueToSum?: number,
|
|
|
|
|
- ): Promise<boolean>;
|
|
|
|
|
|
|
+ activeApp() {
|
|
|
|
|
+ this.logEvent(FBEventNames.ActivatedApp);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ logEvent(eventName: string, parameters?: IFBEventParams, valueToSum?: number): Promise<boolean> {
|
|
|
|
|
+ const fbEvent = EventsMap[eventName]
|
|
|
|
|
+ if (!!fbEvent) {
|
|
|
|
|
+ return this.onLogEvent(fbEvent, parameters, valueToSum);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ abstract onLogEvent(eventName: string, parameters?: IFBEventParams, valueToSum?: number): Promise<boolean>;
|
|
|
|
|
|
|
|
abstract logPurchase(
|
|
abstract logPurchase(
|
|
|
amount: number,
|
|
amount: number,
|