insert-affiliate-react-native-sdk 1.2.4 → 1.2.6
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.
|
@@ -12,7 +12,7 @@ type T_DEEPLINK_IAP_CONTEXT = {
|
|
|
12
12
|
validatePurchaseWithIapticAPI: (jsonIapPurchase: CustomPurchase, iapticAppId: string, iapticAppName: string, iapticPublicKey: string) => Promise<boolean>;
|
|
13
13
|
trackEvent: (eventName: string) => Promise<void>;
|
|
14
14
|
setShortCode: (shortCode: string) => Promise<void>;
|
|
15
|
-
setInsertAffiliateIdentifier: (referringLink: string
|
|
15
|
+
setInsertAffiliateIdentifier: (referringLink: string) => Promise<void>;
|
|
16
16
|
initialize: (code: string | null) => Promise<void>;
|
|
17
17
|
isInitialized: boolean;
|
|
18
18
|
};
|
|
@@ -173,8 +173,8 @@ const DeepLinkIapProvider = ({ children, }) => {
|
|
|
173
173
|
});
|
|
174
174
|
// MARK: Insert Affiliate Identifier
|
|
175
175
|
const setInsertAffiliateIdentifier = (referringLink, completion) => __awaiter(void 0, void 0, void 0, function* () {
|
|
176
|
+
console.log("[Insert Affiliate] Setting affiliate identifier.");
|
|
176
177
|
try {
|
|
177
|
-
console.log("[Insert Affiliate] Setting affiliate identifier.");
|
|
178
178
|
generateThenSetUserID();
|
|
179
179
|
console.log("[Insert Affiliate] Completed generateThenSetUserID within setInsertAffiliateIdentifier.");
|
|
180
180
|
if (!referringLink) {
|
package/package.json
CHANGED
|
@@ -24,10 +24,7 @@ type T_DEEPLINK_IAP_CONTEXT = {
|
|
|
24
24
|
) => Promise<boolean>;
|
|
25
25
|
trackEvent: (eventName: string) => Promise<void>;
|
|
26
26
|
setShortCode: (shortCode: string) => Promise<void>;
|
|
27
|
-
setInsertAffiliateIdentifier: (
|
|
28
|
-
referringLink: string,
|
|
29
|
-
completion: (shortLink: string | null) => void
|
|
30
|
-
) => Promise<void>;
|
|
27
|
+
setInsertAffiliateIdentifier: (referringLink: string) => Promise<void>;
|
|
31
28
|
initialize: (code: string | null) => Promise<void>;
|
|
32
29
|
isInitialized: boolean;
|
|
33
30
|
};
|
|
@@ -67,10 +64,7 @@ export const DeepLinkIapContext = createContext<T_DEEPLINK_IAP_CONTEXT>({
|
|
|
67
64
|
) => false,
|
|
68
65
|
trackEvent: async (eventName: string) => {},
|
|
69
66
|
setShortCode: async (shortCode: string) => {},
|
|
70
|
-
setInsertAffiliateIdentifier: async (
|
|
71
|
-
referringLink: string,
|
|
72
|
-
completion: (shortLink: string | null) => void
|
|
73
|
-
) => {},
|
|
67
|
+
setInsertAffiliateIdentifier: async (referringLink: string) => {},
|
|
74
68
|
initialize: async (code: string | null) => {},
|
|
75
69
|
isInitialized: false
|
|
76
70
|
});
|
|
@@ -206,26 +200,22 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
|
|
|
206
200
|
|
|
207
201
|
|
|
208
202
|
// MARK: Insert Affiliate Identifier
|
|
209
|
-
const setInsertAffiliateIdentifier = async (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
) => {
|
|
203
|
+
const setInsertAffiliateIdentifier = async (referringLink: string) => {
|
|
204
|
+
console.log("[Insert Affiliate] Setting affiliate identifier.");
|
|
205
|
+
|
|
213
206
|
try {
|
|
214
|
-
|
|
215
|
-
generateThenSetUserID();
|
|
207
|
+
await generateThenSetUserID();
|
|
216
208
|
|
|
217
209
|
console.log("[Insert Affiliate] Completed generateThenSetUserID within setInsertAffiliateIdentifier.");
|
|
218
210
|
|
|
219
211
|
if (!referringLink) {
|
|
220
212
|
console.warn("[Insert Affiliate] Referring link is invalid.");
|
|
221
|
-
storeInsertAffiliateIdentifier({ link: referringLink });
|
|
222
|
-
completion(null);
|
|
213
|
+
await storeInsertAffiliateIdentifier({ link: referringLink });
|
|
223
214
|
return;
|
|
224
215
|
}
|
|
225
216
|
|
|
226
217
|
if (!isInitialized || !companyCode) {
|
|
227
218
|
console.error("[Insert Affiliate] SDK is not initialized. Please initialize the SDK with a valid company code.");
|
|
228
|
-
completion(null);
|
|
229
219
|
return;
|
|
230
220
|
}
|
|
231
221
|
|
|
@@ -233,15 +223,13 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
|
|
|
233
223
|
console.error(
|
|
234
224
|
"[Insert Affiliate] Company code is not set. Please initialize the SDK with a valid company code."
|
|
235
225
|
);
|
|
236
|
-
completion(null);
|
|
237
226
|
return;
|
|
238
227
|
}
|
|
239
228
|
|
|
240
229
|
// Check if referring link is already a short code, if so save it and stop here.
|
|
241
230
|
if (isShortCode(referringLink)) {
|
|
242
231
|
console.log("[Insert Affiliate] Referring link is already a short code.");
|
|
243
|
-
storeInsertAffiliateIdentifier({ link: referringLink });
|
|
244
|
-
completion(referringLink);
|
|
232
|
+
await storeInsertAffiliateIdentifier({ link: referringLink });
|
|
245
233
|
return;
|
|
246
234
|
}
|
|
247
235
|
|
|
@@ -250,8 +238,7 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
|
|
|
250
238
|
const encodedAffiliateLink = encodeURIComponent(referringLink);
|
|
251
239
|
if (!encodedAffiliateLink) {
|
|
252
240
|
console.error("[Insert Affiliate] Failed to encode affiliate link.");
|
|
253
|
-
storeInsertAffiliateIdentifier({ link: referringLink });
|
|
254
|
-
completion(null);
|
|
241
|
+
await storeInsertAffiliateIdentifier({ link: referringLink });
|
|
255
242
|
return;
|
|
256
243
|
}
|
|
257
244
|
|
|
@@ -268,16 +255,13 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
|
|
|
268
255
|
if (response.status === 200 && response.data.shortLink) {
|
|
269
256
|
const shortLink = response.data.shortLink;
|
|
270
257
|
console.log("[Insert Affiliate] Short link received:", shortLink);
|
|
271
|
-
storeInsertAffiliateIdentifier({ link: shortLink });
|
|
272
|
-
completion(shortLink);
|
|
258
|
+
await storeInsertAffiliateIdentifier({ link: shortLink });
|
|
273
259
|
} else {
|
|
274
260
|
console.warn("[Insert Affiliate] Unexpected response format.");
|
|
275
|
-
storeInsertAffiliateIdentifier({ link: referringLink });
|
|
276
|
-
completion(null);
|
|
261
|
+
await storeInsertAffiliateIdentifier({ link: referringLink });
|
|
277
262
|
}
|
|
278
263
|
} catch (error) {
|
|
279
264
|
console.error("[Insert Affiliate] Error:", error);
|
|
280
|
-
completion(null);
|
|
281
265
|
}
|
|
282
266
|
};
|
|
283
267
|
|