@progus/connector 0.7.1 → 0.7.3
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/{crossSell-BdqPj2g7.d.cts → crossSell-DGRqzhbh.d.cts} +10 -2
- package/dist/{crossSell-BdqPj2g7.d.ts → crossSell-DGRqzhbh.d.ts} +10 -2
- package/dist/crossSell.d.cts +1 -1
- package/dist/crossSell.d.ts +1 -1
- package/dist/index.cjs +25 -3
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +25 -3
- package/package.json +1 -1
|
@@ -20,13 +20,20 @@ type ConnectorConfig = {
|
|
|
20
20
|
logger?: Logger;
|
|
21
21
|
enableIdempotency?: boolean;
|
|
22
22
|
};
|
|
23
|
-
type TrackEventName = "installation" | "uninstallation" | "subscription";
|
|
23
|
+
type TrackEventName = "installation" | "uninstallation" | "subscription" | "transaction";
|
|
24
|
+
type TransactionEventData = {
|
|
25
|
+
transactionId: string;
|
|
26
|
+
value: number;
|
|
27
|
+
currency?: string;
|
|
28
|
+
platform?: string;
|
|
29
|
+
};
|
|
24
30
|
type TrackEventParams<TData = Record<string, unknown>> = {
|
|
25
31
|
eventName: TrackEventName | (string & {});
|
|
26
32
|
shopDomain: string;
|
|
27
33
|
partnerId?: string | null;
|
|
28
34
|
data?: TData;
|
|
29
35
|
externalId?: string;
|
|
36
|
+
platform?: string;
|
|
30
37
|
};
|
|
31
38
|
type TrackResult<TData = Record<string, unknown>> = {
|
|
32
39
|
success: boolean;
|
|
@@ -51,6 +58,7 @@ type SubscriptionEventData = {
|
|
|
51
58
|
subscriptionId?: number | string;
|
|
52
59
|
subscriptionPrice?: number | string;
|
|
53
60
|
subscriptionPeriod?: string;
|
|
61
|
+
platform?: string;
|
|
54
62
|
};
|
|
55
63
|
type AppsCatalogEntry = {
|
|
56
64
|
key: string;
|
|
@@ -83,4 +91,4 @@ declare function getCrossSellOffers(options?: CrossSellOptions): AppsCatalogEntr
|
|
|
83
91
|
declare function fetchAppsCatalog(options?: CrossSellFetchOptions): Promise<AppsCatalogEntry[]>;
|
|
84
92
|
declare function getCrossSellOffersFromApi(options?: CrossSellFetchOptions): Promise<AppsCatalogEntry[]>;
|
|
85
93
|
|
|
86
|
-
export { type AssignPartnerIdWithSubscriptionInput as A, type ConnectorConfig as C, type Logger as L, type SubscriptionEventData as S, type TrackEventParams as T, type TrackResult as a, type
|
|
94
|
+
export { type AssignPartnerIdWithSubscriptionInput as A, type ConnectorConfig as C, type Logger as L, type SubscriptionEventData as S, type TrackEventParams as T, type TrackResult as a, type TransactionEventData as b, type CheckPartnerIdResult as c, type ShopifyAdminGraphQLClient as d, getCrossSellOffersFromApi as e, fetchAppsCatalog as f, getCrossSellOffers as g, type AppsCatalogEntry as h, type CrossSellFetchOptions as i, type CrossSellOptions as j, type TrackEventName as k };
|
|
@@ -20,13 +20,20 @@ type ConnectorConfig = {
|
|
|
20
20
|
logger?: Logger;
|
|
21
21
|
enableIdempotency?: boolean;
|
|
22
22
|
};
|
|
23
|
-
type TrackEventName = "installation" | "uninstallation" | "subscription";
|
|
23
|
+
type TrackEventName = "installation" | "uninstallation" | "subscription" | "transaction";
|
|
24
|
+
type TransactionEventData = {
|
|
25
|
+
transactionId: string;
|
|
26
|
+
value: number;
|
|
27
|
+
currency?: string;
|
|
28
|
+
platform?: string;
|
|
29
|
+
};
|
|
24
30
|
type TrackEventParams<TData = Record<string, unknown>> = {
|
|
25
31
|
eventName: TrackEventName | (string & {});
|
|
26
32
|
shopDomain: string;
|
|
27
33
|
partnerId?: string | null;
|
|
28
34
|
data?: TData;
|
|
29
35
|
externalId?: string;
|
|
36
|
+
platform?: string;
|
|
30
37
|
};
|
|
31
38
|
type TrackResult<TData = Record<string, unknown>> = {
|
|
32
39
|
success: boolean;
|
|
@@ -51,6 +58,7 @@ type SubscriptionEventData = {
|
|
|
51
58
|
subscriptionId?: number | string;
|
|
52
59
|
subscriptionPrice?: number | string;
|
|
53
60
|
subscriptionPeriod?: string;
|
|
61
|
+
platform?: string;
|
|
54
62
|
};
|
|
55
63
|
type AppsCatalogEntry = {
|
|
56
64
|
key: string;
|
|
@@ -83,4 +91,4 @@ declare function getCrossSellOffers(options?: CrossSellOptions): AppsCatalogEntr
|
|
|
83
91
|
declare function fetchAppsCatalog(options?: CrossSellFetchOptions): Promise<AppsCatalogEntry[]>;
|
|
84
92
|
declare function getCrossSellOffersFromApi(options?: CrossSellFetchOptions): Promise<AppsCatalogEntry[]>;
|
|
85
93
|
|
|
86
|
-
export { type AssignPartnerIdWithSubscriptionInput as A, type ConnectorConfig as C, type Logger as L, type SubscriptionEventData as S, type TrackEventParams as T, type TrackResult as a, type
|
|
94
|
+
export { type AssignPartnerIdWithSubscriptionInput as A, type ConnectorConfig as C, type Logger as L, type SubscriptionEventData as S, type TrackEventParams as T, type TrackResult as a, type TransactionEventData as b, type CheckPartnerIdResult as c, type ShopifyAdminGraphQLClient as d, getCrossSellOffersFromApi as e, fetchAppsCatalog as f, getCrossSellOffers as g, type AppsCatalogEntry as h, type CrossSellFetchOptions as i, type CrossSellOptions as j, type TrackEventName as k };
|
package/dist/crossSell.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { h as AppsCatalogEntry, i as CrossSellFetchOptions, j as CrossSellOptions, f as fetchAppsCatalog, g as getCrossSellOffers, e as getCrossSellOffersFromApi } from './crossSell-DGRqzhbh.cjs';
|
package/dist/crossSell.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { h as AppsCatalogEntry, i as CrossSellFetchOptions, j as CrossSellOptions, f as fetchAppsCatalog, g as getCrossSellOffers, e as getCrossSellOffersFromApi } from './crossSell-DGRqzhbh.js';
|
package/dist/index.cjs
CHANGED
|
@@ -211,6 +211,7 @@ function createProgusConnector(config) {
|
|
|
211
211
|
trackSubscriptionPurchased: fail,
|
|
212
212
|
trackSubscriptionUpdated: fail,
|
|
213
213
|
trackSubscriptionCancelled: fail,
|
|
214
|
+
trackTransaction: fail,
|
|
214
215
|
assignPartnerIdWithSubscription: fail,
|
|
215
216
|
checkPartnerId: async () => ({ success: false, message, status: 500 })
|
|
216
217
|
};
|
|
@@ -233,6 +234,9 @@ function createProgusConnector(config) {
|
|
|
233
234
|
if (partnerId) {
|
|
234
235
|
requestPayload.partnerId = partnerId;
|
|
235
236
|
}
|
|
237
|
+
if (payload.platform !== void 0) {
|
|
238
|
+
requestPayload.platform = payload.platform;
|
|
239
|
+
}
|
|
236
240
|
if (enableIdempotency) {
|
|
237
241
|
const eventId = buildEventId(shopDomain, String(eventName), externalId);
|
|
238
242
|
if (eventId) {
|
|
@@ -288,11 +292,27 @@ function createProgusConnector(config) {
|
|
|
288
292
|
logger?.info?.("Partner event skipped: missing partnerId required for installation event");
|
|
289
293
|
return { success: false, message: "Missing partnerId" };
|
|
290
294
|
}
|
|
291
|
-
return postEvent("installation", {
|
|
295
|
+
return postEvent("installation", {
|
|
296
|
+
shopDomain: payload.shopDomain,
|
|
297
|
+
partnerId,
|
|
298
|
+
platform: payload.platform
|
|
299
|
+
});
|
|
292
300
|
}
|
|
293
301
|
async function trackUninstall(payload) {
|
|
294
302
|
return postEvent("uninstallation", { shopDomain: payload.shopDomain });
|
|
295
303
|
}
|
|
304
|
+
async function trackTransaction(payload) {
|
|
305
|
+
const { transactionId, value } = payload.data;
|
|
306
|
+
if (!transactionId || typeof value !== "number" || !Number.isFinite(value)) {
|
|
307
|
+
logger?.info?.("Partner event skipped: transaction requires transactionId and numeric value");
|
|
308
|
+
return { success: false, message: "Invalid transaction data: transactionId and value required" };
|
|
309
|
+
}
|
|
310
|
+
return postEvent("transaction", {
|
|
311
|
+
shopDomain: payload.shopDomain,
|
|
312
|
+
data: payload.data,
|
|
313
|
+
externalId: transactionId
|
|
314
|
+
});
|
|
315
|
+
}
|
|
296
316
|
async function trackSubscription(payload) {
|
|
297
317
|
const normalized = normalizeSubscriptionData(payload.data);
|
|
298
318
|
if (!normalized) {
|
|
@@ -369,8 +389,9 @@ function createProgusConnector(config) {
|
|
|
369
389
|
}
|
|
370
390
|
}
|
|
371
391
|
function normalizeSubscriptionData(data) {
|
|
372
|
-
const
|
|
373
|
-
|
|
392
|
+
const rawId = data.subscriptionId;
|
|
393
|
+
const subscriptionId = rawId != null && rawId !== "" ? typeof rawId === "number" && Number.isFinite(rawId) ? rawId : String(rawId) : null;
|
|
394
|
+
if (subscriptionId === null) {
|
|
374
395
|
return null;
|
|
375
396
|
}
|
|
376
397
|
const subscriptionPrice = Number(data.subscriptionPrice);
|
|
@@ -397,6 +418,7 @@ function createProgusConnector(config) {
|
|
|
397
418
|
trackSubscriptionPurchased: trackSubscription,
|
|
398
419
|
trackSubscriptionUpdated: trackSubscription,
|
|
399
420
|
trackSubscriptionCancelled: trackSubscription,
|
|
421
|
+
trackTransaction,
|
|
400
422
|
assignPartnerIdWithSubscription,
|
|
401
423
|
checkPartnerId
|
|
402
424
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { C as ConnectorConfig, T as TrackEventParams, a as TrackResult, S as SubscriptionEventData, A as AssignPartnerIdWithSubscriptionInput,
|
|
2
|
-
export {
|
|
1
|
+
import { C as ConnectorConfig, T as TrackEventParams, a as TrackResult, S as SubscriptionEventData, b as TransactionEventData, A as AssignPartnerIdWithSubscriptionInput, c as CheckPartnerIdResult, d as ShopifyAdminGraphQLClient } from './crossSell-DGRqzhbh.cjs';
|
|
2
|
+
export { h as AppsCatalogEntry, i as CrossSellFetchOptions, j as CrossSellOptions, L as Logger, k as TrackEventName, f as fetchAppsCatalog, g as getCrossSellOffers, e as getCrossSellOffersFromApi } from './crossSell-DGRqzhbh.cjs';
|
|
3
3
|
|
|
4
4
|
type Connector = {
|
|
5
5
|
track: (eventName: TrackEventParams["eventName"], payload: Omit<TrackEventParams, "eventName">) => Promise<TrackResult>;
|
|
6
6
|
trackInstall: (payload: {
|
|
7
7
|
shopDomain: string;
|
|
8
8
|
partnerId?: string | null;
|
|
9
|
+
platform?: string;
|
|
9
10
|
}) => Promise<TrackResult>;
|
|
10
11
|
trackUninstall: (payload: {
|
|
11
12
|
shopDomain: string;
|
|
@@ -22,6 +23,10 @@ type Connector = {
|
|
|
22
23
|
shopDomain: string;
|
|
23
24
|
data: SubscriptionEventData;
|
|
24
25
|
}) => Promise<TrackResult>;
|
|
26
|
+
trackTransaction: (payload: {
|
|
27
|
+
shopDomain: string;
|
|
28
|
+
data: TransactionEventData;
|
|
29
|
+
}) => Promise<TrackResult>;
|
|
25
30
|
assignPartnerIdWithSubscription: (payload: AssignPartnerIdWithSubscriptionInput) => Promise<TrackResult & {
|
|
26
31
|
partnerId?: string;
|
|
27
32
|
}>;
|
|
@@ -39,4 +44,4 @@ declare function signPayload(body: string, secret: string): string;
|
|
|
39
44
|
|
|
40
45
|
declare function normalizePartnerId(value?: string | null): string | null;
|
|
41
46
|
|
|
42
|
-
export { AssignPartnerIdWithSubscriptionInput, CheckPartnerIdResult, ConnectorConfig, ShopifyAdminGraphQLClient, SubscriptionEventData, TrackEventParams, TrackResult, createProgusConnector, fetchActiveSubscriptionEventData, normalizePartnerId, signPayload };
|
|
47
|
+
export { AssignPartnerIdWithSubscriptionInput, CheckPartnerIdResult, ConnectorConfig, ShopifyAdminGraphQLClient, SubscriptionEventData, TrackEventParams, TrackResult, TransactionEventData, createProgusConnector, fetchActiveSubscriptionEventData, normalizePartnerId, signPayload };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { C as ConnectorConfig, T as TrackEventParams, a as TrackResult, S as SubscriptionEventData, A as AssignPartnerIdWithSubscriptionInput,
|
|
2
|
-
export {
|
|
1
|
+
import { C as ConnectorConfig, T as TrackEventParams, a as TrackResult, S as SubscriptionEventData, b as TransactionEventData, A as AssignPartnerIdWithSubscriptionInput, c as CheckPartnerIdResult, d as ShopifyAdminGraphQLClient } from './crossSell-DGRqzhbh.js';
|
|
2
|
+
export { h as AppsCatalogEntry, i as CrossSellFetchOptions, j as CrossSellOptions, L as Logger, k as TrackEventName, f as fetchAppsCatalog, g as getCrossSellOffers, e as getCrossSellOffersFromApi } from './crossSell-DGRqzhbh.js';
|
|
3
3
|
|
|
4
4
|
type Connector = {
|
|
5
5
|
track: (eventName: TrackEventParams["eventName"], payload: Omit<TrackEventParams, "eventName">) => Promise<TrackResult>;
|
|
6
6
|
trackInstall: (payload: {
|
|
7
7
|
shopDomain: string;
|
|
8
8
|
partnerId?: string | null;
|
|
9
|
+
platform?: string;
|
|
9
10
|
}) => Promise<TrackResult>;
|
|
10
11
|
trackUninstall: (payload: {
|
|
11
12
|
shopDomain: string;
|
|
@@ -22,6 +23,10 @@ type Connector = {
|
|
|
22
23
|
shopDomain: string;
|
|
23
24
|
data: SubscriptionEventData;
|
|
24
25
|
}) => Promise<TrackResult>;
|
|
26
|
+
trackTransaction: (payload: {
|
|
27
|
+
shopDomain: string;
|
|
28
|
+
data: TransactionEventData;
|
|
29
|
+
}) => Promise<TrackResult>;
|
|
25
30
|
assignPartnerIdWithSubscription: (payload: AssignPartnerIdWithSubscriptionInput) => Promise<TrackResult & {
|
|
26
31
|
partnerId?: string;
|
|
27
32
|
}>;
|
|
@@ -39,4 +44,4 @@ declare function signPayload(body: string, secret: string): string;
|
|
|
39
44
|
|
|
40
45
|
declare function normalizePartnerId(value?: string | null): string | null;
|
|
41
46
|
|
|
42
|
-
export { AssignPartnerIdWithSubscriptionInput, CheckPartnerIdResult, ConnectorConfig, ShopifyAdminGraphQLClient, SubscriptionEventData, TrackEventParams, TrackResult, createProgusConnector, fetchActiveSubscriptionEventData, normalizePartnerId, signPayload };
|
|
47
|
+
export { AssignPartnerIdWithSubscriptionInput, CheckPartnerIdResult, ConnectorConfig, ShopifyAdminGraphQLClient, SubscriptionEventData, TrackEventParams, TrackResult, TransactionEventData, createProgusConnector, fetchActiveSubscriptionEventData, normalizePartnerId, signPayload };
|
package/dist/index.js
CHANGED
|
@@ -168,6 +168,7 @@ function createProgusConnector(config) {
|
|
|
168
168
|
trackSubscriptionPurchased: fail,
|
|
169
169
|
trackSubscriptionUpdated: fail,
|
|
170
170
|
trackSubscriptionCancelled: fail,
|
|
171
|
+
trackTransaction: fail,
|
|
171
172
|
assignPartnerIdWithSubscription: fail,
|
|
172
173
|
checkPartnerId: async () => ({ success: false, message, status: 500 })
|
|
173
174
|
};
|
|
@@ -190,6 +191,9 @@ function createProgusConnector(config) {
|
|
|
190
191
|
if (partnerId) {
|
|
191
192
|
requestPayload.partnerId = partnerId;
|
|
192
193
|
}
|
|
194
|
+
if (payload.platform !== void 0) {
|
|
195
|
+
requestPayload.platform = payload.platform;
|
|
196
|
+
}
|
|
193
197
|
if (enableIdempotency) {
|
|
194
198
|
const eventId = buildEventId(shopDomain, String(eventName), externalId);
|
|
195
199
|
if (eventId) {
|
|
@@ -245,11 +249,27 @@ function createProgusConnector(config) {
|
|
|
245
249
|
logger?.info?.("Partner event skipped: missing partnerId required for installation event");
|
|
246
250
|
return { success: false, message: "Missing partnerId" };
|
|
247
251
|
}
|
|
248
|
-
return postEvent("installation", {
|
|
252
|
+
return postEvent("installation", {
|
|
253
|
+
shopDomain: payload.shopDomain,
|
|
254
|
+
partnerId,
|
|
255
|
+
platform: payload.platform
|
|
256
|
+
});
|
|
249
257
|
}
|
|
250
258
|
async function trackUninstall(payload) {
|
|
251
259
|
return postEvent("uninstallation", { shopDomain: payload.shopDomain });
|
|
252
260
|
}
|
|
261
|
+
async function trackTransaction(payload) {
|
|
262
|
+
const { transactionId, value } = payload.data;
|
|
263
|
+
if (!transactionId || typeof value !== "number" || !Number.isFinite(value)) {
|
|
264
|
+
logger?.info?.("Partner event skipped: transaction requires transactionId and numeric value");
|
|
265
|
+
return { success: false, message: "Invalid transaction data: transactionId and value required" };
|
|
266
|
+
}
|
|
267
|
+
return postEvent("transaction", {
|
|
268
|
+
shopDomain: payload.shopDomain,
|
|
269
|
+
data: payload.data,
|
|
270
|
+
externalId: transactionId
|
|
271
|
+
});
|
|
272
|
+
}
|
|
253
273
|
async function trackSubscription(payload) {
|
|
254
274
|
const normalized = normalizeSubscriptionData(payload.data);
|
|
255
275
|
if (!normalized) {
|
|
@@ -326,8 +346,9 @@ function createProgusConnector(config) {
|
|
|
326
346
|
}
|
|
327
347
|
}
|
|
328
348
|
function normalizeSubscriptionData(data) {
|
|
329
|
-
const
|
|
330
|
-
|
|
349
|
+
const rawId = data.subscriptionId;
|
|
350
|
+
const subscriptionId = rawId != null && rawId !== "" ? typeof rawId === "number" && Number.isFinite(rawId) ? rawId : String(rawId) : null;
|
|
351
|
+
if (subscriptionId === null) {
|
|
331
352
|
return null;
|
|
332
353
|
}
|
|
333
354
|
const subscriptionPrice = Number(data.subscriptionPrice);
|
|
@@ -354,6 +375,7 @@ function createProgusConnector(config) {
|
|
|
354
375
|
trackSubscriptionPurchased: trackSubscription,
|
|
355
376
|
trackSubscriptionUpdated: trackSubscription,
|
|
356
377
|
trackSubscriptionCancelled: trackSubscription,
|
|
378
|
+
trackTransaction,
|
|
357
379
|
assignPartnerIdWithSubscription,
|
|
358
380
|
checkPartnerId
|
|
359
381
|
};
|