insert-affiliate-react-native-sdk 1.2.6 → 1.2.7

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.
@@ -53,7 +53,7 @@ exports.DeepLinkIapContext = (0, react_1.createContext)({
53
53
  validatePurchaseWithIapticAPI: (jsonIapPurchase, iapticAppId, iapticAppName, iapticPublicKey) => __awaiter(void 0, void 0, void 0, function* () { return false; }),
54
54
  trackEvent: (eventName) => __awaiter(void 0, void 0, void 0, function* () { }),
55
55
  setShortCode: (shortCode) => __awaiter(void 0, void 0, void 0, function* () { }),
56
- setInsertAffiliateIdentifier: (referringLink, completion) => __awaiter(void 0, void 0, void 0, function* () { }),
56
+ setInsertAffiliateIdentifier: (referringLink) => __awaiter(void 0, void 0, void 0, function* () { }),
57
57
  initialize: (code) => __awaiter(void 0, void 0, void 0, function* () { }),
58
58
  isInitialized: false
59
59
  });
@@ -172,32 +172,28 @@ const DeepLinkIapProvider = ({ children, }) => {
172
172
  }
173
173
  });
174
174
  // MARK: Insert Affiliate Identifier
175
- const setInsertAffiliateIdentifier = (referringLink, completion) => __awaiter(void 0, void 0, void 0, function* () {
175
+ const setInsertAffiliateIdentifier = (referringLink) => __awaiter(void 0, void 0, void 0, function* () {
176
176
  console.log("[Insert Affiliate] Setting affiliate identifier.");
177
177
  try {
178
- generateThenSetUserID();
178
+ yield generateThenSetUserID();
179
179
  console.log("[Insert Affiliate] Completed generateThenSetUserID within setInsertAffiliateIdentifier.");
180
180
  if (!referringLink) {
181
181
  console.warn("[Insert Affiliate] Referring link is invalid.");
182
- storeInsertAffiliateIdentifier({ link: referringLink });
183
- completion(null);
182
+ yield storeInsertAffiliateIdentifier({ link: referringLink });
184
183
  return;
185
184
  }
186
185
  if (!isInitialized || !companyCode) {
187
186
  console.error("[Insert Affiliate] SDK is not initialized. Please initialize the SDK with a valid company code.");
188
- completion(null);
189
187
  return;
190
188
  }
191
189
  if (!companyCode || companyCode.trim() === "") {
192
190
  console.error("[Insert Affiliate] Company code is not set. Please initialize the SDK with a valid company code.");
193
- completion(null);
194
191
  return;
195
192
  }
196
193
  // Check if referring link is already a short code, if so save it and stop here.
197
194
  if (isShortCode(referringLink)) {
198
195
  console.log("[Insert Affiliate] Referring link is already a short code.");
199
- storeInsertAffiliateIdentifier({ link: referringLink });
200
- completion(referringLink);
196
+ yield storeInsertAffiliateIdentifier({ link: referringLink });
201
197
  return;
202
198
  }
203
199
  // If the code is not already a short code, encode it raedy to send to our endpoint to return the short code. Save it before making the call in case something goes wrong
@@ -205,8 +201,7 @@ const DeepLinkIapProvider = ({ children, }) => {
205
201
  const encodedAffiliateLink = encodeURIComponent(referringLink);
206
202
  if (!encodedAffiliateLink) {
207
203
  console.error("[Insert Affiliate] Failed to encode affiliate link.");
208
- storeInsertAffiliateIdentifier({ link: referringLink });
209
- completion(null);
204
+ yield storeInsertAffiliateIdentifier({ link: referringLink });
210
205
  return;
211
206
  }
212
207
  // Create the request URL
@@ -221,18 +216,15 @@ const DeepLinkIapProvider = ({ children, }) => {
221
216
  if (response.status === 200 && response.data.shortLink) {
222
217
  const shortLink = response.data.shortLink;
223
218
  console.log("[Insert Affiliate] Short link received:", shortLink);
224
- storeInsertAffiliateIdentifier({ link: shortLink });
225
- completion(shortLink);
219
+ yield storeInsertAffiliateIdentifier({ link: shortLink });
226
220
  }
227
221
  else {
228
222
  console.warn("[Insert Affiliate] Unexpected response format.");
229
- storeInsertAffiliateIdentifier({ link: referringLink });
230
- completion(null);
223
+ yield storeInsertAffiliateIdentifier({ link: referringLink });
231
224
  }
232
225
  }
233
226
  catch (error) {
234
227
  console.error("[Insert Affiliate] Error:", error);
235
- completion(null);
236
228
  }
237
229
  });
238
230
  function storeInsertAffiliateIdentifier(_a) {
@@ -7,7 +7,7 @@ declare const useDeepLinkIapProvider: () => {
7
7
  returnInsertAffiliateIdentifier: () => Promise<string | null>;
8
8
  trackEvent: (eventName: string) => Promise<void>;
9
9
  setShortCode: (shortCode: string) => Promise<void>;
10
- setInsertAffiliateIdentifier: (referringLink: string, completion: (shortLink: string | null) => void) => Promise<void>;
10
+ setInsertAffiliateIdentifier: (referringLink: string) => Promise<void>;
11
11
  initialize: (code: string | null) => Promise<void>;
12
12
  isInitialized: boolean;
13
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "insert-affiliate-react-native-sdk",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "A package for connecting with the Insert Affiliate Platform to add app based affiliate marketing.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",