128 lines
4.3 KiB
TypeScript
128 lines
4.3 KiB
TypeScript
// Metro module 6179 (f6180).
|
|
import UserAffinitiesV2Store from "../../user_affinities/UserAffinitiesV2Store";
|
|
import AuthenticationStore from "../../../stores/AuthenticationStore";
|
|
import MessageStore from "../../../stores/MessageStore";
|
|
import { GiftIntentType } from "../PremiumConstants";
|
|
import { AnalyticEvents, Endpoints } from "../../../Constants";
|
|
import { HTTP } from "../../../_bundle/sendRequest";
|
|
import Dispatcher from "../../../Dispatcher";
|
|
import SentryUtils_native from "../../../utils/SentryUtils.native";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import { isFriendshipAnniversaryBackendPersistenceEnabled } from "../experiments/FriendshipAnniversaryBackendPersistenceExperiment";
|
|
let $mk77956 = function() {
|
|
return (a0) => {
|
|
SentryUtils_native.captureException(a0, {
|
|
tags: {
|
|
feature: "gift_intent"
|
|
}
|
|
});
|
|
};
|
|
};
|
|
export function fetchAndReconcileGiftIntentDismissals(settingsTimestampMs) {
|
|
const id = AuthenticationStore.getId();
|
|
return HTTP.get({
|
|
url: Endpoints.GIFT_INTENT_DISMISSALS,
|
|
oldFormErrors: true,
|
|
rejectWithError: true
|
|
}).then((result) => {
|
|
if (AuthenticationStore.getId() === id) {
|
|
let dismissals = result.body.dismissals;
|
|
if (dismissals == null) {
|
|
dismissals = [];
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "GIFT_INTENT_DISMISSALS_FETCH_SUCCESS",
|
|
dismissals: dismissals.map((dismissal) => ({
|
|
targetId: dismissal.target_id,
|
|
dismissedAtMs: Number(dismissal.dismissed_at_ms)
|
|
})),
|
|
settingsTimestampMs
|
|
});
|
|
} else {
|
|
Dispatcher.dispatch({
|
|
type: "GIFT_INTENT_DISMISSALS_FETCH_FAILURE"
|
|
});
|
|
}
|
|
}, (a0) => {
|
|
SentryUtils_native.captureException(a0, {
|
|
tags: {
|
|
feature: "gift_intent"
|
|
}
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "GIFT_INTENT_DISMISSALS_FETCH_FAILURE"
|
|
});
|
|
});
|
|
}
|
|
export function logFriendsListGiftIntentsShown() {
|
|
Dispatcher.dispatch({
|
|
type: "FRIENDS_LIST_GIFT_INTENTS_SHOWN"
|
|
});
|
|
}
|
|
export function logMessageGiftIntentShown(a0, gift_intent_type = GiftIntentType.FRIEND_ANNIVERSARY) {
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_GIFT_INTENT_SHOWN",
|
|
recipientUserId: a0
|
|
});
|
|
AnalyticsUtils.track(AnalyticEvents.GIFT_INTENT_DISMISSED, {
|
|
gift_intent_type,
|
|
dismiss_type: "shown",
|
|
affinity: UserAffinitiesV2Store.getUserAffinity(a0)?.dmProbability
|
|
});
|
|
if (isFriendshipAnniversaryBackendPersistenceEnabled("dismissGiftIntent") && gift_intent_type !== GiftIntentType.UNSPECIFIED) {
|
|
HTTP.post({
|
|
url: Endpoints.GIFT_INTENTS_DISMISS,
|
|
body: {
|
|
intent_type: gift_intent_type,
|
|
target_id: a0
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: true
|
|
}).catch($mk77956());
|
|
}
|
|
}
|
|
export function logGiftIntentMessageDismissed(a0, a1) {
|
|
const giftingPrompt = MessageStore.getMessage(a0, a1)?.giftingPrompt;
|
|
if (giftingPrompt != null) {
|
|
const { giftIntentType, recipientUserId } = giftingPrompt;
|
|
AnalyticsUtils.track(AnalyticEvents.GIFT_INTENT_DISMISSED, {
|
|
gift_intent_type: giftIntentType,
|
|
dismiss_type: "explicit",
|
|
affinity: UserAffinitiesV2Store.getUserAffinity(recipientUserId)?.dmProbability
|
|
});
|
|
if (isFriendshipAnniversaryBackendPersistenceEnabled("dismissGiftIntent") && giftIntentType !== GiftIntentType.UNSPECIFIED) {
|
|
HTTP.post({
|
|
url: Endpoints.GIFT_INTENTS_DISMISS,
|
|
body: {
|
|
intent_type: giftIntentType,
|
|
target_id: recipientUserId
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: true
|
|
}).catch($mk77956());
|
|
}
|
|
}
|
|
}
|
|
export function logGiftIntentFlowPurchasedGift(a0, gift_intent_type = GiftIntentType.FRIEND_ANNIVERSARY) {
|
|
Dispatcher.dispatch({
|
|
type: "GIFT_INTENT_FLOW_PURCHASED_GIFT",
|
|
recipientUserId: a0
|
|
});
|
|
AnalyticsUtils.track(AnalyticEvents.GIFT_INTENT_DISMISSED, {
|
|
gift_intent_type,
|
|
dismiss_type: "gift_sent",
|
|
affinity: UserAffinitiesV2Store.getUserAffinity(a0)?.dmProbability
|
|
});
|
|
if (isFriendshipAnniversaryBackendPersistenceEnabled("dismissGiftIntent") && gift_intent_type !== GiftIntentType.UNSPECIFIED) {
|
|
HTTP.post({
|
|
url: Endpoints.GIFT_INTENTS_DISMISS,
|
|
body: {
|
|
intent_type: gift_intent_type,
|
|
target_id: a0
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: true
|
|
}).catch($mk77956());
|
|
}
|
|
}
|