tagworks-sdk-v1-react 1.1.0

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 (33) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +33 -0
  3. package/android/build.gradle +101 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/AndroidManifestNew.xml +3 -0
  7. package/android/src/main/java/com/tagworkssdkv1/DataBundleModule.kt +229 -0
  8. package/android/src/main/java/com/tagworkssdkv1/StandardEventModule.kt +21 -0
  9. package/android/src/main/java/com/tagworkssdkv1/TagWorksModule.kt +317 -0
  10. package/android/src/main/java/com/tagworkssdkv1/TagworksSdkV1Module.kt +25 -0
  11. package/android/src/main/java/com/tagworkssdkv1/TagworksSdkV1Package.kt +18 -0
  12. package/ios/DataBundleModule.swift +271 -0
  13. package/ios/DataBundleModuleBridge.m +29 -0
  14. package/ios/StandardEventModule.swift +58 -0
  15. package/ios/StandardEventModuleBridge.m +17 -0
  16. package/ios/TagWorksModule.swift +262 -0
  17. package/ios/TagWorksModuleBridge.m +46 -0
  18. package/ios/TagworksSdkV1-Bridging-Header.h +2 -0
  19. package/ios/TagworksSdkV1.mm +14 -0
  20. package/ios/TagworksSdkV1.swift +8 -0
  21. package/lib/commonjs/index.js +38 -0
  22. package/lib/commonjs/index.js.map +1 -0
  23. package/lib/module/index.js +32 -0
  24. package/lib/module/index.js.map +1 -0
  25. package/lib/typescript/commonjs/package.json +1 -0
  26. package/lib/typescript/commonjs/src/index.d.ts +3 -0
  27. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  28. package/lib/typescript/module/package.json +1 -0
  29. package/lib/typescript/module/src/index.d.ts +3 -0
  30. package/lib/typescript/module/src/index.d.ts.map +1 -0
  31. package/package.json +189 -0
  32. package/src/index.tsx +25 -0
  33. package/tagworks-sdk-v1.podspec +43 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 pudaegii
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # tagworks-sdk-v1
2
+
3
+ TagWorks SDK React Native Library
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install tagworks-sdk-v1
9
+ ```
10
+
11
+ ## Usage
12
+
13
+
14
+ ```js
15
+ import { multiply } from 'tagworks-sdk-v1';
16
+
17
+ // ...
18
+
19
+ const result = await multiply(3, 7);
20
+ ```
21
+
22
+
23
+ ## Contributing
24
+
25
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
26
+
27
+ ## License
28
+
29
+ MIT
30
+
31
+ ---
32
+
33
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -0,0 +1,101 @@
1
+ buildscript {
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["TagworksSdkV1_kotlinVersion"]
4
+
5
+ repositories {
6
+ google()
7
+ mavenCentral()
8
+ }
9
+
10
+ dependencies {
11
+ classpath "com.android.tools.build:gradle:7.2.1"
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ }
15
+ }
16
+
17
+ def reactNativeArchitectures() {
18
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
19
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
20
+ }
21
+
22
+ def isNewArchitectureEnabled() {
23
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
24
+ }
25
+
26
+ apply plugin: "com.android.library"
27
+ apply plugin: "kotlin-android"
28
+
29
+ if (isNewArchitectureEnabled()) {
30
+ apply plugin: "com.facebook.react"
31
+ }
32
+
33
+ def getExtOrDefault(name) {
34
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["TagworksSdkV1_" + name]
35
+ }
36
+
37
+ def getExtOrIntegerDefault(name) {
38
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["TagworksSdkV1_" + name]).toInteger()
39
+ }
40
+
41
+ def supportsNamespace() {
42
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
43
+ def major = parsed[0].toInteger()
44
+ def minor = parsed[1].toInteger()
45
+
46
+ // Namespace support was added in 7.3.0
47
+ return (major == 7 && minor >= 3) || major >= 8
48
+ }
49
+
50
+ android {
51
+ if (supportsNamespace()) {
52
+ namespace "com.tagworkssdkv1"
53
+
54
+ sourceSets {
55
+ main {
56
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
57
+ }
58
+ }
59
+ }
60
+
61
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
62
+
63
+ defaultConfig {
64
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
65
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
66
+
67
+ }
68
+
69
+ buildTypes {
70
+ release {
71
+ minifyEnabled false
72
+ }
73
+ }
74
+
75
+ lintOptions {
76
+ disable "GradleCompatible"
77
+ }
78
+
79
+ compileOptions {
80
+ sourceCompatibility JavaVersion.VERSION_1_8
81
+ targetCompatibility JavaVersion.VERSION_1_8
82
+ }
83
+ }
84
+
85
+ repositories {
86
+ mavenCentral()
87
+ google()
88
+ maven { url "https://support.obzen.com/nexus/repository/releases/" }
89
+ }
90
+
91
+ def kotlin_version = getExtOrDefault("kotlinVersion")
92
+
93
+ dependencies {
94
+ // For < 0.71, this will be from the local maven repo
95
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
96
+ //noinspection GradleDynamicVersion
97
+ implementation "com.facebook.react:react-native:+"
98
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
99
+ implementation("com.obzen.tagworks:tagworks-v1-kotlin:1.1.18")
100
+ }
101
+
@@ -0,0 +1,5 @@
1
+ TagworksSdkV1_kotlinVersion=1.7.0
2
+ TagworksSdkV1_minSdkVersion=21
3
+ TagworksSdkV1_targetSdkVersion=31
4
+ TagworksSdkV1_compileSdkVersion=31
5
+ TagworksSdkV1_ndkversion=21.4.7075529
@@ -0,0 +1,4 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.tagworkssdkv1">
3
+ <uses-permission android:name="android.permission.INTERNET" />
4
+ </manifest>
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <uses-permission android:name="android.permission.INTERNET" />
3
+ </manifest>
@@ -0,0 +1,229 @@
1
+ package com.tagworkssdkv1
2
+
3
+ import android.util.Log
4
+ import com.facebook.react.bridge.Arguments
5
+ import com.facebook.react.bridge.Callback
6
+ import com.facebook.react.bridge.ReactApplicationContext
7
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
8
+ import com.facebook.react.bridge.ReactMethod
9
+ import com.obzen.tagworks.data.DataBundle
10
+ import com.obzen.tagworks.data.DimensionType
11
+ import com.obzen.tagworks.util.Logger
12
+ import org.json.JSONArray
13
+ import org.json.JSONObject
14
+
15
+
16
+ class DataBundleModule(context: ReactApplicationContext):ReactContextBaseJavaModule(context) {
17
+
18
+ private var eventData= DataBundle()
19
+
20
+ override fun getName(): String {
21
+ return "DataBundleModule"
22
+ }
23
+
24
+ /**
25
+ * DataBundle 초기화 함수
26
+ */
27
+
28
+
29
+ @ReactMethod
30
+ fun initDataBundle() {
31
+ eventData = DataBundle()
32
+ Logger.d(TAG, "DataBundle initialized")
33
+ }
34
+
35
+ /**
36
+ * DataBundle putString() 함수 - 개별
37
+ */
38
+ @ReactMethod
39
+ fun putString(key:String,value:String){
40
+ Log.d(TAG, "setEventToDataBundle: ${eventData.dataBundle}")
41
+ eventData.dataBundle.putString(key,value)
42
+ }
43
+
44
+
45
+ @ReactMethod
46
+ fun getDataBundle(callback: Callback) {
47
+ val mDataBundle = Arguments.createMap()
48
+
49
+ val dimensionsArray = Arguments.createArray()
50
+ for (dimension in eventData.dimensions) {
51
+ val dimensionMap = Arguments.createMap()
52
+ dimensionMap.putInt("index",dimension.index)
53
+ dimensionMap.putString("type",dimension.type.name)
54
+ if (dimension.value != null) dimensionMap.putString("value",dimension.value)
55
+ dimensionMap.putDouble("numValue",dimension.numValue)
56
+
57
+ dimensionsArray.pushMap(dimensionMap)
58
+ }
59
+
60
+ mDataBundle.putArray("dimensions", dimensionsArray)
61
+
62
+ val bundleMap = Arguments.createMap()
63
+ for (key in eventData.dataBundle.keySet()) {
64
+ bundleMap.putString(key, eventData.dataBundle.get(key) as String)
65
+ }
66
+ mDataBundle.putMap("dataBundle", bundleMap)
67
+
68
+ callback.invoke(mDataBundle)
69
+ }
70
+
71
+ /**
72
+ * dimension 설정
73
+ */
74
+
75
+ @ReactMethod
76
+ fun putDimensionWithString(index: Int, value: String) {
77
+ eventData.setDimension(index, value)
78
+ }
79
+
80
+ @ReactMethod
81
+ fun putDimensionWithDouble(index: Int, value: Double) {
82
+ eventData.setDimension(index, value)
83
+ }
84
+
85
+
86
+ @ReactMethod
87
+ fun getDimensions(callback: Callback) {
88
+ try {
89
+
90
+ val generalMap = Arguments.createMap()
91
+ val factMap = Arguments.createMap()
92
+
93
+ eventData.dimensions.forEach { dimension ->
94
+ when (dimension.type) {
95
+ DimensionType.GENERAL_TYPE -> generalMap.putString(dimension.index.toString(),dimension.value)
96
+ DimensionType.FACT_TYPE -> factMap.putDouble(dimension.index.toString(),dimension.numValue)
97
+ }
98
+ }
99
+
100
+ val generalWrapper = Arguments.createMap()
101
+ generalWrapper.putMap("General",generalMap)
102
+
103
+ val factWrapper = Arguments.createMap()
104
+ factWrapper.putMap("Fact",factMap)
105
+
106
+ val dimensionsArray = Arguments.createArray()
107
+ dimensionsArray.pushMap(generalWrapper)
108
+ dimensionsArray.pushMap(factWrapper)
109
+
110
+
111
+ val result = Arguments.createMap()
112
+ result.putArray("Dimensions", dimensionsArray)
113
+
114
+ // Callback으로 결과 전달
115
+ callback.invoke(result)
116
+ } catch (e: Exception) {
117
+ // 오류 처리
118
+ e.printStackTrace()
119
+ callback.invoke(null)
120
+ }
121
+ }
122
+
123
+ @ReactMethod
124
+ fun getDimensionsOfArrayIndex(callback: Callback) {
125
+ try {
126
+ val dimensions = JSONArray()
127
+
128
+ eventData.dimensions.forEach { dimension ->
129
+ val dimensionObject = JSONObject()
130
+ if (dimension.type == DimensionType.FACT_TYPE) {
131
+ dimensionObject.put("Fact_${dimension.index}",dimension.numValue)
132
+ } else if (dimension.type == DimensionType.GENERAL_TYPE) {
133
+ dimensionObject.put("General_${dimension.index}",dimension.value)
134
+ }
135
+ dimensions.put(dimensionObject)
136
+ }
137
+ val jsonString = dimensions.toString(4)
138
+ callback.invoke(jsonString)
139
+ } catch (e:Exception) {
140
+ callback.invoke(null)
141
+ }
142
+ }
143
+
144
+ @ReactMethod
145
+ fun getDimensionWithString(index: Int, callback: Callback) {
146
+ val mDimension = eventData.dimensions.firstOrNull { it.type == DimensionType.GENERAL_TYPE && it.index == index }
147
+
148
+ if (mDimension != null) {
149
+ callback.invoke(mDimension.value)
150
+ } else {
151
+ callback.invoke(null)
152
+ }
153
+ }
154
+
155
+ @ReactMethod
156
+ fun getDimensionWithDouble(index: Int, callback: Callback) {
157
+ val mDimension = eventData.dimensions.firstOrNull { it.type == DimensionType.FACT_TYPE && it.index == index }
158
+
159
+ if (mDimension != null) {
160
+ callback.invoke(mDimension.numValue)
161
+ } else {
162
+ callback.invoke(null)
163
+ }
164
+ }
165
+
166
+ /**
167
+ * Dimension 삭제
168
+ */
169
+
170
+ @ReactMethod
171
+ fun removeDimensionInGeneralType(index: Int) {
172
+ this.eventData.dimensions.removeAll { dimension ->
173
+ dimension.type == DimensionType.GENERAL_TYPE && dimension.index == index
174
+ }
175
+ }
176
+
177
+ @ReactMethod
178
+ fun removeDimensionInFactType(index: Int) {
179
+ this.eventData.dimensions.removeAll { dimension ->
180
+ dimension.type == DimensionType.FACT_TYPE && dimension.index == index
181
+ }
182
+ }
183
+
184
+ @ReactMethod
185
+ fun removeDimensionWithArrayIndex(arrayIndex: Int) {
186
+ this.eventData.dimensions.removeAt(arrayIndex)
187
+ }
188
+
189
+ @ReactMethod
190
+ fun removeAllDimension() {
191
+ this.eventData.dimensions.clear()
192
+ }
193
+
194
+
195
+ @ReactMethod
196
+ fun isParameterEmpty(callback: Callback) {
197
+ callback.invoke(this.eventData.dataBundle.isEmpty)
198
+ }
199
+
200
+ @ReactMethod
201
+ fun isDimensionEmpty(callback: Callback) {
202
+ callback.invoke(this.eventData.dimensions.isEmpty())
203
+ }
204
+
205
+ @ReactMethod
206
+ fun parameterCount(callback: Callback) {
207
+ callback.invoke(this.eventData.dataBundle.size())
208
+ }
209
+
210
+ @ReactMethod
211
+ fun dimensionCount(callback: Callback) {
212
+ callback.invoke(this.eventData.dimensions.size)
213
+ }
214
+
215
+
216
+ override fun getConstants(): MutableMap<String, Any> {
217
+ return mutableMapOf(
218
+ "EVENT_TAG_NAME" to DataBundle.EVENT_TAG_NAME,
219
+ "EVENT_TAG_PARAM_PAGE_PATH" to DataBundle.EVENT_TAG_PARAM_PAGE_PATH,
220
+ "EVENT_TAG_PARAM_TITLE" to DataBundle.EVENT_TAG_PARAM_TITLE,
221
+ "EVENT_TAG_PARAM_KEYWORD" to DataBundle.EVENT_TAG_PARAM_KEYWORD,
222
+ "EVENT_TAG_PARAM_CUSTOM_PATH" to DataBundle.EVENT_TAG_PARAM_CUSTOM_PATH
223
+ )
224
+ }
225
+
226
+ companion object{
227
+ const val TAG="DataBundleModule"
228
+ }
229
+ }
@@ -0,0 +1,21 @@
1
+ package com.tagworkssdkv1
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
5
+ import com.obzen.tagworks.constants.StandardEvent
6
+
7
+ class StandardEventModule(context: ReactApplicationContext):ReactContextBaseJavaModule(context) {
8
+
9
+ override fun getName(): String {
10
+ return "StandardEventModule"
11
+ }
12
+
13
+ override fun getConstants(): MutableMap<String, Any> {
14
+
15
+ val constants = mutableMapOf<String,Any>()
16
+ StandardEvent.values().forEach {
17
+ constants[it.name] = it.name
18
+ }
19
+ return constants
20
+ }
21
+ }