@apps-in-toss/native-modules 2.9.0 → 2.9.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/bridges-meta.json +4 -4
- package/dist/index.cjs +57 -43
- package/dist/index.js +57 -43
- package/package.json +2 -2
- package/src/MiniAppModule/native-modules/eventLog.ts +21 -2
package/dist/bridges-meta.json
CHANGED
|
@@ -71,6 +71,10 @@
|
|
|
71
71
|
"identifier": "appLogin",
|
|
72
72
|
"dts": "/**\n * @public\n * @category 로그인\n * @name appLogin\n * @description 토스 인증으로 로그인해요. 로그인이 완료되면 다시 토스 앱으로 이동해요.\n * @example\n *\n * ### 토스 인증을 통해 로그인을 하는 예제\n *\n * ```tsx\n * import { Button } from 'react-native';\n * import { appLogin } from '@apps-in-toss/framework';\n *\n * function Page() {\n * const handleLogin = async () => {\n * const { authorizationCode, referrer } = await appLogin();\n *\n * // 획득한 인가 코드(`authorizationCode`)와 `referrer`를 서버로 전달해요.\n * }\n *\n * return <Button title=\"로그인\" onPress={handleLogin} />;\n * }\n * ```\n */\nexport declare function appLogin(): Promise<{\n\tauthorizationCode: string;\n\treferrer: \"DEFAULT\" | \"SANDBOX\";\n}>;\n\nexport {};\n"
|
|
73
73
|
},
|
|
74
|
+
{
|
|
75
|
+
"identifier": "getAnonymousKey",
|
|
76
|
+
"dts": "export interface GetAnonymousKeySuccessResponse {\n\thash: string;\n\ttype: \"HASH\";\n}\nexport type GetAnonymousKeyResponse = GetAnonymousKeySuccessResponse;\n/**\n * @public\n * @name getAnonymousKey\n * @description\n * 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 데이터를 관리할 수 있어요.\n * @returns {Promise<GetAnonymousKeyResponse | 'ERROR' | undefined>}\n * 사용자 키 조회 결과를 반환해요.\n * - `GetAnonymousKeyResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.\n * - `'ERROR'`: 알 수 없는 오류가 발생했어요.\n * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.\n *\n * @example\n * ```tsx\n * // react-native\n * import { Button } from 'react-native';\n * import { getAnonymousKey } from '@apps-in-toss/framework';\n *\n * function UserKeyButton() {\n * async function handlePress() {\n * const result = await getAnonymousKey();\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('사용자 키 조회 중 오류가 발생했어요.');\n * return;\n * }\n *\n * if (result.type === 'HASH') {\n * console.log('사용자 키:', result.hash);\n * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.\n * }\n * }\n *\n * return (\n * <Button onPress={handlePress} title=\"유저 키 가져오기\" />\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // webview\n * import { getAnonymousKey } from '@apps-in-toss/web-framework';\n *\n * function UserKeyButton() {\n * async function handleClick() {\n * const result = await getAnonymousKey();\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('사용자 키 조회 중 오류가 발생했어요.');\n * return;\n * }\n *\n * if (result.type === 'HASH') {\n * console.log('사용자 키:', result.hash);\n * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.\n * }\n * }\n *\n * return (\n * <button onClick={handleClick}>유저 키 가져오기</button>\n * );\n * }\n * ```\n */\nexport declare function getAnonymousKey(): Promise<GetAnonymousKeySuccessResponse | \"ERROR\" | undefined>;\n\nexport {};\n"
|
|
77
|
+
},
|
|
74
78
|
{
|
|
75
79
|
"identifier": "eventLog",
|
|
76
80
|
"dts": "export type Primitive = string | number | boolean | null | undefined | symbol;\nexport interface EventLogParams {\n\tlog_name: string;\n\tlog_type: \"debug\" | \"info\" | \"warn\" | \"error\" | \"event\" | \"screen\" | \"impression\" | \"click\" | \"popup\";\n\tparams: Record<string, Primitive>;\n}\n/**\n * @category 로깅\n * @kind function\n * @name eventLog\n * @description\n * 이벤트 로그를 기록하는 함수예요.\n *\n * 이 함수는 앱 내에서 발생하는 다양한 이벤트를 로깅하는 데 사용돼요. 디버깅, 정보 제공, 경고, 오류 등 다양한 유형의 로그를 기록할 수 있어요. 샌드박스 환경에서는 콘솔에 로그가 출력되고, 실제 환경에서는 로그 시스템에 기록돼요.\n *\n * @param {Object} params 로그 기록에 필요한 매개변수 객체예요.\n * @param {string} params.log_name 로그의 이름이에요.\n * @param {'debug' | 'info' | 'warn' | 'error' | 'event' | 'screen' | 'impression' | 'click'} params.log_type 로그의 유형이에요.\n * @param {Record<string, Primitive>} params.params 로그에 포함할 추가 매개변수 객체예요.\n *\n * @returns {Promise<void>} 로그 기록이 완료되면 해결되는 Promise예요.\n *\n * @example\n * ### 이벤트 로그 기록하기\n *\n * ```tsx\n * import { eventLog } from '@apps-in-toss/framework';\n *\n * function logUserAction() {\n * eventLog({\n * log_name: 'user_action',\n * log_type: 'info',\n * params: {\n * action: 'button_click',\n * screen: 'main',\n * userId: 12345\n * }\n * });\n * }\n * ```\n */\nexport declare function eventLog(params: EventLogParams): Promise<void>;\n\nexport {};\n"
|
|
@@ -119,10 +123,6 @@
|
|
|
119
123
|
"identifier": "submitGameCenterLeaderBoardScore",
|
|
120
124
|
"dts": "/**\n * @public\n * @category 게임센터\n * @name SubmitGameCenterLeaderBoardScoreResponse\n * @description\n * 토스게임센터 리더보드에 점수를 제출한 결과 정보를 담아서 반환해요. 반환된 정보를 사용해서 점수 제출 결과에 따라 적절한 에러 처리를 할 수 있어요.\n * @property {'SUCCESS' | 'LEADERBOARD_NOT_FOUND' | 'PROFILE_NOT_FOUND' | 'UNPARSABLE_SCORE'} statusCode\n * 점수 제출 결과를 나타내는 상태 코드예요.\n * - `'SUCCESS'`: 점수 제출이 성공했어요.\n * - `'LEADERBOARD_NOT_FOUND'`: `gameId`에 해당하는 리더보드를 찾을 수 없어요.\n * - `'PROFILE_NOT_FOUND'`: 사용자의 프로필이 없어요.\n * - `'UNPARSABLE_SCORE'`: 점수를 해석할 수 없어요. 점수는 실수(float) 형태의 문자열로 전달해야 해요.\n */\nexport interface SubmitGameCenterLeaderBoardScoreResponse {\n\tstatusCode: \"SUCCESS\" | \"LEADERBOARD_NOT_FOUND\" | \"PROFILE_NOT_FOUND\" | \"UNPARSABLE_SCORE\";\n}\n/**\n * @public\n * @category 게임센터\n * @name submitGameCenterLeaderBoardScore\n * @description\n * 사용자의 게임 점수를 토스게임센터 리더보드에 제출해요. 이 기능으로 사용자의 점수를 공식 리더보드에 기록하고 다른 사용자와 비교할 수 있어요.\n * @param {string} params.score\n * 제출할 게임 점수예요. 실수 형태의 숫자를 문자열로 전달해야 해요. 예를들어 `\"123.45\"` 또는 `\"9999\"` 예요.\n * @returns {Promise<SubmitGameCenterLeaderBoardScoreResponse | undefined>}\n * 점수 제출 결과를 반환해요. 앱 버전이 최소 지원 버전보다 낮으면 아무 동작도 하지 않고 `undefined`를 반환해요.\n *\n * @example\n * ### 게임 점수를 토스게임센터 리더보드에 제출하기\n * ```tsx\n * import { Button } from 'react-native';\n * import { submitGameCenterLeaderBoardScore } from '@apps-in-toss/framework';\n *\n * function GameCenterLeaderBoardScoreSubmitButton() {\n * async function handlePress() {\n * try {\n * const result = await submitGameCenterLeaderBoardScore({ score: '123.45' });\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result.statusCode === 'SUCCESS') {\n * console.log('점수 제출 성공!');\n * } else {\n * console.error('점수 제출 실패:', result.statusCode);\n * }\n * } catch (error) {\n * console.error('점수 제출 중 오류가 발생했어요.', error);\n * }\n * }\n *\n * return (\n * <Button onPress={handlePress}>점수 제출하기</Button>\n * );\n * }\n * ```\n */\nexport declare function submitGameCenterLeaderBoardScore(params: {\n\tscore: string;\n}): Promise<SubmitGameCenterLeaderBoardScoreResponse | undefined>;\n\nexport {};\n"
|
|
121
125
|
},
|
|
122
|
-
{
|
|
123
|
-
"identifier": "getAnonymousKey",
|
|
124
|
-
"dts": "export interface GetAnonymousKeySuccessResponse {\n\thash: string;\n\ttype: \"HASH\";\n}\nexport type GetAnonymousKeyResponse = GetAnonymousKeySuccessResponse;\n/**\n * @public\n * @name getAnonymousKey\n * @description\n * 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 데이터를 관리할 수 있어요.\n * @returns {Promise<GetAnonymousKeyResponse | 'ERROR' | undefined>}\n * 사용자 키 조회 결과를 반환해요.\n * - `GetAnonymousKeyResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.\n * - `'ERROR'`: 알 수 없는 오류가 발생했어요.\n * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.\n *\n * @example\n * ```tsx\n * // react-native\n * import { Button } from 'react-native';\n * import { getAnonymousKey } from '@apps-in-toss/framework';\n *\n * function UserKeyButton() {\n * async function handlePress() {\n * const result = await getAnonymousKey();\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('사용자 키 조회 중 오류가 발생했어요.');\n * return;\n * }\n *\n * if (result.type === 'HASH') {\n * console.log('사용자 키:', result.hash);\n * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.\n * }\n * }\n *\n * return (\n * <Button onPress={handlePress} title=\"유저 키 가져오기\" />\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // webview\n * import { getAnonymousKey } from '@apps-in-toss/web-framework';\n *\n * function UserKeyButton() {\n * async function handleClick() {\n * const result = await getAnonymousKey();\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('사용자 키 조회 중 오류가 발생했어요.');\n * return;\n * }\n *\n * if (result.type === 'HASH') {\n * console.log('사용자 키:', result.hash);\n * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.\n * }\n * }\n *\n * return (\n * <button onClick={handleClick}>유저 키 가져오기</button>\n * );\n * }\n * ```\n */\nexport declare function getAnonymousKey(): Promise<GetAnonymousKeySuccessResponse | \"ERROR\" | undefined>;\n\nexport {};\n"
|
|
125
|
-
},
|
|
126
126
|
{
|
|
127
127
|
"identifier": "getUserKeyForGame",
|
|
128
128
|
"dts": "export interface GetAnonymousKeySuccessResponse {\n\thash: string;\n\ttype: \"HASH\";\n}\nexport type GetAnonymousKeyResponse = GetAnonymousKeySuccessResponse;\n/**\n * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetAnonymousKeySuccessResponse}를 사용해주세요.\n */\nexport type GetUserKeyForGameSuccessResponse = GetAnonymousKeySuccessResponse;\n/**\n * @deprecated 이 타입은 더 이상 사용되지 않습니다.\n */\nexport type GetUserKeyForGameErrorResponse = {\n\ttype: \"NOT_AVAILABLE\";\n};\n/**\n * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetAnonymousKeyResponse}를 사용해주세요.\n */\nexport type GetUserKeyForGameResponse = GetAnonymousKeyResponse | GetUserKeyForGameErrorResponse;\n/**\n *\n * @deprecated 이 함수는 더 이상 사용되지 않습니다. 대신 {@link getAnonymousKey}를 사용해주세요.\n */\nexport declare function getUserKeyForGame(): Promise<GetUserKeyForGameSuccessResponse | \"INVALID_CATEGORY\" | \"ERROR\" | undefined>;\n\nexport {};\n"
|
package/dist/index.cjs
CHANGED
|
@@ -514,6 +514,45 @@ async function appLogin() {
|
|
|
514
514
|
return safePostMessage("appLogin", {});
|
|
515
515
|
}
|
|
516
516
|
|
|
517
|
+
// src/MiniAppModule/constants.ts
|
|
518
|
+
var GAME_CENTER_MIN_VERSION = {
|
|
519
|
+
android: "5.221.0",
|
|
520
|
+
ios: "5.221.0"
|
|
521
|
+
};
|
|
522
|
+
var USER_KEY_MIN_VERSION = {
|
|
523
|
+
android: "5.232.0",
|
|
524
|
+
ios: "5.232.0"
|
|
525
|
+
};
|
|
526
|
+
var PROMOTION_REWARD_MIN_VERSION = {
|
|
527
|
+
android: "5.232.0",
|
|
528
|
+
ios: "5.232.0"
|
|
529
|
+
};
|
|
530
|
+
var GET_IS_TOSS_LOGIN_INTEGRATED_SERVICE_MIN_VERSION = {
|
|
531
|
+
android: "5.237.0",
|
|
532
|
+
ios: "5.237.0"
|
|
533
|
+
};
|
|
534
|
+
var GET_SERVER_TIME_MIN_VERSION = {
|
|
535
|
+
android: "5.245.0",
|
|
536
|
+
ios: "5.245.0"
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
// src/MiniAppModule/native-modules/getAnonymousKey.ts
|
|
540
|
+
async function getAnonymousKey() {
|
|
541
|
+
const isSupported = isMinVersionSupported(USER_KEY_MIN_VERSION);
|
|
542
|
+
if (!isSupported) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
try {
|
|
546
|
+
const response = await safePostMessage("getUserKeyForGame", {});
|
|
547
|
+
if (response.type === "HASH") {
|
|
548
|
+
return response;
|
|
549
|
+
}
|
|
550
|
+
return "ERROR";
|
|
551
|
+
} catch {
|
|
552
|
+
return "ERROR";
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
517
556
|
// src/MiniAppModule/native-modules/eventLog.ts
|
|
518
557
|
function normalizeParams(params) {
|
|
519
558
|
return Object.fromEntries(
|
|
@@ -521,11 +560,18 @@ function normalizeParams(params) {
|
|
|
521
560
|
);
|
|
522
561
|
}
|
|
523
562
|
async function eventLog(params) {
|
|
563
|
+
const logParams = {
|
|
564
|
+
anonymous_key: await cache("eventLog.defaultParams.anonymous_key", async () => {
|
|
565
|
+
const result = await getAnonymousKey();
|
|
566
|
+
return typeof result === "object" ? result.hash : "NONE";
|
|
567
|
+
}),
|
|
568
|
+
...params.params
|
|
569
|
+
};
|
|
524
570
|
if (MiniAppModule.getConstants().operationalEnvironment === "sandbox") {
|
|
525
571
|
console.log("[eventLogDebug]", {
|
|
526
572
|
log_name: params.log_name,
|
|
527
573
|
log_type: params.log_type,
|
|
528
|
-
params: normalizeParams(
|
|
574
|
+
params: normalizeParams(logParams)
|
|
529
575
|
});
|
|
530
576
|
return;
|
|
531
577
|
}
|
|
@@ -539,9 +585,18 @@ async function eventLog(params) {
|
|
|
539
585
|
return safePostMessage("eventLog", {
|
|
540
586
|
log_name: params.log_name,
|
|
541
587
|
log_type: params.log_type,
|
|
542
|
-
params: normalizeParams(
|
|
588
|
+
params: normalizeParams(logParams)
|
|
543
589
|
});
|
|
544
590
|
}
|
|
591
|
+
var _cache = {};
|
|
592
|
+
async function cache(key, fetcher) {
|
|
593
|
+
if (_cache[key]) {
|
|
594
|
+
return _cache[key];
|
|
595
|
+
}
|
|
596
|
+
const value = await fetcher();
|
|
597
|
+
_cache[key] = value;
|
|
598
|
+
return value;
|
|
599
|
+
}
|
|
545
600
|
|
|
546
601
|
// src/MiniAppModule/native-modules/permissions/fetchAlbumPhotos/fetchAlbumPhotos.ts
|
|
547
602
|
var import_types2 = require("@apps-in-toss/types");
|
|
@@ -948,30 +1003,6 @@ var Storage = {
|
|
|
948
1003
|
|
|
949
1004
|
// src/MiniAppModule/native-modules/openGameCenterLeaderboard.ts
|
|
950
1005
|
var import_react_native7 = require("@granite-js/react-native");
|
|
951
|
-
|
|
952
|
-
// src/MiniAppModule/constants.ts
|
|
953
|
-
var GAME_CENTER_MIN_VERSION = {
|
|
954
|
-
android: "5.221.0",
|
|
955
|
-
ios: "5.221.0"
|
|
956
|
-
};
|
|
957
|
-
var USER_KEY_MIN_VERSION = {
|
|
958
|
-
android: "5.232.0",
|
|
959
|
-
ios: "5.232.0"
|
|
960
|
-
};
|
|
961
|
-
var PROMOTION_REWARD_MIN_VERSION = {
|
|
962
|
-
android: "5.232.0",
|
|
963
|
-
ios: "5.232.0"
|
|
964
|
-
};
|
|
965
|
-
var GET_IS_TOSS_LOGIN_INTEGRATED_SERVICE_MIN_VERSION = {
|
|
966
|
-
android: "5.237.0",
|
|
967
|
-
ios: "5.237.0"
|
|
968
|
-
};
|
|
969
|
-
var GET_SERVER_TIME_MIN_VERSION = {
|
|
970
|
-
android: "5.245.0",
|
|
971
|
-
ios: "5.245.0"
|
|
972
|
-
};
|
|
973
|
-
|
|
974
|
-
// src/MiniAppModule/native-modules/openGameCenterLeaderboard.ts
|
|
975
1006
|
async function openGameCenterLeaderboard() {
|
|
976
1007
|
if (!isMinVersionSupported(GAME_CENTER_MIN_VERSION)) {
|
|
977
1008
|
return;
|
|
@@ -1004,23 +1035,6 @@ async function submitGameCenterLeaderBoardScore(params) {
|
|
|
1004
1035
|
return safePostMessage("submitGameCenterLeaderBoardScore", params);
|
|
1005
1036
|
}
|
|
1006
1037
|
|
|
1007
|
-
// src/MiniAppModule/native-modules/getAnonymousKey.ts
|
|
1008
|
-
async function getAnonymousKey() {
|
|
1009
|
-
const isSupported = isMinVersionSupported(USER_KEY_MIN_VERSION);
|
|
1010
|
-
if (!isSupported) {
|
|
1011
|
-
return;
|
|
1012
|
-
}
|
|
1013
|
-
try {
|
|
1014
|
-
const response = await safePostMessage("getUserKeyForGame", {});
|
|
1015
|
-
if (response.type === "HASH") {
|
|
1016
|
-
return response;
|
|
1017
|
-
}
|
|
1018
|
-
return "ERROR";
|
|
1019
|
-
} catch {
|
|
1020
|
-
return "ERROR";
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
1038
|
// src/MiniAppModule/native-modules/getUserKeyForGame.ts
|
|
1025
1039
|
async function getUserKeyForGame() {
|
|
1026
1040
|
return getAnonymousKey();
|
package/dist/index.js
CHANGED
|
@@ -427,6 +427,45 @@ async function appLogin() {
|
|
|
427
427
|
return safePostMessage("appLogin", {});
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
+
// src/MiniAppModule/constants.ts
|
|
431
|
+
var GAME_CENTER_MIN_VERSION = {
|
|
432
|
+
android: "5.221.0",
|
|
433
|
+
ios: "5.221.0"
|
|
434
|
+
};
|
|
435
|
+
var USER_KEY_MIN_VERSION = {
|
|
436
|
+
android: "5.232.0",
|
|
437
|
+
ios: "5.232.0"
|
|
438
|
+
};
|
|
439
|
+
var PROMOTION_REWARD_MIN_VERSION = {
|
|
440
|
+
android: "5.232.0",
|
|
441
|
+
ios: "5.232.0"
|
|
442
|
+
};
|
|
443
|
+
var GET_IS_TOSS_LOGIN_INTEGRATED_SERVICE_MIN_VERSION = {
|
|
444
|
+
android: "5.237.0",
|
|
445
|
+
ios: "5.237.0"
|
|
446
|
+
};
|
|
447
|
+
var GET_SERVER_TIME_MIN_VERSION = {
|
|
448
|
+
android: "5.245.0",
|
|
449
|
+
ios: "5.245.0"
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
// src/MiniAppModule/native-modules/getAnonymousKey.ts
|
|
453
|
+
async function getAnonymousKey() {
|
|
454
|
+
const isSupported = isMinVersionSupported(USER_KEY_MIN_VERSION);
|
|
455
|
+
if (!isSupported) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
try {
|
|
459
|
+
const response = await safePostMessage("getUserKeyForGame", {});
|
|
460
|
+
if (response.type === "HASH") {
|
|
461
|
+
return response;
|
|
462
|
+
}
|
|
463
|
+
return "ERROR";
|
|
464
|
+
} catch {
|
|
465
|
+
return "ERROR";
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
430
469
|
// src/MiniAppModule/native-modules/eventLog.ts
|
|
431
470
|
function normalizeParams(params) {
|
|
432
471
|
return Object.fromEntries(
|
|
@@ -434,11 +473,18 @@ function normalizeParams(params) {
|
|
|
434
473
|
);
|
|
435
474
|
}
|
|
436
475
|
async function eventLog(params) {
|
|
476
|
+
const logParams = {
|
|
477
|
+
anonymous_key: await cache("eventLog.defaultParams.anonymous_key", async () => {
|
|
478
|
+
const result = await getAnonymousKey();
|
|
479
|
+
return typeof result === "object" ? result.hash : "NONE";
|
|
480
|
+
}),
|
|
481
|
+
...params.params
|
|
482
|
+
};
|
|
437
483
|
if (MiniAppModule.getConstants().operationalEnvironment === "sandbox") {
|
|
438
484
|
console.log("[eventLogDebug]", {
|
|
439
485
|
log_name: params.log_name,
|
|
440
486
|
log_type: params.log_type,
|
|
441
|
-
params: normalizeParams(
|
|
487
|
+
params: normalizeParams(logParams)
|
|
442
488
|
});
|
|
443
489
|
return;
|
|
444
490
|
}
|
|
@@ -452,9 +498,18 @@ async function eventLog(params) {
|
|
|
452
498
|
return safePostMessage("eventLog", {
|
|
453
499
|
log_name: params.log_name,
|
|
454
500
|
log_type: params.log_type,
|
|
455
|
-
params: normalizeParams(
|
|
501
|
+
params: normalizeParams(logParams)
|
|
456
502
|
});
|
|
457
503
|
}
|
|
504
|
+
var _cache = {};
|
|
505
|
+
async function cache(key, fetcher) {
|
|
506
|
+
if (_cache[key]) {
|
|
507
|
+
return _cache[key];
|
|
508
|
+
}
|
|
509
|
+
const value = await fetcher();
|
|
510
|
+
_cache[key] = value;
|
|
511
|
+
return value;
|
|
512
|
+
}
|
|
458
513
|
|
|
459
514
|
// src/MiniAppModule/native-modules/permissions/fetchAlbumPhotos/fetchAlbumPhotos.ts
|
|
460
515
|
import { FetchAlbumPhotosPermissionError } from "@apps-in-toss/types";
|
|
@@ -861,30 +916,6 @@ var Storage = {
|
|
|
861
916
|
|
|
862
917
|
// src/MiniAppModule/native-modules/openGameCenterLeaderboard.ts
|
|
863
918
|
import { openURL } from "@granite-js/react-native";
|
|
864
|
-
|
|
865
|
-
// src/MiniAppModule/constants.ts
|
|
866
|
-
var GAME_CENTER_MIN_VERSION = {
|
|
867
|
-
android: "5.221.0",
|
|
868
|
-
ios: "5.221.0"
|
|
869
|
-
};
|
|
870
|
-
var USER_KEY_MIN_VERSION = {
|
|
871
|
-
android: "5.232.0",
|
|
872
|
-
ios: "5.232.0"
|
|
873
|
-
};
|
|
874
|
-
var PROMOTION_REWARD_MIN_VERSION = {
|
|
875
|
-
android: "5.232.0",
|
|
876
|
-
ios: "5.232.0"
|
|
877
|
-
};
|
|
878
|
-
var GET_IS_TOSS_LOGIN_INTEGRATED_SERVICE_MIN_VERSION = {
|
|
879
|
-
android: "5.237.0",
|
|
880
|
-
ios: "5.237.0"
|
|
881
|
-
};
|
|
882
|
-
var GET_SERVER_TIME_MIN_VERSION = {
|
|
883
|
-
android: "5.245.0",
|
|
884
|
-
ios: "5.245.0"
|
|
885
|
-
};
|
|
886
|
-
|
|
887
|
-
// src/MiniAppModule/native-modules/openGameCenterLeaderboard.ts
|
|
888
919
|
async function openGameCenterLeaderboard() {
|
|
889
920
|
if (!isMinVersionSupported(GAME_CENTER_MIN_VERSION)) {
|
|
890
921
|
return;
|
|
@@ -917,23 +948,6 @@ async function submitGameCenterLeaderBoardScore(params) {
|
|
|
917
948
|
return safePostMessage("submitGameCenterLeaderBoardScore", params);
|
|
918
949
|
}
|
|
919
950
|
|
|
920
|
-
// src/MiniAppModule/native-modules/getAnonymousKey.ts
|
|
921
|
-
async function getAnonymousKey() {
|
|
922
|
-
const isSupported = isMinVersionSupported(USER_KEY_MIN_VERSION);
|
|
923
|
-
if (!isSupported) {
|
|
924
|
-
return;
|
|
925
|
-
}
|
|
926
|
-
try {
|
|
927
|
-
const response = await safePostMessage("getUserKeyForGame", {});
|
|
928
|
-
if (response.type === "HASH") {
|
|
929
|
-
return response;
|
|
930
|
-
}
|
|
931
|
-
return "ERROR";
|
|
932
|
-
} catch {
|
|
933
|
-
return "ERROR";
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
|
|
937
951
|
// src/MiniAppModule/native-modules/getUserKeyForGame.ts
|
|
938
952
|
async function getUserKeyForGame() {
|
|
939
953
|
return getAnonymousKey();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/native-modules",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.9.
|
|
4
|
+
"version": "2.9.1",
|
|
5
5
|
"description": "Native Modules for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"typecheck": "tsc --noEmit",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"vitest": "^3.2.4"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@apps-in-toss/types": "2.9.
|
|
45
|
+
"@apps-in-toss/types": "2.9.1",
|
|
46
46
|
"brick-module": "0.5.2",
|
|
47
47
|
"es-toolkit": "^1.39.3"
|
|
48
48
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getAnonymousKey } from './getAnonymousKey';
|
|
1
2
|
import { isMinVersionSupported } from './isMinVersionSupported';
|
|
2
3
|
import { MiniAppModule, safePostMessage } from '../../natives';
|
|
3
4
|
import { Primitive } from '../../types';
|
|
@@ -52,11 +53,19 @@ export interface EventLogParams {
|
|
|
52
53
|
* ```
|
|
53
54
|
*/
|
|
54
55
|
export async function eventLog(params: EventLogParams) {
|
|
56
|
+
const logParams = {
|
|
57
|
+
anonymous_key: await cache('eventLog.defaultParams.anonymous_key', async () => {
|
|
58
|
+
const result = await getAnonymousKey();
|
|
59
|
+
return typeof result === 'object' ? result.hash : 'NONE';
|
|
60
|
+
}),
|
|
61
|
+
...params.params,
|
|
62
|
+
};
|
|
63
|
+
|
|
55
64
|
if (MiniAppModule.getConstants().operationalEnvironment === 'sandbox') {
|
|
56
65
|
console.log('[eventLogDebug]', {
|
|
57
66
|
log_name: params.log_name,
|
|
58
67
|
log_type: params.log_type,
|
|
59
|
-
params: normalizeParams(
|
|
68
|
+
params: normalizeParams(logParams),
|
|
60
69
|
});
|
|
61
70
|
return;
|
|
62
71
|
}
|
|
@@ -72,6 +81,16 @@ export async function eventLog(params: EventLogParams) {
|
|
|
72
81
|
return safePostMessage('eventLog', {
|
|
73
82
|
log_name: params.log_name,
|
|
74
83
|
log_type: params.log_type,
|
|
75
|
-
params: normalizeParams(
|
|
84
|
+
params: normalizeParams(logParams),
|
|
76
85
|
});
|
|
77
86
|
}
|
|
87
|
+
|
|
88
|
+
const _cache: Record<string, any> = {};
|
|
89
|
+
async function cache(key: string, fetcher: () => Promise<any>) {
|
|
90
|
+
if (_cache[key]) {
|
|
91
|
+
return _cache[key];
|
|
92
|
+
}
|
|
93
|
+
const value = await fetcher();
|
|
94
|
+
_cache[key] = value;
|
|
95
|
+
return value;
|
|
96
|
+
}
|