@smartico/public-api 0.0.380 → 0.0.382
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/CLAUDE.md +103 -0
- package/README.md +32 -10
- package/dist/Base/ClassId.d.ts +2 -0
- package/dist/Jackpots/JackpotDetails.d.ts +14 -15
- package/dist/Jackpots/JackpotPot.d.ts +10 -6
- package/dist/MiniGames/SAWGameType.d.ts +3 -1
- package/dist/MiniGames/SAWTemplateUI.d.ts +7 -0
- package/dist/Raffle/GetRaffleWonPrizesRequest.d.ts +9 -0
- package/dist/Raffle/GetRaffleWonPrizesResponse.d.ts +52 -0
- package/dist/Raffle/index.d.ts +2 -0
- package/dist/SmarticoAPI.d.ts +6 -1
- package/dist/SmarticoLib/index.d.ts +5 -1
- package/dist/WSAPI/WSAPIAvatars.d.ts +267 -49
- package/dist/WSAPI/WSAPIBonuses.d.ts +224 -10
- package/dist/WSAPI/WSAPIGamePick.d.ts +538 -253
- package/dist/WSAPI/WSAPIGeneral.d.ts +156 -14
- package/dist/WSAPI/WSAPIInbox.d.ts +547 -58
- package/dist/WSAPI/WSAPIJackpots.d.ts +292 -57
- package/dist/WSAPI/WSAPILeaderBoard.d.ts +127 -13
- package/dist/WSAPI/WSAPIMiniGames.d.ts +465 -49
- package/dist/WSAPI/WSAPIRaffles.d.ts +576 -52
- package/dist/WSAPI/WSAPITournaments.d.ts +3 -3
- package/dist/WSAPI/WSAPITypes.d.ts +243 -132
- package/dist/WSAPI/WSAPIUser.d.ts +193 -43
- package/dist/index.js +3412 -616
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +3395 -609
- package/dist/index.modern.mjs.map +1 -1
- package/docs/Callbacks.md +162 -0
- package/docs/SmarticoObject.md +445 -0
- package/docs/Transforms.md +99 -0
- package/docs/api/README.md +26 -0
- package/docs/api/classes/WSAPIAvatars.md +282 -54
- package/docs/api/classes/WSAPIBonuses.md +233 -12
- package/docs/api/classes/WSAPIClans.md +380 -10
- package/docs/api/classes/WSAPIGamePick.md +555 -26
- package/docs/api/classes/WSAPIGeneral.md +165 -16
- package/docs/api/classes/WSAPIInbox.md +588 -64
- package/docs/api/classes/WSAPIJackpots.md +320 -66
- package/docs/api/classes/WSAPILeaderBoard.md +133 -15
- package/docs/api/classes/WSAPIMiniGames.md +501 -64
- package/docs/api/classes/WSAPIMissions.md +58 -79
- package/docs/api/classes/WSAPIRaffles.md +647 -69
- package/docs/api/classes/WSAPIStore.md +83 -108
- package/docs/api/classes/WSAPITournaments.md +495 -28
- package/docs/api/classes/WSAPIUser.md +520 -83
- package/docs/api/documents/Callbacks.md +162 -0
- package/docs/api/documents/SmarticoObject.md +445 -0
- package/docs/api/documents/Transforms.md +99 -0
- package/docs/api/enumerations/BonusStatus-1.md +11 -6
- package/docs/api/enumerations/JoinClanErrorCode.md +81 -0
- package/docs/api/enumerations/TournamentRegistrationError.md +12 -0
- package/docs/api/functions/clanTournamentPlayersTransform.md +13 -0
- package/docs/api/interfaces/AvatarCustomized.md +25 -0
- package/docs/api/interfaces/AvatarDefinition.md +94 -0
- package/docs/api/interfaces/AvatarPrompt.md +45 -0
- package/docs/api/interfaces/BonusMetaMap-1.md +4 -1
- package/docs/api/interfaces/BonusTemplateMetaMap-1.md +9 -4
- package/docs/api/interfaces/Clan.md +4 -0
- package/docs/api/interfaces/ClanInfo.md +109 -0
- package/docs/api/interfaces/ClanMember.md +53 -0
- package/docs/api/interfaces/ClanTournamentPlayerRaw.md +67 -0
- package/docs/api/interfaces/GemsDiamondsLog.md +43 -0
- package/docs/api/interfaces/GetClanInfoResponse.md +61 -0
- package/docs/api/interfaces/GetClanTournamentPlayersResponse.md +81 -0
- package/docs/api/interfaces/GetRaffleWonPrizesRequest.md +59 -0
- package/docs/api/interfaces/GetRaffleWonPrizesResponse.md +95 -0
- package/docs/api/interfaces/InboxMarkMessageAction.md +10 -2
- package/docs/api/interfaces/JackpotDetails.md +14 -15
- package/docs/api/interfaces/JackpotPot.md +9 -6
- package/docs/api/interfaces/LeaderBoardDetailsT.md +14 -8
- package/docs/api/interfaces/LeaderBoardUserT.md +8 -5
- package/docs/api/interfaces/LeaderBoardsRewardsT.md +7 -0
- package/docs/api/interfaces/PointsLog.md +43 -0
- package/docs/api/interfaces/RaffleWonPrize.md +59 -0
- package/docs/api/interfaces/RaffleWonPrizePublicMeta.md +27 -0
- package/docs/api/interfaces/RaffleWonPrizeUser.md +43 -0
- package/docs/api/interfaces/TAchCategory.md +2 -7
- package/docs/api/interfaces/TAvatarCustomized.md +4 -4
- package/docs/api/interfaces/TAvatarDefinition.md +13 -14
- package/docs/api/interfaces/TAvatarPrompt.md +6 -6
- package/docs/api/interfaces/TBonus.md +16 -8
- package/docs/api/interfaces/TBuyStoreItemResult.md +4 -29
- package/docs/api/interfaces/TClaimBonusResult.md +5 -5
- package/docs/api/interfaces/TClan.md +8 -4
- package/docs/api/interfaces/TClanInfo.md +47 -0
- package/docs/api/interfaces/TClanJoinResult.md +11 -1
- package/docs/api/interfaces/TClanTournamentPlayer.md +55 -0
- package/docs/api/interfaces/TClanTournamentPlayersResult.md +27 -0
- package/docs/api/interfaces/TClans.md +3 -1
- package/docs/api/interfaces/TGetTranslations.md +4 -0
- package/docs/api/interfaces/TInboxMessage.md +14 -6
- package/docs/api/interfaces/TInboxMessageBody.md +18 -12
- package/docs/api/interfaces/TLevel.md +17 -20
- package/docs/api/interfaces/TLevelCurrent.md +19 -18
- package/docs/api/interfaces/TMiniGamePlayBatchResult.md +14 -6
- package/docs/api/interfaces/TMiniGamePlayResult.md +9 -4
- package/docs/api/interfaces/TMissionClaimRewardResult.md +1 -9
- package/docs/api/interfaces/TMissionOptInResult.md +1 -5
- package/docs/api/interfaces/TMissionOrBadge.md +4 -7
- package/docs/api/interfaces/TRaffleOptinResponse.md +4 -2
- package/docs/api/interfaces/TSegmentCheckResult.md +10 -0
- package/docs/api/interfaces/TSetAvatarResult.md +3 -3
- package/docs/api/interfaces/TStoreItem.md +3 -13
- package/docs/api/interfaces/TTournament.md +1 -1
- package/docs/api/interfaces/TTournamentDetailed.md +1 -1
- package/docs/api/interfaces/TTournamentRegistrationResult.md +4 -2
- package/docs/api/interfaces/TUICustomSection.md +23 -19
- package/docs/api/interfaces/TUserProfile.md +18 -16
- package/docs/api/interfaces/TransformedRaffleClaimPrizeResponse.md +6 -2
- package/docs/api/interfaces/UserLevelExtraCountersT.md +9 -2
- package/docs/api/type-aliases/ActivityLogEntry.md +3 -0
- package/docs/native/ADDING_METHODS.md +7 -2
- package/docs/native/PROTOCOL.md +337 -0
- package/docs/ui/avatars/UIGuide_getAvatarPrompts.md +100 -0
- package/docs/ui/avatars/UIGuide_getAvatarsCustomized.md +90 -0
- package/docs/ui/avatars/UIGuide_getAvatarsList.md +105 -0
- package/docs/ui/avatars/UIGuide_setAvatar.md +118 -0
- package/docs/ui/bonuses/UIGuide_claimBonus.md +144 -0
- package/docs/ui/bonuses/UIGuide_getBonuses.md +176 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md +99 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md +76 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetBoard.md +81 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md +78 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetHistory.md +55 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md +71 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md +64 -0
- package/docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md +103 -0
- package/docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md +67 -0
- package/docs/ui/general/UIGuide_getCustomSections.md +137 -0
- package/docs/ui/general/UIGuide_getRelatedItemsForGame.md +140 -0
- package/docs/ui/inbox/UIGuide_deleteInboxMessage.md +135 -0
- package/docs/ui/inbox/UIGuide_getInboxMessageBody.md +133 -0
- package/docs/ui/inbox/UIGuide_getInboxMessages.md +186 -0
- package/docs/ui/inbox/UIGuide_markInboxMessageAsRead.md +122 -0
- package/docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md +84 -0
- package/docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md +73 -0
- package/docs/ui/jackpots/UIGuide_getJackpotWinners.md +83 -0
- package/docs/ui/jackpots/UIGuide_jackpotGet.md +138 -0
- package/docs/ui/jackpots/UIGuide_jackpotOptIn.md +85 -0
- package/docs/ui/jackpots/UIGuide_jackpotOptOut.md +65 -0
- package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +166 -0
- package/docs/ui/minigames/UIGuide_getMiniGames.md +153 -0
- package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +90 -0
- package/docs/ui/minigames/UIGuide_playMiniGame.md +150 -0
- package/docs/ui/minigames/UIGuide_playMiniGameBatch.md +128 -0
- package/docs/ui/raffles/UIGuide_claimRafflePrize.md +99 -0
- package/docs/ui/raffles/UIGuide_getRaffleDrawRun.md +117 -0
- package/docs/ui/raffles/UIGuide_getRaffleDrawRunsHistory.md +92 -0
- package/docs/ui/raffles/UIGuide_getRaffleWonPrizes.md +120 -0
- package/docs/ui/raffles/UIGuide_getRaffles.md +175 -0
- package/docs/ui/raffles/UIGuide_requestRaffleOptin.md +114 -0
- package/docs/ui/user/UIGuide_getActivityLog.md +130 -0
- package/docs/ui/user/UIGuide_getLevels.md +47 -42
- package/package.json +1 -1
- package/src/Base/ClassId.ts +2 -0
- package/src/Jackpots/JackpotDetails.ts +14 -15
- package/src/Jackpots/JackpotPot.ts +10 -6
- package/src/MiniGames/SAWGameType.ts +3 -0
- package/src/MiniGames/SAWTemplateUI.ts +10 -0
- package/src/Raffle/GetRaffleWonPrizesRequest.ts +12 -0
- package/src/Raffle/GetRaffleWonPrizesResponse.ts +56 -0
- package/src/Raffle/index.ts +3 -1
- package/src/SmarticoAPI.ts +14 -1
- package/src/SmarticoLib/index.ts +4 -0
- package/src/WSAPI/WSAPIAvatars.ts +267 -49
- package/src/WSAPI/WSAPIBonuses.ts +224 -10
- package/src/WSAPI/WSAPIGamePick.ts +538 -253
- package/src/WSAPI/WSAPIGeneral.ts +156 -14
- package/src/WSAPI/WSAPIInbox.ts +545 -56
- package/src/WSAPI/WSAPIJackpots.ts +297 -61
- package/src/WSAPI/WSAPILeaderBoard.ts +127 -13
- package/src/WSAPI/WSAPIMiniGames.ts +465 -49
- package/src/WSAPI/WSAPIRaffles.ts +592 -64
- package/src/WSAPI/WSAPITournaments.ts +3 -3
- package/src/WSAPI/WSAPITypes.ts +243 -132
- package/src/WSAPI/WSAPIUser.ts +193 -43
- package/tsconfig.json +9 -1
|
@@ -5,25 +5,140 @@
|
|
|
5
5
|
|
|
6
6
|
> **getUserProfile**(): [`TUserProfile`](../interfaces/TUserProfile.md)
|
|
7
7
|
|
|
8
|
+
Returns the current user's public profile — the source of truth for
|
|
9
|
+
balances (points / gems / diamonds), the current level ID, the
|
|
10
|
+
display username + avatar, language, public tags, and the inbox
|
|
11
|
+
unread count. **This method is synchronous** (returns `TUserProfile`,
|
|
12
|
+
not a Promise): the SDK keeps a local snapshot of the user's public
|
|
13
|
+
properties that is initialised at identify time and kept live by a
|
|
14
|
+
server-driven update channel — every call returns the latest cached
|
|
15
|
+
values without a network round-trip.
|
|
16
|
+
|
|
17
|
+
Subscribe to changes by registering a callback on `_smartico.on('props_change', ...)`
|
|
18
|
+
— the callback fires with the full snapshot at identify and with
|
|
19
|
+
partial-key updates on every subsequent server push (typically
|
|
20
|
+
under 1 second after the underlying state change).
|
|
21
|
+
|
|
8
22
|
#### Returns
|
|
9
23
|
|
|
10
24
|
[`TUserProfile`](../interfaces/TUserProfile.md)
|
|
11
25
|
|
|
26
|
+
The current cached `TUserProfile` snapshot. A shallow copy —
|
|
27
|
+
mutating it does not affect the SDK's internal state.
|
|
28
|
+
|
|
29
|
+
#### Remarks
|
|
30
|
+
|
|
31
|
+
**Preconditions**
|
|
32
|
+
The tracker must be initialised — calling this before the identify
|
|
33
|
+
round-trip completes throws (`"Tracker is not initialized, cannot
|
|
34
|
+
getUserProfile"`). Safe ways to wait for readiness:
|
|
35
|
+
- register `_smartico.on('identify', (errCode, props) => ...)` —
|
|
36
|
+
fires once after a successful identify with the full props
|
|
37
|
+
- register `_smartico.on('props_change', () => ...)` — fires first
|
|
38
|
+
at identify with the full snapshot, then on every push update
|
|
39
|
+
|
|
40
|
+
**What's kept live (push-updated)**
|
|
41
|
+
Balance fields (`ach_points_balance`, `ach_gems_balance`,
|
|
42
|
+
`ach_diamonds_balance`, `ach_points_ever`), `ach_level_current_id`,
|
|
43
|
+
`core_public_tags`, `core_inbox_unread_count`, `core_user_language`,
|
|
44
|
+
`avatar_url`, `public_username`, and the AI-driven recommended-amount
|
|
45
|
+
fields all flow over the SDK's user-properties update channel as
|
|
46
|
+
partial updates — the snapshot is patched in place when any of them
|
|
47
|
+
change server-side. Re-call `getUserProfile()` (or watch
|
|
48
|
+
`props_change`) to observe new values.
|
|
49
|
+
|
|
50
|
+
**Reading state from the returned profile**
|
|
51
|
+
Balances (`ach_points_balance`, `ach_gems_balance`,
|
|
52
|
+
`ach_diamonds_balance`) are the canonical source for affordability
|
|
53
|
+
checks across the SDK — compare against `entry_fee_amount` (clans),
|
|
54
|
+
`registration_cost_points` / `_gems` / `_diamonds` (tournaments), and
|
|
55
|
+
`price` / `discounted_price` + `purchase_type` (store items).
|
|
56
|
+
`ach_points_ever` is monotonic — store purchases deduct from
|
|
57
|
+
`ach_points_balance` but NEVER from `ach_points_ever`, so it remains
|
|
58
|
+
useful for level-progress math (`required_points` on the next
|
|
59
|
+
[getLevels](#getlevels) entry minus `ach_points_ever`). `ach_level_current_id`
|
|
60
|
+
is the FK into the level ladder — resolve metadata via
|
|
61
|
+
[getCurrentLevel](#getcurrentlevel) (richer, includes progress %) or
|
|
62
|
+
[getLevels](#getlevels) (full ladder lookup table).
|
|
63
|
+
|
|
64
|
+
**Inbox unread count** — `core_inbox_unread_count` on this profile
|
|
65
|
+
is push-updated in real time (under 1 second). For an inbox badge,
|
|
66
|
+
prefer this field over `getInboxUnreadCount` (which is cached
|
|
67
|
+
for 30 s) — same value, fresher signal.
|
|
68
|
+
|
|
69
|
+
**Language**: `core_user_language` reflects the server's stored
|
|
70
|
+
language. If the consumer just called `_smartico.changeLanguage(...)`,
|
|
71
|
+
the field may briefly lag the local intent until the server push
|
|
72
|
+
arrives. Use `_smartico.getPublicProps()` for the
|
|
73
|
+
client-fallback-applied version if instant accuracy matters.
|
|
74
|
+
|
|
75
|
+
**Idempotency / Side effects**: trivially safe — no network call,
|
|
76
|
+
no state mutation.
|
|
77
|
+
|
|
78
|
+
**UI guidance**: see [UI Guide — `getUserProfile`](../_media/UIGuide_getUserProfile.md).
|
|
79
|
+
|
|
80
|
+
**Visitor mode**: not supported — throws. Visitor sessions do not
|
|
81
|
+
have a public-profile snapshot.
|
|
82
|
+
|
|
83
|
+
#### Throws
|
|
84
|
+
|
|
85
|
+
`Error("Tracker is not initialized, cannot getUserProfile")`
|
|
86
|
+
if called before identify completes or from a visitor session.
|
|
87
|
+
|
|
88
|
+
#### Example
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
// Wait for identify before calling.
|
|
92
|
+
window._smartico.on('identify', (errCode) => {
|
|
93
|
+
if (errCode !== 0) return;
|
|
94
|
+
const profile = window._smartico.api.getUserProfile();
|
|
95
|
+
console.log('[smartico] initial profile loaded — render the user widget:', profile);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Stay in sync with live updates.
|
|
99
|
+
window._smartico.on('props_change', (changed) => {
|
|
100
|
+
// `changed` is the partial keys for this push (full snapshot at identify).
|
|
101
|
+
const profile = window._smartico.api.getUserProfile();
|
|
102
|
+
console.log('[smartico] profile updated — re-render any widgets bound to:', Object.keys(changed),
|
|
103
|
+
'— balances now:', profile.ach_points_balance, profile.ach_gems_balance, profile.ach_diamonds_balance);
|
|
104
|
+
|
|
105
|
+
// React to specific fields.
|
|
106
|
+
if ('ach_level_current_id' in changed) {
|
|
107
|
+
console.log('[smartico] level changed — call getCurrentLevel() for richer detail, animate the level badge');
|
|
108
|
+
}
|
|
109
|
+
if ('core_inbox_unread_count' in changed) {
|
|
110
|
+
console.log('[smartico] inbox unread count changed — update the badge to:', profile.core_inbox_unread_count);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Affordability gating example — used inside a clan / tournament / store CTA handler.
|
|
115
|
+
const profile = window._smartico.api.getUserProfile();
|
|
116
|
+
const item = await window._smartico.api.getStoreItems().then(items => items[0]);
|
|
117
|
+
const price = item.discounted_price ?? item.price;
|
|
118
|
+
const balance = {
|
|
119
|
+
points: profile.ach_points_balance,
|
|
120
|
+
gems: profile.ach_gems_balance,
|
|
121
|
+
diamonds: profile.ach_diamonds_balance,
|
|
122
|
+
}[item.purchase_type];
|
|
123
|
+
if (balance < price) {
|
|
124
|
+
console.log('[smartico] insufficient', item.purchase_type, '— disable Buy and show deficit', price - balance);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
12
128
|
***
|
|
13
129
|
|
|
14
130
|
### checkSegmentMatch()
|
|
15
131
|
|
|
16
132
|
> **checkSegmentMatch**(`segment_id`): `Promise`\<`boolean`\>
|
|
17
133
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
console.log(result);
|
|
23
|
-
});
|
|
24
|
-
```
|
|
134
|
+
Checks whether the current user matches a single segment, returning
|
|
135
|
+
`true` / `false` directly. Use this as a decision primitive to gate
|
|
136
|
+
UI surfaces (e.g. show a "VIP lounge" tab only when the user is in
|
|
137
|
+
the VIP segment), or to drive segment-specific CTA copy.
|
|
25
138
|
|
|
26
|
-
|
|
139
|
+
Every call is a server round-trip — there is no SDK-side cache. For
|
|
140
|
+
checking multiple segments in one round-trip, use
|
|
141
|
+
[checkSegmentListMatch](#checksegmentlistmatch) instead.
|
|
27
142
|
|
|
28
143
|
#### Parameters
|
|
29
144
|
|
|
@@ -31,24 +146,85 @@ _smartico.api.checkSegmentMatch(1).then((result) => {
|
|
|
31
146
|
|
|
32
147
|
`number`
|
|
33
148
|
|
|
149
|
+
The segment ID. Segment IDs are label-scoped;
|
|
150
|
+
the same numeric ID can refer to different
|
|
151
|
+
segments under different labels. Use the IDs
|
|
152
|
+
configured for your label.
|
|
153
|
+
|
|
34
154
|
#### Returns
|
|
35
155
|
|
|
36
156
|
`Promise`\<`boolean`\>
|
|
37
157
|
|
|
158
|
+
`true` if the user currently matches the
|
|
159
|
+
segment, `false` otherwise. `false` also covers
|
|
160
|
+
the "segment doesn't exist for this label"
|
|
161
|
+
case — these are not distinguishable.
|
|
162
|
+
|
|
163
|
+
#### Remarks
|
|
164
|
+
|
|
165
|
+
**Refresh model**
|
|
166
|
+
- **No client cache.** Every call sends a request; the SDK does not
|
|
167
|
+
memoize results.
|
|
168
|
+
- **No push event** notifies the consumer when segment membership
|
|
169
|
+
flips (the user crosses a qualification threshold, or the
|
|
170
|
+
operator changes the segment definition). Membership changes
|
|
171
|
+
become visible only on the next `checkSegmentMatch` call.
|
|
172
|
+
- **Behavioral segments (configured against BigQuery) have batch
|
|
173
|
+
lag** — even if the user's activity has changed (deposit, wager,
|
|
174
|
+
etc.), the segment-membership result may not reflect that change
|
|
175
|
+
until the next batch evaluation run (typically up to several
|
|
176
|
+
hours).
|
|
177
|
+
|
|
178
|
+
**Rate limit** (important)
|
|
179
|
+
The server caps `checkSegment*` calls at **10 requests per
|
|
180
|
+
60-second window**, with a minimum gap of **~5 seconds between
|
|
181
|
+
consecutive calls**. Avoid calling on every render — cache the
|
|
182
|
+
result client-side for the session, or until you have a reason to
|
|
183
|
+
believe the user's state changed (e.g. after a deposit completes,
|
|
184
|
+
a level changes via [getUserProfile](#getuserprofile)'s `props_change`, or a
|
|
185
|
+
specific custom event fires).
|
|
186
|
+
|
|
187
|
+
**`is_matching: false` is ambiguous on the server** — both "the
|
|
188
|
+
segment doesn't exist for this label" and "the user doesn't
|
|
189
|
+
qualify" return `false` with no distinguishing signal. Pass IDs
|
|
190
|
+
you've verified are valid for your label.
|
|
191
|
+
|
|
192
|
+
**Idempotency**: safe. Read-only. No side effects (no analytics
|
|
193
|
+
events, no DB writes).
|
|
194
|
+
|
|
195
|
+
**Visitor mode**: not supported.
|
|
196
|
+
|
|
197
|
+
#### Example
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
const isVip = await window._smartico.api.checkSegmentMatch(vipSegmentId);
|
|
201
|
+
if (isVip) {
|
|
202
|
+
console.log('[smartico] user is in VIP segment — render the VIP-only widget surface');
|
|
203
|
+
} else {
|
|
204
|
+
console.log('[smartico] user not in VIP segment (or segment id misconfigured) — hide the VIP surface');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Cache the result for the session; re-check after material user-state changes.
|
|
208
|
+
window._smartico.on('props_change', async (changed) => {
|
|
209
|
+
if ('ach_points_ever' in changed || 'ach_level_current_id' in changed) {
|
|
210
|
+
const fresh = await window._smartico.api.checkSegmentMatch(vipSegmentId);
|
|
211
|
+
console.log('[smartico] user state changed — VIP membership now:', fresh);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
38
216
|
***
|
|
39
217
|
|
|
40
218
|
### checkSegmentListMatch()
|
|
41
219
|
|
|
42
220
|
> **checkSegmentListMatch**(`segment_ids`): `Promise`\<[`TSegmentCheckResult`](../interfaces/TSegmentCheckResult.md)[]\>
|
|
43
221
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
**Visitor mode: not supported**
|
|
222
|
+
Checks the current user's membership in multiple segments in a
|
|
223
|
+
single server round-trip — returns a `TSegmentCheckResult[]` with
|
|
224
|
+
one entry per *unique* segment ID. Use this instead of looping
|
|
225
|
+
[checkSegmentMatch](#checksegmentmatch) when you need to evaluate several
|
|
226
|
+
segments at once (e.g. multi-segment composite gating, A/B-style
|
|
227
|
+
cohort detection).
|
|
52
228
|
|
|
53
229
|
#### Parameters
|
|
54
230
|
|
|
@@ -56,145 +232,406 @@ _smartico.api.checkSegmentListMatch([1, 2, 3]).then((result) => {
|
|
|
56
232
|
|
|
57
233
|
`number`[]
|
|
58
234
|
|
|
235
|
+
Array of segment IDs to check. Duplicates are
|
|
236
|
+
silently de-duplicated server-side. Segment IDs
|
|
237
|
+
are label-scoped — use the IDs configured for
|
|
238
|
+
your label.
|
|
239
|
+
|
|
59
240
|
#### Returns
|
|
60
241
|
|
|
61
242
|
`Promise`\<[`TSegmentCheckResult`](../interfaces/TSegmentCheckResult.md)[]\>
|
|
62
243
|
|
|
244
|
+
Array of `{ segment_id, is_matching }` results.
|
|
245
|
+
Order is NOT guaranteed; correlate by
|
|
246
|
+
`segment_id`. Length may be less than the input
|
|
247
|
+
when duplicate IDs were sent.
|
|
248
|
+
|
|
249
|
+
#### Remarks
|
|
250
|
+
|
|
251
|
+
**Response order is NOT guaranteed**
|
|
252
|
+
The server returns results in an unspecified order — different
|
|
253
|
+
from the input array. Always correlate by the `segment_id` field on
|
|
254
|
+
each `TSegmentCheckResult` rather than by array position. The
|
|
255
|
+
returned array length may also be smaller than the input array
|
|
256
|
+
(duplicate IDs are silently de-duplicated server-side).
|
|
257
|
+
|
|
258
|
+
**Single round-trip**
|
|
259
|
+
The entire `segment_ids` array is sent in one request. Two segments
|
|
260
|
+
cost the same as one in terms of network latency and rate-limit
|
|
261
|
+
consumption (one call = one rate-limit slot, regardless of how many
|
|
262
|
+
segments).
|
|
263
|
+
|
|
264
|
+
**Shared semantics with `checkSegmentMatch`**
|
|
265
|
+
Both methods wrap the same underlying server endpoint and share
|
|
266
|
+
the same caching, refresh, rate-limit, and ambiguity behavior. See
|
|
267
|
+
[checkSegmentMatch](#checksegmentmatch) for: no client cache · no push event for
|
|
268
|
+
membership changes · behavioral segments have batch lag · rate
|
|
269
|
+
limit (10 requests / 60 s, ~5 s minimum gap between calls) ·
|
|
270
|
+
`is_matching: false` doesn't distinguish "not in segment" from
|
|
271
|
+
"segment doesn't exist for this label".
|
|
272
|
+
|
|
273
|
+
**Idempotency**: safe. Read-only. No side effects.
|
|
274
|
+
|
|
275
|
+
**Visitor mode**: not supported.
|
|
276
|
+
|
|
277
|
+
#### Example
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
const segmentIds = [vipSegmentId, newPlayerSegmentId, freeRollSegmentId];
|
|
281
|
+
const results = await window._smartico.api.checkSegmentListMatch(segmentIds);
|
|
282
|
+
|
|
283
|
+
// Always correlate by segment_id — the response order is unspecified.
|
|
284
|
+
const byId = new Map(results.map(r => [r.segment_id, r.is_matching]));
|
|
285
|
+
|
|
286
|
+
if (byId.get(vipSegmentId)) {
|
|
287
|
+
console.log('[smartico] user is in VIP segment — render VIP surface');
|
|
288
|
+
}
|
|
289
|
+
if (byId.get(newPlayerSegmentId) && byId.get(freeRollSegmentId)) {
|
|
290
|
+
console.log('[smartico] new player AND eligible for free roll — show the welcome promo');
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Cache the result map for the session; refresh on material state changes.
|
|
294
|
+
```
|
|
295
|
+
|
|
63
296
|
***
|
|
64
297
|
|
|
65
298
|
### getLevels()
|
|
66
299
|
|
|
67
300
|
> **getLevels**(): `Promise`\<[`TLevel`](../interfaces/TLevel.md)[]\>
|
|
68
301
|
|
|
69
|
-
Returns
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
**Example in the Visitor mode**:
|
|
78
|
-
```
|
|
79
|
-
_smartico.vapi('EN').getLevels().then((result) => {
|
|
80
|
-
console.log(result);
|
|
81
|
-
});
|
|
82
|
-
```
|
|
302
|
+
Returns the full level ladder configured for the current label —
|
|
303
|
+
one `TLevel` per active level, server-sorted by `required_points`
|
|
304
|
+
ASC (lowest first; `ordinal_position` is a 1-based index into the
|
|
305
|
+
returned array). Use this to render a level map / progression
|
|
306
|
+
screen, or as a lookup table to resolve `ach_level_current_id` from
|
|
307
|
+
[getUserProfile](#getuserprofile) into a richer level object.
|
|
83
308
|
|
|
84
309
|
#### Returns
|
|
85
310
|
|
|
86
311
|
`Promise`\<[`TLevel`](../interfaces/TLevel.md)[]\>
|
|
87
312
|
|
|
313
|
+
Promise resolving to the ordered `TLevel[]` ladder. Empty
|
|
314
|
+
if no levels are configured for the label.
|
|
315
|
+
|
|
316
|
+
#### Remarks
|
|
317
|
+
|
|
318
|
+
**Server-side filtering**
|
|
319
|
+
The server returns ALL active levels for the label. There is NO
|
|
320
|
+
per-user filtering on visibility, level-status, or anything else —
|
|
321
|
+
the response is identical across users of the same label. Apply
|
|
322
|
+
`visibility_points` filtering client-side if you want to hide
|
|
323
|
+
not-yet-reached levels (compare against
|
|
324
|
+
`getUserProfile().ach_points_ever` and exclude levels where
|
|
325
|
+
`visibility_points > ach_points_ever`).
|
|
326
|
+
|
|
327
|
+
**Sort order**
|
|
328
|
+
The returned array is already sorted by `required_points` ASC, and
|
|
329
|
+
`ordinal_position` is a 1-based index into that same sort order —
|
|
330
|
+
client-side re-sorting is not required for the default rendering.
|
|
331
|
+
If your label uses sliding-window leveling logic
|
|
332
|
+
(see [getUserLevelExtraCounters](#getuserlevelextracounters)) and you want to sort by
|
|
333
|
+
a multi-criteria key (`required_points`, then
|
|
334
|
+
`required_level_counter_1`, then `required_level_counter_2`), do
|
|
335
|
+
that client-side.
|
|
336
|
+
|
|
337
|
+
**Cache TTL**: the SDK caches the response for 30 seconds. Cache
|
|
338
|
+
is fully cleared on login / logout. Operator-driven level edits
|
|
339
|
+
surface on the next cache miss.
|
|
340
|
+
|
|
341
|
+
**Idempotency / Side effects**: safe. Read-only metadata. Calls
|
|
342
|
+
within the cache window de-duplicate to the same cached array.
|
|
343
|
+
|
|
344
|
+
**UI guidance**: see [UI Guide — `getLevels`](../_media/UIGuide_getLevels.md).
|
|
345
|
+
|
|
346
|
+
**Visitor mode**: supported. Use `_smartico.vapi(lang).getLevels()`
|
|
347
|
+
to fetch the ladder for anonymous viewers; the level configuration
|
|
348
|
+
is label-scoped static data so the response is meaningful even
|
|
349
|
+
without an authenticated user. Per-user fields (the implicit
|
|
350
|
+
"current level" via [getCurrentLevel](#getcurrentlevel), or the user's progress)
|
|
351
|
+
are not available in visitor mode.
|
|
352
|
+
|
|
353
|
+
#### Example
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
const [levels, profile] = await Promise.all([
|
|
357
|
+
window._smartico.api.getLevels(),
|
|
358
|
+
Promise.resolve(window._smartico.api.getUserProfile()),
|
|
359
|
+
]);
|
|
360
|
+
|
|
361
|
+
// Resolve the user's current level by ID.
|
|
362
|
+
const current = levels.find(l => l.id === profile.ach_level_current_id);
|
|
363
|
+
console.log('[smartico] render header badge — current level:', current?.name,
|
|
364
|
+
'(position', current?.ordinal_position, 'of', levels.length, ')');
|
|
365
|
+
|
|
366
|
+
// Filter to levels the user has unlocked enough to see.
|
|
367
|
+
const visible = levels.filter(l =>
|
|
368
|
+
l.visibility_points == null || l.visibility_points <= profile.ach_points_ever
|
|
369
|
+
);
|
|
370
|
+
console.log('[smartico] render the level map with', visible.length, 'visible tiles');
|
|
371
|
+
|
|
372
|
+
// Visitor-mode equivalent: returns the same ladder; no per-user state.
|
|
373
|
+
// const visitorLevels = await window._smartico.vapi('EN').getLevels();
|
|
374
|
+
```
|
|
375
|
+
|
|
88
376
|
***
|
|
89
377
|
|
|
90
378
|
### getCurrentLevel()
|
|
91
379
|
|
|
92
380
|
> **getCurrentLevel**(): `Promise`\<[`TLevelCurrent`](../interfaces/TLevelCurrent.md)\>
|
|
93
381
|
|
|
94
|
-
Returns the current level
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
```
|
|
98
|
-
_smartico.api.getCurrentLevel().then((result) => {
|
|
99
|
-
console.log(result);
|
|
100
|
-
});
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
**Visitor mode: not supported**
|
|
382
|
+
Returns the user's current level — every `TLevel` field plus a
|
|
383
|
+
computed `progress` percentage toward the next level. Use this to
|
|
384
|
+
power a level badge with a progress bar.
|
|
104
385
|
|
|
105
386
|
#### Returns
|
|
106
387
|
|
|
107
388
|
`Promise`\<[`TLevelCurrent`](../interfaces/TLevelCurrent.md)\>
|
|
108
389
|
|
|
390
|
+
Promise resolving to `TLevelCurrent` — the current level
|
|
391
|
+
plus `progress: number` (0–100).
|
|
392
|
+
|
|
393
|
+
#### Remarks
|
|
394
|
+
|
|
395
|
+
**How `progress` is computed**
|
|
396
|
+
The SDK derives `progress` as the *delta-from-current-level-floor*:
|
|
397
|
+
`(ach_points_ever − current.required_points) / (next.required_points
|
|
398
|
+
− current.required_points) × 100`, clamped to `[0, 100]`. At the
|
|
399
|
+
highest level (no next level), `progress` is `100`. Reading the
|
|
400
|
+
source values directly from [getUserProfile](#getuserprofile)'s
|
|
401
|
+
`ach_points_ever` and [getLevels](#getlevels) would also work, but
|
|
402
|
+
`progress` saves the math.
|
|
403
|
+
|
|
404
|
+
**Cache TTL**: the SDK caches the response for 30 seconds. There is
|
|
405
|
+
no push event that refreshes this cache; a server-side level change
|
|
406
|
+
(visible immediately on [getUserProfile](#getuserprofile)'s `ach_level_current_id`
|
|
407
|
+
via the user-properties update channel) becomes visible on this
|
|
408
|
+
method only after the cache TTL expires, or after
|
|
409
|
+
`_smartico.api.clearCaches()` is called.
|
|
410
|
+
|
|
411
|
+
**Leveling logic**
|
|
412
|
+
The semantics of how a user advances depends on the label's
|
|
413
|
+
leveling logic (configured per brand): points-only (the default),
|
|
414
|
+
sliding-window with extra counters (uses
|
|
415
|
+
[getUserLevelExtraCounters](#getuserlevelextracounters)), or fully-manual operator
|
|
416
|
+
assignment. The `progress` percentage on this method assumes the
|
|
417
|
+
points-only model — it's not meaningful for manual-only labels
|
|
418
|
+
where level changes are operator-driven rather than points-driven.
|
|
419
|
+
|
|
420
|
+
**Idempotency**: safe. Read-only. Repeated calls within the cache
|
|
421
|
+
window return a deep-cloned cached value without a network
|
|
422
|
+
round-trip.
|
|
423
|
+
|
|
424
|
+
**Side effects**: none — pure read.
|
|
425
|
+
|
|
426
|
+
**Visitor mode**: not supported.
|
|
427
|
+
|
|
428
|
+
#### Example
|
|
429
|
+
|
|
430
|
+
```ts
|
|
431
|
+
const level = await window._smartico.api.getCurrentLevel();
|
|
432
|
+
console.log('[smartico] render level badge — name:', level.name,
|
|
433
|
+
'progress:', Math.round(level.progress), '%');
|
|
434
|
+
|
|
435
|
+
// Detect level-up via getUserProfile's push channel.
|
|
436
|
+
window._smartico.on('props_change', async (changed) => {
|
|
437
|
+
if ('ach_level_current_id' in changed) {
|
|
438
|
+
await window._smartico.api.clearCaches(); // bust the 30 s cache
|
|
439
|
+
const fresh = await window._smartico.api.getCurrentLevel();
|
|
440
|
+
console.log('[smartico] user levelled up — animate badge to new level:', fresh.name);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
```
|
|
444
|
+
|
|
109
445
|
***
|
|
110
446
|
|
|
111
447
|
### getUserLevelExtraCounters()
|
|
112
448
|
|
|
113
449
|
> **getUserLevelExtraCounters**(): `Promise`\<[`UserLevelExtraCountersT`](../interfaces/UserLevelExtraCountersT.md)\>
|
|
114
450
|
|
|
115
|
-
Returns the
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
console.log(result);
|
|
123
|
-
});
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
**Visitor mode: not supported**
|
|
451
|
+
Returns the user's current values for the two label-defined "extra
|
|
452
|
+
counters" used by sliding-window leveling logic. Operators
|
|
453
|
+
configure what each counter means per label (e.g. `level_counter_1`
|
|
454
|
+
= total deposits in the last 30 days, `level_counter_2` = total
|
|
455
|
+
wagering in the last 30 days). Compare against
|
|
456
|
+
`required_level_counter_1` / `_2` on the next level from
|
|
457
|
+
[getLevels](#getlevels) to know how close the user is to advancing.
|
|
127
458
|
|
|
128
459
|
#### Returns
|
|
129
460
|
|
|
130
461
|
`Promise`\<[`UserLevelExtraCountersT`](../interfaces/UserLevelExtraCountersT.md)\>
|
|
131
462
|
|
|
463
|
+
Promise resolving to `UserLevelExtraCountersT`. Both
|
|
464
|
+
fields are `undefined` on labels not using sliding-window
|
|
465
|
+
leveling.
|
|
466
|
+
|
|
467
|
+
#### Remarks
|
|
468
|
+
|
|
469
|
+
**When this matters**
|
|
470
|
+
Only labels configured for sliding-window leveling populate the
|
|
471
|
+
counter fields. On the default points-only leveling model, both
|
|
472
|
+
`level_counter_1` and `level_counter_2` are `undefined`. Detect
|
|
473
|
+
a points-only label by either counter being `undefined`.
|
|
474
|
+
|
|
475
|
+
**Counter semantics — operator-defined**
|
|
476
|
+
The SDK exposes raw numeric values; the meaning of each counter
|
|
477
|
+
(deposit amount, wager amount, lifetime spend, etc.) is fully
|
|
478
|
+
operator-defined per label. Resolve labels for display via
|
|
479
|
+
`getTranslations` — the operator's display strings are
|
|
480
|
+
stored under the translation keys `levelsCounter1Name` and
|
|
481
|
+
`levelsCounter2Name`.
|
|
482
|
+
|
|
483
|
+
**Refresh cadence**
|
|
484
|
+
Sliding-window counters are recomputed by a server-side job that
|
|
485
|
+
runs roughly every 60 seconds against the operator's BigQuery
|
|
486
|
+
dataset; level transitions driven by counter changes have a
|
|
487
|
+
latency of up to several minutes after the underlying activity
|
|
488
|
+
(e.g. a deposit). The SDK caches the response for 30 seconds; no
|
|
489
|
+
push event refreshes this cache. After a level change visible on
|
|
490
|
+
[getUserProfile](#getuserprofile)'s `ach_level_current_id`, call
|
|
491
|
+
`_smartico.api.clearCaches()` to force a fresh fetch.
|
|
492
|
+
|
|
493
|
+
**Idempotency**: safe. Read-only. Repeated calls within the cache
|
|
494
|
+
window return a deep-cloned cached value without a network
|
|
495
|
+
round-trip.
|
|
496
|
+
|
|
497
|
+
**Side effects**: none — pure read.
|
|
498
|
+
|
|
499
|
+
**Visitor mode**: not supported.
|
|
500
|
+
|
|
501
|
+
#### Example
|
|
502
|
+
|
|
503
|
+
```ts
|
|
504
|
+
const [counters, levels, profile] = await Promise.all([
|
|
505
|
+
window._smartico.api.getUserLevelExtraCounters(),
|
|
506
|
+
window._smartico.api.getLevels(),
|
|
507
|
+
Promise.resolve(window._smartico.api.getUserProfile()),
|
|
508
|
+
]);
|
|
509
|
+
|
|
510
|
+
// Quick detection: undefined means this label doesn't use sliding-window leveling.
|
|
511
|
+
if (counters.level_counter_1 === undefined) {
|
|
512
|
+
console.log('[smartico] points-only label — skip counter UI; show points progress only');
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// Find the next level and render a 3-bar progress block.
|
|
517
|
+
const currentIdx = levels.findIndex(l => l.id === profile.ach_level_current_id);
|
|
518
|
+
const next = levels[currentIdx + 1];
|
|
519
|
+
if (next) {
|
|
520
|
+
console.log('[smartico] render points bar:', profile.ach_points_ever, '/', next.required_points);
|
|
521
|
+
if (next.required_level_counter_1) {
|
|
522
|
+
console.log('[smartico] render counter 1 bar:', counters.level_counter_1, '/', next.required_level_counter_1);
|
|
523
|
+
}
|
|
524
|
+
if (next.required_level_counter_2) {
|
|
525
|
+
console.log('[smartico] render counter 2 bar:', counters.level_counter_2, '/', next.required_level_counter_2);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
```
|
|
529
|
+
|
|
132
530
|
***
|
|
133
531
|
|
|
134
532
|
### getActivityLog()
|
|
135
533
|
|
|
136
|
-
> **getActivityLog**(`
|
|
137
|
-
|
|
138
|
-
Returns the activity log for a user within a specified time range.
|
|
139
|
-
The response includes both points changes and gems/diamonds changes.
|
|
140
|
-
Each log entry contains information about the change amount, balance, and source.
|
|
141
|
-
The returned list is cached for 30 seconds.
|
|
142
|
-
You can pass the onUpdate callback as a parameter, it will be called every time the activity log is updated and will provide the updated list of activity logs for the last 10 minutes.
|
|
534
|
+
> **getActivityLog**(`__namedParameters`): `Promise`\<[`TActivityLog`](../interfaces/TActivityLog.md)[]\>
|
|
143
535
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
_smartico.api.getActivityLog({
|
|
150
|
-
startTimeSeconds: startTime,
|
|
151
|
-
endTimeSeconds: endTime,
|
|
152
|
-
from: 0,
|
|
153
|
-
to: 50,
|
|
154
|
-
onUpdate: (data) => console.log('Updated:', data)
|
|
155
|
-
}).then((result) => {
|
|
156
|
-
console.log(result);
|
|
157
|
-
});
|
|
158
|
-
```
|
|
536
|
+
Returns the user's unified balance-change history — every points, gems, and
|
|
537
|
+
diamonds transaction within the requested time window, ordered newest-first.
|
|
538
|
+
Use to power an "Activity" / "History" tab showing wins, claims, purchases,
|
|
539
|
+
level-up rewards, and operator adjustments.
|
|
159
540
|
|
|
160
|
-
|
|
541
|
+
The returned shape is the same regardless of currency type — `type` (see
|
|
542
|
+
[UserBalanceType](../enumerations/UserBalanceType.md)) distinguishes points / gems / diamonds and
|
|
543
|
+
`source_type_id` (see [PointChangeSourceType](../enumerations/PointChangeSourceType.md)) names the originating
|
|
544
|
+
event.
|
|
161
545
|
|
|
162
546
|
#### Parameters
|
|
163
547
|
|
|
164
|
-
#####
|
|
165
|
-
|
|
166
|
-
Activity log parameters
|
|
548
|
+
##### \_\_namedParameters
|
|
167
549
|
|
|
168
550
|
###### startTimeSeconds
|
|
169
551
|
|
|
170
552
|
`number`
|
|
171
553
|
|
|
172
|
-
|
|
554
|
+
Window start in epoch seconds.
|
|
173
555
|
|
|
174
556
|
###### endTimeSeconds
|
|
175
557
|
|
|
176
558
|
`number`
|
|
177
559
|
|
|
178
|
-
|
|
560
|
+
Window end in epoch seconds.
|
|
179
561
|
|
|
180
562
|
###### from
|
|
181
563
|
|
|
182
564
|
`number`
|
|
183
565
|
|
|
184
|
-
|
|
566
|
+
Pagination offset (0-based).
|
|
185
567
|
|
|
186
568
|
###### to
|
|
187
569
|
|
|
188
570
|
`number`
|
|
189
571
|
|
|
190
|
-
|
|
572
|
+
Pagination ceiling (exclusive); server caps `to - from` at 50.
|
|
191
573
|
|
|
192
574
|
###### onUpdate?
|
|
193
575
|
|
|
194
576
|
(`data`) => `void`
|
|
195
577
|
|
|
196
|
-
Optional callback
|
|
578
|
+
Optional push callback; payload is a fixed 10-min / 50-entry refresh on every wallet change (see Subscription model).
|
|
197
579
|
|
|
198
580
|
#### Returns
|
|
199
581
|
|
|
200
582
|
`Promise`\<[`TActivityLog`](../interfaces/TActivityLog.md)[]\>
|
|
583
|
+
|
|
584
|
+
Array of [TActivityLog](../interfaces/TActivityLog.md) ordered newest-first.
|
|
585
|
+
|
|
586
|
+
#### Remarks
|
|
587
|
+
|
|
588
|
+
**Preconditions**
|
|
589
|
+
- User must be authenticated. Visitor mode is not guarded at the SDK level
|
|
590
|
+
but is not meaningful — activity is per-user.
|
|
591
|
+
|
|
592
|
+
**Pagination — `from` / `to` are offset + ceiling, not timestamps**
|
|
593
|
+
The SDK derives `offset = from`, `limit = min(to - from, 50)` — the server
|
|
594
|
+
hard-caps a single response at 50 entries. For infinite scroll, advance
|
|
595
|
+
`from` by 50 between calls. Both `startTimeSeconds` and `endTimeSeconds`
|
|
596
|
+
are epoch seconds bounding the window the server scans.
|
|
597
|
+
|
|
598
|
+
**Subscription model (`onUpdate`)**
|
|
599
|
+
The callback fires when the user's `ach_points_balance`,
|
|
600
|
+
`ach_gems_balance`, or `ach_diamonds_balance` changes (i.e. whenever a
|
|
601
|
+
wallet event lands). The pushed payload is a FIXED re-fetch of the
|
|
602
|
+
**last 10 minutes / first 50 entries** — it does NOT honor the original
|
|
603
|
+
call's `startTimeSeconds` / `endTimeSeconds` / `from` / `to`. Consumers
|
|
604
|
+
maintaining a long historical view must re-call `getActivityLog` with
|
|
605
|
+
their own params after receiving an `onUpdate` notification.
|
|
606
|
+
|
|
607
|
+
**Refresh**
|
|
608
|
+
- The SDK caches results for 30 seconds.
|
|
609
|
+
- Push triggers fire only on balance changes; transactions that don't
|
|
610
|
+
alter a balance (theoretical zero-amount entries) won't refresh.
|
|
611
|
+
|
|
612
|
+
**Visitor mode**: not meaningful (no per-user history available).
|
|
613
|
+
|
|
614
|
+
**UI guidance**: see [UI Guide — `getActivityLog`](../_media/UIGuide_getActivityLog.md).
|
|
615
|
+
|
|
616
|
+
#### Example
|
|
617
|
+
|
|
618
|
+
```ts
|
|
619
|
+
const now = Math.floor(Date.now() / 1000);
|
|
620
|
+
const start = now - 86400 * 30; // 30 days
|
|
621
|
+
|
|
622
|
+
const log = await window._smartico.api.getActivityLog({
|
|
623
|
+
startTimeSeconds: start,
|
|
624
|
+
endTimeSeconds: now,
|
|
625
|
+
from: 0,
|
|
626
|
+
to: 50,
|
|
627
|
+
onUpdate: (refreshed) => {
|
|
628
|
+
console.log('[smartico] wallet changed — refreshed payload is last 10 min / 50 entries:', refreshed.length, 'rows');
|
|
629
|
+
// If the consumer is showing a full 30-day view, re-call getActivityLog with the original params here.
|
|
630
|
+
},
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
for (const row of log) {
|
|
634
|
+
const sign = row.amount >= 0 ? '+' : '';
|
|
635
|
+
console.log('[smartico] activity row — render with', row.type === 0 ? 'points' : row.type === 1 ? 'gems' : 'diamonds', 'icon, color by sign:', sign + row.amount, 'balance after:', row.balance, 'source:', row.source_type_id);
|
|
636
|
+
}
|
|
637
|
+
```
|