apps-sdk 1.1.34 → 1.1.37
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.
- package/config.js +13 -0
- package/index.js +1 -0
- package/package.json +2 -1
- package/src/libraries/Adapty.js +10 -0
- package/src/libraries/Facebook.js +128 -0
- package/src/libraries/index.js +1 -0
- package/types/index.d.ts +13 -0
package/config.js
CHANGED
|
@@ -73,4 +73,17 @@ export var CONFIG_EXTRA = {};
|
|
|
73
73
|
|
|
74
74
|
export var QUICK_ACTIONS = {};
|
|
75
75
|
|
|
76
|
+
export const FACEBOOK = {
|
|
77
|
+
APP_ID: 'your_facebook_app_id',
|
|
78
|
+
CLIENT_TOKEN: 'your_client_token',
|
|
79
|
+
DEBUG: true,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export var EVENTS_FACEBOOK = {
|
|
83
|
+
'picture_upload': 'custom_picture_upload',
|
|
84
|
+
'write_prompt': 'custom_write_prompt',
|
|
85
|
+
'picture_generated': 'custom_picture_generated',
|
|
86
|
+
'paywall_view': 'custom_paywall_view'
|
|
87
|
+
}
|
|
88
|
+
|
|
76
89
|
export const DEBUG_MODE = false;
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apps-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.37",
|
|
4
4
|
"description": "Apps SDK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"react-native-adapty": "^3.11.1",
|
|
36
36
|
"react-native-adjust": "^5.0.2",
|
|
37
37
|
"react-native-btr": "^2.2.1",
|
|
38
|
+
"react-native-fbsdk-next": "^13.4.1",
|
|
38
39
|
"react-native-iap": "^12.13.0",
|
|
39
40
|
"react-native-webview": "13.12.5",
|
|
40
41
|
"semver": "^7.6.0"
|
package/src/libraries/Adapty.js
CHANGED
|
@@ -72,6 +72,7 @@ class Adapty {
|
|
|
72
72
|
onRenderingFailed: eventHandlers.onRenderingFailed || (() => { return true; }),
|
|
73
73
|
onLoadingProductsFailed: eventHandlers.onLoadingProductsFailed || (() => { paywallView.dismiss(); return true; }),
|
|
74
74
|
onUrlPress: eventHandlers.onUrlPress || (() => { return true; }),
|
|
75
|
+
onCustomAction: eventHandlers.onCustomAction || (() => { }),
|
|
75
76
|
});
|
|
76
77
|
await paywallView.present();
|
|
77
78
|
} else {
|
|
@@ -134,6 +135,7 @@ class Adapty {
|
|
|
134
135
|
onRenderingFailed: eventHandlers.onRenderingFailed || (() => { return true; }),
|
|
135
136
|
onLoadingProductsFailed: eventHandlers.onLoadingProductsFailed || (() => { paywallView.dismiss(); return true; }),
|
|
136
137
|
onUrlPress: eventHandlers.onUrlPress || (() => { return true; }),
|
|
138
|
+
onCustomAction: eventHandlers.onCustomAction || (() => { }),
|
|
137
139
|
});
|
|
138
140
|
await paywallView.present();
|
|
139
141
|
} else {
|
|
@@ -169,6 +171,14 @@ class Adapty {
|
|
|
169
171
|
console.error('Error setting integration identifier:', error);
|
|
170
172
|
}
|
|
171
173
|
}
|
|
174
|
+
|
|
175
|
+
async setMixpanelIntegrationIdentifier(integrationIdentifier) {
|
|
176
|
+
try {
|
|
177
|
+
await adapty.setIntegrationIdentifier('mixpanel_user_id', integrationIdentifier);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error('Error setting integration identifier:', error);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
172
182
|
}
|
|
173
183
|
|
|
174
184
|
export default new Adapty();
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { AppEventsLogger, Settings } from 'react-native-fbsdk-next';
|
|
2
|
+
import * as config from '../../config';
|
|
3
|
+
import Networking from "./Networking";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* "react-native-fbsdk-next" events coding:
|
|
7
|
+
* https://github.com/thebergamo/react-native-fbsdk-next/blob/master/src/FBAppEventsLogger.ts
|
|
8
|
+
*
|
|
9
|
+
* Facebook Standard and Custom events:
|
|
10
|
+
* https://developers.facebook.com/docs/marketing-api/app-event-api/
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
class Facebook {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.facebook = null;
|
|
16
|
+
this.isInitialized = false;
|
|
17
|
+
this.appId = null;
|
|
18
|
+
this.clientToken = null;
|
|
19
|
+
this.devMode = false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async initialize(appId = null, clientToken = null, debugMode = false, devMode = false) {
|
|
23
|
+
this.devMode = devMode;
|
|
24
|
+
this.appId = appId || config.FACEBOOK.APP_ID;
|
|
25
|
+
this.clientToken = clientToken || config.FACEBOOK.CLIENT_TOKEN;
|
|
26
|
+
|
|
27
|
+
console.log('Initializing Facebook with appId: ' + this.appId);
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
if (!this.appId || !this.clientToken) {
|
|
31
|
+
console.error('Facebook initialize - Missing appId or clientToken');
|
|
32
|
+
Networking.sendEvent('other', 'facebook_init_ko');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Configure Facebook SDK
|
|
37
|
+
Settings.setAppID(this.appId);
|
|
38
|
+
Settings.setClientToken(this.clientToken);
|
|
39
|
+
Settings.setAutoLogAppEventsEnabled(true);
|
|
40
|
+
|
|
41
|
+
if (debugMode || config.FACEBOOK.DEBUG) {
|
|
42
|
+
Settings.setAdvertiserIDCollectionEnabled(true);
|
|
43
|
+
Settings.setAutoInitEnabled(true);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
await Settings.initializeSDK();
|
|
47
|
+
|
|
48
|
+
this.isInitialized = true;
|
|
49
|
+
config.DEBUG_MODE && console.log('Facebook initialized: OK');
|
|
50
|
+
Networking.sendEvent('other', 'facebook_init_ok');
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('Error initializing Facebook:', error);
|
|
53
|
+
Networking.sendEvent('other', 'facebook_init_ko');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async trackEvent(eventName, properties = {}) {
|
|
58
|
+
if (!this.isInitialized) {
|
|
59
|
+
console.log('Facebook is not initialized');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
if (!this.devMode) {
|
|
65
|
+
await AppEventsLogger.logEvent(eventName, properties);
|
|
66
|
+
config.DEBUG_MODE && console.log(`Facebook Event tracked: ${eventName} with properties:`, properties);
|
|
67
|
+
} else {
|
|
68
|
+
config.DEBUG_MODE && console.log(`Facebook Event tracked but not send (DEV_MODE ON): ${eventName} with properties:`, properties);
|
|
69
|
+
}
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('Error tracking event:', error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async trackEventIfExist(eventKeyword, eventData = {}) {
|
|
76
|
+
if (config.EVENTS_FACEBOOK[eventKeyword]) {
|
|
77
|
+
this.trackEvent(config.EVENTS_FACEBOOK[eventKeyword], eventData);
|
|
78
|
+
} else {
|
|
79
|
+
console.log("Event not found in Facebook, not sent: " + eventKeyword);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async trackPurchase(valueToSum, currency, parameters = {}) {
|
|
84
|
+
if (!this.isInitialized) {
|
|
85
|
+
console.log('Facebook is not initialized');
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
if (!this.devMode) {
|
|
91
|
+
await AppEventsLogger.logPurchase(valueToSum, currency, parameters);
|
|
92
|
+
config.DEBUG_MODE && console.log(`Facebook Purchase tracked: ${valueToSum} ${currency} with parameters:`, parameters);
|
|
93
|
+
} else {
|
|
94
|
+
config.DEBUG_MODE && console.log(`Facebook Purchase tracked but not send (DEV_MODE ON): ${valueToSum} ${currency} with parameters:`, parameters);
|
|
95
|
+
}
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error('Error tracking purchase:', error);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async trackPushNotificationOpen(payload = {}) {
|
|
102
|
+
if (!this.isInitialized) {
|
|
103
|
+
console.log('Facebook is not initialized');
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
if (!this.devMode) {
|
|
109
|
+
await AppEventsLogger.logPushNotificationOpen(payload);
|
|
110
|
+
config.DEBUG_MODE && console.log('Facebook Push Notification Open tracked with payload:', payload);
|
|
111
|
+
} else {
|
|
112
|
+
config.DEBUG_MODE && console.log('Facebook Push Notification Open tracked but not send (DEV_MODE ON) with payload:', payload);
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.error('Error tracking push notification open:', error);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
isFacebookInitialized() {
|
|
120
|
+
return this.isInitialized;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
getApplicationId() {
|
|
124
|
+
return this.appId;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default new Facebook();
|
package/src/libraries/index.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -208,6 +208,7 @@ declare module 'apps-sdk' {
|
|
|
208
208
|
onRenderingFailed?: (error: any) => void;
|
|
209
209
|
onLoadingProductsFailed?: (error: any) => void;
|
|
210
210
|
onUrlPress?: (url: string) => void;
|
|
211
|
+
onCustomAction?: (action: string, data: any) => void;
|
|
211
212
|
};
|
|
212
213
|
|
|
213
214
|
export class Adapty {
|
|
@@ -222,6 +223,7 @@ declare module 'apps-sdk' {
|
|
|
222
223
|
getProfile(): Promise<any>;
|
|
223
224
|
updateAdjustAttributionData(attribution: any): Promise<void>;
|
|
224
225
|
setAdjustIntegrationIdentifier(adjustIntegrationIdentifier: string): Promise<void>;
|
|
226
|
+
setMixpanelIntegrationIdentifier(mixpanelIntegrationIdentifier: string): Promise<void>;
|
|
225
227
|
closePaywall(): Promise<void>;
|
|
226
228
|
}
|
|
227
229
|
|
|
@@ -236,6 +238,16 @@ declare module 'apps-sdk' {
|
|
|
236
238
|
itemCallback(itemCallbackFunction: any): Promise<void>;
|
|
237
239
|
}
|
|
238
240
|
|
|
241
|
+
export class Facebook {
|
|
242
|
+
initialize(appId?: string, clientToken?: string, debugMode?: boolean, devMode?: boolean): Promise<void>;
|
|
243
|
+
trackEvent(eventName: string, properties?: object): Promise<void>;
|
|
244
|
+
trackEventIfExist(eventKeyword: string, eventData?: object): Promise<void>;
|
|
245
|
+
trackPurchase(valueToSum: number, currency: string, parameters?: object): Promise<void>;
|
|
246
|
+
trackPushNotificationOpen(payload?: object): Promise<void>;
|
|
247
|
+
isFacebookInitialized(): boolean;
|
|
248
|
+
getApplicationId(): string | null;
|
|
249
|
+
}
|
|
250
|
+
|
|
239
251
|
export class AppsSDK {
|
|
240
252
|
initializePushNotifications(): Promise<string>;
|
|
241
253
|
}
|
|
@@ -257,6 +269,7 @@ declare module 'apps-sdk' {
|
|
|
257
269
|
voice : Voice;
|
|
258
270
|
adapty : Adapty;
|
|
259
271
|
homeActions : HomeActions;
|
|
272
|
+
facebook : Facebook;
|
|
260
273
|
}
|
|
261
274
|
|
|
262
275
|
const Core: AppsSDK;
|