hypertrack-sdk-react-native 7.19.0 → 8.0.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 (40) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CONTRIBUTING.md +154 -0
  3. package/README.md +25 -16
  4. package/android/build.gradle +141 -35
  5. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  6. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  7. package/android/gradle.properties +6 -0
  8. package/android/gradlew +185 -0
  9. package/android/gradlew.bat +89 -0
  10. package/android/src/main/AndroidManifest.xml +2 -3
  11. package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackModule.kt +284 -0
  12. package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackSdkPackage.kt +17 -0
  13. package/hypertrack-sdk-react-native.podspec +34 -15
  14. package/ios/{RNHyperTrack/RNHyperTrack.h → HyperTrack.h} +1 -2
  15. package/ios/HyperTrack.m +384 -0
  16. package/ios/{RNHyperTrack.xcodeproj → HyperTrackSdk.xcodeproj}/project.pbxproj +70 -99
  17. package/lib/commonjs/HyperTrack/HyperTrack.js +244 -0
  18. package/lib/commonjs/HyperTrack/HyperTrack.js.map +1 -0
  19. package/lib/commonjs/index.js +52 -0
  20. package/lib/commonjs/index.js.map +1 -0
  21. package/lib/module/HyperTrack/HyperTrack.js +230 -0
  22. package/lib/module/HyperTrack/HyperTrack.js.map +1 -0
  23. package/lib/module/index.js +5 -0
  24. package/lib/module/index.js.map +1 -0
  25. package/lib/typescript/HyperTrack/HyperTrack.d.ts +161 -0
  26. package/lib/typescript/index.d.ts +4 -0
  27. package/package.json +145 -47
  28. package/src/HyperTrack/HyperTrack.ts +273 -0
  29. package/src/index.tsx +11 -0
  30. package/android/src/main/java/com/hypertrack/reactnative/androidsdk/HTSDKModule.java +0 -301
  31. package/android/src/main/java/com/hypertrack/reactnative/androidsdk/HTSDKPackage.java +0 -29
  32. package/ios/RNHyperTrack/RNHyperTrack.m +0 -312
  33. package/ios/RNHyperTrack.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  34. package/ios/RNHyperTrack.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  35. package/ios/RNHyperTrack.xcodeproj/project.xcworkspace/xcuserdata/tulushev.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  36. package/ios/RNHyperTrack.xcodeproj/xcuserdata/tulushev.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  37. package/js/CriticalErrors.js +0 -97
  38. package/js/EventEmitter.js +0 -11
  39. package/js/HyperTrack.js +0 -130
  40. package/js/index.js +0 -13
package/package.json CHANGED
@@ -1,65 +1,163 @@
1
1
  {
2
2
  "name": "hypertrack-sdk-react-native",
3
- "version": "7.19.0",
4
- "description": "React Native module for a HyperTrack SDK",
5
- "main": "./js/index.js",
6
- "author": "HyperTrack <help@hypertrack.com> (https://hypertrack.com)",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/hypertrack/sdk-react-native.git"
3
+ "version": "8.0.0",
4
+ "description": "test",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "cpp",
16
+ "hypertrack-sdk-react-native.podspec",
17
+ "LICENSE.txt",
18
+ "README.md",
19
+ "CHANGELOG.md",
20
+ "CONTRIBUTING.md",
21
+ "!lib/typescript/example",
22
+ "!android/build",
23
+ "!ios/build",
24
+ "!**/__tests__",
25
+ "!**/__fixtures__",
26
+ "!**/__mocks__"
27
+ ],
28
+ "scripts": {
29
+ "test": "jest",
30
+ "typescript": "tsc --noEmit",
31
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
32
+ "prepare": "bob build",
33
+ "release": "release-it",
34
+ "docs": "typedoc --options typedoc.json",
35
+ "bootstrap": "yarn && yarn docs"
10
36
  },
11
- "homepage": "https://github.com/hypertrack/sdk-react-native/",
12
37
  "keywords": [
13
- "react",
14
38
  "react-native",
15
- "react-component",
16
39
  "ios",
17
40
  "android",
18
41
  "hypertrack",
19
42
  "location",
20
43
  "tracking"
21
44
  ],
45
+ "repository": "https://github.com/hypertrack/sdk-react-native",
46
+ "author": "HyperTrack <help@hypertrack.com> (https://hypertrack.com)",
22
47
  "license": "MIT",
23
- "scripts": {
24
- "start": "react-native start",
25
- "flow": "flow",
26
- "lint": "eslint ."
48
+ "bugs": {
49
+ "url": "https://github.com/hypertrack/sdk-react-native/issues"
27
50
  },
28
- "files": [
29
- "android/src/main/AndroidManifest.xml",
30
- "android/src/main/java/",
31
- "android/build.gradle",
32
- "ios",
33
- "js",
34
- "LICENSE.txt",
35
- "README.md",
36
- "CHANGELOG.md",
37
- "hypertrack-sdk-react-native.podspec"
38
- ],
39
- "dependencies": {},
40
- "peerDependencies": {
41
- "react-native": "0.63.3"
51
+ "homepage": "https://github.com/hypertrack/sdk-react-native#readme",
52
+ "publishConfig": {
53
+ "registry": "https://registry.npmjs.org/"
42
54
  },
43
55
  "devDependencies": {
44
- "@babel/core": "^7.8.4",
45
- "@babel/runtime": "^7.8.4",
46
- "babel-eslint": "^10.0.1",
47
- "babel-jest": "^24.8.0",
48
- "eslint-plugin-babel": "^5.2.1",
49
- "eslint-plugin-flowtype": "2.43.0",
50
- "eslint-plugin-import": "^2.9.0",
51
- "eslint-plugin-jest": "21.8.0",
52
- "eslint-plugin-jsx-a11y": "6.0.3",
53
- "eslint-plugin-react": "7.6.1",
54
- "eslint": "5.1.0",
55
- "flow-bin": "^0.98.0",
56
- "jest": "^25.1.0",
57
- "metro-react-native-babel-preset": "^0.59.0",
58
- "react-native": "0.63.3",
59
- "react-test-renderer": "16.13.1",
60
- "react": "16.8.6"
56
+ "@babel/eslint-parser": "^7.18.2",
57
+ "@commitlint/config-conventional": "^17.0.2",
58
+ "@react-native-community/eslint-config": "^3.0.2",
59
+ "@release-it/bumper": "^4.0.0",
60
+ "@release-it/conventional-changelog": "^5.0.0",
61
+ "@types/jest": "^28.1.2",
62
+ "@types/react": "~17.0.21",
63
+ "@types/react-native": "0.68.0",
64
+ "@typescript-eslint/parser": "^5.30.5",
65
+ "auto-changelog": "^2.4.0",
66
+ "commitlint": "^17.0.2",
67
+ "eslint": "^8.4.1",
68
+ "eslint-config-prettier": "^8.5.0",
69
+ "eslint-plugin-prettier": "^4.0.0",
70
+ "jest": "^28.1.1",
71
+ "pod-install": "^0.1.0",
72
+ "prettier": "^2.0.5",
73
+ "react": "18.0.0",
74
+ "react-native": "0.69.1",
75
+ "react-native-builder-bob": "^0.18.3",
76
+ "release-it": "^15.0.0",
77
+ "typedoc": "^0.23.2",
78
+ "typedoc-plugin-merge-modules": "^3.1.0",
79
+ "typedoc-plugin-rename-defaults": "^0.6.1",
80
+ "typescript": "^4.5.2"
61
81
  },
62
- "bugs": {
63
- "url": "https://github.com/hypertrack/sdk-react-native/issues"
82
+ "resolutions": {
83
+ "@types/react": "17.0.21"
84
+ },
85
+ "peerDependencies": {
86
+ "react": "*",
87
+ "react-native": "*"
88
+ },
89
+ "jest": {
90
+ "preset": "react-native",
91
+ "modulePathIgnorePatterns": [
92
+ "<rootDir>/lib/"
93
+ ]
94
+ },
95
+ "commitlint": {
96
+ "extends": [
97
+ "@commitlint/config-conventional"
98
+ ]
99
+ },
100
+ "release-it": {
101
+ "git": {
102
+ "changelog": "auto-changelog --stdout --commit-limit false --unreleased --template https://raw.githubusercontent.com/release-it/release-it/master/templates/changelog-compact.hbs",
103
+ "commitMessage": "Release ${version}",
104
+ "requireCleanWorkingDir": false,
105
+ "tagName": "${version}",
106
+ "requireCommits": true
107
+ },
108
+ "github": {
109
+ "release": true
110
+ },
111
+ "hooks": {
112
+ "after:bump": "auto-changelog --package --commit-limit false --template https://raw.githubusercontent.com/release-it/release-it/master/templates/keepachangelog.hbs"
113
+ },
114
+ "npm": {
115
+ "publish": true
116
+ }
117
+ },
118
+ "eslintConfig": {
119
+ "root": true,
120
+ "parser": "@typescript-eslint/parser",
121
+ "extends": [
122
+ "@react-native-community",
123
+ "prettier"
124
+ ],
125
+ "rules": {
126
+ "prettier/prettier": [
127
+ "error",
128
+ {
129
+ "quoteProps": "consistent",
130
+ "singleQuote": true,
131
+ "tabWidth": 2,
132
+ "trailingComma": "es5",
133
+ "useTabs": false
134
+ }
135
+ ]
136
+ }
137
+ },
138
+ "eslintIgnore": [
139
+ "node_modules/",
140
+ "lib/"
141
+ ],
142
+ "prettier": {
143
+ "quoteProps": "consistent",
144
+ "singleQuote": true,
145
+ "tabWidth": 2,
146
+ "trailingComma": "es5",
147
+ "useTabs": false
148
+ },
149
+ "react-native-builder-bob": {
150
+ "source": "src",
151
+ "output": "lib",
152
+ "targets": [
153
+ "commonjs",
154
+ "module",
155
+ [
156
+ "typescript",
157
+ {
158
+ "project": "tsconfig.build.json"
159
+ }
160
+ ]
161
+ ]
64
162
  }
65
163
  }
@@ -0,0 +1,273 @@
1
+ import { NativeModules, Platform, NativeEventEmitter } from 'react-native';
2
+
3
+ const LINKING_ERROR =
4
+ `The package 'hypertrack-sdk-react-native' doesn't seem to be linked. Make sure: \n\n` +
5
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
6
+ '- You rebuilt the app after installing the package\n' +
7
+ '- You are not using Expo managed workflow\n';
8
+
9
+ const HyperTrackSdk = NativeModules.HyperTrack
10
+ ? NativeModules.HyperTrack
11
+ : new Proxy(
12
+ {},
13
+ {
14
+ get() {
15
+ throw new Error(LINKING_ERROR);
16
+ },
17
+ }
18
+ );
19
+
20
+ const EventEmitter = new NativeEventEmitter(HyperTrackSdk);
21
+
22
+ export enum SDKError {
23
+ /**
24
+ * An error that we couldn't recognize.
25
+ */
26
+ GENERAL = 0,
27
+ /**
28
+ * Publishable key is invalid. Check your key on hypertrack dashboard setup.
29
+ */
30
+ INVALID_PUBLISHABLE_KEY = 1,
31
+ /**
32
+ * Your free trial ended or account was not renewed. Check your account on hypertrack dashboard.
33
+ */
34
+ AUTHORIZATION_FAILED = 2,
35
+ /**
36
+ * Tracking won't start due to denied (or absent) permission.
37
+ */
38
+ PERMISSION_DENIED = 3,
39
+ }
40
+
41
+ /**
42
+ * A base interface for errors in SDK.
43
+ */
44
+ export type Error = {
45
+ code: SDKError;
46
+ message?: string;
47
+ };
48
+
49
+ /**
50
+ * Interface for accessing adding geotag result.
51
+ */
52
+ export enum GeotagError {
53
+ /** Expected location is not supported on this platform */
54
+ PLATFORM_NOT_SUPPORTED = 0,
55
+ /** Expected vs actual location difference is greater then required */
56
+ LOCATION_MISMATCH = 1,
57
+ /** SDK can't get actual location from OS sensors */
58
+ LOCATION_NOT_AVAILABLE = 2,
59
+ /** Invalid arguments */
60
+ INVALID_ARGUMENTS = 3,
61
+ }
62
+
63
+ export interface Location {
64
+ location: {
65
+ latitude: number;
66
+ longitude: number;
67
+ };
68
+ }
69
+
70
+ export enum LocationError {
71
+ // The user has not chosen whether the app can use location services.
72
+ // SDK automatically asked for permissions.
73
+ LOCATION_PERMISSIONS_NOT_DETERMINED = 'location_permissions_not_determined',
74
+ // The user has not chosen whether the app can use location services.
75
+ // SDK can't ask for permissions in background.
76
+ LOCATION_PERMISSIONS_CANT_BE_ASKED_IN_BACKGROUND = 'location_permissions_cant_be_asked_in_background',
77
+ // Can't start tracking in background with When In Use location
78
+ // permissions. SDK will automatically start tracking when app will return
79
+ // to foreground.
80
+ LOCATION_PERMISSIONS_INSUFFICIENT_FOR_BACKGROUND = 'location_permissions_insufficient_for_background',
81
+ // The app is not authorized to use location services.
82
+ LOCATION_PERMISSIONS_RESTRICTED = 'location_permissions_restricted',
83
+ // The user didn't grant precise location permissions or downgraded permissions to imprecise.
84
+ LOCATION_PERMISSIONS_REDUCED_ACCURACY = 'location_permissions_reduced_accuracy',
85
+ // The user denied location permissions.
86
+ LOCATION_PERMISSIONS_DENIED = 'location_permissions_denied',
87
+ // The user disabled location services systemwide.
88
+ LOCATION_SERVICES_DISABLED = 'location_services_disabled',
89
+ // The user has not chosen whether the app can use motion activity
90
+ // services. SDK automatically asked for permissions.
91
+ MOTION_ACTIVITY_PERMISSIONS_NOT_DETERMINED = 'motion_activity_permissions_not_determined',
92
+ // The user has not chosen whether the app can use motion activity
93
+ // services. SDK can't ask for permissions in background.
94
+ MOTION_ACTIVITY_PERMISSIONS_CANT_BE_ASKED_IN_BACKGROUND = 'motion_activity_permissions_cant_be_asked_in_background',
95
+ // Motion activity permissions denied after SDK's initialization. Granting
96
+ // them will restart the app, so in effect, they are denied during this app's
97
+ // session.
98
+ MOTION_ACTIVITY_PERMISSIONS_DENIED = 'motion_activity_permissions_denied',
99
+ // The user disabled motion services systemwide.
100
+ MOTION_ACTIVITY_SERVICES_DISABLED = 'motion_activity_services_disabled',
101
+ // The SDK is not collecting locations because it's either not tracking or is unavailable.
102
+ NOT_RUNNING = 'not_running',
103
+ // GPS satellites are not in view.
104
+ GPS_SIGNAL_LOST = 'gps_signal_lost',
105
+ // The SDK started collecting locations and is waiting for OS location services to respond.
106
+ STARTING = 'starting',
107
+ // The user enabled mock location app while mocking locations is prohibited.
108
+ LOCATION_MOCKED = 'location_mocked',
109
+ }
110
+
111
+ export default class HyperTrack {
112
+ constructor() {
113
+ return this;
114
+ }
115
+
116
+ static async createInstance(
117
+ publishableKey: string,
118
+ automaticallyRequestPermissions = true
119
+ ) {
120
+ try {
121
+ await HyperTrackSdk.initialize(
122
+ publishableKey,
123
+ false,
124
+ automaticallyRequestPermissions
125
+ );
126
+ return new HyperTrack();
127
+ } catch (error: any) {
128
+ throw new Error(error.message);
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Enables debug log output. This is very verbose, so you shouldn't use this for
134
+ * production build.
135
+ */
136
+ static enableDebugLogging(enable: boolean) {
137
+ HyperTrack.enableDebugLogging(enable);
138
+ }
139
+
140
+ /**
141
+ * Returns a string which is used by HyperTrack to uniquely identify the user.
142
+ */
143
+ async getDeviceID(): Promise<string> {
144
+ return HyperTrackSdk.getDeviceID();
145
+ }
146
+
147
+ /**
148
+ * Device's availability for nearby search
149
+ *
150
+ * @returns true when is available or false when unavailable
151
+ */
152
+ isAvailable(): Promise<boolean> {
153
+ return HyperTrackSdk.isAvailable();
154
+ }
155
+
156
+ /**
157
+ * Allows you to set device availability for nearby search
158
+ *
159
+ * @param availability true when is available or false when unavailable
160
+ */
161
+ async setAvailability(availability: Boolean): Promise<void> {
162
+ return HyperTrackSdk.setAvailability(availability);
163
+ }
164
+
165
+ /**
166
+ * Determine whether the SDK is tracking the movement of the user.
167
+ * @return {boolean} Whether the user's movement data is getting tracked or not.
168
+ */
169
+ isTracking(): Promise<boolean> {
170
+ return HyperTrackSdk.isTracking();
171
+ }
172
+
173
+ /**
174
+ * Update device state from server.
175
+ */
176
+ syncDeviceSettings() {
177
+ HyperTrackSdk.syncDeviceSettings();
178
+ }
179
+
180
+ /**
181
+ * Start or resume tracking location and activity events.
182
+ */
183
+ startTracking() {
184
+ HyperTrackSdk.startTracking();
185
+ }
186
+
187
+ /**
188
+ * Stops the SDK from listening to the user's movement updates and recording any data.
189
+ */
190
+ stopTracking() {
191
+ HyperTrackSdk.stopTracking();
192
+ }
193
+
194
+ /// The current location of the user or an outage reason.
195
+ getLocation(): Promise<LocationError | Location> {
196
+ return HyperTrackSdk.getLocation();
197
+ }
198
+
199
+ /**
200
+ * Listen for errors.
201
+ *
202
+ * @param listener (errors: {code, message}) => void
203
+ * @returns EmitterSubscription
204
+ * @example
205
+ * ```js
206
+ * const subscription = HyperTrack.subscribeToErrors(errors => {
207
+ * errors.forEach(error => {
208
+ * // ... error
209
+ * })
210
+ * })
211
+ *
212
+ * // later, to stop listening
213
+ * subscription.remove()
214
+ * ```
215
+ */
216
+ subscribeToErrors(listener: (errors: Error) => void) {
217
+ return EventEmitter.addListener('onTrackingErrorHyperTrack', listener);
218
+ }
219
+
220
+ /**
221
+ * Listen for tracking changes.
222
+ *
223
+ * @param listener (isTracking: boolean) => void
224
+ * @returns EmitterSubscription
225
+ * @example
226
+ * ```js
227
+ * const subscription = HyperTrack.subscribeToTracking(isTracking => {
228
+ * if (isTracking) {
229
+ * // ... ready to go
230
+ * }
231
+ * })
232
+ *
233
+ * // later, to stop listening
234
+ * subscription.remove()
235
+ * ```
236
+ */
237
+ subscribeToTracking(listener: (isTracking: boolean) => void) {
238
+ return EventEmitter.addListener('onTrackingStateChanged', listener);
239
+ }
240
+
241
+ /**
242
+ * Send device name to HyperTrack
243
+ * @param {string} name - Device name you want to see in the Dashboard.
244
+ */
245
+ setDeviceName(name: string) {
246
+ HyperTrackSdk.setDeviceName(name);
247
+ }
248
+
249
+ /**
250
+ * Send metadata details to HyperTrack
251
+ * @param {Object} data - Send extra device information.
252
+ */
253
+ setMetadata(data: Object) {
254
+ HyperTrackSdk.setMetadata(data);
255
+ }
256
+
257
+ /**
258
+ * @deprecated
259
+ * Set a trip marker
260
+ * @param {Object} _data - Include anything that can be parsed into JSON.
261
+ */
262
+ setTripMarker(_data: Object) {
263
+ throw new Error('Deprecated');
264
+ }
265
+
266
+ /**
267
+ * Add geotag
268
+ * @param {Object} data - Include anything that can be parsed into JSON.
269
+ */
270
+ addGeotag(data: Object): Promise<LocationError | Location> {
271
+ return HyperTrackSdk.addGeotag(data);
272
+ }
273
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,11 @@
1
+ import HyperTrack from './HyperTrack/HyperTrack';
2
+ export default HyperTrack;
3
+ export { HyperTrack };
4
+
5
+ export {
6
+ Location,
7
+ Error,
8
+ SDKError,
9
+ GeotagError,
10
+ LocationError,
11
+ } from './HyperTrack/HyperTrack';