@snowplow/react-native-tracker 1.4.0 → 2.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 (240) hide show
  1. package/.editorconfig +15 -0
  2. package/.eslintignore +6 -0
  3. package/.gitattributes +3 -0
  4. package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
  5. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. package/.github/actions/setup/action.yml +28 -0
  7. package/.github/workflows/build.yml +155 -0
  8. package/.github/workflows/deploy.yml +97 -0
  9. package/.github/workflows/e2e-android.yml +121 -0
  10. package/.github/workflows/e2e-ios.yml +95 -0
  11. package/.github/workflows/snyk.yml +21 -0
  12. package/.gitignore +70 -0
  13. package/.npmignore +60 -0
  14. package/.nvmrc +1 -0
  15. package/.watchmanconfig +1 -0
  16. package/.yarnrc +3 -0
  17. package/CHANGELOG +176 -0
  18. package/CONTRIBUTING.md +80 -0
  19. package/LICENSE +1 -1
  20. package/README.md +24 -111
  21. package/android/build.gradle +93 -37
  22. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  23. package/android/gradle/wrapper/gradle-wrapper.properties +1 -2
  24. package/android/gradle.properties +5 -2
  25. package/android/gradlew +172 -110
  26. package/android/gradlew.bat +24 -19
  27. package/android/src/main/AndroidManifest.xml +1 -3
  28. package/android/src/main/AndroidManifestNew.xml +2 -0
  29. package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerModule.kt +744 -0
  30. package/android/src/main/java/com/snowplow/reactnativetracker/ReactNativeTrackerPackage.kt +17 -0
  31. package/android/src/main/java/com/snowplow/reactnativetracker/util/ConfigUtil.kt +274 -0
  32. package/android/src/main/java/com/snowplow/reactnativetracker/util/EventUtil.kt +233 -0
  33. package/android/src/main/java/com/snowplow/reactnativetracker/util/TrackerVersion.kt +5 -0
  34. package/babel.config.js +3 -0
  35. package/example/.watchmanconfig +1 -0
  36. package/example/Gemfile +6 -0
  37. package/example/android/app/build.gradle +129 -0
  38. package/example/android/app/debug.keystore +0 -0
  39. package/example/android/app/proguard-rules.pro +10 -0
  40. package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTest.java +36 -0
  41. package/example/android/app/src/androidTest/java/com/reactnativetrackerexample/DetoxTestAppJUnitRunner.java +21 -0
  42. package/example/android/app/src/debug/AndroidManifest.xml +13 -0
  43. package/example/android/app/src/debug/java/com/reactnativetrackerexample/ReactNativeFlipper.java +75 -0
  44. package/example/android/app/src/main/AndroidManifest.xml +26 -0
  45. package/example/android/app/src/main/java/com/reactnativetrackerexample/MainActivity.java +32 -0
  46. package/example/android/app/src/main/java/com/reactnativetrackerexample/MainApplication.java +62 -0
  47. package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
  48. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  49. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  50. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  51. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  52. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  53. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  54. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  55. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  56. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  57. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  58. package/example/android/app/src/main/res/values/strings.xml +3 -0
  59. package/example/android/app/src/main/res/values/styles.xml +9 -0
  60. package/example/android/app/src/release/java/com/reactnativetrackerexample/ReactNativeFlipper.java +20 -0
  61. package/example/android/build.gradle +31 -0
  62. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  63. package/example/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  64. package/example/android/gradle.properties +44 -0
  65. package/example/android/gradlew +244 -0
  66. package/example/android/gradlew.bat +92 -0
  67. package/example/android/settings.gradle +4 -0
  68. package/example/app.json +4 -0
  69. package/example/babel.config.js +17 -0
  70. package/example/detox.config.js +92 -0
  71. package/example/e2e/config.json +10 -0
  72. package/example/e2e/emitEvents.e2e.detox.js +95 -0
  73. package/example/e2e/environment.js +23 -0
  74. package/example/e2e/helpers/microCommands.js +140 -0
  75. package/example/e2e/helpers/microHelpers.js +333 -0
  76. package/example/e2e/helpers/microHelpers.test.js +295 -0
  77. package/example/e2e/helpers/schemas.js +49 -0
  78. package/example/e2e/jest.config.js +16 -0
  79. package/example/e2e/setup.js +4 -0
  80. package/example/e2e/testEvents.micro.test.js +287 -0
  81. package/example/index.js +5 -0
  82. package/example/ios/.xcode.env +11 -0
  83. package/example/ios/Podfile +62 -0
  84. package/example/ios/Podfile.lock +730 -0
  85. package/example/ios/ReactNativeTrackerExample/AppDelegate.h +6 -0
  86. package/example/ios/ReactNativeTrackerExample/AppDelegate.mm +26 -0
  87. package/example/ios/ReactNativeTrackerExample/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  88. package/example/ios/ReactNativeTrackerExample/Images.xcassets/Contents.json +6 -0
  89. package/example/ios/ReactNativeTrackerExample/Info.plist +55 -0
  90. package/example/ios/ReactNativeTrackerExample/LaunchScreen.storyboard +47 -0
  91. package/example/ios/ReactNativeTrackerExample/main.m +10 -0
  92. package/example/ios/ReactNativeTrackerExample-Bridging-Header.h +3 -0
  93. package/example/ios/ReactNativeTrackerExample.xcodeproj/project.pbxproj +722 -0
  94. package/{ios/RNSnowplowTracker.xcodeproj/xcshareddata/xcschemes/RNSnowplowTracker.xcscheme → example/ios/ReactNativeTrackerExample.xcodeproj/xcshareddata/xcschemes/ReactNativeTrackerExample.xcscheme} +29 -21
  95. package/example/ios/ReactNativeTrackerExample.xcworkspace/contents.xcworkspacedata +10 -0
  96. package/example/ios/ReactNativeTrackerExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  97. package/example/ios/ReactNativeTrackerExampleTests/Info.plist +24 -0
  98. package/example/ios/ReactNativeTrackerExampleTests/ReactNativeTrackerExampleTests.m +66 -0
  99. package/example/metro.config.js +45 -0
  100. package/example/package.json +54 -0
  101. package/example/react-native.config.js +10 -0
  102. package/example/src/App.js +566 -0
  103. package/example/tsconfig.json +5 -0
  104. package/example/yarn.lock +7379 -0
  105. package/ios/ReactNativeTracker-Bridging-Header.h +2 -0
  106. package/ios/ReactNativeTracker.mm +175 -0
  107. package/ios/ReactNativeTracker.swift +822 -0
  108. package/ios/{RNSnowplowTracker.xcodeproj → ReactNativeTracker.xcodeproj}/project.pbxproj +55 -79
  109. package/ios/Util/ConfigUtils.swift +209 -0
  110. package/ios/Util/TrackerVersion.swift +3 -0
  111. package/ios/Util/Utilities.swift +37 -0
  112. package/lefthook.yml +11 -0
  113. package/lib/commonjs/api.js +490 -0
  114. package/lib/commonjs/api.js.map +1 -0
  115. package/lib/commonjs/configurations.js +196 -0
  116. package/lib/commonjs/configurations.js.map +1 -0
  117. package/lib/commonjs/constants.js +77 -0
  118. package/lib/commonjs/constants.js.map +1 -0
  119. package/lib/commonjs/events.js +277 -0
  120. package/lib/commonjs/events.js.map +1 -0
  121. package/lib/commonjs/index.js +132 -0
  122. package/lib/commonjs/index.js.map +1 -0
  123. package/lib/commonjs/jsCore.js +427 -0
  124. package/lib/commonjs/jsCore.js.map +1 -0
  125. package/lib/commonjs/native.js +16 -0
  126. package/lib/commonjs/native.js.map +1 -0
  127. package/lib/commonjs/subject.js +235 -0
  128. package/lib/commonjs/subject.js.map +1 -0
  129. package/lib/commonjs/tracker.js +248 -0
  130. package/lib/commonjs/tracker.js.map +1 -0
  131. package/lib/commonjs/types.js +2 -0
  132. package/lib/commonjs/types.js.map +1 -0
  133. package/lib/commonjs/utils.js +72 -0
  134. package/lib/commonjs/utils.js.map +1 -0
  135. package/lib/commonjs/webViewInterface.js +66 -0
  136. package/lib/commonjs/webViewInterface.js.map +1 -0
  137. package/lib/module/api.js +452 -0
  138. package/lib/module/api.js.map +1 -0
  139. package/lib/module/configurations.js +184 -0
  140. package/lib/module/configurations.js.map +1 -0
  141. package/lib/module/constants.js +72 -0
  142. package/lib/module/constants.js.map +1 -0
  143. package/lib/module/events.js +259 -0
  144. package/lib/module/events.js.map +1 -0
  145. package/lib/module/index.js +120 -0
  146. package/lib/module/index.js.map +1 -0
  147. package/lib/module/jsCore.js +424 -0
  148. package/lib/module/jsCore.js.map +1 -0
  149. package/lib/module/native.js +12 -0
  150. package/lib/module/native.js.map +1 -0
  151. package/lib/module/subject.js +222 -0
  152. package/lib/module/subject.js.map +1 -0
  153. package/lib/module/tracker.js +234 -0
  154. package/lib/module/tracker.js.map +1 -0
  155. package/lib/module/types.js +2 -0
  156. package/lib/module/types.js.map +1 -0
  157. package/lib/module/utils.js +66 -0
  158. package/lib/module/utils.js.map +1 -0
  159. package/lib/module/webViewInterface.js +62 -0
  160. package/lib/module/webViewInterface.js.map +1 -0
  161. package/lib/typescript/__tests__/api.test.d.ts +2 -0
  162. package/lib/typescript/__tests__/api.test.d.ts.map +1 -0
  163. package/lib/typescript/__tests__/configurations.test.d.ts +2 -0
  164. package/lib/typescript/__tests__/configurations.test.d.ts.map +1 -0
  165. package/lib/typescript/__tests__/events.test.d.ts +2 -0
  166. package/lib/typescript/__tests__/events.test.d.ts.map +1 -0
  167. package/lib/typescript/__tests__/index.test.d.ts +2 -0
  168. package/lib/typescript/__tests__/index.test.d.ts.map +1 -0
  169. package/lib/typescript/__tests__/jsCore.test.d.ts +2 -0
  170. package/lib/typescript/__tests__/jsCore.test.d.ts.map +1 -0
  171. package/lib/typescript/__tests__/utils.test.d.ts +2 -0
  172. package/lib/typescript/__tests__/utils.test.d.ts.map +1 -0
  173. package/lib/typescript/api.d.ts +240 -0
  174. package/lib/typescript/api.d.ts.map +1 -0
  175. package/lib/typescript/configurations.d.ts +73 -0
  176. package/lib/typescript/configurations.d.ts.map +1 -0
  177. package/lib/typescript/constants.d.ts +64 -0
  178. package/lib/typescript/constants.d.ts.map +1 -0
  179. package/lib/typescript/events.d.ts +115 -0
  180. package/lib/typescript/events.d.ts.map +1 -0
  181. package/lib/typescript/index.d.ts +27 -0
  182. package/lib/typescript/index.d.ts.map +1 -0
  183. package/lib/typescript/jsCore.d.ts +152 -0
  184. package/lib/typescript/jsCore.d.ts.map +1 -0
  185. package/lib/typescript/native.d.ts +4 -0
  186. package/lib/typescript/native.d.ts.map +1 -0
  187. package/lib/typescript/subject.d.ts +91 -0
  188. package/lib/typescript/subject.d.ts.map +1 -0
  189. package/lib/typescript/tracker.d.ts +111 -0
  190. package/lib/typescript/tracker.d.ts.map +1 -0
  191. package/{dist/index.d.ts → lib/typescript/types.d.ts} +264 -73
  192. package/lib/typescript/types.d.ts.map +1 -0
  193. package/lib/typescript/utils.d.ts +35 -0
  194. package/lib/typescript/utils.d.ts.map +1 -0
  195. package/lib/typescript/webViewInterface.d.ts +15 -0
  196. package/lib/typescript/webViewInterface.d.ts.map +1 -0
  197. package/package.json +135 -53
  198. package/scripts/bootstrap.js +29 -0
  199. package/snowplow-react-native-tracker.podspec +42 -0
  200. package/src/__mocks__/react-native.js +7 -0
  201. package/src/__tests__/api.test.ts +21 -0
  202. package/src/__tests__/configurations.test.ts +608 -0
  203. package/src/__tests__/events.test.ts +736 -0
  204. package/src/__tests__/index.test.ts +14 -0
  205. package/src/__tests__/jsCore.test.ts +199 -0
  206. package/src/__tests__/utils.test.ts +10 -0
  207. package/src/api.ts +556 -0
  208. package/src/configurations.ts +325 -0
  209. package/src/constants.ts +97 -0
  210. package/src/events.ts +355 -0
  211. package/src/index.ts +184 -0
  212. package/src/jsCore.ts +603 -0
  213. package/src/native.ts +21 -0
  214. package/src/subject.ts +302 -0
  215. package/src/tracker.ts +377 -0
  216. package/src/types.ts +1162 -0
  217. package/src/utils.ts +65 -0
  218. package/src/webViewInterface.ts +92 -0
  219. package/tsconfig.build.json +5 -0
  220. package/tsconfig.json +28 -0
  221. package/turbo.json +34 -0
  222. package/yarn.lock +9333 -0
  223. package/RNSnowplowTracker.podspec +0 -24
  224. package/android/src/main/java/com/snowplowanalytics/react/tracker/RNSnowplowTrackerModule.java +0 -750
  225. package/android/src/main/java/com/snowplowanalytics/react/tracker/RNSnowplowTrackerPackage.java +0 -29
  226. package/android/src/main/java/com/snowplowanalytics/react/util/ConfigUtil.java +0 -351
  227. package/android/src/main/java/com/snowplowanalytics/react/util/EventUtil.java +0 -339
  228. package/android/src/main/java/com/snowplowanalytics/react/util/TrackerVersion.java +0 -7
  229. package/dist/index.js +0 -2026
  230. package/dist/index.js.map +0 -1
  231. package/ios/RNSnowplowTracker.h +0 -34
  232. package/ios/RNSnowplowTracker.m +0 -911
  233. package/ios/Util/NSDictionary+RNSP_TypeMethods.h +0 -33
  234. package/ios/Util/NSDictionary+RNSP_TypeMethods.m +0 -40
  235. package/ios/Util/RNConfigUtils.h +0 -44
  236. package/ios/Util/RNConfigUtils.m +0 -209
  237. package/ios/Util/RNTrackerVersion.h +0 -27
  238. package/ios/Util/RNTrackerVersion.m +0 -27
  239. package/ios/Util/RNUtilities.h +0 -32
  240. package/ios/Util/RNUtilities.m +0 -68
package/.editorconfig ADDED
@@ -0,0 +1,15 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+
7
+ [*]
8
+
9
+ indent_style = space
10
+ indent_size = 2
11
+
12
+ end_of_line = lf
13
+ charset = utf-8
14
+ trim_trailing_whitespace = true
15
+ insert_final_newline = true
package/.eslintignore ADDED
@@ -0,0 +1,6 @@
1
+ # don't lint node_modules
2
+ node_modules
3
+ # don't lint build output
4
+ dist
5
+ # don't lint example app here
6
+ example
package/.gitattributes ADDED
@@ -0,0 +1,3 @@
1
+ *.pbxproj -text
2
+ # specific for windows script files
3
+ *.bat text eol=crlf
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior or code snippets that produce the issue.
15
+
16
+ **Expected behavior**
17
+ A clear and concise description of what you expected to happen.
18
+
19
+ **Screenshots**
20
+ If applicable, add screenshots to help explain your problem.
21
+
22
+ **Smartphone (please complete the following information):**
23
+ - Device: [e.g. iPhone6]
24
+ - OS: [e.g. iOS8.1]
25
+ - Browser [e.g. stock browser, safari]
26
+ - Version [e.g. 22]
27
+
28
+ **Additional context**
29
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: enhancement
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,28 @@
1
+ name: Setup
2
+ description: Setup Node.js and install dependencies
3
+
4
+ runs:
5
+ using: composite
6
+ steps:
7
+ - name: Setup Node.js
8
+ uses: actions/setup-node@v3
9
+ with:
10
+ node-version-file: .nvmrc
11
+
12
+ - name: Cache dependencies
13
+ id: yarn-cache
14
+ uses: actions/cache@v3
15
+ with:
16
+ path: |
17
+ **/node_modules
18
+ key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}
19
+ restore-keys: |
20
+ ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
21
+ ${{ runner.os }}-yarn-
22
+
23
+ - name: Install dependencies
24
+ if: steps.yarn-cache.outputs.cache-hit != 'true'
25
+ run: |
26
+ yarn install --cwd example --frozen-lockfile
27
+ yarn install --frozen-lockfile
28
+ shell: bash
@@ -0,0 +1,155 @@
1
+ name: Build
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*.*.*'
7
+ pull_request:
8
+
9
+ jobs:
10
+ lint:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v4
15
+
16
+ - name: Setup
17
+ uses: ./.github/actions/setup
18
+
19
+ - name: Lint files
20
+ run: yarn lint
21
+
22
+ - name: Typecheck files
23
+ run: yarn typecheck
24
+
25
+ test:
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - name: Checkout
29
+ uses: actions/checkout@v4
30
+
31
+ - name: Setup
32
+ uses: ./.github/actions/setup
33
+
34
+ - name: Run unit tests
35
+ run: yarn test --maxWorkers=2 --coverage
36
+
37
+ build-library:
38
+ runs-on: ubuntu-latest
39
+ steps:
40
+ - name: Checkout
41
+ uses: actions/checkout@v4
42
+
43
+ - name: Setup
44
+ uses: ./.github/actions/setup
45
+
46
+ - name: Build package
47
+ run: yarn prepack
48
+
49
+ build-android:
50
+ runs-on: ubuntu-latest
51
+ env:
52
+ TURBO_CACHE_DIR: .turbo/android
53
+ steps:
54
+ - name: Checkout
55
+ uses: actions/checkout@v4
56
+
57
+ - name: Setup
58
+ uses: ./.github/actions/setup
59
+
60
+ - name: Cache turborepo for Android
61
+ uses: actions/cache@v3
62
+ with:
63
+ path: ${{ env.TURBO_CACHE_DIR }}
64
+ key: ${{ runner.os }}-turborepo-android-${{ hashFiles('**/yarn.lock') }}
65
+ restore-keys: |
66
+ ${{ runner.os }}-turborepo-android-
67
+
68
+ - name: Check turborepo cache for Android
69
+ run: |
70
+ TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
71
+
72
+ if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
73
+ echo "turbo_cache_hit=1" >> $GITHUB_ENV
74
+ fi
75
+
76
+ - name: Install JDK
77
+ if: env.turbo_cache_hit != 1
78
+ uses: actions/setup-java@v3
79
+ with:
80
+ distribution: 'zulu'
81
+ java-version: '11'
82
+
83
+ - name: Finalize Android SDK
84
+ if: env.turbo_cache_hit != 1
85
+ run: |
86
+ /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
87
+
88
+ - name: Cache Gradle
89
+ if: env.turbo_cache_hit != 1
90
+ uses: actions/cache@v3
91
+ with:
92
+ path: |
93
+ ~/.gradle/wrapper
94
+ ~/.gradle/caches
95
+ key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
96
+ restore-keys: |
97
+ ${{ runner.os }}-gradle-
98
+
99
+ - name: Build example for Android
100
+ run: |
101
+ yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
102
+
103
+ build-ios:
104
+ runs-on: macos-latest
105
+ env:
106
+ TURBO_CACHE_DIR: .turbo/ios
107
+ steps:
108
+ - name: Checkout
109
+ uses: actions/checkout@v4
110
+
111
+ - name: setup-cocoapods
112
+ uses: maxim-lobanov/setup-cocoapods@v1
113
+ with:
114
+ version: 1.15.2
115
+
116
+ - name: Setup
117
+ uses: ./.github/actions/setup
118
+
119
+ - name: Cache turborepo for iOS
120
+ uses: actions/cache@v3
121
+ with:
122
+ path: ${{ env.TURBO_CACHE_DIR }}
123
+ key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('**/yarn.lock') }}
124
+ restore-keys: |
125
+ ${{ runner.os }}-turborepo-ios-
126
+
127
+ - name: Check turborepo cache for iOS
128
+ run: |
129
+ TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
130
+
131
+ if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
132
+ echo "turbo_cache_hit=1" >> $GITHUB_ENV
133
+ fi
134
+
135
+ - name: Cache cocoapods
136
+ if: env.turbo_cache_hit != 1
137
+ id: cocoapods-cache
138
+ uses: actions/cache@v3
139
+ with:
140
+ path: |
141
+ **/ios/Pods
142
+ key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }}
143
+ restore-keys: |
144
+ ${{ runner.os }}-cocoapods-
145
+
146
+ - name: Install cocoapods
147
+ if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
148
+ run: |
149
+ yarn example pods
150
+ env:
151
+ NO_FLIPPER: 1
152
+
153
+ - name: Build example for iOS
154
+ run: |
155
+ yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
@@ -0,0 +1,97 @@
1
+ name: Deploy
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '[0-9]+.[0-9]+.[0-9]+*'
7
+
8
+ jobs:
9
+
10
+ version_check:
11
+ runs-on: ubuntu-latest
12
+ outputs:
13
+ v_tracker: ${{ steps.version.outputs.RN_TRACKER_VERSION}}
14
+
15
+ steps:
16
+ - name: Checkout code
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Get tag and tracker versions
20
+ id: version
21
+ env:
22
+ IOS_VER_FILEPATH: 'ios/Util/TrackerVersion.swift'
23
+ ANDR_VER_FILEPATH: 'android/src/main/java/com/snowplow/reactnativetracker/util/TrackerVersion.kt'
24
+ JS_VER_FILEPATH: 'src/jsCore.ts'
25
+ run: |
26
+ echo "TAG_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
27
+ echo "RN_TRACKER_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
28
+ echo "RN_IOS_TRACKER_VERSION=$(cat "${IOS_VER_FILEPATH}" | sed -n -e 's/^.*kRNTrackerVersion = "rn-\(.*\)"/\1/p')" >> $GITHUB_OUTPUT
29
+ echo "RN_ANDROID_TRACKER_VERSION=$(cat "${ANDR_VER_FILEPATH}" | sed -n -e 's/^.*RN_TRACKER_VERSION = "rn-\(.*\)"/\1/p')" >> $GITHUB_OUTPUT
30
+ echo "RN_JS_TRACKER_VERSION=$(cat "${JS_VER_FILEPATH}" | sed -n -e 's/^.*trackerVersion = '\''rn-\(.*\)'\'';/\1/p')" >> $GITHUB_OUTPUT
31
+
32
+ - name: Fail if version mismatch
33
+ run: |
34
+ if [ "${{ steps.version.outputs.TAG_VERSION }}" != "${{ steps.version.outputs.RN_TRACKER_VERSION }}" ] ; then
35
+ echo "Tag version (${{ steps.version.outputs.TAG_VERSION }}) doesn't match version in project (${{ steps.version.outputs.RN_TRACKER_VERSION }})"
36
+ exit 1
37
+ fi
38
+ if [ "${{ steps.version.outputs.TAG_VERSION }}" != "${{ steps.version.outputs.RN_IOS_TRACKER_VERSION }}" ] ; then
39
+ echo "Tag version (${{ steps.version.outputs.TAG_VERSION }}) doesn't match version in project(ios) (${{ steps.version.outputs.RN_IOS_TRACKER_VERSION }})"
40
+ exit 1
41
+ fi
42
+ if [ "${{ steps.version.outputs.TAG_VERSION }}" != "${{ steps.version.outputs.RN_ANDROID_TRACKER_VERSION }}" ] ; then
43
+ echo "Tag version (${{ steps.version.outputs.TAG_VERSION }}) doesn't match version in project(android) (${{ steps.version.outputs.RN_ANDROID_TRACKER_VERSION }})"
44
+ exit 1
45
+ fi
46
+ if [ "${{ steps.version.outputs.TAG_VERSION }}" != "${{ steps.version.outputs.RN_JS_TRACKER_VERSION }}" ] ; then
47
+ echo "Tag version (${{ steps.version.outputs.TAG_VERSION }}) doesn't match version in project(js) (${{ steps.version.outputs.RN_JS_TRACKER_VERSION }})"
48
+ exit 1
49
+ fi
50
+
51
+ publish_npm:
52
+ needs: ["version_check"]
53
+ runs-on: ubuntu-latest
54
+
55
+ steps:
56
+ - name: Checkout
57
+ uses: actions/checkout@v4
58
+
59
+ - name: Setup
60
+ uses: ./.github/actions/setup
61
+
62
+ - name: Run unit tests
63
+ run: yarn test
64
+
65
+ - name: Build dist files
66
+ run: |
67
+ yarn
68
+ yarn prepack
69
+
70
+ - name: NPM Publish
71
+ run: |
72
+ echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
73
+ if [[ "${{ needs.version_check.outputs.v_tracker }}" = *-* ]] ; then
74
+ yarn publish --access public --tag next
75
+ else
76
+ yarn publish --access public
77
+ fi
78
+ env:
79
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
80
+
81
+ release:
82
+ needs: ["publish_npm", "version_check"]
83
+ runs-on: ubuntu-latest
84
+
85
+ steps:
86
+ - name: Checkout code
87
+ uses: actions/checkout@v2
88
+
89
+ - name: Release
90
+ uses: softprops/action-gh-release@v0.1.7
91
+ env:
92
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93
+ with:
94
+ tag_name: ${{ github.event.workflow_run.head_branch }}
95
+ name: Version ${{ needs.version_check.outputs.v_tracker }}
96
+ draft: false
97
+ prerelease: ${{ contains(needs.version_check.outputs.v_tracker, '-') }}
@@ -0,0 +1,121 @@
1
+ name: e2e-android
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ jobs:
7
+ e2e:
8
+ runs-on: macos-latest
9
+ timeout-minutes: 60
10
+ env:
11
+ TURBO_CACHE_DIR: .turbo/android-e2e
12
+
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Setup
18
+ uses: ./.github/actions/setup
19
+
20
+ - name: Cache turborepo for Android
21
+ uses: actions/cache@v3
22
+ with:
23
+ path: ${{ env.TURBO_CACHE_DIR }}
24
+ key: ${{ runner.os }}-turborepo-e2e-android-${{ hashFiles('**/yarn.lock') }}
25
+ restore-keys: |
26
+ ${{ runner.os }}-turborepo-e2e-android-
27
+
28
+ - name: Check turborepo cache for Android
29
+ run: |
30
+ TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
31
+
32
+ if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
33
+ echo "turbo_cache_hit=1" >> $GITHUB_ENV
34
+ fi
35
+
36
+ - name: Install JDK
37
+ if: env.turbo_cache_hit != 1
38
+ uses: actions/setup-java@v3
39
+ with:
40
+ distribution: 'zulu'
41
+ java-version: '11'
42
+
43
+ - name: Finalize Android SDK
44
+ if: env.turbo_cache_hit != 1
45
+ run: |
46
+ /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
47
+
48
+ - name: Cache Gradle
49
+ if: env.turbo_cache_hit != 1
50
+ uses: actions/cache@v3
51
+ with:
52
+ path: |
53
+ ~/.gradle/wrapper
54
+ ~/.gradle/caches
55
+ key: ${{ runner.os }}-gradle-e2e-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
56
+ restore-keys: |
57
+ ${{ runner.os }}-gradle-e2e-
58
+
59
+ # -- Micro --
60
+ - name: Cache Micro
61
+ id: cache-micro
62
+ uses: actions/cache@v3
63
+ with:
64
+ path: micro.jar
65
+ key: ${{ runner.os }}-micro
66
+
67
+ - name: Get micro
68
+ if: steps.cache-micro.outputs.cache-hit != 'true'
69
+ run: curl -o micro.jar -L https://github.com/snowplow-incubator/snowplow-micro/releases/download/micro-1.7.2/snowplow-micro-1.7.2.jar
70
+
71
+ - name: Run Micro in background
72
+ run: java -jar micro.jar &
73
+
74
+ - name: Wait on Micro endpoint
75
+ timeout-minutes: 2
76
+ run: while ! nc -z '0.0.0.0' 9090; do sleep 1; done
77
+
78
+ - name: Prepare example for Micro
79
+ working-directory: example/src
80
+ run: perl -i -pe "s/^.*collectorEndpoint =\K.*/ \'http:\/\/10.0.2.2:9090\'\;/" App.js
81
+
82
+ # -- Emulator --
83
+ - name: Get AOSP system image and create Android virtual device
84
+ run: |
85
+ echo 'y' | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "system-images;android-28;default;x86_64"
86
+ echo 'no' | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager create avd --force --name Pixel_API_28_AOSP -d pixel --package "system-images;android-28;default;x86_64"
87
+
88
+ - name: Start Android emulator
89
+ timeout-minutes: 10
90
+ run: |
91
+ echo "Starting emulator.."
92
+ nohup $ANDROID_HOME/emulator/emulator -avd Pixel_API_28_AOSP -no-audio -no-snapshot -no-window &
93
+ $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
94
+ $ANDROID_HOME/platform-tools/adb devices
95
+ echo "Emulator started!"
96
+
97
+ # -- Test --
98
+ - name: Detox Jest android
99
+ id: dj
100
+ run: |
101
+ yarn turbo run e2e:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
102
+
103
+ - name: Log events if Detox-Jest failed
104
+ id: eventlog
105
+ if: ${{ failure() && steps.dj.outcome == 'failure' }}
106
+ run: |
107
+ echo "{ \"all\": $(curl -s -o - 'http://0.0.0.0:9090/micro/all'), \
108
+ \"bad\": $(curl -s -o - 'http://0.0.0.0:9090/micro/bad'), \
109
+ \"good\": $(curl -s -o - 'http://0.0.0.0:9090/micro/good') }"\
110
+ | jq '.' > android-events-micro.json
111
+
112
+ - name: Upload events artifact if Detox-Jest failed
113
+ if: ${{ failure() && steps.dj.outcome == 'failure' && steps.eventlog.outcome == 'success' }}
114
+ uses: actions/upload-artifact@v2
115
+ with:
116
+ name: android-events-artifact
117
+ path: android-events-micro.json
118
+
119
+ # -- Cleanup --
120
+ - name: Stop gradle daemon
121
+ run: gradle --stop
@@ -0,0 +1,95 @@
1
+ name: e2e-ios
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ jobs:
7
+ e2e:
8
+ runs-on: macos-latest
9
+ timeout-minutes: 60
10
+ env:
11
+ TURBO_CACHE_DIR: .turbo/ios-e2e
12
+
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v2
16
+
17
+ - name: setup-cocoapods
18
+ uses: maxim-lobanov/setup-cocoapods@v1
19
+ with:
20
+ version: 1.15.2
21
+
22
+ - name: Setup
23
+ uses: ./.github/actions/setup
24
+
25
+ - name: Cache turborepo for iOS
26
+ uses: actions/cache@v3
27
+ with:
28
+ path: ${{ env.TURBO_CACHE_DIR }}
29
+ key: ${{ runner.os }}-turborepo-e2e-ios-${{ hashFiles('**/yarn.lock') }}
30
+ restore-keys: |
31
+ ${{ runner.os }}-turborepo-e2e-ios-
32
+
33
+ - name: Check turborepo cache for iOS
34
+ run: |
35
+ TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
36
+
37
+ if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
38
+ echo "turbo_cache_hit=1" >> $GITHUB_ENV
39
+ fi
40
+
41
+ # -- Micro --
42
+ - name: Cache Micro
43
+ id: cache-micro
44
+ uses: actions/cache@v3
45
+ with:
46
+ path: micro.jar
47
+ key: ${{ runner.os }}-micro
48
+
49
+ - name: Get micro
50
+ if: steps.cache-micro.outputs.cache-hit != 'true'
51
+ run: curl -o micro.jar -L https://github.com/snowplow-incubator/snowplow-micro/releases/download/micro-1.7.2/snowplow-micro-1.7.2.jar
52
+
53
+ - name: Run Micro in background
54
+ run: java -jar micro.jar &
55
+
56
+ - name: Wait on Micro endpoint
57
+ timeout-minutes: 2
58
+ run: while ! nc -z '0.0.0.0' 9090; do sleep 1; done
59
+
60
+ - name: Prepare example for Micro
61
+ working-directory: example/src
62
+ run: perl -i -pe "s/^.*collectorEndpoint =\K.*/ \'http:\/\/0.0.0.0:9090\'\;/" App.js
63
+
64
+ # -- Simulator --
65
+ - name: Install applesimutils
66
+ run: |
67
+ brew tap wix/brew
68
+ brew install applesimutils
69
+
70
+ # -- Bootstrap --
71
+ - name: Bootstrap project
72
+ run: |
73
+ yarn turbo run bootstrap --cache-dir="${{ env.TURBO_CACHE_DIR }}"
74
+
75
+ # -- Test --
76
+ - name: Detox Jest ios
77
+ id: dj
78
+ run: |
79
+ yarn turbo run e2e:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
80
+
81
+ - name: Log events if Detox-Jest failed
82
+ id: eventlog
83
+ if: ${{ failure() && steps.dj.outcome == 'failure' }}
84
+ run: |
85
+ echo "{ \"all\": $(curl -s -o - 'http://0.0.0.0:9090/micro/all'), \
86
+ \"bad\": $(curl -s -o - 'http://0.0.0.0:9090/micro/bad'), \
87
+ \"good\": $(curl -s -o - 'http://0.0.0.0:9090/micro/good') }"\
88
+ | jq '.' > ios-events-micro.json
89
+
90
+ - name: Upload events artifact if Detox-Jest failed
91
+ if: ${{ failure() && steps.dj.outcome == 'failure' && steps.eventlog.outcome == 'success' }}
92
+ uses: actions/upload-artifact@v2
93
+ with:
94
+ name: ios-events-artifact
95
+ path: ios-events-micro.json
@@ -0,0 +1,21 @@
1
+
2
+ name: Snyk
3
+
4
+ on:
5
+ push:
6
+ branches: [ master ]
7
+
8
+ jobs:
9
+ security:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - name: Run Snyk to check for vulnerabilities
16
+ uses: snyk/actions/node@master
17
+ with:
18
+ command: monitor
19
+ args: --project-name=@snowplow/react-native-tracker
20
+ env:
21
+ SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
package/.gitignore ADDED
@@ -0,0 +1,70 @@
1
+ # OSX
2
+ #
3
+ .DS_Store
4
+
5
+ # XDE
6
+ .expo/
7
+
8
+ # VSCode
9
+ .vscode/
10
+ jsconfig.json
11
+
12
+ # Xcode
13
+ #
14
+ build/
15
+ *.pbxuser
16
+ !default.pbxuser
17
+ *.mode1v3
18
+ !default.mode1v3
19
+ *.mode2v3
20
+ !default.mode2v3
21
+ *.perspectivev3
22
+ !default.perspectivev3
23
+ xcuserdata
24
+ *.xccheckout
25
+ *.moved-aside
26
+ DerivedData
27
+ *.hmap
28
+ *.ipa
29
+ *.xcuserstate
30
+ project.xcworkspace
31
+
32
+ # Android/IJ
33
+ #
34
+ .classpath
35
+ .cxx
36
+ .gradle
37
+ .idea
38
+ .project
39
+ .settings
40
+ local.properties
41
+ android.iml
42
+
43
+ # Cocoapods
44
+ #
45
+ example/ios/Pods
46
+
47
+ # Ruby
48
+ example/vendor/
49
+
50
+ # node.js
51
+ #
52
+ node_modules/
53
+ npm-debug.log
54
+ yarn-debug.log
55
+ yarn-error.log
56
+
57
+ # BUCK
58
+ buck-out/
59
+ \.buckd/
60
+ android/app/libs
61
+ android/keystores/debug.keystore
62
+
63
+ # Expo
64
+ .expo/
65
+
66
+ # Turborepo
67
+ .turbo/
68
+
69
+ # generated by bob
70
+ lib/