insert-affiliate-react-native-sdk 1.2.0 → 1.2.2

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.
@@ -15,23 +15,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
35
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -106,7 +96,7 @@ const DeepLinkIapProvider = ({ children, }) => {
106
96
  });
107
97
  fetchAsyncEssentials();
108
98
  }, []);
109
- function setUserID() {
99
+ function generateThenSetUserID() {
110
100
  return __awaiter(this, void 0, void 0, function* () {
111
101
  let userId = yield getValueFromAsync(ASYNC_KEYS.USER_ID);
112
102
  if (!userId) {
@@ -163,7 +153,7 @@ const DeepLinkIapProvider = ({ children, }) => {
163
153
  };
164
154
  function setShortCode(shortCode) {
165
155
  return __awaiter(this, void 0, void 0, function* () {
166
- setUserID();
156
+ generateThenSetUserID();
167
157
  // Validate it is a short code
168
158
  const capitalisedShortCode = shortCode.toUpperCase();
169
159
  isShortCode(capitalisedShortCode);
@@ -184,7 +174,12 @@ const DeepLinkIapProvider = ({ children, }) => {
184
174
  // MARK: Insert Affiliate Identifier
185
175
  const setInsertAffiliateIdentifier = (referringLink, completion) => __awaiter(void 0, void 0, void 0, function* () {
186
176
  try {
187
- setUserID();
177
+ try {
178
+ generateThenSetUserID();
179
+ }
180
+ catch (error) {
181
+ console.error("[Insert Affiliate] Error setting user ID:", error);
182
+ }
188
183
  if (!referringLink) {
189
184
  console.warn("[Insert Affiliate] Referring link is invalid.");
190
185
  storeInsertAffiliateIdentifier({ link: referringLink });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "insert-affiliate-react-native-sdk",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
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",
package/readme.md CHANGED
@@ -34,7 +34,7 @@ Follow the steps below to install the SDK.
34
34
 
35
35
  #### Step 1: Initialisation in `App.tsx`
36
36
 
37
- First, wrap your with our provider and call the `initialise` method early in your app's lifecycle:
37
+ First, wrap your with our provider and call the `initialize` method early in your app's lifecycle:
38
38
 
39
39
  ```javascript
40
40
  const Child = () => {
@@ -120,7 +120,7 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
120
120
  fetchAsyncEssentials();
121
121
  }, []);
122
122
 
123
- async function setUserID() {
123
+ async function generateThenSetUserID() {
124
124
  let userId = await getValueFromAsync(ASYNC_KEYS.USER_ID);
125
125
  if (!userId) {
126
126
  userId = generateUserID();
@@ -184,7 +184,7 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
184
184
  };
185
185
 
186
186
  async function setShortCode(shortCode: string): Promise<void> {
187
- setUserID();
187
+ generateThenSetUserID();
188
188
 
189
189
  // Validate it is a short code
190
190
  const capitalisedShortCode = shortCode.toUpperCase();
@@ -211,7 +211,8 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
211
211
  completion: (shortLink: string | null) => void
212
212
  ) => {
213
213
  try {
214
- setUserID();
214
+ console.log("[Insert Affiliate] Setting affiliate identifier.");
215
+ generateThenSetUserID();
215
216
 
216
217
  if (!referringLink) {
217
218
  console.warn("[Insert Affiliate] Referring link is invalid.");
@@ -254,6 +255,7 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
254
255
 
255
256
  // Create the request URL
256
257
  const urlString = `https://api.insertaffiliate.com/V1/convert-deep-link-to-short-link?companyId=${companyCode}&deepLinkUrl=${encodedAffiliateLink}`;
258
+ console.log("[Insert Affiliate] urlString .", urlString);
257
259
  const response = await axios.get(urlString, {
258
260
  headers: {
259
261
  "Content-Type": "application/json",