@cpdunphy/neuroid-reactnative-sdk 3.6.3
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/LICENSE +21 -0
- package/README.md +42 -0
- package/android/.gradle/7.3.3/checksums/checksums.lock +0 -0
- package/android/.gradle/7.3.3/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.3.3/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.3.3/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.3.3/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.3.3/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +139 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +10 -0
- package/android/gradlew +234 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/neuroidreactnativesdk/NeuroidReactnativeSdkModule.kt +197 -0
- package/android/src/main/java/com/neuroidreactnativesdk/NeuroidReactnativeSdkPackage.kt +19 -0
- package/ios/NeuroidReactnativeSdk-Bridging-Header.h +2 -0
- package/ios/NeuroidReactnativeSdk.m +97 -0
- package/ios/NeuroidReactnativeSdk.swift +160 -0
- package/ios/NeuroidReactnativeSdk.xcodeproj/project.pbxproj +284 -0
- package/ios/NeuroidReactnativeSdk.xcodeproj/xcshareddata/xcschemes/NeuroidReactnativeSdk.xcscheme +67 -0
- package/lib/commonjs/index.js +201 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/logger.js +34 -0
- package/lib/commonjs/logger.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/index.js +194 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/logger.js +28 -0
- package/lib/module/logger.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/logger.d.ts +3 -0
- package/lib/typescript/src/types.d.ts +48 -0
- package/neuroid-reactnative-sdk.podspec +20 -0
- package/package.json +162 -0
- package/src/index.tsx +274 -0
- package/src/logger.tsx +30 -0
- package/src/types.js +1 -0
- package/src/types.ts +61 -0
package/package.json
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cpdunphy/neuroid-reactnative-sdk",
|
|
3
|
+
"version": "3.6.3",
|
|
4
|
+
"description": "Official NeuroID React Native SDK",
|
|
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
|
+
"neuroid-reactnative-sdk.podspec",
|
|
17
|
+
"!lib/typescript/example",
|
|
18
|
+
"!android/build",
|
|
19
|
+
"!ios/build",
|
|
20
|
+
"!**/__tests__",
|
|
21
|
+
"!**/__fixtures__",
|
|
22
|
+
"!**/__mocks__"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "jest",
|
|
26
|
+
"typescript": "tsc --noEmit",
|
|
27
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
28
|
+
"prepare": "bob build",
|
|
29
|
+
"release": "release-it",
|
|
30
|
+
"postinstall": "patch-package",
|
|
31
|
+
"bootstrap": "yarn"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"react-native",
|
|
35
|
+
"ios",
|
|
36
|
+
"android"
|
|
37
|
+
],
|
|
38
|
+
"repository": "https://github.com/cpdunphy-nid/neuroid",
|
|
39
|
+
"author": "NeuroID <engineering@neuro-id.com> (https://github.com/Neuro-ID/neuroid-reactnative-sdk)",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/Neuro-ID/neuroid-reactnative-sdk/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/Neuro-ID/neuroid-reactnative-sdk#readme",
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@commitlint/config-conventional": "^17.7.0",
|
|
47
|
+
"@react-native-community/eslint-config": "^3.2.0",
|
|
48
|
+
"@release-it/conventional-changelog": "^10.0.0",
|
|
49
|
+
"@types/jest": "^29.5.5",
|
|
50
|
+
"@types/react": "^18.2.24",
|
|
51
|
+
"commitlint": "^17.7.2",
|
|
52
|
+
"eslint": "^8.50.0",
|
|
53
|
+
"eslint-config-prettier": "^9.0.0",
|
|
54
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
55
|
+
"husky": "^8.0.3",
|
|
56
|
+
"jest": "^29.7.0",
|
|
57
|
+
"pod-install": "^0.1.0",
|
|
58
|
+
"prettier": "^3.0.3",
|
|
59
|
+
"react": "18.2.0",
|
|
60
|
+
"react-native": "0.74.0",
|
|
61
|
+
"react-native-builder-bob": "^0.18.0",
|
|
62
|
+
"react-scripts": "^0.0.0",
|
|
63
|
+
"release-it": "^19.0.2",
|
|
64
|
+
"typescript": "^4.1.3",
|
|
65
|
+
"yarn-audit-fix": "^10.0.7"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"react": "*",
|
|
69
|
+
"react-native": ">=0.73.0"
|
|
70
|
+
},
|
|
71
|
+
"jest": {
|
|
72
|
+
"preset": "react-native",
|
|
73
|
+
"modulePathIgnorePatterns": [
|
|
74
|
+
"<rootDir>/example/node_modules",
|
|
75
|
+
"<rootDir>/lib/"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
"commitlint": {
|
|
79
|
+
"extends": [
|
|
80
|
+
"@commitlint/config-conventional"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"release-it": {
|
|
84
|
+
"git": {
|
|
85
|
+
"commitMessage": "chore: release ${version}",
|
|
86
|
+
"tagName": "v${version}"
|
|
87
|
+
},
|
|
88
|
+
"npm": {
|
|
89
|
+
"publish": true
|
|
90
|
+
},
|
|
91
|
+
"github": {
|
|
92
|
+
"release": true
|
|
93
|
+
},
|
|
94
|
+
"plugins": {
|
|
95
|
+
"@release-it/conventional-changelog": {
|
|
96
|
+
"preset": "angular"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"eslintConfig": {
|
|
101
|
+
"root": true,
|
|
102
|
+
"extends": [
|
|
103
|
+
"@react-native-community",
|
|
104
|
+
"prettier"
|
|
105
|
+
],
|
|
106
|
+
"rules": {
|
|
107
|
+
"prettier/prettier": [
|
|
108
|
+
"error",
|
|
109
|
+
{
|
|
110
|
+
"quoteProps": "consistent",
|
|
111
|
+
"singleQuote": true,
|
|
112
|
+
"tabWidth": 2,
|
|
113
|
+
"trailingComma": "es5",
|
|
114
|
+
"useTabs": false
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"eslintIgnore": [
|
|
120
|
+
"node_modules/",
|
|
121
|
+
"lib/"
|
|
122
|
+
],
|
|
123
|
+
"prettier": {
|
|
124
|
+
"quoteProps": "consistent",
|
|
125
|
+
"singleQuote": true,
|
|
126
|
+
"tabWidth": 2,
|
|
127
|
+
"trailingComma": "es5",
|
|
128
|
+
"useTabs": false
|
|
129
|
+
},
|
|
130
|
+
"react-native-builder-bob": {
|
|
131
|
+
"source": "src",
|
|
132
|
+
"output": "lib",
|
|
133
|
+
"targets": [
|
|
134
|
+
"commonjs",
|
|
135
|
+
"module",
|
|
136
|
+
[
|
|
137
|
+
"typescript",
|
|
138
|
+
{
|
|
139
|
+
"project": "tsconfig.build.json"
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
"dependencies": {
|
|
145
|
+
"@react-native-community/cli-platform-android": "^7.0.1",
|
|
146
|
+
"patch-package": "^8.0.0",
|
|
147
|
+
"postinstall-postinstall": "^2.1.0",
|
|
148
|
+
"react-dev-utils": "^12.0.1"
|
|
149
|
+
},
|
|
150
|
+
"resolutions": {
|
|
151
|
+
"nth-check": "2.0.1",
|
|
152
|
+
"postcss": "8.4.35"
|
|
153
|
+
},
|
|
154
|
+
"overrides": {
|
|
155
|
+
"body-parser": "^1.20.3",
|
|
156
|
+
"rollup": "^3.29.5",
|
|
157
|
+
"path-to-regexp": "^0.1.10",
|
|
158
|
+
"nth-check": "^2.0.1",
|
|
159
|
+
"cross-spawn": "^7.0.5",
|
|
160
|
+
"postcss": "8.4.35"
|
|
161
|
+
}
|
|
162
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
import type {
|
|
3
|
+
NeuroIDClass,
|
|
4
|
+
NeuroIDConfigOptions,
|
|
5
|
+
SessionStartResult,
|
|
6
|
+
} from './types';
|
|
7
|
+
import { version } from '../package.json';
|
|
8
|
+
import NeuroIDLog from './logger';
|
|
9
|
+
|
|
10
|
+
const LINKING_ERROR =
|
|
11
|
+
`The package 'neuroid-reactnative-sdk' doesn't seem to be linked. Make sure: \n\n` +
|
|
12
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
13
|
+
'- You rebuilt the app after installing the package\n' +
|
|
14
|
+
'- You are not using Expo managed workflow\n';
|
|
15
|
+
|
|
16
|
+
const NeuroidReactnativeSdk = NativeModules.NeuroidReactnativeSdk
|
|
17
|
+
? NativeModules.NeuroidReactnativeSdk
|
|
18
|
+
: new Proxy(
|
|
19
|
+
{},
|
|
20
|
+
{
|
|
21
|
+
get() {
|
|
22
|
+
throw new Error(LINKING_ERROR);
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
var usingRNNavigation = false;
|
|
28
|
+
|
|
29
|
+
export const NeuroID: NeuroIDClass = {
|
|
30
|
+
configure: async function configure(
|
|
31
|
+
apiKey: string,
|
|
32
|
+
configOptions?: NeuroIDConfigOptions
|
|
33
|
+
): Promise<boolean> {
|
|
34
|
+
usingRNNavigation = !!configOptions?.usingReactNavigation;
|
|
35
|
+
|
|
36
|
+
const pattern = /key_(live|test)_[A-Za-z0-9]+/;
|
|
37
|
+
if (!pattern.test(apiKey)) {
|
|
38
|
+
NeuroIDLog.e('Invalid API Key');
|
|
39
|
+
return Promise.resolve(false);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const configured = await NeuroidReactnativeSdk.configure(
|
|
43
|
+
apiKey,
|
|
44
|
+
configOptions
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return Promise.resolve(configured);
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
enableLogging: function enableLogging(enable?: boolean): Promise<void> {
|
|
51
|
+
NeuroIDLog.enableLogging(enable);
|
|
52
|
+
|
|
53
|
+
if (enable) {
|
|
54
|
+
NeuroIDLog.i('Logging Enabled');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return Promise.resolve(NeuroidReactnativeSdk.enableLogging(enable));
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
excludeViewByTestID: function excludeViewByTestID(
|
|
61
|
+
excludedView: string
|
|
62
|
+
): Promise<void> {
|
|
63
|
+
return Promise.resolve(
|
|
64
|
+
NeuroidReactnativeSdk.excludeViewByTestID(excludedView)
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
getClientID: function getClientID(): Promise<string> {
|
|
69
|
+
return Promise.resolve(NeuroidReactnativeSdk.getClientID());
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
getEnvironment: function getEnvironment(): Promise<string> {
|
|
73
|
+
return Promise.resolve(NeuroidReactnativeSdk.getEnvironment());
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
getSDKVersion: function getSDKVersion(): Promise<string> {
|
|
77
|
+
return new Promise((res) => res(`React-Native:${version}`));
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
getScreenName: function getScreenName(): Promise<string> {
|
|
81
|
+
return Promise.resolve(NeuroidReactnativeSdk.getScreenName());
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
getSessionID: function getSessionID(): Promise<string> {
|
|
85
|
+
return Promise.resolve(NeuroidReactnativeSdk.getSessionID());
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
getUserID: function getUserID(): Promise<string> {
|
|
89
|
+
return Promise.resolve(NeuroidReactnativeSdk.getUserID());
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
getRegisteredUserID: function getUserID(): Promise<string> {
|
|
93
|
+
return Promise.resolve(NeuroidReactnativeSdk.getRegisteredUserID());
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
isStopped: function isStopped(): Promise<boolean> {
|
|
97
|
+
return Promise.resolve(NeuroidReactnativeSdk.isStopped());
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
setEnvironmentProduction: function setEnvironmentProduction(value: Boolean) {
|
|
101
|
+
NeuroIDLog.i('**** NOTE: THIS METHOD IS DEPRECATED');
|
|
102
|
+
NeuroIDLog.d(`Environment Being Set - ${value ? 'Production' : 'Test'}`);
|
|
103
|
+
return Promise.resolve();
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
setScreenName: function setScreenName(screenName: string): Promise<boolean> {
|
|
107
|
+
NeuroIDLog.d('setScreenName()', screenName);
|
|
108
|
+
return Promise.resolve(NeuroidReactnativeSdk.setScreenName(screenName));
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
setSiteId: function setSiteId(siteId: string): Promise<void> {
|
|
112
|
+
// Pre-release
|
|
113
|
+
NeuroIDLog.i('SiteID set ', siteId);
|
|
114
|
+
NeuroIDLog.i('**** NOTE: THIS METHOD IS DEPRECATED');
|
|
115
|
+
return Promise.resolve(NeuroidReactnativeSdk.setSiteId(siteId));
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
setUserID: function setUserID(userID: string): Promise<boolean> {
|
|
119
|
+
NeuroIDLog.i('Setting User ID: ', userID);
|
|
120
|
+
|
|
121
|
+
return new Promise((resolve, reject) => {
|
|
122
|
+
const result = NeuroidReactnativeSdk.setUserID(userID);
|
|
123
|
+
|
|
124
|
+
if (result) {
|
|
125
|
+
resolve(true);
|
|
126
|
+
} else {
|
|
127
|
+
NeuroIDLog.e('Failed to set user ID');
|
|
128
|
+
reject(false);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
setRegisteredUserID: function setRegisteredUserID(
|
|
134
|
+
userID: string
|
|
135
|
+
): Promise<boolean> {
|
|
136
|
+
NeuroIDLog.i('Setting Registered User ID: ', userID);
|
|
137
|
+
|
|
138
|
+
return new Promise((resolve, reject) => {
|
|
139
|
+
const result = NeuroidReactnativeSdk.setRegisteredUserID(userID);
|
|
140
|
+
|
|
141
|
+
if (result) {
|
|
142
|
+
resolve(true);
|
|
143
|
+
} else {
|
|
144
|
+
NeuroIDLog.e('Failed to set registered user ID');
|
|
145
|
+
reject(false);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
attemptedLogin: function attemptedLogin(userID: string): Promise<boolean> {
|
|
151
|
+
NeuroIDLog.i('Attempted Login User ID: ', userID);
|
|
152
|
+
|
|
153
|
+
return new Promise((resolve, reject) => {
|
|
154
|
+
const result = NeuroidReactnativeSdk.attemptedLogin(userID ?? '');
|
|
155
|
+
|
|
156
|
+
if (result) {
|
|
157
|
+
resolve(true);
|
|
158
|
+
} else {
|
|
159
|
+
NeuroIDLog.e('Failed to set attmpted login user ID');
|
|
160
|
+
reject(false);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
setVerifyIntegrationHealth: function setVerifyIntegrationHealth(
|
|
166
|
+
value: Boolean
|
|
167
|
+
) {
|
|
168
|
+
if (value)
|
|
169
|
+
NeuroIDLog.i(
|
|
170
|
+
'Please view the Xcode or Android Studio console to see instructions on how to access The Integration Health Report'
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
return Promise.resolve(
|
|
174
|
+
NeuroidReactnativeSdk.setVerifyIntegrationHealth(value)
|
|
175
|
+
);
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
setVariable: function setVariable(key: string, value: string): Promise<void> {
|
|
179
|
+
return new Promise(async function (resolve) {
|
|
180
|
+
NeuroIDLog.d(`Setting Variable - ${key}: ${value}`);
|
|
181
|
+
await NeuroidReactnativeSdk.setVariable(key, value);
|
|
182
|
+
resolve();
|
|
183
|
+
});
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
start: function start(): Promise<Boolean> {
|
|
187
|
+
return new Promise(async function (resolve) {
|
|
188
|
+
try {
|
|
189
|
+
const result = await Promise.resolve(NeuroidReactnativeSdk.start());
|
|
190
|
+
let _cid = await NeuroidReactnativeSdk.getSessionID();
|
|
191
|
+
|
|
192
|
+
NeuroIDLog.d('NeuroID Started: ', result);
|
|
193
|
+
NeuroIDLog.i('Client ID:', _cid);
|
|
194
|
+
resolve(result);
|
|
195
|
+
} catch (e: any) {
|
|
196
|
+
NeuroIDLog.e('Failed to start NID', e);
|
|
197
|
+
resolve(false);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
stop: function stop(): Promise<Boolean> {
|
|
203
|
+
return new Promise(async function (resolve) {
|
|
204
|
+
try {
|
|
205
|
+
const result = await Promise.resolve(NeuroidReactnativeSdk.stop());
|
|
206
|
+
resolve(result);
|
|
207
|
+
NeuroIDLog.d('NeuroID Stopped: ', result);
|
|
208
|
+
} catch (e: any) {
|
|
209
|
+
NeuroIDLog.e('Failed to stop NID', e);
|
|
210
|
+
resolve(false);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
registerPageTargets: function registerPageTargets(): Promise<void> {
|
|
216
|
+
if (Platform.OS === 'ios') {
|
|
217
|
+
if (!usingRNNavigation) {
|
|
218
|
+
return Promise.resolve(NeuroidReactnativeSdk.registerPageTargets());
|
|
219
|
+
} else {
|
|
220
|
+
return Promise.resolve();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return Promise.resolve(NeuroidReactnativeSdk.registerPageTargets());
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
setupPage: async function setupPage(screenName: string): Promise<void> {
|
|
227
|
+
await Promise.resolve(NeuroidReactnativeSdk.setScreenName(screenName));
|
|
228
|
+
|
|
229
|
+
return Promise.resolve(NeuroidReactnativeSdk.registerPageTargets());
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
startSession: async function startSession(
|
|
233
|
+
sessionID?: string
|
|
234
|
+
): Promise<SessionStartResult> {
|
|
235
|
+
const result = await NeuroidReactnativeSdk.startSession(sessionID);
|
|
236
|
+
NeuroIDLog.d('startSession(): ' + result.sessionID + ' ' + result.started);
|
|
237
|
+
return Promise.resolve({
|
|
238
|
+
sessionID: result.sessionID as string,
|
|
239
|
+
started: result.started as boolean,
|
|
240
|
+
} as SessionStartResult);
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
stopSession: async function stopSession(): Promise<boolean> {
|
|
244
|
+
let result = await NeuroidReactnativeSdk.stopSession();
|
|
245
|
+
NeuroIDLog.d('stopSession(): ' + result);
|
|
246
|
+
return Promise.resolve(result);
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
pauseCollection: async function pauseCollection(): Promise<void> {
|
|
250
|
+
NeuroidReactnativeSdk.pauseCollection();
|
|
251
|
+
NeuroIDLog.d('pauseCollection()');
|
|
252
|
+
return Promise.resolve();
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
resumeCollection: async function resumeCollection(): Promise<void> {
|
|
256
|
+
NeuroidReactnativeSdk.resumeCollection();
|
|
257
|
+
NeuroIDLog.d('resumeCollection()');
|
|
258
|
+
return Promise.resolve();
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
startAppFlow: async function startAppFlow(
|
|
262
|
+
siteID: string,
|
|
263
|
+
userID?: string
|
|
264
|
+
): Promise<SessionStartResult> {
|
|
265
|
+
const result = await NeuroidReactnativeSdk.startAppFlow(siteID, userID);
|
|
266
|
+
NeuroIDLog.d('startAppFlow(): ' + result.sessionID + ' ' + result.started);
|
|
267
|
+
return Promise.resolve({
|
|
268
|
+
sessionID: result.sessionID as string,
|
|
269
|
+
started: result.started as boolean,
|
|
270
|
+
} as SessionStartResult);
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export default NeuroID;
|
package/src/logger.tsx
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { NeuroIDLogClass } from './types';
|
|
2
|
+
|
|
3
|
+
var showlogs = true;
|
|
4
|
+
export const NeuroIDLog: NeuroIDLogClass = {
|
|
5
|
+
enableLogging: function enableLogging(value?: boolean) {
|
|
6
|
+
showlogs = value === false ? false : true;
|
|
7
|
+
},
|
|
8
|
+
log: function log(...message: String[]) {
|
|
9
|
+
if (showlogs) {
|
|
10
|
+
console.log('(NeuroID) ', message);
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
d: function d(...message: String[]) {
|
|
14
|
+
if (showlogs) {
|
|
15
|
+
console.debug('(NeuroID Debug) ', message);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
i: function i(...message: String[]) {
|
|
19
|
+
if (showlogs) {
|
|
20
|
+
console.info('(NeuroID Info) ', message);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
e: function e(...message: String[]) {
|
|
24
|
+
if (showlogs) {
|
|
25
|
+
console.error('****** NeuroID ERROR: ******\n', message);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default NeuroIDLog;
|
package/src/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface NeuroIDClass {
|
|
2
|
+
configure: (
|
|
3
|
+
apiKey: string,
|
|
4
|
+
options: NeuroIDConfigOptions
|
|
5
|
+
) => Promise<boolean>;
|
|
6
|
+
enableLogging: (enable?: boolean) => Promise<void>;
|
|
7
|
+
excludeViewByTestID: (excludedView: string) => Promise<void>;
|
|
8
|
+
|
|
9
|
+
getClientID: () => Promise<string>;
|
|
10
|
+
getEnvironment: () => Promise<string>;
|
|
11
|
+
getSDKVersion: () => Promise<string>; // JS side not native
|
|
12
|
+
getScreenName: () => Promise<string>; // ios, NOT Android
|
|
13
|
+
getSessionID: () => Promise<string>;
|
|
14
|
+
getUserID: () => Promise<string>;
|
|
15
|
+
getRegisteredUserID: () => Promise<string>;
|
|
16
|
+
|
|
17
|
+
isStopped: () => Promise<boolean>;
|
|
18
|
+
setEnvironmentProduction: (value: Boolean) => Promise<void>; // deprecated
|
|
19
|
+
setScreenName: (screenName: string) => Promise<boolean>;
|
|
20
|
+
setSiteId: (siteId: string) => Promise<void>; // deprecated
|
|
21
|
+
setUserID: (userID: string) => Promise<boolean>;
|
|
22
|
+
setRegisteredUserID: (userID: string) => Promise<boolean>;
|
|
23
|
+
attemptedLogin: (userID: string) => Promise<boolean>;
|
|
24
|
+
setVerifyIntegrationHealth: (value: Boolean) => Promise<void>;
|
|
25
|
+
setVariable(key: string, value: string): Promise<void>;
|
|
26
|
+
|
|
27
|
+
start: () => Promise<Boolean>;
|
|
28
|
+
stop: () => Promise<Boolean>;
|
|
29
|
+
|
|
30
|
+
registerPageTargets: () => Promise<void>;
|
|
31
|
+
setupPage: (screenName: string) => Promise<void>;
|
|
32
|
+
startSession: (sessionID?: string) => Promise<SessionStartResult>;
|
|
33
|
+
stopSession: () => Promise<boolean>;
|
|
34
|
+
resumeCollection: () => Promise<void>;
|
|
35
|
+
pauseCollection: () => Promise<void>;
|
|
36
|
+
startAppFlow: (
|
|
37
|
+
siteID: string,
|
|
38
|
+
userID?: string
|
|
39
|
+
) => Promise<SessionStartResult>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface NeuroIDConfigOptions {
|
|
43
|
+
usingReactNavigation: boolean;
|
|
44
|
+
isAdvancedDevice: boolean;
|
|
45
|
+
environment: string;
|
|
46
|
+
advancedDeviceKey?: string;
|
|
47
|
+
useAdvancedDeviceProxy: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface NeuroIDLogClass {
|
|
51
|
+
enableLogging: (enable?: boolean) => void;
|
|
52
|
+
log: (...message: String[]) => void;
|
|
53
|
+
d: (...message: String[]) => void;
|
|
54
|
+
i: (...message: String[]) => void;
|
|
55
|
+
e: (...message: String[]) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface SessionStartResult {
|
|
59
|
+
started: boolean;
|
|
60
|
+
sessionID: String;
|
|
61
|
+
}
|