tagworks-sdk-v1-react 1.1.21 → 1.1.23

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.
Files changed (62) hide show
  1. package/LICENSE +3 -1
  2. package/README.md +6 -1049
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/com/tagworkssdkv1/DataBundleModule.kt +2 -27
  5. package/android/src/main/java/com/tagworkssdkv1/OnCmsBannerView.kt +68 -0
  6. package/android/src/main/java/com/tagworkssdkv1/OnCmsBannerViewManager.kt +23 -52
  7. package/android/src/main/java/com/tagworkssdkv1/TagWorksDeeplinkModule.kt +2 -2
  8. package/android/src/main/java/com/tagworkssdkv1/TagWorksModule.kt +47 -35
  9. package/android/src/main/java/com/tagworkssdkv1/TagworksSdkV1Package.kt +1 -1
  10. package/ios/DataBundleModule.swift +8 -8
  11. package/ios/OnCMSBannerViewManagerBridge.m +3 -2
  12. package/ios/OnCmsBannerViewManager.swift +145 -43
  13. package/ios/TagWorksDeeplinkModule.swift +1 -1
  14. package/ios/TagWorksDeeplinkModuleBridge.m +0 -34
  15. package/ios/TagWorksModule.swift +58 -45
  16. package/ios/TagWorksModuleBridge.m +14 -10
  17. package/ios/TagWorksPopupModule.swift +41 -24
  18. package/ios/TagWorksPopupModuleBridge.m +2 -0
  19. package/lib/commonjs/OnCmsBannerCommands.js +30 -0
  20. package/lib/commonjs/OnCmsBannerCommands.js.map +1 -0
  21. package/lib/commonjs/RegisterOnCmsBannerView.js +10 -0
  22. package/lib/commonjs/RegisterOnCmsBannerView.js.map +1 -0
  23. package/lib/commonjs/autoTrackers/ReactNavigationPageTracker.js +135 -0
  24. package/lib/commonjs/autoTrackers/ReactNavigationPageTracker.js.map +1 -0
  25. package/lib/commonjs/index.js +21 -5
  26. package/lib/commonjs/index.js.map +1 -1
  27. package/lib/module/OnCmsBannerCommands.js +25 -0
  28. package/lib/module/OnCmsBannerCommands.js.map +1 -0
  29. package/lib/module/RegisterOnCmsBannerView.js +6 -0
  30. package/lib/module/RegisterOnCmsBannerView.js.map +1 -0
  31. package/lib/module/autoTrackers/ReactNavigationPageTracker.js +131 -0
  32. package/lib/module/autoTrackers/ReactNavigationPageTracker.js.map +1 -0
  33. package/lib/module/index.js +8 -5
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/typescript/commonjs/android/build/intermediates/assets/debugAndroidTest/mergeDebugAndroidTestAssets/fingerprint_lib.d.ts +19 -0
  36. package/lib/typescript/commonjs/android/build/intermediates/assets/debugAndroidTest/mergeDebugAndroidTestAssets/fingerprint_lib.d.ts.map +1 -0
  37. package/lib/typescript/commonjs/src/OnCmsBannerCommands.d.ts +2 -0
  38. package/lib/typescript/commonjs/src/OnCmsBannerCommands.d.ts.map +1 -0
  39. package/lib/typescript/commonjs/src/RegisterOnCmsBannerView.d.ts +3 -0
  40. package/lib/typescript/commonjs/src/RegisterOnCmsBannerView.d.ts.map +1 -0
  41. package/lib/typescript/commonjs/src/autoTrackers/ReactNavigationPageTracker.d.ts +12 -0
  42. package/lib/typescript/commonjs/src/autoTrackers/ReactNavigationPageTracker.d.ts.map +1 -0
  43. package/lib/typescript/commonjs/src/index.d.ts +3 -2
  44. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  45. package/lib/typescript/module/android/build/intermediates/assets/debugAndroidTest/mergeDebugAndroidTestAssets/fingerprint_lib.d.ts +19 -0
  46. package/lib/typescript/module/android/build/intermediates/assets/debugAndroidTest/mergeDebugAndroidTestAssets/fingerprint_lib.d.ts.map +1 -0
  47. package/lib/typescript/module/src/OnCmsBannerCommands.d.ts +2 -0
  48. package/lib/typescript/module/src/OnCmsBannerCommands.d.ts.map +1 -0
  49. package/lib/typescript/module/src/RegisterOnCmsBannerView.d.ts +3 -0
  50. package/lib/typescript/module/src/RegisterOnCmsBannerView.d.ts.map +1 -0
  51. package/lib/typescript/module/src/autoTrackers/ReactNavigationPageTracker.d.ts +12 -0
  52. package/lib/typescript/module/src/autoTrackers/ReactNavigationPageTracker.d.ts.map +1 -0
  53. package/lib/typescript/module/src/index.d.ts +3 -2
  54. package/lib/typescript/module/src/index.d.ts.map +1 -1
  55. package/package.json +22 -4
  56. package/src/OnCmsBannerCommands.js +31 -0
  57. package/src/RegisterOnCmsBannerView.js +5 -0
  58. package/src/autoTrackers/ReactNavigationPageTracker.js +137 -0
  59. package/src/index.js +23 -6
  60. package/tagworks-sdk-v1-react.podspec +3 -2
  61. package/android/src/main/java/com/tagworkssdkv1/TagWorks.kt +0 -37
  62. package/android/src/main/java/com/tagworkssdkv1/TagworksSdkV1Module.kt +0 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tagworks-sdk-v1-react",
3
- "version": "1.1.21",
3
+ "version": "1.1.23",
4
4
  "description": "TagWorks SDK React Native Library",
5
5
  "source": "./src/index.js",
6
6
  "main": "./lib/commonjs/index.js",
@@ -55,7 +55,7 @@
55
55
  "url": "git+http://192.168.20.44:8443/etc/mobile/sdk/tagworks-sdk-v1-react.git"
56
56
  },
57
57
  "author": "pudaegii <pudaegii@obzen.com> (https://github.com/JongCheol-obzen)",
58
- "license": "MIT",
58
+ "license": "Apache-2.0",
59
59
  "bugs": {
60
60
  "url": "http://192.168.20.44:8443/etc/mobile/sdk/tagworks-sdk-v1-react/issues"
61
61
  },
@@ -75,7 +75,7 @@
75
75
  "eslint-plugin-prettier": "^5.0.1",
76
76
  "jest": "^29.7.0",
77
77
  "prettier": "^3.0.3",
78
- "react": "^18.3.1",
78
+ "react": "18.3.1",
79
79
  "react-native": "^0.76.5",
80
80
  "react-native-builder-bob": "^0.35.2",
81
81
  "release-it": "^17.10.0",
@@ -89,8 +89,26 @@
89
89
  "@types/react": "^18.2.44"
90
90
  },
91
91
  "peerDependencies": {
92
+ "@react-navigation/native": "*",
93
+ "@react-navigation/native-stack": "*",
92
94
  "react": "*",
93
- "react-native": "*"
95
+ "react-native": "*",
96
+ "react-native-safe-area-context": "*",
97
+ "react-native-screens": "*"
98
+ },
99
+ "peerDependenciesMeta": {
100
+ "@react-navigation/native": {
101
+ "optional": true
102
+ },
103
+ "@react-navigation/native-stack": {
104
+ "optional": true
105
+ },
106
+ "react-native-safe-area-context": {
107
+ "optional": true
108
+ },
109
+ "react-native-screens": {
110
+ "optional": true
111
+ }
94
112
  },
95
113
  "workspaces": [
96
114
  "example"
@@ -0,0 +1,31 @@
1
+ // OnCmsBannerCommands.js
2
+ import { UIManager, findNodeHandle, Platform } from 'react-native';
3
+
4
+ const VIEW_NAME = 'OnCmsBannerView';
5
+
6
+ export function attachBanner(ref, params) {
7
+ console.log('🟡 attachBannerRef:', ref);
8
+ console.log('🟡 attachBannerParams:', params);
9
+ const tag = findNodeHandle(ref.current);
10
+ if (!tag) return;
11
+
12
+ // 'VIEW_NAME'에 해당하는 네이티브 ViewManager 정보 조회
13
+ const config = UIManager.getViewManagerConfig(VIEW_NAME);
14
+ // console.log('🟡 ViewManagerConfig:', config);
15
+ // const commandId = config.Commands.setOnCmsBannerParam;
16
+ const commandId = config?.Constants?.Commands?.setOnCmsBannerParam;
17
+
18
+ if (commandId === undefined) {
19
+ console.error('❌ attach command not found', config);
20
+ return;
21
+ }
22
+
23
+ console.log('🟡 dispatchViewManagerCommand tag:', tag);
24
+ console.log('🟡 dispatchViewManagerCommand commandId:', commandId);
25
+ UIManager.dispatchViewManagerCommand(tag, commandId, [
26
+ params.url,
27
+ params.custId,
28
+ params.areaCd,
29
+ params.defaultImage,
30
+ ]);
31
+ }
@@ -0,0 +1,5 @@
1
+ import { requireNativeComponent } from 'react-native';
2
+
3
+ const OnCmsBannerView = requireNativeComponent('OnCmsBannerView');
4
+
5
+ export default OnCmsBannerView;
@@ -0,0 +1,137 @@
1
+ // autoTrackers/reactNavigationPageTracker.js
2
+ // React Navigation 전용
3
+
4
+ import * as React from 'react';
5
+ import { useRef, useCallback } from 'react';
6
+ import * as ReactNavigation from '@react-navigation/native';
7
+ import { NavigationContainer } from '@react-navigation/native';
8
+ import { NativeModules } from 'react-native';
9
+
10
+ // 로그 전송 함수
11
+ const logEventPageView = (currentScreen, previousScreen, indexPath) => {
12
+ const { TagWorksModule, DataBundleModule, StandardEventModule } = NativeModules;
13
+
14
+ if (currentScreen) {
15
+ console.log(`[TagWorks SDK] 화면 전환 완료: ${previousScreen || '앱 시작'} -> ${currentScreen}, indexPath: ${indexPath}`);
16
+
17
+ // TODO: 여기에 SDK의 실제 로그 전송 API 호출 로직을 구현합니다.
18
+ DataBundleModule.initialize();
19
+ DataBundleModule.putString(
20
+ DataBundleModule.EVENT_TAG_NAME, StandardEventModule.PAGE_VIEW
21
+ );
22
+ DataBundleModule.putString(
23
+ DataBundleModule.EVENT_TAG_PARAM_TITLE, currentScreen
24
+ );
25
+ DataBundleModule.putString(
26
+ DataBundleModule.EVENT_TAG_PARAM_PAGE_PATH, indexPath
27
+ );
28
+ DataBundleModule.getDataBundle((bundleString) => {
29
+ console.log('Received Dictionary String:', bundleString);
30
+
31
+ TagWorksModule.logEvent(
32
+ TagWorksModule.EVENT_TYPE_PAGE,
33
+ bundleString,
34
+ (result) => {
35
+ console.log(result);
36
+ }
37
+ );
38
+ });
39
+ }
40
+ };
41
+
42
+ function buildPathFromStack(state) {
43
+ const segments = state.routes.map(r => r.name);
44
+ return segments.join('/');
45
+ }
46
+
47
+ /**
48
+ * React Navigation 기반 앱의 화면 전환 로그를 자동으로 추적하는 래퍼 컴포넌트입니다.
49
+ * * @param {object} props
50
+ * @param {React.ReactNode} props.children - NavigationContainer 내부의 모든 내비게이터
51
+ * @param {(state: NavigationState | undefined) => void} [props.onStateChange] - 앱 개발자가 정의한 onStateChange 핸들러 (체인 연결)
52
+ */
53
+ export function TagWorksNavigationContainer({
54
+ children,
55
+ onReady,
56
+ onStateChange, // <-- onReady, onStateChange prop 추가
57
+ excludedScreenNames = [], // ✨ 기본값으로 빈 배열을 설정하고 prop으로 받습니다.
58
+ ...restProps // ✨ 나머지 모든 prop을 받습니다.
59
+ }) {
60
+ // 이전 화면 이름을 저장하기 위한 Ref
61
+ const routeNameRef = useRef(null);
62
+ // NavigationContainer의 Ref (navigation 객체 접근용)
63
+ const navigationRef = useRef(null);
64
+
65
+ // onReady 핸들러를 체인으로 연결하는 함수
66
+ const chainedHandleReady = useCallback(() => {
67
+ // 1. SDK의 내부 로직 실행
68
+ if (navigationRef.current) {
69
+ const initialRoute = navigationRef.current.getCurrentRoute();
70
+ routeNameRef.current = initialRoute ? initialRoute.name : null;
71
+ // SDK의 로그 전송 로직 실행
72
+ // 초기 화면이 제외 목록에 포함되지 않는 경우에만 로그 전송
73
+ if (routeNameRef.current && !excludedScreenNames.includes(routeNameRef.current)) { // ✨ 제외 로직 추가
74
+ logEventPageView(routeNameRef.current, "", routeNameRef.current);
75
+ }
76
+ console.log(`[TagWorks SDK] NavigationContainer 준비 완료. 초기 화면: ${routeNameRef.current}`);
77
+ }
78
+
79
+ // 2. 외부에서 전달된 onReady prop이 있다면 실행
80
+ if (onReady) {
81
+ onReady();
82
+ }
83
+ }, [onReady]); // onReady prop이 변경될 때마다 함수가 재생성됩니다.
84
+
85
+ // SDK의 로그 로직과 외부 prop을 연결하는 체인 함수
86
+ const chainedHandleStateChange = useCallback((state) => {
87
+
88
+ // 1. **널 체크:** navigationRef.current가 설정되지 않았으면 (초기화 전) 로직 중단
89
+ if (!navigationRef.current) {
90
+ if (onStateChange) {
91
+ onStateChange(state); // 외부 함수는 호출
92
+ }
93
+ return;
94
+ }
95
+
96
+ // 2. 현재 활성화된 화면 정보 가져오기 (React Navigation 내부 함수 활용)
97
+ const currentRoute = navigationRef.current.getCurrentRoute();
98
+ const currentRouteName = currentRoute ? currentRoute.name : null;
99
+ const previousRouteName = routeNameRef.current;
100
+
101
+ // 3. **로그 중복 방지 및 화면 전환 확인**
102
+ // 이전 화면 이름과 현재 화면 이름이 다를 때만 로그 전송
103
+ if (currentRouteName && previousRouteName !== currentRouteName) {
104
+ // ✨ 핵심: 현재 화면 이름이 제외 대상 목록에 포함되는지 확인
105
+ const shouldExclude = excludedScreenNames.includes(currentRouteName);
106
+
107
+ if (!shouldExclude) { // 제외 대상이 아닐 경우에만 로그 전송
108
+ // SDK의 로그 전송 로직 실행
109
+ logEventPageView(currentRouteName, previousRouteName, buildPathFromStack(state));
110
+ console.log(`[TagWorks SDK] 로그 전송: ${previousRouteName} -> ${currentRouteName}`);
111
+ } else {
112
+ console.log(`[TagWorks SDK] 로그 제외 (Excluded Screen): ${currentRouteName}`);
113
+ }
114
+
115
+ // 현재 화면 이름을 저장하여 다음 전환 시 이전 화면으로 사용
116
+ routeNameRef.current = currentRouteName;
117
+ }
118
+
119
+ // 4. **체이닝:** 외부에서 전달된 onStateChange prop이 있다면 실행
120
+ if (onStateChange) {
121
+ onStateChange(state);
122
+ }
123
+
124
+ }, [onStateChange, excludedScreenNames]); // onStateChange prop이 변경될 때마다 useCallback이 최신 함수를 참조하도록 합니다.
125
+ // excludedScreenNames도 의존성 배열에 추가합니다.
126
+
127
+ return (
128
+ <NavigationContainer
129
+ ref={navigationRef}
130
+ onReady={chainedHandleReady} // <-- 체인된 함수를 전달합니다.
131
+ onStateChange={chainedHandleStateChange}
132
+ {...restProps} // ✨ 나머지 prop을 여기에 전달합니다.
133
+ >
134
+ {children}
135
+ </NavigationContainer>
136
+ );
137
+ }
package/src/index.js CHANGED
@@ -1,11 +1,28 @@
1
- // import { NativeModules, Platform } from 'react-native';
2
- import { NativeModules, requireNativeComponent } from 'react-native';
1
+ import { NativeModules } from 'react-native';
3
2
  import TagWorksDeeplink from './TagWorksDeeplink';
3
+ import OnCmsBannerView from './RegisterOnCmsBannerView';
4
+ // import { attachBanner } from './OnCmsBannerCommands';
5
+ import { TagWorksNavigationContainer } from './autoTrackers/ReactNavigationPageTracker';
4
6
 
5
- const OnCmsBannerView = requireNativeComponent('OnCmsBannerView');
7
+ // NativeModules
8
+ const {
9
+ TagWorksModule,
10
+ DataBundleModule,
11
+ StandardEventModule,
12
+ TagWorksPopupModule,
13
+ TagWorksDeeplinkModule,
14
+ } = NativeModules;
6
15
 
7
- const { TagWorksModule, DataBundleModule, StandardEventModule, TagWorksPopupModule, TagWorksDeeplinkModule } = NativeModules;
8
- export { TagWorksModule, DataBundleModule, StandardEventModule, TagWorksPopupModule, TagWorksDeeplinkModule, OnCmsBannerView, TagWorksDeeplink };
16
+ export {
17
+ TagWorksModule,
18
+ DataBundleModule,
19
+ StandardEventModule,
20
+ TagWorksPopupModule,
21
+ TagWorksDeeplinkModule,
22
+ TagWorksDeeplink,
23
+ OnCmsBannerView,
24
+ TagWorksNavigationContainer,
25
+ };
9
26
 
10
27
 
11
28
 
@@ -13,7 +30,7 @@ export { TagWorksModule, DataBundleModule, StandardEventModule, TagWorksPopupMod
13
30
  // const LINKING_ERROR =
14
31
  // `The package 'tagworks-sdk-v1' doesn't seem to be linked. Make sure: \n\n` +
15
32
  // Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
16
- // '- You rebuilt the app after installing the package\n' +
33
+ // '- You rebuilt the app after installing the package\n' +33
17
34
  // '- You are not using Expo Go\n';
18
35
 
19
36
  // const TagworksSdkV1 = NativeModules.TagworksSdkV1
@@ -12,11 +12,12 @@ Pod::Spec.new do |s|
12
12
  s.authors = package["author"]
13
13
 
14
14
  s.platforms = { :ios => min_ios_version_supported }
15
- # s.source = { :git => "http://192.168.20.44:8443/etc/mobile/sdk/tagworks-sdk-v1-react.git", :tag => "#{s.version}" }
15
+ s.source = { :git => "http://192.168.20.44:8443/etc/mobile/sdk/tagworks-sdk-v1-react.git", :tag => "#{s.version}" }
16
16
 
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
  s.requires_arc = true
19
- s.dependency "TagWorks-SDK-iOS", '~> 1.1.30'
19
+ s.dependency "TagWorks_SDK_iOS_v1", '~> 1.1.7'
20
+ #s.dependency "TagWorks-SDK-iOS", '~> 1.1.30'
20
21
 
21
22
 
22
23
  # XCFramework 배포
@@ -1,37 +0,0 @@
1
- package com.tagworkssdkv1
2
-
3
- import android.content.Context
4
- import com.obzen.tagworks.TagWorks
5
- import com.obzen.tagworks.TagWorksConfig
6
-
7
- object TagWorks {
8
-
9
- fun initializeTagWorks(
10
- context: Context, // ApplicationContext 사용
11
- siteId: String,
12
- baseUrl: String,
13
- isUseIntervals: Boolean,
14
- dispatchInterval: Long,
15
- sessionTimeout: Long,
16
- isManualDispatch: Boolean,
17
- appVersion: String? = null,
18
- appName: String? = null,
19
- isUseDynamicParameter: Boolean,
20
- deeplinkServerUrl: String
21
- ) {
22
- val config = TagWorksConfig.Builder()
23
- .setSiteId(siteId)
24
- .setBaseUrl(baseUrl)
25
- .setDispatchInterval(dispatchInterval)
26
- .setSessionTimeOut((sessionTimeout * 1000))
27
- .setAppVersion(appVersion)
28
- .setAppName(appName)
29
- .setManualDispatch(isManualDispatch)
30
- .setIsUseIntervals(isUseIntervals)
31
- .setIsUseDynamicParameter(isUseDynamicParameter)
32
- .setDeeplinkServerUrl(deeplinkServerUrl)
33
- .build()
34
- TagWorks.initializeSdk(context, config) // ReactApplicationContext 필요 없음
35
- }
36
- }
37
-
@@ -1,25 +0,0 @@
1
- package com.tagworkssdkv1
2
-
3
- import com.facebook.react.bridge.ReactApplicationContext
4
- import com.facebook.react.bridge.ReactContextBaseJavaModule
5
- import com.facebook.react.bridge.ReactMethod
6
- import com.facebook.react.bridge.Promise
7
-
8
- class TagworksSdkV1Module(reactContext: ReactApplicationContext) :
9
- ReactContextBaseJavaModule(reactContext) {
10
-
11
- override fun getName(): String {
12
- return NAME
13
- }
14
-
15
- // Example method
16
- // See https://reactnative.dev/docs/native-modules-android
17
- @ReactMethod
18
- fun multiply(a: Double, b: Double, promise: Promise) {
19
- promise.resolve(a * b)
20
- }
21
-
22
- companion object {
23
- const val NAME = "TagworksSdkV1"
24
- }
25
- }