@fuul/sdk 1.1.5 → 2.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 +21 -43
- package/dist/ConversionService.d.ts +12 -0
- package/dist/ConversionService.d.ts.map +1 -0
- package/dist/EventService.d.ts +18 -0
- package/dist/EventService.d.ts.map +1 -0
- package/dist/{infrastructure/http/HttpClient.d.ts → HttpClient.d.ts} +2 -2
- package/dist/HttpClient.d.ts.map +1 -0
- package/dist/core.d.ts +58 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/index.d.ts +4 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +488 -498
- package/dist/index.umd.js +3 -3
- package/dist/tracking.d.ts +8 -0
- package/dist/tracking.d.ts.map +1 -0
- package/dist/{infrastructure/conversions/dtos.d.ts → types/api.d.ts} +49 -27
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/sdk.d.ts +15 -0
- package/dist/types/sdk.d.ts.map +1 -0
- package/package.json +4 -4
- package/dist/constants.d.ts +0 -13
- package/dist/constants.d.ts.map +0 -1
- package/dist/infrastructure/conversions/conversionService.d.ts +0 -8
- package/dist/infrastructure/conversions/conversionService.d.ts.map +0 -1
- package/dist/infrastructure/conversions/dtos.d.ts.map +0 -1
- package/dist/infrastructure/http/HttpClient.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -42
- package/dist/types/index.d.ts.map +0 -1
- package/dist/utils/events.d.ts +0 -4
- package/dist/utils/events.d.ts.map +0 -1
- package/dist/utils/localStorage.d.ts +0 -14
- package/dist/utils/localStorage.d.ts.map +0 -1
- package/dist/utils/queryParams.d.ts +0 -2
- package/dist/utils/queryParams.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Getting started with Fuul SDK
|
|
2
2
|
|
|
3
|
-
## Installation
|
|
3
|
+
## Installation & minimum set up
|
|
4
4
|
|
|
5
|
-
### 1.
|
|
5
|
+
### 1. Installation
|
|
6
6
|
|
|
7
7
|
Run one of the following commands to add Fuul SDK to your project:
|
|
8
8
|
|
|
@@ -18,67 +18,45 @@ Yarn:
|
|
|
18
18
|
yarn add @fuul/sdk
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
### 2. Set up
|
|
21
|
+
### 2. Set up
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Before using the SDK you must initialize it by supplying your Fuul issued API key.
|
|
24
|
+
|
|
25
|
+
NOTE: Be sure to do this at the root of your app so you have the SDK ready for use just by importing it at the usage point.
|
|
24
26
|
|
|
25
27
|
```tsx
|
|
26
|
-
|
|
27
|
-
apiKey: "your-fuul-api-key"
|
|
28
|
-
};
|
|
28
|
+
import { Fuul } from ('@fuul/sdk');
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Fuul.init({ apiKey: "your-fuul-api-key" });
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
Now you
|
|
34
|
-
|
|
35
|
-
### 3. Test your integration
|
|
33
|
+
Now you can start sending events.
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
### 3. Sending events
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
function main() {
|
|
41
|
-
fuul.verifyConnection();
|
|
42
|
-
}
|
|
43
|
-
main();
|
|
44
|
-
```
|
|
37
|
+
For Fuul to attribute conversion events you'll need to report the "pageview" and "connect wallet" events.
|
|
45
38
|
|
|
46
|
-
### 4. Sending events
|
|
47
|
-
|
|
48
|
-
For Fuul to attribute conversion events to your visitors, you'll need to report the connect_wallet event.
|
|
49
|
-
|
|
50
|
-
#### Connect wallet event
|
|
51
39
|
|
|
52
|
-
|
|
40
|
+
#### Page view event
|
|
53
41
|
|
|
54
|
-
|
|
42
|
+
Projects must send this event every time a user visits a page on their website.
|
|
55
43
|
|
|
56
44
|
```tsx
|
|
57
|
-
|
|
45
|
+
import { Fuul } from ('@fuul/sdk');
|
|
46
|
+
|
|
47
|
+
await Fuul.sendPageview();
|
|
58
48
|
```
|
|
59
49
|
|
|
60
|
-
### Sending Custom Events
|
|
61
50
|
|
|
62
|
-
|
|
51
|
+
#### Connect wallet event
|
|
63
52
|
|
|
64
|
-
|
|
65
|
-
await fuul.sendEvent("my-custom-event", {
|
|
66
|
-
arg1: 'arg1',
|
|
67
|
-
arg2: 'arg2',
|
|
68
|
-
});
|
|
69
|
-
```
|
|
53
|
+
Projects must send this event every time users connect a wallet to their website.
|
|
70
54
|
|
|
71
|
-
|
|
55
|
+
NOTE: Make sure to send the event when connecting a wallet for the first time as well as when changing wallets during the session.
|
|
72
56
|
|
|
73
|
-
You can also generate the tracking link for a given wallet `address` and `project id`
|
|
74
57
|
|
|
75
58
|
```tsx
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const myWonderfulReferrerAddress: string = "0xE8BF39dCd16CF20d39006ba3C722A02e701bf0eE"
|
|
79
|
-
const projectId: string = "79e72760-c730-4422-9e7b-3b730e8800dc"
|
|
80
|
-
|
|
81
|
-
const myTrackingId: string = Fuul.generateTrackingLink(myWonderfulReferrerAddress, projectId);
|
|
59
|
+
import { Fuul } from ('@fuul/sdk');
|
|
82
60
|
|
|
83
|
-
|
|
61
|
+
await Fuul.sendConnectWallet({ userAddress: '0x01' });
|
|
84
62
|
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HttpClient } from './HttpClient';
|
|
2
|
+
import { Conversion } from './types/api';
|
|
3
|
+
export type ConversionServiceSettings = {
|
|
4
|
+
httpClient: HttpClient;
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare class ConversionService {
|
|
8
|
+
private httpClient;
|
|
9
|
+
constructor(settings: ConversionServiceSettings);
|
|
10
|
+
getAll(): Promise<Conversion[]>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ConversionService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConversionService.d.ts","sourceRoot":"","sources":["../../src/ConversionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAa;gBAEnB,QAAQ,EAAE,yBAAyB;IAIzC,MAAM,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;CAKtC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HttpClient } from './HttpClient';
|
|
2
|
+
import { FuulEvent } from './types/api';
|
|
3
|
+
export declare const SENT_EVENT_ID_KEY = "fuul.sent";
|
|
4
|
+
export declare const SENT_EVENT_VALIDITY_PERIOD_SECONDS = 60;
|
|
5
|
+
export type EventServiceSettings = {
|
|
6
|
+
httpClient: HttpClient;
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare class EventService {
|
|
10
|
+
private readonly debug;
|
|
11
|
+
private readonly httpClient;
|
|
12
|
+
constructor(settings: EventServiceSettings);
|
|
13
|
+
sendEvent(event: FuulEvent): Promise<void>;
|
|
14
|
+
isDuplicate(thisEvent: FuulEvent): boolean;
|
|
15
|
+
private getCurrentTimestamp;
|
|
16
|
+
private saveSentEvent;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=EventService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventService.d.ts","sourceRoot":"","sources":["../../src/EventService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAC7C,eAAO,MAAM,kCAAkC,KAAK,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;gBAE5B,QAAQ,EAAE,oBAAoB;IAK7B,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAYhD,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAyCjD,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,aAAa;CAQtB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosResponse
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
2
|
interface HttpClientOptions {
|
|
3
3
|
baseURL: string;
|
|
4
4
|
timeout: number;
|
|
@@ -13,6 +13,7 @@ export declare class HttpClient {
|
|
|
13
13
|
private readonly client;
|
|
14
14
|
private readonly queryParams;
|
|
15
15
|
constructor(options: HttpClientOptions);
|
|
16
|
+
private buildQueryParams;
|
|
16
17
|
get<T>(path: string, params?: any): Promise<AxiosResponse<T>>;
|
|
17
18
|
post<T>(path: string, data: {
|
|
18
19
|
[key: string]: any;
|
|
@@ -21,7 +22,6 @@ export declare class HttpClient {
|
|
|
21
22
|
[key: string]: any;
|
|
22
23
|
}): Promise<AxiosResponse<T>>;
|
|
23
24
|
delete<T>(path: string): Promise<AxiosResponse<T>>;
|
|
24
|
-
_getHeaders(apiKey: string): RawAxiosRequestHeaders;
|
|
25
25
|
}
|
|
26
26
|
export {};
|
|
27
27
|
//# sourceMappingURL=HttpClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/HttpClient.ts"],"names":[],"mappings":"AAAA,OAAc,EAAiB,aAAa,EAA0B,MAAM,OAAO,CAAC;AAEpF,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAEzB,OAAO,EAAE,iBAAiB;IAUtC,OAAO,CAAC,gBAAgB;IAWlB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAI7D,IAAI,CAAC,CAAC,EACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,GACA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAItB,GAAG,CAAC,CAAC,EACT,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,GACA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAItB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAGzD"}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Conversion } from './types/api';
|
|
2
|
+
import { EventArgs, FuulSettings, UserMetadata } from './types/sdk';
|
|
3
|
+
export declare function init(settings: FuulSettings): void;
|
|
4
|
+
/**
|
|
5
|
+
* @param {string} name Event name
|
|
6
|
+
* @param {EventArgs} args Event arguments
|
|
7
|
+
* @param {UserMetadata} userMetadata User metadata
|
|
8
|
+
* @returns {Promise<void>}
|
|
9
|
+
* @example
|
|
10
|
+
* ```js
|
|
11
|
+
* sendEvent('my_event', { value: 10 }, { userAddress: '0x01' })
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function sendEvent(name: string, args?: EventArgs, userMetadata?: UserMetadata): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} pageName Optional page name, default is document.location.pathname
|
|
17
|
+
* @see https://docs.fuul.xyz/technical-guide-for-projects/sending-events-through-the-fuul-sdk#pageview-event
|
|
18
|
+
* @returns {Promise<void>}
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* sendPageview({ page: '/home' })
|
|
22
|
+
* sendPageview({ page: '/product/123' })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function sendPageview(pageName?: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* @param {UserMetadata} userMetadata Metadata from the user that connected the wallet
|
|
28
|
+
* @see https://docs.fuul.xyz/technical-guide-for-projects/sending-events-through-the-fuul-sdk#connect-wallet-event
|
|
29
|
+
* @returns {Promise<void>}
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* sendConnectWallet({
|
|
33
|
+
* userAddress: '0x12345',
|
|
34
|
+
* signature: '0xaad9a0b62f87c15a248cb99ca926785b828b5',
|
|
35
|
+
* signatureMessage: 'Accept referral from Fuul'
|
|
36
|
+
* })
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function sendConnectWallet(userMetadata: UserMetadata): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Generates a tracking link for an affiliate
|
|
42
|
+
* @param {string} landingUrl - Landing URL of your project
|
|
43
|
+
* @param {string} affiliateAddress - Affiliate wallet address
|
|
44
|
+
* @param {string} projectId - Project ID
|
|
45
|
+
* @returns {string} Tracking link
|
|
46
|
+
**/
|
|
47
|
+
export declare function generateTrackingLink(landingUrl: string, affiliateAddress: string, projectId: string): string;
|
|
48
|
+
export declare function getConversions(): Promise<Conversion[]>;
|
|
49
|
+
declare const _default: {
|
|
50
|
+
init: typeof init;
|
|
51
|
+
sendEvent: typeof sendEvent;
|
|
52
|
+
sendPageview: typeof sendPageview;
|
|
53
|
+
sendConnectWallet: typeof sendConnectWallet;
|
|
54
|
+
generateTrackingLink: typeof generateTrackingLink;
|
|
55
|
+
getConversions: typeof getConversions;
|
|
56
|
+
};
|
|
57
|
+
export default _default;
|
|
58
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAWpE,wBAAgB,IAAI,CAAC,QAAQ,EAAE,YAAY,QAoB1C;AAQD;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD1G;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjF;AAED;;;;;;IAMI;AACJ,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5G;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAG5D;;;;;;;;;AAuBD,wBAOE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,50 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
private readonly BASE_API_URL;
|
|
6
|
-
private readonly httpClient;
|
|
7
|
-
private readonly settings;
|
|
8
|
-
private conversionService;
|
|
9
|
-
constructor(apiKey: string, settings?: FuulSettings);
|
|
10
|
-
init(): Promise<void>;
|
|
11
|
-
checkApiKey(): void;
|
|
12
|
-
/**
|
|
13
|
-
* @param {EventType} name Event name.
|
|
14
|
-
* @param {EventArgs} args Event arguments
|
|
15
|
-
* @param {EventMetadata} metadata Event metadata like userAddress, signature, signatureMessage
|
|
16
|
-
* @returns {Promise<void>}
|
|
17
|
-
* @example
|
|
18
|
-
* ```js
|
|
19
|
-
* fuul.sendEvent('my_event', { value: 10 }, { userAddress: '0x01' })
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
sendEvent(name: string, args?: EventArgs, metadata?: EventMetadata): Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* @param {UserMetadata} userMetadata Metadata from the user that is connecting the wallet
|
|
25
|
-
* @see https://docs.fuul.xyz/technical-guide-for-projects/sending-events-through-the-fuul-sdk#connect-wallet-event
|
|
26
|
-
* @returns {Promise<void>}
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* fuul.sendConnectWalletEvent({
|
|
30
|
-
* userAddress: '0x12345',
|
|
31
|
-
* signature: '0xaad9a0b62f87c15a248cb99ca926785b828b5',
|
|
32
|
-
* signatureMessage: 'Accept referral from Fuul'
|
|
33
|
-
* })
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
sendConnectWalletEvent(userMetadata: UserMetadata): Promise<void>;
|
|
37
|
-
verifyConnection(): void;
|
|
38
|
-
/**
|
|
39
|
-
* Generates a tracking link for a referrer
|
|
40
|
-
* @param {Object} trackingLinkParams - Tracking link parameters
|
|
41
|
-
* @param {string} trackingLinkParams.address - Referrer wallet address.
|
|
42
|
-
* @param {string} trackingLinkParams.projectId - Project ID.
|
|
43
|
-
* @param {string} trackingLinkParams.baseUrl - Base URL of your app. Defaults to window.location.href.
|
|
44
|
-
* @returns {string} tracking link
|
|
45
|
-
**/
|
|
46
|
-
generateTrackingLink({ address, projectId, baseUrl }: IGenerateTrackingLink): string;
|
|
47
|
-
getAllConversions(): Promise<ConversionDTO[]>;
|
|
48
|
-
}
|
|
49
|
-
export default Fuul;
|
|
1
|
+
import Fuul from './core';
|
|
2
|
+
export type { Conversion } from './types/api';
|
|
3
|
+
export type { EventArgs, FuulSettings, UserMetadata } from './types/sdk';
|
|
4
|
+
export { Fuul };
|
|
50
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,IAAI,EAAE,CAAC"}
|