@formo/analytics 1.11.0 → 1.11.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 +2 -1
- package/package.json +1 -1
- package/src/FormoAnalytics.ts +4 -2
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ Add the following to your `index.html`:
|
|
|
17
17
|
FormoAnalytics.init(apiKey, projectId).then(
|
|
18
18
|
(sdkInstance) => (window.formo = sdkInstance)
|
|
19
19
|
);
|
|
20
|
+
window.formo.trackPageHit();
|
|
20
21
|
};
|
|
21
22
|
document.head.appendChild(script);
|
|
22
23
|
</script>
|
|
@@ -123,7 +124,7 @@ export default function RootLayout({
|
|
|
123
124
|
```
|
|
124
125
|
|
|
125
126
|
### 4. Using the SDK
|
|
126
|
-
|
|
127
|
+
|
|
127
128
|
Once the SDK is initialized, you can use its methods to track events and user interactions. Here’s how to do that:
|
|
128
129
|
|
|
129
130
|
```jsx
|
package/package.json
CHANGED
package/src/FormoAnalytics.ts
CHANGED
|
@@ -21,8 +21,8 @@ export class FormoAnalytics implements IFormoAnalytics {
|
|
|
21
21
|
this.config = {
|
|
22
22
|
token: this.apiKey,
|
|
23
23
|
};
|
|
24
|
-
this.trackPageHit();
|
|
25
24
|
}
|
|
25
|
+
|
|
26
26
|
static async init(
|
|
27
27
|
apiKey: string,
|
|
28
28
|
projectId: string
|
|
@@ -94,6 +94,8 @@ export class FormoAnalytics implements IFormoAnalytics {
|
|
|
94
94
|
payload: isNotEmpty(payload) ? this.maskSensitiveData(payload) : payload,
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
+
console.log(`Request data: ${JSON.stringify(requestData)}`);
|
|
98
|
+
|
|
97
99
|
const sendRequest = async (): Promise<void> => {
|
|
98
100
|
try {
|
|
99
101
|
const response = await axios.post(apiUrl, JSON.stringify(requestData), {
|
|
@@ -109,7 +111,7 @@ export class FormoAnalytics implements IFormoAnalytics {
|
|
|
109
111
|
}
|
|
110
112
|
} catch (error) {
|
|
111
113
|
attempt++;
|
|
112
|
-
|
|
114
|
+
|
|
113
115
|
if (attempt <= maxRetries) {
|
|
114
116
|
const retryDelay = Math.pow(2, attempt) * 1000;
|
|
115
117
|
console.error(
|