insert-affiliate-js-sdk 1.0.0 → 1.0.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/README.md CHANGED
@@ -179,7 +179,7 @@ async function trackSignupEvent() {
179
179
 
180
180
  ### What are Short Codes?
181
181
 
182
- Short codes are unique, 10-character alphanumeric identifiers that affiliates can use to promote products or subscriptions. These codes are ideal for influencers or partners, making them easier to share than long URLs.
182
+ Short codes are unique, 3 to 25 character alphanumeric identifiers that affiliates can use to promote products or subscriptions. These codes are ideal for influencers or partners, making them easier to share than long URLs.
183
183
 
184
184
  **Example Use Case**: An influencer promotes a subscription with the short code "JOIN123456" within their TikTok video's description. When users enter this code within your app during sign-up or before purchase, the app tracks the subscription back to the influencer for commission payouts.
185
185
 
@@ -190,7 +190,7 @@ For more information, visit the [Insert Affiliate Short Codes Documentation](htt
190
190
  Use the `setShortCode` method to associate a short code with an affiliate. This is ideal for scenarios where users enter the code via an input field, pop-up, or similar UI element.
191
191
 
192
192
  Short codes must meet the following criteria:
193
- - Exactly **10 characters long**.
193
+ - Between **3 and 25 characters long**.
194
194
  - Contain only **letters and numbers** (alphanumeric characters).
195
195
  - Replace {{ user_entered_short_code }} with the short code the user enters through your chosen input method, i.e. an input field / pop up element
196
196
 
package/dist/index.js CHANGED
@@ -112,11 +112,19 @@ var InsertAffiliate = class {
112
112
  console.warn("[Insert Affiliate] No affiliate identifier found.");
113
113
  return;
114
114
  }
115
+ const companyCode = this.companyCode || await getValue("companyCode");
116
+ if (!companyCode) return;
115
117
  try {
116
118
  await fetch("https://api.insertaffiliate.com/v1/trackEvent", {
117
119
  method: "POST",
118
120
  headers: { "Content-Type": "application/json" },
119
- body: JSON.stringify({ eventName, deepLinkParam: id })
121
+ body: JSON.stringify(
122
+ {
123
+ eventName,
124
+ deepLinkParam: id,
125
+ companyId: companyCode
126
+ }
127
+ )
120
128
  });
121
129
  console.log("[Insert Affiliate] Event tracked:", eventName);
122
130
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "insert-affiliate-js-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -64,16 +64,26 @@ export class InsertAffiliate {
64
64
 
65
65
  static async trackEvent(eventName: string): Promise<void> {
66
66
  const id = await this.returnInsertAffiliateIdentifier();
67
+
67
68
  if (!id) {
68
69
  console.warn('[Insert Affiliate] No affiliate identifier found.');
69
70
  return;
70
71
  }
71
72
 
73
+ const companyCode = this.companyCode || await getValue('companyCode');
74
+
75
+ if (!companyCode) return;
76
+
72
77
  try {
73
78
  await fetch('https://api.insertaffiliate.com/v1/trackEvent', {
74
79
  method: 'POST',
75
80
  headers: { 'Content-Type': 'application/json' },
76
- body: JSON.stringify({ eventName, deepLinkParam: id }),
81
+ body: JSON.stringify(
82
+ {
83
+ eventName,
84
+ deepLinkParam: id,
85
+ companyId: companyCode,
86
+ }),
77
87
  });
78
88
  console.log('[Insert Affiliate] Event tracked:', eventName);
79
89
  } catch (err) {