@fuul/sdk 0.14.0 → 0.16.0
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/lib/cjs/constants.js +6 -1
- package/lib/cjs/index.js +68 -31
- package/lib/cjs/infrastructure/{campaigns/campaignsService.js → conversions/conversionService.js} +5 -5
- package/lib/cjs/types/constants.d.ts +5 -0
- package/lib/cjs/types/constants.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +4 -12
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/infrastructure/conversions/conversionService.d.ts +8 -0
- package/lib/cjs/types/infrastructure/conversions/conversionService.d.ts.map +1 -0
- package/lib/cjs/types/infrastructure/conversions/dtos.d.ts +16 -0
- package/lib/cjs/types/infrastructure/conversions/dtos.d.ts.map +1 -0
- package/lib/cjs/types/types/types.d.ts +6 -7
- package/lib/cjs/types/types/types.d.ts.map +1 -1
- package/lib/cjs/types/utils/localStorage.d.ts +4 -0
- package/lib/cjs/types/utils/localStorage.d.ts.map +1 -1
- package/lib/cjs/utils/localStorage.js +9 -1
- package/lib/esm/constants.js +5 -0
- package/lib/esm/index.mjs +70 -33
- package/lib/esm/infrastructure/{campaigns/campaignsService.js → conversions/conversionService.js} +3 -3
- package/lib/esm/types/constants.d.ts +5 -0
- package/lib/esm/types/constants.d.ts.map +1 -1
- package/lib/esm/types/index.d.ts +4 -12
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/infrastructure/conversions/conversionService.d.ts +8 -0
- package/lib/esm/types/infrastructure/conversions/conversionService.d.ts.map +1 -0
- package/lib/esm/types/infrastructure/conversions/dtos.d.ts +16 -0
- package/lib/esm/types/infrastructure/conversions/dtos.d.ts.map +1 -0
- package/lib/esm/types/types/types.d.ts +6 -7
- package/lib/esm/types/types/types.d.ts.map +1 -1
- package/lib/esm/types/utils/localStorage.d.ts +4 -0
- package/lib/esm/types/utils/localStorage.d.ts.map +1 -1
- package/lib/esm/utils/localStorage.js +5 -1
- package/package.json +1 -1
- package/lib/cjs/types/infrastructure/campaigns/campaignsService.d.ts +0 -8
- package/lib/cjs/types/infrastructure/campaigns/campaignsService.d.ts.map +0 -1
- package/lib/cjs/types/infrastructure/campaigns/dtos.d.ts +0 -32
- package/lib/cjs/types/infrastructure/campaigns/dtos.d.ts.map +0 -1
- package/lib/esm/types/infrastructure/campaigns/campaignsService.d.ts +0 -8
- package/lib/esm/types/infrastructure/campaigns/campaignsService.d.ts.map +0 -1
- package/lib/esm/types/infrastructure/campaigns/dtos.d.ts +0 -32
- package/lib/esm/types/infrastructure/campaigns/dtos.d.ts.map +0 -1
- /package/lib/cjs/infrastructure/{campaigns → conversions}/dtos.js +0 -0
- /package/lib/esm/infrastructure/{campaigns → conversions}/dtos.js +0 -0
package/lib/cjs/constants.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SENT_EVENT_VALIDITY_PERIOD_MS = exports.SENT_EVENT_ID_KEY = exports.REFERRER_ID_KEY = exports.PROJECT_ID_KEY = exports.TRACKING_ID_KEY = exports.SESSION_ID_KEY = void 0;
|
|
3
|
+
exports.SEARCH_ENGINE_URLS = exports.SENT_EVENT_VALIDITY_PERIOD_MS = exports.SENT_EVENT_ID_KEY = exports.TRAFFIC_TAG_KEY = exports.TRAFFIC_TITLE_KEY = exports.TRAFFIC_CATEGORY_KEY = exports.TRAFFIC_SOURCE_KEY = exports.REFERRER_ID_KEY = exports.PROJECT_ID_KEY = exports.TRACKING_ID_KEY = exports.SESSION_ID_KEY = void 0;
|
|
4
4
|
exports.SESSION_ID_KEY = "fuul.session_id";
|
|
5
5
|
exports.TRACKING_ID_KEY = "fuul.tracking_id";
|
|
6
6
|
exports.PROJECT_ID_KEY = "fuul.project_id";
|
|
7
7
|
exports.REFERRER_ID_KEY = "fuul.referrer_id";
|
|
8
|
+
exports.TRAFFIC_SOURCE_KEY = "fuul.traffic_source";
|
|
9
|
+
exports.TRAFFIC_CATEGORY_KEY = "fuul.traffic_category";
|
|
10
|
+
exports.TRAFFIC_TITLE_KEY = "fuul.traffic_title";
|
|
11
|
+
exports.TRAFFIC_TAG_KEY = "fuul.traffic_tag";
|
|
8
12
|
exports.SENT_EVENT_ID_KEY = "fuul.sent";
|
|
9
13
|
exports.SENT_EVENT_VALIDITY_PERIOD_MS = 60000;
|
|
14
|
+
exports.SEARCH_ENGINE_URLS = ["google.com", "bing.com", "yahoo.com"];
|
package/lib/cjs/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const nanoid_1 = require("nanoid");
|
|
|
14
14
|
const localStorage_js_1 = require("./utils/localStorage.js");
|
|
15
15
|
const constants_js_1 = require("./constants.js");
|
|
16
16
|
const HttpClient_js_1 = require("./infrastructure/http/HttpClient.js");
|
|
17
|
-
const
|
|
17
|
+
const conversionService_js_1 = require("./infrastructure/conversions/conversionService.js");
|
|
18
18
|
const saveSentEvent = (eventName, params) => {
|
|
19
19
|
const timestamp = Date.now();
|
|
20
20
|
const SENT_EVENT_KEY = `${constants_js_1.SENT_EVENT_ID_KEY}_${eventName}`;
|
|
@@ -44,35 +44,69 @@ const shouldEventBeSent = (eventName, params) => {
|
|
|
44
44
|
eventArgsMatch =
|
|
45
45
|
parsedEvent["tracking_id"] === params.tracking_id &&
|
|
46
46
|
parsedEvent["project_id"] === params.project_id &&
|
|
47
|
-
parsedEvent["referrer_id"] === params.referrer_id
|
|
47
|
+
parsedEvent["referrer_id"] === params.referrer_id &&
|
|
48
|
+
parsedEvent["source"] === params.source &&
|
|
49
|
+
parsedEvent["category"] === params.category &&
|
|
50
|
+
parsedEvent["title"] === params.title &&
|
|
51
|
+
parsedEvent["tag"] === params.tag;
|
|
48
52
|
}
|
|
49
53
|
return !eventArgsMatch;
|
|
50
54
|
};
|
|
51
55
|
const generateRandomId = () => (0, nanoid_1.nanoid)();
|
|
56
|
+
const isBrowserUndefined = typeof window === "undefined" || typeof document === "undefined";
|
|
52
57
|
const saveSessionId = () => {
|
|
53
|
-
if (
|
|
58
|
+
if (isBrowserUndefined) {
|
|
54
59
|
return;
|
|
60
|
+
}
|
|
55
61
|
localStorage.setItem(constants_js_1.SESSION_ID_KEY, generateRandomId());
|
|
56
62
|
};
|
|
57
63
|
const saveTrackingId = () => {
|
|
58
|
-
|
|
59
|
-
if (typeof window === "undefined" || typeof document === "undefined")
|
|
60
|
-
return;
|
|
61
|
-
const queryParams = new URLSearchParams(window.location.search);
|
|
62
|
-
if (!queryParams.has("p") ||
|
|
63
|
-
!queryParams.has("origin") ||
|
|
64
|
-
!queryParams.has("r"))
|
|
65
|
-
return;
|
|
66
|
-
const isFuulOrigin = queryParams.get("origin") === "fuul";
|
|
67
|
-
if (!isFuulOrigin)
|
|
64
|
+
if (isBrowserUndefined) {
|
|
68
65
|
return;
|
|
66
|
+
}
|
|
69
67
|
if (!(0, localStorage_js_1.getTrackingId)()) {
|
|
70
68
|
localStorage.setItem(constants_js_1.TRACKING_ID_KEY, generateRandomId());
|
|
71
69
|
}
|
|
72
|
-
localStorage.setItem(constants_js_1.REFERRER_ID_KEY, (_a = queryParams.get("r")) !== null && _a !== void 0 ? _a : "");
|
|
73
70
|
};
|
|
74
|
-
const
|
|
75
|
-
|
|
71
|
+
const saveUrlParams = () => {
|
|
72
|
+
var _a, _b, _c;
|
|
73
|
+
if (isBrowserUndefined) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const queryParams = new URLSearchParams(window.location.search);
|
|
77
|
+
saveTrafficSource(queryParams);
|
|
78
|
+
localStorage.setItem(constants_js_1.TRAFFIC_CATEGORY_KEY, (_a = queryParams.get("category")) !== null && _a !== void 0 ? _a : "");
|
|
79
|
+
localStorage.setItem(constants_js_1.TRAFFIC_TITLE_KEY, (_b = queryParams.get("title")) !== null && _b !== void 0 ? _b : "");
|
|
80
|
+
localStorage.setItem(constants_js_1.TRAFFIC_TAG_KEY, (_c = queryParams.get("tag")) !== null && _c !== void 0 ? _c : "");
|
|
81
|
+
};
|
|
82
|
+
const saveTrafficSource = (queryParams) => {
|
|
83
|
+
const trafficSourceParam = queryParams.get("source");
|
|
84
|
+
const referrerParam = queryParams.get("r");
|
|
85
|
+
// if is an affiliate link
|
|
86
|
+
if (referrerParam) {
|
|
87
|
+
localStorage.setItem(constants_js_1.TRAFFIC_SOURCE_KEY, "affiliate");
|
|
88
|
+
localStorage.setItem(constants_js_1.TRAFFIC_CATEGORY_KEY, "affiliate");
|
|
89
|
+
localStorage.setItem(constants_js_1.TRAFFIC_TITLE_KEY, referrerParam);
|
|
90
|
+
localStorage.setItem(constants_js_1.REFERRER_ID_KEY, referrerParam);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// if traffic source is defined
|
|
94
|
+
if (trafficSourceParam) {
|
|
95
|
+
localStorage.setItem(constants_js_1.TRAFFIC_SOURCE_KEY, trafficSourceParam);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// if traffic source is not defined
|
|
99
|
+
const originURL = document.referrer;
|
|
100
|
+
localStorage.setItem(constants_js_1.TRAFFIC_CATEGORY_KEY, originURL);
|
|
101
|
+
localStorage.setItem(constants_js_1.TRAFFIC_TITLE_KEY, originURL);
|
|
102
|
+
// if traffic source is a search engine
|
|
103
|
+
if (constants_js_1.SEARCH_ENGINE_URLS.includes(originURL)) {
|
|
104
|
+
localStorage.setItem(constants_js_1.TRAFFIC_SOURCE_KEY, "organic");
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
// if traffic source is direct
|
|
108
|
+
localStorage.setItem(constants_js_1.TRAFFIC_SOURCE_KEY, "direct");
|
|
109
|
+
}
|
|
76
110
|
};
|
|
77
111
|
class Fuul {
|
|
78
112
|
constructor(apiKey, settings = {}) {
|
|
@@ -82,11 +116,12 @@ class Fuul {
|
|
|
82
116
|
this.checkApiKey();
|
|
83
117
|
saveSessionId();
|
|
84
118
|
saveTrackingId();
|
|
119
|
+
saveUrlParams();
|
|
85
120
|
this.httpClient = new HttpClient_js_1.HttpClient(Object.assign({ baseURL: this.BASE_API_URL, timeout: 10000, apiKey: this.apiKey }, (this.settings.defaultQueryParams &&
|
|
86
121
|
typeof this.settings.defaultQueryParams !== "string" && {
|
|
87
122
|
queryParams: this.settings.defaultQueryParams,
|
|
88
123
|
})));
|
|
89
|
-
this.
|
|
124
|
+
this.conversionService = new conversionService_js_1.ConversionService(this.httpClient);
|
|
90
125
|
this.init();
|
|
91
126
|
}
|
|
92
127
|
init() {
|
|
@@ -140,13 +175,25 @@ class Fuul {
|
|
|
140
175
|
};
|
|
141
176
|
}
|
|
142
177
|
else {
|
|
178
|
+
const source = (0, localStorage_js_1.getTrafficSource)();
|
|
179
|
+
const category = (0, localStorage_js_1.getTrafficCategory)();
|
|
180
|
+
const title = (0, localStorage_js_1.getTrafficTitle)();
|
|
181
|
+
const tag = (0, localStorage_js_1.getTrafficTag)();
|
|
143
182
|
if (!referrer_id)
|
|
144
183
|
return;
|
|
145
|
-
params = Object.assign(Object.assign({}, params), {
|
|
184
|
+
params = Object.assign(Object.assign({}, params), { project_id: args === null || args === void 0 ? void 0 : args.project_id, referrer_id,
|
|
185
|
+
source,
|
|
186
|
+
category,
|
|
187
|
+
title,
|
|
188
|
+
tag });
|
|
146
189
|
reqBody = {
|
|
147
190
|
name,
|
|
148
191
|
session_id,
|
|
149
|
-
event_args: Object.assign(Object.assign({}, args), { referrer: referrer_id, tracking_id
|
|
192
|
+
event_args: Object.assign(Object.assign({}, args), { referrer: referrer_id, tracking_id,
|
|
193
|
+
source,
|
|
194
|
+
category,
|
|
195
|
+
title,
|
|
196
|
+
tag }),
|
|
150
197
|
};
|
|
151
198
|
}
|
|
152
199
|
reqBody = Object.assign(Object.assign(Object.assign({}, reqBody), (signature && {
|
|
@@ -171,19 +218,9 @@ class Fuul {
|
|
|
171
218
|
window.alert("You are successfully connected to Fuul SDK! ✅");
|
|
172
219
|
}
|
|
173
220
|
}
|
|
174
|
-
|
|
175
|
-
* Generates a tracking link for a referrer
|
|
176
|
-
* @param {string} address referrer address
|
|
177
|
-
* @param {string} pid project id you want to refer the user
|
|
178
|
-
* @param {string} baseUrl base url of your app
|
|
179
|
-
* @returns {string} tracking link
|
|
180
|
-
*/
|
|
181
|
-
generateTrackingLink({ address, pid, baseUrl, }) {
|
|
182
|
-
return `${baseUrl !== null && baseUrl !== void 0 ? baseUrl : window.location.href}?${buildTrackingLinkQueryParams(address, pid)}`;
|
|
183
|
-
}
|
|
184
|
-
getAllCampaigns() {
|
|
221
|
+
getAllConversions() {
|
|
185
222
|
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
-
return this.
|
|
223
|
+
return this.conversionService.getAll();
|
|
187
224
|
});
|
|
188
225
|
}
|
|
189
226
|
}
|
package/lib/cjs/infrastructure/{campaigns/campaignsService.js → conversions/conversionService.js}
RENAMED
|
@@ -9,16 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
class
|
|
12
|
+
exports.ConversionService = void 0;
|
|
13
|
+
class ConversionService {
|
|
14
14
|
constructor(httpClient) {
|
|
15
15
|
this.httpClient = httpClient;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
getAll() {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const { data } = yield this.httpClient.get("
|
|
19
|
+
const { data } = yield this.httpClient.get("conversions");
|
|
20
20
|
return data;
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
exports.
|
|
24
|
+
exports.ConversionService = ConversionService;
|
|
@@ -2,6 +2,11 @@ export declare const SESSION_ID_KEY = "fuul.session_id";
|
|
|
2
2
|
export declare const TRACKING_ID_KEY = "fuul.tracking_id";
|
|
3
3
|
export declare const PROJECT_ID_KEY = "fuul.project_id";
|
|
4
4
|
export declare const REFERRER_ID_KEY = "fuul.referrer_id";
|
|
5
|
+
export declare const TRAFFIC_SOURCE_KEY = "fuul.traffic_source";
|
|
6
|
+
export declare const TRAFFIC_CATEGORY_KEY = "fuul.traffic_category";
|
|
7
|
+
export declare const TRAFFIC_TITLE_KEY = "fuul.traffic_title";
|
|
8
|
+
export declare const TRAFFIC_TAG_KEY = "fuul.traffic_tag";
|
|
5
9
|
export declare const SENT_EVENT_ID_KEY = "fuul.sent";
|
|
6
10
|
export declare const SENT_EVENT_VALIDITY_PERIOD_MS = 60000;
|
|
11
|
+
export declare const SEARCH_ENGINE_URLS: string[];
|
|
7
12
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAClD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAClD,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAC7C,eAAO,MAAM,6BAA6B,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAClD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAClD,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AACxD,eAAO,MAAM,oBAAoB,0BAA0B,CAAC;AAC5D,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AACtD,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAClD,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAC7C,eAAO,MAAM,6BAA6B,QAAQ,CAAC;AAEnD,eAAO,MAAM,kBAAkB,UAA0C,CAAC"}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { EventArgsType, EventType, FuulSettings
|
|
2
|
-
import {
|
|
1
|
+
import { EventArgsType, EventType, FuulSettings } from "./types/types.js";
|
|
2
|
+
import { ConversionDTO } from "./infrastructure/conversions/dtos.js";
|
|
3
3
|
export declare class Fuul {
|
|
4
4
|
private readonly apiKey;
|
|
5
5
|
private readonly BASE_API_URL;
|
|
6
6
|
private readonly httpClient;
|
|
7
7
|
private readonly settings;
|
|
8
|
-
private
|
|
8
|
+
private conversionService;
|
|
9
9
|
constructor(apiKey: string, settings?: FuulSettings);
|
|
10
10
|
init(): Promise<void>;
|
|
11
11
|
checkApiKey(): void;
|
|
@@ -29,15 +29,7 @@ export declare class Fuul {
|
|
|
29
29
|
*/
|
|
30
30
|
sendEvent(name: EventType, args?: EventArgsType, signature?: string, signature_message?: string): Promise<any>;
|
|
31
31
|
verifyConnection(): void;
|
|
32
|
-
|
|
33
|
-
* Generates a tracking link for a referrer
|
|
34
|
-
* @param {string} address referrer address
|
|
35
|
-
* @param {string} pid project id you want to refer the user
|
|
36
|
-
* @param {string} baseUrl base url of your app
|
|
37
|
-
* @returns {string} tracking link
|
|
38
|
-
*/
|
|
39
|
-
generateTrackingLink({ address, pid, baseUrl, }: IGenerateTrackingLink): string;
|
|
40
|
-
getAllCampaigns(): Promise<CampaignDTO[]>;
|
|
32
|
+
getAllConversions(): Promise<ConversionDTO[]>;
|
|
41
33
|
}
|
|
42
34
|
declare const _default: {
|
|
43
35
|
Fuul: typeof Fuul;
|
|
@@ -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":"AAyBA,OAAO,EACL,aAAa,EACb,SAAS,EACT,YAAY,EAEb,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AA2HrE,qBAAa,IAAI;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0C;IACvE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IAExC,OAAO,CAAC,iBAAiB,CAAoB;gBAEjC,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,YAAiB;IAwBjD,IAAI;IAQV,WAAW,IAAI,IAAI;IAMnB;;;;;;;;;;;;;;;;;OAiBG;IACG,SAAS,CACb,IAAI,EAAE,SAAS,EACf,IAAI,CAAC,EAAE,aAAa,EACpB,SAAS,CAAC,EAAE,MAAM,EAClB,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,GAAG,CAAC;IAmFf,gBAAgB,IAAI,IAAI;IAMlB,iBAAiB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;CAGpD;;;;AAOD,wBAEE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HttpClient } from "../http/HttpClient.js";
|
|
2
|
+
import { ConversionDTO } from "./dtos.js";
|
|
3
|
+
export declare class ConversionService {
|
|
4
|
+
private httpClient;
|
|
5
|
+
constructor(httpClient: HttpClient);
|
|
6
|
+
getAll(): Promise<ConversionDTO[]>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=conversionService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversionService.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/conversions/conversionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAa;gBAEnB,UAAU,EAAE,UAAU;IAI5B,MAAM,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;CAKzC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Project {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
thumbnail_url: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ConversionDTO {
|
|
7
|
+
id: string;
|
|
8
|
+
payment_currency: string;
|
|
9
|
+
conversion_window: number;
|
|
10
|
+
payment_type: string;
|
|
11
|
+
payment_argument: string;
|
|
12
|
+
referrer_amount: number;
|
|
13
|
+
referral_amount: number;
|
|
14
|
+
attribution_type: string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=dtos.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dtos.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/conversions/dtos.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -12,12 +12,11 @@ export type EventType = "connect_wallet" | "pageview";
|
|
|
12
12
|
export interface SentEventParams {
|
|
13
13
|
tracking_id: string;
|
|
14
14
|
project_id?: string;
|
|
15
|
-
referrer_id?: string;
|
|
16
|
-
address?: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
baseUrl?: string;
|
|
15
|
+
referrer_id?: string | null;
|
|
16
|
+
address?: string | null;
|
|
17
|
+
source?: string | null;
|
|
18
|
+
category?: string | null;
|
|
19
|
+
title?: string | null;
|
|
20
|
+
tag?: string | null;
|
|
22
21
|
}
|
|
23
22
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB"}
|
|
@@ -2,4 +2,8 @@ export declare const getSessionId: () => string | null;
|
|
|
2
2
|
export declare const getTrackingId: () => string | null;
|
|
3
3
|
export declare const getProjectId: () => string | null;
|
|
4
4
|
export declare const getReferrerId: () => string | null;
|
|
5
|
+
export declare const getTrafficSource: () => string | null;
|
|
6
|
+
export declare const getTrafficCategory: () => string | null;
|
|
7
|
+
export declare const getTrafficTitle: () => string | null;
|
|
8
|
+
export declare const getTrafficTag: () => string | null;
|
|
5
9
|
//# sourceMappingURL=localStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localStorage.d.ts","sourceRoot":"","sources":["../../../../src/utils/localStorage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"localStorage.d.ts","sourceRoot":"","sources":["../../../../src/utils/localStorage.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,YAAY,qBAA6C,CAAC;AACvE,eAAO,MAAM,aAAa,qBAA8C,CAAC;AACzE,eAAO,MAAM,YAAY,qBAA6C,CAAC;AACvE,eAAO,MAAM,aAAa,qBAA8C,CAAC;AACzE,eAAO,MAAM,gBAAgB,qBAAiD,CAAC;AAC/E,eAAO,MAAM,kBAAkB,qBACa,CAAC;AAC7C,eAAO,MAAM,eAAe,qBAAgD,CAAC;AAC7E,eAAO,MAAM,aAAa,qBAA8C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getReferrerId = exports.getProjectId = exports.getTrackingId = exports.getSessionId = void 0;
|
|
3
|
+
exports.getTrafficTag = exports.getTrafficTitle = exports.getTrafficCategory = exports.getTrafficSource = exports.getReferrerId = exports.getProjectId = exports.getTrackingId = exports.getSessionId = void 0;
|
|
4
4
|
const constants_js_1 = require("../constants.js");
|
|
5
5
|
const getSessionId = () => localStorage.getItem(constants_js_1.SESSION_ID_KEY);
|
|
6
6
|
exports.getSessionId = getSessionId;
|
|
@@ -10,3 +10,11 @@ const getProjectId = () => localStorage.getItem(constants_js_1.PROJECT_ID_KEY);
|
|
|
10
10
|
exports.getProjectId = getProjectId;
|
|
11
11
|
const getReferrerId = () => localStorage.getItem(constants_js_1.REFERRER_ID_KEY);
|
|
12
12
|
exports.getReferrerId = getReferrerId;
|
|
13
|
+
const getTrafficSource = () => localStorage.getItem(constants_js_1.TRAFFIC_SOURCE_KEY);
|
|
14
|
+
exports.getTrafficSource = getTrafficSource;
|
|
15
|
+
const getTrafficCategory = () => localStorage.getItem(constants_js_1.TRAFFIC_CATEGORY_KEY);
|
|
16
|
+
exports.getTrafficCategory = getTrafficCategory;
|
|
17
|
+
const getTrafficTitle = () => localStorage.getItem(constants_js_1.TRAFFIC_TITLE_KEY);
|
|
18
|
+
exports.getTrafficTitle = getTrafficTitle;
|
|
19
|
+
const getTrafficTag = () => localStorage.getItem(constants_js_1.TRAFFIC_TAG_KEY);
|
|
20
|
+
exports.getTrafficTag = getTrafficTag;
|
package/lib/esm/constants.js
CHANGED
|
@@ -2,5 +2,10 @@ export const SESSION_ID_KEY = "fuul.session_id";
|
|
|
2
2
|
export const TRACKING_ID_KEY = "fuul.tracking_id";
|
|
3
3
|
export const PROJECT_ID_KEY = "fuul.project_id";
|
|
4
4
|
export const REFERRER_ID_KEY = "fuul.referrer_id";
|
|
5
|
+
export const TRAFFIC_SOURCE_KEY = "fuul.traffic_source";
|
|
6
|
+
export const TRAFFIC_CATEGORY_KEY = "fuul.traffic_category";
|
|
7
|
+
export const TRAFFIC_TITLE_KEY = "fuul.traffic_title";
|
|
8
|
+
export const TRAFFIC_TAG_KEY = "fuul.traffic_tag";
|
|
5
9
|
export const SENT_EVENT_ID_KEY = "fuul.sent";
|
|
6
10
|
export const SENT_EVENT_VALIDITY_PERIOD_MS = 60000;
|
|
11
|
+
export const SEARCH_ENGINE_URLS = ["google.com", "bing.com", "yahoo.com"];
|
package/lib/esm/index.mjs
CHANGED
|
@@ -8,10 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { nanoid } from "nanoid";
|
|
11
|
-
import { getReferrerId, getSessionId, getTrackingId, } from "./utils/localStorage.js";
|
|
12
|
-
import { REFERRER_ID_KEY, SENT_EVENT_ID_KEY, SESSION_ID_KEY, TRACKING_ID_KEY, SENT_EVENT_VALIDITY_PERIOD_MS, } from "./constants.js";
|
|
11
|
+
import { getReferrerId, getSessionId, getTrackingId, getTrafficCategory, getTrafficSource, getTrafficTag, getTrafficTitle, } from "./utils/localStorage.js";
|
|
12
|
+
import { REFERRER_ID_KEY, SENT_EVENT_ID_KEY, SESSION_ID_KEY, TRACKING_ID_KEY, SENT_EVENT_VALIDITY_PERIOD_MS, TRAFFIC_SOURCE_KEY, TRAFFIC_CATEGORY_KEY, TRAFFIC_TITLE_KEY, TRAFFIC_TAG_KEY, SEARCH_ENGINE_URLS, } from "./constants.js";
|
|
13
13
|
import { HttpClient } from "./infrastructure/http/HttpClient.js";
|
|
14
|
-
import {
|
|
14
|
+
import { ConversionService } from "./infrastructure/conversions/conversionService.js";
|
|
15
15
|
const saveSentEvent = (eventName, params) => {
|
|
16
16
|
const timestamp = Date.now();
|
|
17
17
|
const SENT_EVENT_KEY = `${SENT_EVENT_ID_KEY}_${eventName}`;
|
|
@@ -41,35 +41,69 @@ const shouldEventBeSent = (eventName, params) => {
|
|
|
41
41
|
eventArgsMatch =
|
|
42
42
|
parsedEvent["tracking_id"] === params.tracking_id &&
|
|
43
43
|
parsedEvent["project_id"] === params.project_id &&
|
|
44
|
-
parsedEvent["referrer_id"] === params.referrer_id
|
|
44
|
+
parsedEvent["referrer_id"] === params.referrer_id &&
|
|
45
|
+
parsedEvent["source"] === params.source &&
|
|
46
|
+
parsedEvent["category"] === params.category &&
|
|
47
|
+
parsedEvent["title"] === params.title &&
|
|
48
|
+
parsedEvent["tag"] === params.tag;
|
|
45
49
|
}
|
|
46
50
|
return !eventArgsMatch;
|
|
47
51
|
};
|
|
48
52
|
const generateRandomId = () => nanoid();
|
|
53
|
+
const isBrowserUndefined = typeof window === "undefined" || typeof document === "undefined";
|
|
49
54
|
const saveSessionId = () => {
|
|
50
|
-
if (
|
|
55
|
+
if (isBrowserUndefined) {
|
|
51
56
|
return;
|
|
57
|
+
}
|
|
52
58
|
localStorage.setItem(SESSION_ID_KEY, generateRandomId());
|
|
53
59
|
};
|
|
54
60
|
const saveTrackingId = () => {
|
|
55
|
-
|
|
56
|
-
if (typeof window === "undefined" || typeof document === "undefined")
|
|
57
|
-
return;
|
|
58
|
-
const queryParams = new URLSearchParams(window.location.search);
|
|
59
|
-
if (!queryParams.has("p") ||
|
|
60
|
-
!queryParams.has("origin") ||
|
|
61
|
-
!queryParams.has("r"))
|
|
62
|
-
return;
|
|
63
|
-
const isFuulOrigin = queryParams.get("origin") === "fuul";
|
|
64
|
-
if (!isFuulOrigin)
|
|
61
|
+
if (isBrowserUndefined) {
|
|
65
62
|
return;
|
|
63
|
+
}
|
|
66
64
|
if (!getTrackingId()) {
|
|
67
65
|
localStorage.setItem(TRACKING_ID_KEY, generateRandomId());
|
|
68
66
|
}
|
|
69
|
-
localStorage.setItem(REFERRER_ID_KEY, (_a = queryParams.get("r")) !== null && _a !== void 0 ? _a : "");
|
|
70
67
|
};
|
|
71
|
-
const
|
|
72
|
-
|
|
68
|
+
const saveUrlParams = () => {
|
|
69
|
+
var _a, _b, _c;
|
|
70
|
+
if (isBrowserUndefined) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const queryParams = new URLSearchParams(window.location.search);
|
|
74
|
+
saveTrafficSource(queryParams);
|
|
75
|
+
localStorage.setItem(TRAFFIC_CATEGORY_KEY, (_a = queryParams.get("category")) !== null && _a !== void 0 ? _a : "");
|
|
76
|
+
localStorage.setItem(TRAFFIC_TITLE_KEY, (_b = queryParams.get("title")) !== null && _b !== void 0 ? _b : "");
|
|
77
|
+
localStorage.setItem(TRAFFIC_TAG_KEY, (_c = queryParams.get("tag")) !== null && _c !== void 0 ? _c : "");
|
|
78
|
+
};
|
|
79
|
+
const saveTrafficSource = (queryParams) => {
|
|
80
|
+
const trafficSourceParam = queryParams.get("source");
|
|
81
|
+
const referrerParam = queryParams.get("r");
|
|
82
|
+
// if is an affiliate link
|
|
83
|
+
if (referrerParam) {
|
|
84
|
+
localStorage.setItem(TRAFFIC_SOURCE_KEY, "affiliate");
|
|
85
|
+
localStorage.setItem(TRAFFIC_CATEGORY_KEY, "affiliate");
|
|
86
|
+
localStorage.setItem(TRAFFIC_TITLE_KEY, referrerParam);
|
|
87
|
+
localStorage.setItem(REFERRER_ID_KEY, referrerParam);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// if traffic source is defined
|
|
91
|
+
if (trafficSourceParam) {
|
|
92
|
+
localStorage.setItem(TRAFFIC_SOURCE_KEY, trafficSourceParam);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// if traffic source is not defined
|
|
96
|
+
const originURL = document.referrer;
|
|
97
|
+
localStorage.setItem(TRAFFIC_CATEGORY_KEY, originURL);
|
|
98
|
+
localStorage.setItem(TRAFFIC_TITLE_KEY, originURL);
|
|
99
|
+
// if traffic source is a search engine
|
|
100
|
+
if (SEARCH_ENGINE_URLS.includes(originURL)) {
|
|
101
|
+
localStorage.setItem(TRAFFIC_SOURCE_KEY, "organic");
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// if traffic source is direct
|
|
105
|
+
localStorage.setItem(TRAFFIC_SOURCE_KEY, "direct");
|
|
106
|
+
}
|
|
73
107
|
};
|
|
74
108
|
export class Fuul {
|
|
75
109
|
constructor(apiKey, settings = {}) {
|
|
@@ -79,11 +113,12 @@ export class Fuul {
|
|
|
79
113
|
this.checkApiKey();
|
|
80
114
|
saveSessionId();
|
|
81
115
|
saveTrackingId();
|
|
116
|
+
saveUrlParams();
|
|
82
117
|
this.httpClient = new HttpClient(Object.assign({ baseURL: this.BASE_API_URL, timeout: 10000, apiKey: this.apiKey }, (this.settings.defaultQueryParams &&
|
|
83
118
|
typeof this.settings.defaultQueryParams !== "string" && {
|
|
84
119
|
queryParams: this.settings.defaultQueryParams,
|
|
85
120
|
})));
|
|
86
|
-
this.
|
|
121
|
+
this.conversionService = new ConversionService(this.httpClient);
|
|
87
122
|
this.init();
|
|
88
123
|
}
|
|
89
124
|
init() {
|
|
@@ -137,13 +172,25 @@ export class Fuul {
|
|
|
137
172
|
};
|
|
138
173
|
}
|
|
139
174
|
else {
|
|
175
|
+
const source = getTrafficSource();
|
|
176
|
+
const category = getTrafficCategory();
|
|
177
|
+
const title = getTrafficTitle();
|
|
178
|
+
const tag = getTrafficTag();
|
|
140
179
|
if (!referrer_id)
|
|
141
180
|
return;
|
|
142
|
-
params = Object.assign(Object.assign({}, params), {
|
|
181
|
+
params = Object.assign(Object.assign({}, params), { project_id: args === null || args === void 0 ? void 0 : args.project_id, referrer_id,
|
|
182
|
+
source,
|
|
183
|
+
category,
|
|
184
|
+
title,
|
|
185
|
+
tag });
|
|
143
186
|
reqBody = {
|
|
144
187
|
name,
|
|
145
188
|
session_id,
|
|
146
|
-
event_args: Object.assign(Object.assign({}, args), { referrer: referrer_id, tracking_id
|
|
189
|
+
event_args: Object.assign(Object.assign({}, args), { referrer: referrer_id, tracking_id,
|
|
190
|
+
source,
|
|
191
|
+
category,
|
|
192
|
+
title,
|
|
193
|
+
tag }),
|
|
147
194
|
};
|
|
148
195
|
}
|
|
149
196
|
reqBody = Object.assign(Object.assign(Object.assign({}, reqBody), (signature && {
|
|
@@ -168,19 +215,9 @@ export class Fuul {
|
|
|
168
215
|
window.alert("You are successfully connected to Fuul SDK! ✅");
|
|
169
216
|
}
|
|
170
217
|
}
|
|
171
|
-
|
|
172
|
-
* Generates a tracking link for a referrer
|
|
173
|
-
* @param {string} address referrer address
|
|
174
|
-
* @param {string} pid project id you want to refer the user
|
|
175
|
-
* @param {string} baseUrl base url of your app
|
|
176
|
-
* @returns {string} tracking link
|
|
177
|
-
*/
|
|
178
|
-
generateTrackingLink({ address, pid, baseUrl, }) {
|
|
179
|
-
return `${baseUrl !== null && baseUrl !== void 0 ? baseUrl : window.location.href}?${buildTrackingLinkQueryParams(address, pid)}`;
|
|
180
|
-
}
|
|
181
|
-
getAllCampaigns() {
|
|
218
|
+
getAllConversions() {
|
|
182
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
-
return this.
|
|
220
|
+
return this.conversionService.getAll();
|
|
184
221
|
});
|
|
185
222
|
}
|
|
186
223
|
}
|
package/lib/esm/infrastructure/{campaigns/campaignsService.js → conversions/conversionService.js}
RENAMED
|
@@ -7,13 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
export class
|
|
10
|
+
export class ConversionService {
|
|
11
11
|
constructor(httpClient) {
|
|
12
12
|
this.httpClient = httpClient;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
getAll() {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const { data } = yield this.httpClient.get("
|
|
16
|
+
const { data } = yield this.httpClient.get("conversions");
|
|
17
17
|
return data;
|
|
18
18
|
});
|
|
19
19
|
}
|
|
@@ -2,6 +2,11 @@ export declare const SESSION_ID_KEY = "fuul.session_id";
|
|
|
2
2
|
export declare const TRACKING_ID_KEY = "fuul.tracking_id";
|
|
3
3
|
export declare const PROJECT_ID_KEY = "fuul.project_id";
|
|
4
4
|
export declare const REFERRER_ID_KEY = "fuul.referrer_id";
|
|
5
|
+
export declare const TRAFFIC_SOURCE_KEY = "fuul.traffic_source";
|
|
6
|
+
export declare const TRAFFIC_CATEGORY_KEY = "fuul.traffic_category";
|
|
7
|
+
export declare const TRAFFIC_TITLE_KEY = "fuul.traffic_title";
|
|
8
|
+
export declare const TRAFFIC_TAG_KEY = "fuul.traffic_tag";
|
|
5
9
|
export declare const SENT_EVENT_ID_KEY = "fuul.sent";
|
|
6
10
|
export declare const SENT_EVENT_VALIDITY_PERIOD_MS = 60000;
|
|
11
|
+
export declare const SEARCH_ENGINE_URLS: string[];
|
|
7
12
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAClD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAClD,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAC7C,eAAO,MAAM,6BAA6B,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAClD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAClD,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AACxD,eAAO,MAAM,oBAAoB,0BAA0B,CAAC;AAC5D,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AACtD,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAClD,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAC7C,eAAO,MAAM,6BAA6B,QAAQ,CAAC;AAEnD,eAAO,MAAM,kBAAkB,UAA0C,CAAC"}
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { EventArgsType, EventType, FuulSettings
|
|
2
|
-
import {
|
|
1
|
+
import { EventArgsType, EventType, FuulSettings } from "./types/types.js";
|
|
2
|
+
import { ConversionDTO } from "./infrastructure/conversions/dtos.js";
|
|
3
3
|
export declare class Fuul {
|
|
4
4
|
private readonly apiKey;
|
|
5
5
|
private readonly BASE_API_URL;
|
|
6
6
|
private readonly httpClient;
|
|
7
7
|
private readonly settings;
|
|
8
|
-
private
|
|
8
|
+
private conversionService;
|
|
9
9
|
constructor(apiKey: string, settings?: FuulSettings);
|
|
10
10
|
init(): Promise<void>;
|
|
11
11
|
checkApiKey(): void;
|
|
@@ -29,15 +29,7 @@ export declare class Fuul {
|
|
|
29
29
|
*/
|
|
30
30
|
sendEvent(name: EventType, args?: EventArgsType, signature?: string, signature_message?: string): Promise<any>;
|
|
31
31
|
verifyConnection(): void;
|
|
32
|
-
|
|
33
|
-
* Generates a tracking link for a referrer
|
|
34
|
-
* @param {string} address referrer address
|
|
35
|
-
* @param {string} pid project id you want to refer the user
|
|
36
|
-
* @param {string} baseUrl base url of your app
|
|
37
|
-
* @returns {string} tracking link
|
|
38
|
-
*/
|
|
39
|
-
generateTrackingLink({ address, pid, baseUrl, }: IGenerateTrackingLink): string;
|
|
40
|
-
getAllCampaigns(): Promise<CampaignDTO[]>;
|
|
32
|
+
getAllConversions(): Promise<ConversionDTO[]>;
|
|
41
33
|
}
|
|
42
34
|
declare const _default: {
|
|
43
35
|
Fuul: typeof Fuul;
|
|
@@ -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":"AAyBA,OAAO,EACL,aAAa,EACb,SAAS,EACT,YAAY,EAEb,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AA2HrE,qBAAa,IAAI;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0C;IACvE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IAExC,OAAO,CAAC,iBAAiB,CAAoB;gBAEjC,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,YAAiB;IAwBjD,IAAI;IAQV,WAAW,IAAI,IAAI;IAMnB;;;;;;;;;;;;;;;;;OAiBG;IACG,SAAS,CACb,IAAI,EAAE,SAAS,EACf,IAAI,CAAC,EAAE,aAAa,EACpB,SAAS,CAAC,EAAE,MAAM,EAClB,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,GAAG,CAAC;IAmFf,gBAAgB,IAAI,IAAI;IAMlB,iBAAiB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;CAGpD;;;;AAOD,wBAEE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HttpClient } from "../http/HttpClient.js";
|
|
2
|
+
import { ConversionDTO } from "./dtos.js";
|
|
3
|
+
export declare class ConversionService {
|
|
4
|
+
private httpClient;
|
|
5
|
+
constructor(httpClient: HttpClient);
|
|
6
|
+
getAll(): Promise<ConversionDTO[]>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=conversionService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversionService.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/conversions/conversionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAa;gBAEnB,UAAU,EAAE,UAAU;IAI5B,MAAM,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;CAKzC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Project {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
thumbnail_url: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ConversionDTO {
|
|
7
|
+
id: string;
|
|
8
|
+
payment_currency: string;
|
|
9
|
+
conversion_window: number;
|
|
10
|
+
payment_type: string;
|
|
11
|
+
payment_argument: string;
|
|
12
|
+
referrer_amount: number;
|
|
13
|
+
referral_amount: number;
|
|
14
|
+
attribution_type: string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=dtos.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dtos.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/conversions/dtos.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -12,12 +12,11 @@ export type EventType = "connect_wallet" | "pageview";
|
|
|
12
12
|
export interface SentEventParams {
|
|
13
13
|
tracking_id: string;
|
|
14
14
|
project_id?: string;
|
|
15
|
-
referrer_id?: string;
|
|
16
|
-
address?: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
baseUrl?: string;
|
|
15
|
+
referrer_id?: string | null;
|
|
16
|
+
address?: string | null;
|
|
17
|
+
source?: string | null;
|
|
18
|
+
category?: string | null;
|
|
19
|
+
title?: string | null;
|
|
20
|
+
tag?: string | null;
|
|
22
21
|
}
|
|
23
22
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB"}
|
|
@@ -2,4 +2,8 @@ export declare const getSessionId: () => string | null;
|
|
|
2
2
|
export declare const getTrackingId: () => string | null;
|
|
3
3
|
export declare const getProjectId: () => string | null;
|
|
4
4
|
export declare const getReferrerId: () => string | null;
|
|
5
|
+
export declare const getTrafficSource: () => string | null;
|
|
6
|
+
export declare const getTrafficCategory: () => string | null;
|
|
7
|
+
export declare const getTrafficTitle: () => string | null;
|
|
8
|
+
export declare const getTrafficTag: () => string | null;
|
|
5
9
|
//# sourceMappingURL=localStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localStorage.d.ts","sourceRoot":"","sources":["../../../../src/utils/localStorage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"localStorage.d.ts","sourceRoot":"","sources":["../../../../src/utils/localStorage.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,YAAY,qBAA6C,CAAC;AACvE,eAAO,MAAM,aAAa,qBAA8C,CAAC;AACzE,eAAO,MAAM,YAAY,qBAA6C,CAAC;AACvE,eAAO,MAAM,aAAa,qBAA8C,CAAC;AACzE,eAAO,MAAM,gBAAgB,qBAAiD,CAAC;AAC/E,eAAO,MAAM,kBAAkB,qBACa,CAAC;AAC7C,eAAO,MAAM,eAAe,qBAAgD,CAAC;AAC7E,eAAO,MAAM,aAAa,qBAA8C,CAAC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { PROJECT_ID_KEY, REFERRER_ID_KEY, SESSION_ID_KEY, TRACKING_ID_KEY, } from "../constants.js";
|
|
1
|
+
import { PROJECT_ID_KEY, REFERRER_ID_KEY, SESSION_ID_KEY, TRACKING_ID_KEY, TRAFFIC_CATEGORY_KEY, TRAFFIC_SOURCE_KEY, TRAFFIC_TAG_KEY, TRAFFIC_TITLE_KEY, } from "../constants.js";
|
|
2
2
|
export const getSessionId = () => localStorage.getItem(SESSION_ID_KEY);
|
|
3
3
|
export const getTrackingId = () => localStorage.getItem(TRACKING_ID_KEY);
|
|
4
4
|
export const getProjectId = () => localStorage.getItem(PROJECT_ID_KEY);
|
|
5
5
|
export const getReferrerId = () => localStorage.getItem(REFERRER_ID_KEY);
|
|
6
|
+
export const getTrafficSource = () => localStorage.getItem(TRAFFIC_SOURCE_KEY);
|
|
7
|
+
export const getTrafficCategory = () => localStorage.getItem(TRAFFIC_CATEGORY_KEY);
|
|
8
|
+
export const getTrafficTitle = () => localStorage.getItem(TRAFFIC_TITLE_KEY);
|
|
9
|
+
export const getTrafficTag = () => localStorage.getItem(TRAFFIC_TAG_KEY);
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "../http/HttpClient.js";
|
|
2
|
-
import { CampaignDTO } from "./dtos.js";
|
|
3
|
-
export declare class CampaignsService {
|
|
4
|
-
private httpClient;
|
|
5
|
-
constructor(httpClient: HttpClient);
|
|
6
|
-
getAllCampaignsByProjectId(): Promise<CampaignDTO[]>;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=campaignsService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"campaignsService.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/campaigns/campaignsService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,UAAU,CAAa;gBAEnB,UAAU,EAAE,UAAU;IAI5B,0BAA0B,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;CAK3D"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface Project {
|
|
2
|
-
id: string;
|
|
3
|
-
name: string;
|
|
4
|
-
thumbnail_url: string;
|
|
5
|
-
}
|
|
6
|
-
export interface ConversionDTO {
|
|
7
|
-
id: string;
|
|
8
|
-
payment_type: string;
|
|
9
|
-
referrer_amount: number;
|
|
10
|
-
referral_amount: number;
|
|
11
|
-
payment_currency: string;
|
|
12
|
-
triggers?: TriggerDTO[];
|
|
13
|
-
}
|
|
14
|
-
export interface TriggerDTO {
|
|
15
|
-
name: string;
|
|
16
|
-
description: string;
|
|
17
|
-
contracts?: ContractDTO[];
|
|
18
|
-
}
|
|
19
|
-
export interface ContractDTO {
|
|
20
|
-
address: string;
|
|
21
|
-
network: string;
|
|
22
|
-
}
|
|
23
|
-
export interface CampaignDTO {
|
|
24
|
-
conversions?: ConversionDTO[];
|
|
25
|
-
id: string;
|
|
26
|
-
name: string;
|
|
27
|
-
project: Project;
|
|
28
|
-
referrer_excerpt?: string;
|
|
29
|
-
url: string;
|
|
30
|
-
user_excerpt?: string;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=dtos.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dtos.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/campaigns/dtos.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "../http/HttpClient.js";
|
|
2
|
-
import { CampaignDTO } from "./dtos.js";
|
|
3
|
-
export declare class CampaignsService {
|
|
4
|
-
private httpClient;
|
|
5
|
-
constructor(httpClient: HttpClient);
|
|
6
|
-
getAllCampaignsByProjectId(): Promise<CampaignDTO[]>;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=campaignsService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"campaignsService.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/campaigns/campaignsService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,UAAU,CAAa;gBAEnB,UAAU,EAAE,UAAU;IAI5B,0BAA0B,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;CAK3D"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface Project {
|
|
2
|
-
id: string;
|
|
3
|
-
name: string;
|
|
4
|
-
thumbnail_url: string;
|
|
5
|
-
}
|
|
6
|
-
export interface ConversionDTO {
|
|
7
|
-
id: string;
|
|
8
|
-
payment_type: string;
|
|
9
|
-
referrer_amount: number;
|
|
10
|
-
referral_amount: number;
|
|
11
|
-
payment_currency: string;
|
|
12
|
-
triggers?: TriggerDTO[];
|
|
13
|
-
}
|
|
14
|
-
export interface TriggerDTO {
|
|
15
|
-
name: string;
|
|
16
|
-
description: string;
|
|
17
|
-
contracts?: ContractDTO[];
|
|
18
|
-
}
|
|
19
|
-
export interface ContractDTO {
|
|
20
|
-
address: string;
|
|
21
|
-
network: string;
|
|
22
|
-
}
|
|
23
|
-
export interface CampaignDTO {
|
|
24
|
-
conversions?: ConversionDTO[];
|
|
25
|
-
id: string;
|
|
26
|
-
name: string;
|
|
27
|
-
project: Project;
|
|
28
|
-
referrer_excerpt?: string;
|
|
29
|
-
url: string;
|
|
30
|
-
user_excerpt?: string;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=dtos.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dtos.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/campaigns/dtos.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
File without changes
|
|
File without changes
|