insert-affiliate-react-native-sdk 1.1.9 → 1.2.1
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/dist/DeepLinkIapProvider.js +9 -4
- package/package.json +4 -2
- package/readme.md +1 -1
- package/src/DeepLinkIapProvider.tsx +9 -4
|
@@ -96,7 +96,7 @@ const DeepLinkIapProvider = ({ children, }) => {
|
|
|
96
96
|
});
|
|
97
97
|
fetchAsyncEssentials();
|
|
98
98
|
}, []);
|
|
99
|
-
function
|
|
99
|
+
function generateThenSetUserID() {
|
|
100
100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
101
|
let userId = yield getValueFromAsync(ASYNC_KEYS.USER_ID);
|
|
102
102
|
if (!userId) {
|
|
@@ -153,7 +153,7 @@ const DeepLinkIapProvider = ({ children, }) => {
|
|
|
153
153
|
};
|
|
154
154
|
function setShortCode(shortCode) {
|
|
155
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
|
|
156
|
+
generateThenSetUserID();
|
|
157
157
|
// Validate it is a short code
|
|
158
158
|
const capitalisedShortCode = shortCode.toUpperCase();
|
|
159
159
|
isShortCode(capitalisedShortCode);
|
|
@@ -174,7 +174,12 @@ const DeepLinkIapProvider = ({ children, }) => {
|
|
|
174
174
|
// MARK: Insert Affiliate Identifier
|
|
175
175
|
const setInsertAffiliateIdentifier = (referringLink, completion) => __awaiter(void 0, void 0, void 0, function* () {
|
|
176
176
|
try {
|
|
177
|
-
|
|
177
|
+
try {
|
|
178
|
+
generateThenSetUserID();
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
console.error("[Insert Affiliate] Error setting user ID:", error);
|
|
182
|
+
}
|
|
178
183
|
if (!referringLink) {
|
|
179
184
|
console.warn("[Insert Affiliate] Referring link is invalid.");
|
|
180
185
|
storeInsertAffiliateIdentifier({ link: referringLink });
|
|
@@ -208,7 +213,7 @@ const DeepLinkIapProvider = ({ children, }) => {
|
|
|
208
213
|
return;
|
|
209
214
|
}
|
|
210
215
|
// Create the request URL
|
|
211
|
-
const urlString = `
|
|
216
|
+
const urlString = `https://api.insertaffiliate.com/V1/convert-deep-link-to-short-link?companyId=${companyCode}&deepLinkUrl=${encodedAffiliateLink}`;
|
|
212
217
|
const response = yield axios_1.default.get(urlString, {
|
|
213
218
|
headers: {
|
|
214
219
|
"Content-Type": "application/json",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insert-affiliate-react-native-sdk",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
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",
|
|
@@ -22,11 +22,13 @@
|
|
|
22
22
|
"@types/react": "^18.3.12",
|
|
23
23
|
"@types/react-native": "^0.72.8",
|
|
24
24
|
"axios": "^1.7.7",
|
|
25
|
-
"patch-package": "^8.0.0",
|
|
26
25
|
"react": "^18.3.1",
|
|
27
26
|
"react-native": "^0.76.1",
|
|
28
27
|
"react-native-branch": "^6.4.0",
|
|
29
28
|
"react-native-iap": "^12.15.7",
|
|
30
29
|
"typescript": "^5.6.3"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"patch-package": "^8.0.0"
|
|
31
33
|
}
|
|
32
34
|
}
|
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 `
|
|
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
|
|
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
|
-
|
|
187
|
+
generateThenSetUserID();
|
|
188
188
|
|
|
189
189
|
// Validate it is a short code
|
|
190
190
|
const capitalisedShortCode = shortCode.toUpperCase();
|
|
@@ -211,7 +211,12 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
|
|
|
211
211
|
completion: (shortLink: string | null) => void
|
|
212
212
|
) => {
|
|
213
213
|
try {
|
|
214
|
-
|
|
214
|
+
try {
|
|
215
|
+
generateThenSetUserID();
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.error("[Insert Affiliate] Error setting user ID:", error);
|
|
218
|
+
}
|
|
219
|
+
|
|
215
220
|
|
|
216
221
|
if (!referringLink) {
|
|
217
222
|
console.warn("[Insert Affiliate] Referring link is invalid.");
|
|
@@ -253,7 +258,7 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
|
|
|
253
258
|
}
|
|
254
259
|
|
|
255
260
|
// Create the request URL
|
|
256
|
-
const urlString = `
|
|
261
|
+
const urlString = `https://api.insertaffiliate.com/V1/convert-deep-link-to-short-link?companyId=${companyCode}&deepLinkUrl=${encodedAffiliateLink}`;
|
|
257
262
|
const response = await axios.get(urlString, {
|
|
258
263
|
headers: {
|
|
259
264
|
"Content-Type": "application/json",
|