@timardex/cluemart-shared 2.5.0 → 2.5.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/dist/{ad-DRI2CIzV.d.ts → ad-C7GbDyUi.d.ts} +1 -1
- package/dist/{ad-BSyVGv8q.d.mts → ad-DB9gvcJW.d.mts} +1 -1
- package/dist/{chunk-L4NHGGT7.mjs → chunk-H6HM2FOZ.mjs} +2 -2
- package/dist/{chunk-DEK7NF3O.mjs → chunk-NEOBS55J.mjs} +1 -1
- package/dist/{chunk-2RHUGVV3.mjs → chunk-WOBG6I4T.mjs} +175 -12
- package/dist/chunk-WOBG6I4T.mjs.map +1 -0
- package/dist/chunk-YCUKTVVA.mjs +69 -0
- package/dist/chunk-YCUKTVVA.mjs.map +1 -0
- package/dist/formFields/index.mjs +3 -3
- package/dist/graphql/index.cjs +193 -13
- package/dist/graphql/index.cjs.map +1 -1
- package/dist/graphql/index.d.mts +46 -3
- package/dist/graphql/index.d.ts +46 -3
- package/dist/graphql/index.mjs +8 -2
- package/dist/hooks/index.cjs +23 -13
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.mjs +4 -4
- package/dist/index.cjs +209 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +61 -2
- package/dist/index.d.ts +61 -2
- package/dist/index.mjs +196 -9
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.cjs +34 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.mts +17 -1
- package/dist/utils/index.d.ts +17 -1
- package/dist/utils/index.mjs +15 -3
- package/package.json +1 -1
- package/dist/chunk-2RHUGVV3.mjs.map +0 -1
- package/dist/chunk-7DQBUZXY.mjs +0 -41
- package/dist/chunk-7DQBUZXY.mjs.map +0 -1
- /package/dist/{chunk-L4NHGGT7.mjs.map → chunk-H6HM2FOZ.mjs.map} +0 -0
- /package/dist/{chunk-DEK7NF3O.mjs.map → chunk-NEOBS55J.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -2874,6 +2874,28 @@ function isTransientNetworkError(err) {
|
|
|
2874
2874
|
return TRANSIENT_NETWORK_PATTERNS.some((pattern) => pattern.test(message));
|
|
2875
2875
|
}
|
|
2876
2876
|
|
|
2877
|
+
// src/utils/adMetrics.ts
|
|
2878
|
+
var AD_METRIC_ROTATION_INTERVAL_MS = 8e3;
|
|
2879
|
+
var AD_METRIC_IMPRESSION_RETRY_DELAY_MS = 1e3;
|
|
2880
|
+
function getAdMetricRotationSlot(epochMilliseconds) {
|
|
2881
|
+
return Math.floor(epochMilliseconds / AD_METRIC_ROTATION_INTERVAL_MS);
|
|
2882
|
+
}
|
|
2883
|
+
function getAdMetricRotationIndex(epochMilliseconds, count) {
|
|
2884
|
+
if (count <= 0) return 0;
|
|
2885
|
+
return getAdMetricRotationSlot(epochMilliseconds) % count;
|
|
2886
|
+
}
|
|
2887
|
+
function buildAdMetricSlotKey(adId, placement, slot) {
|
|
2888
|
+
return `${adId}:${placement}:${slot}`;
|
|
2889
|
+
}
|
|
2890
|
+
function generateAdClickId() {
|
|
2891
|
+
const cryptoApi = globalThis.crypto;
|
|
2892
|
+
if (typeof cryptoApi?.randomUUID === "function") {
|
|
2893
|
+
return cryptoApi.randomUUID();
|
|
2894
|
+
}
|
|
2895
|
+
const randomPart = Math.random().toString(36).slice(2) || "0";
|
|
2896
|
+
return `click-${Date.now()}-${randomPart}`;
|
|
2897
|
+
}
|
|
2898
|
+
|
|
2877
2899
|
// src/utils/billingCatalog/index.ts
|
|
2878
2900
|
var BILLING_CATALOG_KEYS = [
|
|
2879
2901
|
"pro_vendor_monthly",
|
|
@@ -7239,6 +7261,7 @@ var useGetUsersByPromoCode = (promoCode, options) => {
|
|
|
7239
7261
|
|
|
7240
7262
|
// src/graphql/hooks/ad/hooksMutation.ts
|
|
7241
7263
|
import { useMutation as useMutation12 } from "@apollo/client";
|
|
7264
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
7242
7265
|
|
|
7243
7266
|
// src/graphql/mutations/ad.ts
|
|
7244
7267
|
import { gql as gql27 } from "@apollo/client";
|
|
@@ -7404,6 +7427,15 @@ var GET_AD_SETTINGS = gql28`
|
|
|
7404
7427
|
}
|
|
7405
7428
|
}
|
|
7406
7429
|
`;
|
|
7430
|
+
var GET_AD_METRIC_TOTALS = gql28`
|
|
7431
|
+
query getAdMetricTotals($filter: AdMetricTotalsFilterInputGraphQLType) {
|
|
7432
|
+
adMetricTotals(filter: $filter) {
|
|
7433
|
+
adId
|
|
7434
|
+
clicks
|
|
7435
|
+
impressions
|
|
7436
|
+
}
|
|
7437
|
+
}
|
|
7438
|
+
`;
|
|
7407
7439
|
|
|
7408
7440
|
// src/graphql/mutations/adBooking.ts
|
|
7409
7441
|
var CREATE_AD_CHECKOUT_MUTATION = gql29`
|
|
@@ -7520,14 +7552,147 @@ var useRecordAdClick = () => {
|
|
|
7520
7552
|
recordAdClick
|
|
7521
7553
|
};
|
|
7522
7554
|
};
|
|
7555
|
+
var defaultAdMetricErrorHandler = (message, error) => {
|
|
7556
|
+
console.error(message, error);
|
|
7557
|
+
};
|
|
7558
|
+
var useAdMetricsReporter = (input, onError = defaultAdMetricErrorHandler) => {
|
|
7559
|
+
const { recordAdImpression } = useRecordAdImpression();
|
|
7560
|
+
const { recordAdClick } = useRecordAdClick();
|
|
7561
|
+
const reportedSlotRef = useRef({
|
|
7562
|
+
keys: /* @__PURE__ */ new Set(),
|
|
7563
|
+
slot: -1
|
|
7564
|
+
});
|
|
7565
|
+
const inFlightRef = useRef(false);
|
|
7566
|
+
const disposedRef = useRef(false);
|
|
7567
|
+
const safeOnError = useCallback(
|
|
7568
|
+
(message, error) => {
|
|
7569
|
+
try {
|
|
7570
|
+
onError(message, error);
|
|
7571
|
+
} catch {
|
|
7572
|
+
}
|
|
7573
|
+
},
|
|
7574
|
+
[onError]
|
|
7575
|
+
);
|
|
7576
|
+
useEffect(() => {
|
|
7577
|
+
disposedRef.current = false;
|
|
7578
|
+
return () => {
|
|
7579
|
+
disposedRef.current = true;
|
|
7580
|
+
};
|
|
7581
|
+
}, []);
|
|
7582
|
+
const reportImpression = useCallback(
|
|
7583
|
+
async (opts) => {
|
|
7584
|
+
if (inFlightRef.current || disposedRef.current) return false;
|
|
7585
|
+
const now = opts?.nowMs ?? Date.now();
|
|
7586
|
+
const slot = getAdMetricRotationSlot(now);
|
|
7587
|
+
const key = buildAdMetricSlotKey(input.adId, input.placement, slot);
|
|
7588
|
+
const reported = reportedSlotRef.current;
|
|
7589
|
+
if (reported.slot !== slot) {
|
|
7590
|
+
reported.slot = slot;
|
|
7591
|
+
reported.keys.clear();
|
|
7592
|
+
}
|
|
7593
|
+
if (reported.keys.has(key)) return false;
|
|
7594
|
+
inFlightRef.current = true;
|
|
7595
|
+
try {
|
|
7596
|
+
const result = await recordAdImpression({
|
|
7597
|
+
variables: {
|
|
7598
|
+
input: {
|
|
7599
|
+
adId: input.adId,
|
|
7600
|
+
placement: input.placement,
|
|
7601
|
+
platform: input.platform,
|
|
7602
|
+
region: input.region
|
|
7603
|
+
}
|
|
7604
|
+
}
|
|
7605
|
+
});
|
|
7606
|
+
if (result.data?.recordAdImpression?.data !== true) {
|
|
7607
|
+
return false;
|
|
7608
|
+
}
|
|
7609
|
+
reported.keys.add(key);
|
|
7610
|
+
return true;
|
|
7611
|
+
} catch (error) {
|
|
7612
|
+
safeOnError(
|
|
7613
|
+
"Ad impression report failed; retrying within the rotation.",
|
|
7614
|
+
error
|
|
7615
|
+
);
|
|
7616
|
+
if (!disposedRef.current && getAdMetricRotationSlot(Date.now()) === slot) {
|
|
7617
|
+
await new Promise(
|
|
7618
|
+
(resolve) => setTimeout(resolve, AD_METRIC_IMPRESSION_RETRY_DELAY_MS)
|
|
7619
|
+
);
|
|
7620
|
+
if (!disposedRef.current && getAdMetricRotationSlot(Date.now()) === slot) {
|
|
7621
|
+
try {
|
|
7622
|
+
const retryResult = await recordAdImpression({
|
|
7623
|
+
variables: {
|
|
7624
|
+
input: {
|
|
7625
|
+
adId: input.adId,
|
|
7626
|
+
placement: input.placement,
|
|
7627
|
+
platform: input.platform,
|
|
7628
|
+
region: input.region
|
|
7629
|
+
}
|
|
7630
|
+
}
|
|
7631
|
+
});
|
|
7632
|
+
if (retryResult.data?.recordAdImpression?.data !== true) {
|
|
7633
|
+
return false;
|
|
7634
|
+
}
|
|
7635
|
+
reported.keys.add(key);
|
|
7636
|
+
return true;
|
|
7637
|
+
} catch (retryError) {
|
|
7638
|
+
safeOnError("Ad impression retry failed.", retryError);
|
|
7639
|
+
}
|
|
7640
|
+
}
|
|
7641
|
+
}
|
|
7642
|
+
return false;
|
|
7643
|
+
} finally {
|
|
7644
|
+
inFlightRef.current = false;
|
|
7645
|
+
}
|
|
7646
|
+
},
|
|
7647
|
+
[
|
|
7648
|
+
input.adId,
|
|
7649
|
+
input.placement,
|
|
7650
|
+
input.platform,
|
|
7651
|
+
input.region,
|
|
7652
|
+
safeOnError,
|
|
7653
|
+
recordAdImpression
|
|
7654
|
+
]
|
|
7655
|
+
);
|
|
7656
|
+
const reportClick = useCallback(
|
|
7657
|
+
(adIdOverride) => {
|
|
7658
|
+
try {
|
|
7659
|
+
void recordAdClick({
|
|
7660
|
+
variables: {
|
|
7661
|
+
input: {
|
|
7662
|
+
adId: adIdOverride ?? input.adId,
|
|
7663
|
+
clickId: generateAdClickId(),
|
|
7664
|
+
placement: input.placement,
|
|
7665
|
+
platform: input.platform,
|
|
7666
|
+
region: input.region
|
|
7667
|
+
}
|
|
7668
|
+
}
|
|
7669
|
+
}).catch((error) => {
|
|
7670
|
+
safeOnError("Ad click report failed.", error);
|
|
7671
|
+
});
|
|
7672
|
+
} catch (error) {
|
|
7673
|
+
safeOnError("Ad click report failed.", error);
|
|
7674
|
+
}
|
|
7675
|
+
},
|
|
7676
|
+
[
|
|
7677
|
+
input.adId,
|
|
7678
|
+
input.placement,
|
|
7679
|
+
input.platform,
|
|
7680
|
+
input.region,
|
|
7681
|
+
safeOnError,
|
|
7682
|
+
recordAdClick
|
|
7683
|
+
]
|
|
7684
|
+
);
|
|
7685
|
+
return { reportClick, reportImpression };
|
|
7686
|
+
};
|
|
7523
7687
|
|
|
7524
7688
|
// src/graphql/hooks/ad/hooksQuery.ts
|
|
7525
7689
|
import { useQuery as useQuery7 } from "@apollo/client";
|
|
7526
|
-
var useGetAds = () => {
|
|
7690
|
+
var useGetAds = (skip = false) => {
|
|
7527
7691
|
const { data, loading, error, refetch } = useQuery7(
|
|
7528
7692
|
GET_ADS,
|
|
7529
7693
|
{
|
|
7530
|
-
fetchPolicy: "no-cache"
|
|
7694
|
+
fetchPolicy: "no-cache",
|
|
7695
|
+
skip
|
|
7531
7696
|
}
|
|
7532
7697
|
);
|
|
7533
7698
|
return {
|
|
@@ -7563,6 +7728,19 @@ var useGetAdsByRegion = (region, platform, showOn) => {
|
|
|
7563
7728
|
refetch
|
|
7564
7729
|
};
|
|
7565
7730
|
};
|
|
7731
|
+
var useGetAdMetricTotals = (filter, skip = false) => {
|
|
7732
|
+
const { data, loading, error, refetch } = useQuery7(GET_AD_METRIC_TOTALS, {
|
|
7733
|
+
fetchPolicy: "no-cache",
|
|
7734
|
+
skip,
|
|
7735
|
+
variables: filter ? { filter } : void 0
|
|
7736
|
+
});
|
|
7737
|
+
return {
|
|
7738
|
+
adMetricTotals: data?.adMetricTotals || [],
|
|
7739
|
+
error,
|
|
7740
|
+
loading,
|
|
7741
|
+
refetch
|
|
7742
|
+
};
|
|
7743
|
+
};
|
|
7566
7744
|
|
|
7567
7745
|
// src/graphql/hooks/resourceActivities/hooksMutation.ts
|
|
7568
7746
|
import { useMutation as useMutation13 } from "@apollo/client";
|
|
@@ -9177,7 +9355,7 @@ var useGetCoupon = (_id) => {
|
|
|
9177
9355
|
|
|
9178
9356
|
// src/graphql/hooks/usePaginatedList.ts
|
|
9179
9357
|
import { useQuery as useQuery18 } from "@apollo/client";
|
|
9180
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
9358
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState } from "react";
|
|
9181
9359
|
function usePaginatedList({
|
|
9182
9360
|
document,
|
|
9183
9361
|
getItems,
|
|
@@ -9196,7 +9374,7 @@ function usePaginatedList({
|
|
|
9196
9374
|
const [hasMore, setHasMore] = useState(!skip);
|
|
9197
9375
|
const [hasSettled, setHasSettled] = useState(false);
|
|
9198
9376
|
const variablesKey = JSON.stringify(variables ?? null);
|
|
9199
|
-
|
|
9377
|
+
useEffect2(() => {
|
|
9200
9378
|
setItems([]);
|
|
9201
9379
|
setHasMore(!skip);
|
|
9202
9380
|
setHasSettled(false);
|
|
@@ -9207,14 +9385,14 @@ function usePaginatedList({
|
|
|
9207
9385
|
skip,
|
|
9208
9386
|
variables: { ...variables, options: { limit: pageSize + 1, offset } }
|
|
9209
9387
|
});
|
|
9210
|
-
const refetchRef =
|
|
9388
|
+
const refetchRef = useRef2(refetch);
|
|
9211
9389
|
refetchRef.current = refetch;
|
|
9212
|
-
const variablesRef =
|
|
9390
|
+
const variablesRef = useRef2(variables);
|
|
9213
9391
|
variablesRef.current = variables;
|
|
9214
9392
|
const rawPage = getItems(data);
|
|
9215
9393
|
const page = rawPage.length > pageSize ? rawPage.slice(0, pageSize) : rawPage;
|
|
9216
9394
|
const hasMorePage = rawPage.length > pageSize;
|
|
9217
|
-
|
|
9395
|
+
useEffect2(() => {
|
|
9218
9396
|
if (loading || skip || error) {
|
|
9219
9397
|
return;
|
|
9220
9398
|
}
|
|
@@ -9230,7 +9408,7 @@ function usePaginatedList({
|
|
|
9230
9408
|
setHasSettled(true);
|
|
9231
9409
|
setHasMore(hasMorePage);
|
|
9232
9410
|
}, [loading, skip, error, page, hasMorePage, hasSettled, pageSize, getId]);
|
|
9233
|
-
const loadMore =
|
|
9411
|
+
const loadMore = useCallback2(() => {
|
|
9234
9412
|
if (loading || skip) {
|
|
9235
9413
|
return;
|
|
9236
9414
|
}
|
|
@@ -9246,7 +9424,7 @@ function usePaginatedList({
|
|
|
9246
9424
|
}
|
|
9247
9425
|
setOffset(offset + pageSize);
|
|
9248
9426
|
}, [loading, skip, error, hasSettled, hasMore, offset, pageSize]);
|
|
9249
|
-
const refresh =
|
|
9427
|
+
const refresh = useCallback2(() => {
|
|
9250
9428
|
setItems([]);
|
|
9251
9429
|
setHasMore(!skip);
|
|
9252
9430
|
setHasSettled(false);
|
|
@@ -9828,6 +10006,8 @@ export {
|
|
|
9828
10006
|
ADMIN_APP_ROLES,
|
|
9829
10007
|
ADMIN_DASHBOARD_CONTEXTS,
|
|
9830
10008
|
AD_BOOKING_FIELDS_FRAGMENT,
|
|
10009
|
+
AD_METRIC_IMPRESSION_RETRY_DELAY_MS,
|
|
10010
|
+
AD_METRIC_ROTATION_INTERVAL_MS,
|
|
9831
10011
|
AFFILIATE_PARTICIPANT_TYPE_LABELS,
|
|
9832
10012
|
AFFILIATE_REWARDS,
|
|
9833
10013
|
ANDROID_URL,
|
|
@@ -9891,6 +10071,7 @@ export {
|
|
|
9891
10071
|
FUTURE_EVENT_DATE_STATUSES,
|
|
9892
10072
|
GET_AD_BOOKING,
|
|
9893
10073
|
GET_AD_DAILY_PRICES,
|
|
10074
|
+
GET_AD_METRIC_TOTALS,
|
|
9894
10075
|
GET_AD_SETTINGS,
|
|
9895
10076
|
GET_EVENT,
|
|
9896
10077
|
GET_EVENTS,
|
|
@@ -9984,6 +10165,7 @@ export {
|
|
|
9984
10165
|
badges,
|
|
9985
10166
|
bankAccountDetailsFields,
|
|
9986
10167
|
billingCatalogDefinitionMatches,
|
|
10168
|
+
buildAdMetricSlotKey,
|
|
9987
10169
|
buildApplicationShareDescription,
|
|
9988
10170
|
buildCalendarSheetContentData,
|
|
9989
10171
|
buildInvitationShareDescription,
|
|
@@ -10056,6 +10238,9 @@ export {
|
|
|
10056
10238
|
futureTimePeriods,
|
|
10057
10239
|
gameScreenIdentifierList,
|
|
10058
10240
|
gameTypeToDisplayName,
|
|
10241
|
+
generateAdClickId,
|
|
10242
|
+
getAdMetricRotationIndex,
|
|
10243
|
+
getAdMetricRotationSlot,
|
|
10059
10244
|
getAllowedEventDateStatuses,
|
|
10060
10245
|
getBillingCatalogKeyForSelection,
|
|
10061
10246
|
getCurrentAndFutureDates,
|
|
@@ -10170,6 +10355,7 @@ export {
|
|
|
10170
10355
|
truncateText,
|
|
10171
10356
|
updateSingleDateTimeStatus,
|
|
10172
10357
|
useActivateVendorClaim,
|
|
10358
|
+
useAdMetricsReporter,
|
|
10173
10359
|
useAddParticipantToChat,
|
|
10174
10360
|
useAddUserFavouriteResource,
|
|
10175
10361
|
useAddUserGoingResource,
|
|
@@ -10220,6 +10406,7 @@ export {
|
|
|
10220
10406
|
useDeleteVendor,
|
|
10221
10407
|
useEndImpersonation,
|
|
10222
10408
|
useGetAd,
|
|
10409
|
+
useGetAdMetricTotals,
|
|
10223
10410
|
useGetAds,
|
|
10224
10411
|
useGetAdsByRegion,
|
|
10225
10412
|
useGetAffiliate,
|