@screeb/react-native 2.1.17 → 2.2.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.
- package/README.md +24 -5
- package/{screeb-module.podspec → ScreebReactNative.podspec} +6 -4
- package/android/build.gradle +36 -86
- package/android/gradle.properties +5 -3
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/app/screeb/reactnative/ScreebReactNativeModule.kt +258 -0
- package/android/src/main/java/app/screeb/reactnative/ScreebReactNativePackage.kt +33 -0
- package/ios/ScreebReactNative.m +63 -0
- package/ios/{ScreebModule.swift → ScreebReactNative.swift} +116 -32
- package/lib/module/NativeScreebReactNative.js +10 -0
- package/lib/module/NativeScreebReactNative.js.map +1 -0
- package/lib/module/index.js +170 -88
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeScreebReactNative.d.ts +49 -0
- package/lib/typescript/src/NativeScreebReactNative.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +25 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +153 -59
- package/src/NativeScreebReactNative.ts +81 -0
- package/src/index.tsx +251 -144
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -185
- package/android/gradlew.bat +0 -89
- package/android/src/main/java/com/screebmodule/ScreebModuleModule.kt +0 -186
- package/android/src/main/java/com/screebmodule/ScreebModulePackage.kt +0 -17
- package/ios/ScreebModule-Bridging-Header.h +0 -3
- package/ios/ScreebModule.m +0 -24
- package/ios/ScreebModule.xcodeproj/project.pbxproj +0 -293
- package/lib/commonjs/index.js +0 -130
- package/lib/typescript/index.d.ts +0 -13
package/lib/commonjs/index.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initSdk = initSdk;
|
|
4
|
-
exports.setIdentity = setIdentity;
|
|
5
|
-
exports.setProperties = setProperties;
|
|
6
|
-
exports.assignGroup = assignGroup;
|
|
7
|
-
exports.unassignGroup = unassignGroup;
|
|
8
|
-
exports.trackEvent = trackEvent;
|
|
9
|
-
exports.trackScreen = trackScreen;
|
|
10
|
-
exports.startSurvey = startSurvey;
|
|
11
|
-
exports.debug = debug;
|
|
12
|
-
exports.debugTargeting = debugTargeting;
|
|
13
|
-
exports.resetIdentity = resetIdentity;
|
|
14
|
-
exports.closeSdk = closeSdk;
|
|
15
|
-
exports.closeSurvey = closeSurvey;
|
|
16
|
-
const react_native_1 = require("react-native");
|
|
17
|
-
const LINKING_ERROR = `The package '@screeb/react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
18
|
-
react_native_1.Platform.select({ ios: "- You have run 'pod install'\n", default: "" }) +
|
|
19
|
-
"- You rebuilt the app after installing the package\n" +
|
|
20
|
-
"- You are not using Expo managed workflow\n";
|
|
21
|
-
const ScreebModule = react_native_1.NativeModules.ScreebModule
|
|
22
|
-
? react_native_1.NativeModules.ScreebModule
|
|
23
|
-
: new Proxy({}, {
|
|
24
|
-
get() {
|
|
25
|
-
throw new Error(LINKING_ERROR);
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
let hooksRegistry = new Map();
|
|
29
|
-
function initSdk(androidChannelId, iosChannelId, userId, properties, hooks, isDebugMode, language) {
|
|
30
|
-
const emitter = react_native_1.Platform.OS === "ios"
|
|
31
|
-
? new react_native_1.NativeEventEmitter(react_native_1.NativeModules.ScreebModule)
|
|
32
|
-
: react_native_1.DeviceEventEmitter;
|
|
33
|
-
emitter.addListener("ScreebEvent", handleEvent);
|
|
34
|
-
let mapHooksId = undefined;
|
|
35
|
-
if (hooks != null) {
|
|
36
|
-
mapHooksId = new Object();
|
|
37
|
-
Object.keys(hooks).map((key) => {
|
|
38
|
-
if (key == "version") {
|
|
39
|
-
mapHooksId = { ...mapHooksId, version: hooks[key] };
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
let uuid = Date.now().toString() + Math.random().toString() + key;
|
|
43
|
-
hooksRegistry.set(uuid, hooks[key]);
|
|
44
|
-
mapHooksId = { ...mapHooksId, [key]: uuid };
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (react_native_1.Platform.OS === "ios") {
|
|
49
|
-
return ScreebModule.initSdk(iosChannelId, userId, properties, mapHooksId, isDebugMode, language);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
return ScreebModule.initSdk(androidChannelId, userId, properties, mapHooksId, isDebugMode, language);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function setIdentity(userId, properties) {
|
|
56
|
-
return ScreebModule.setIdentity(userId, properties);
|
|
57
|
-
}
|
|
58
|
-
function setProperties(properties) {
|
|
59
|
-
return ScreebModule.setProperties(properties);
|
|
60
|
-
}
|
|
61
|
-
function assignGroup(type, name, properties) {
|
|
62
|
-
return ScreebModule.assignGroup(type, name, properties);
|
|
63
|
-
}
|
|
64
|
-
function unassignGroup(type, name, properties) {
|
|
65
|
-
return ScreebModule.unassignGroup(type, name, properties);
|
|
66
|
-
}
|
|
67
|
-
function trackEvent(name, properties) {
|
|
68
|
-
return ScreebModule.trackEvent(name, properties);
|
|
69
|
-
}
|
|
70
|
-
function trackScreen(name, properties) {
|
|
71
|
-
return ScreebModule.trackScreen(name, properties);
|
|
72
|
-
}
|
|
73
|
-
function startSurvey(surveyId, allowMultipleResponses, hiddenFields, ignoreSurveyStatus, hooks, language) {
|
|
74
|
-
let mapHooksId = undefined;
|
|
75
|
-
if (hooks != undefined) {
|
|
76
|
-
mapHooksId = new Object();
|
|
77
|
-
Object.keys(hooks).map((key) => {
|
|
78
|
-
if (key == "version") {
|
|
79
|
-
mapHooksId = { ...mapHooksId, version: hooks[key] };
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
let uuid = Date.now().toString() + Math.random().toString() + key;
|
|
83
|
-
hooksRegistry.set(uuid, hooks[key]);
|
|
84
|
-
mapHooksId = { ...mapHooksId, [key]: uuid };
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
return ScreebModule.startSurvey(surveyId, allowMultipleResponses ?? true, hiddenFields, ignoreSurveyStatus ?? true, mapHooksId, language);
|
|
89
|
-
}
|
|
90
|
-
function debug() {
|
|
91
|
-
return ScreebModule.debug();
|
|
92
|
-
}
|
|
93
|
-
function debugTargeting() {
|
|
94
|
-
return ScreebModule.debugTargeting();
|
|
95
|
-
}
|
|
96
|
-
function resetIdentity() {
|
|
97
|
-
return ScreebModule.resetIdentity();
|
|
98
|
-
}
|
|
99
|
-
function closeSdk() {
|
|
100
|
-
return ScreebModule.closeSdk();
|
|
101
|
-
}
|
|
102
|
-
function closeSurvey() {
|
|
103
|
-
return ScreebModule.closeSurvey();
|
|
104
|
-
}
|
|
105
|
-
function handleEvent(event) {
|
|
106
|
-
if (event?.hookId != null) {
|
|
107
|
-
let hook = hooksRegistry.get(event.hookId);
|
|
108
|
-
if (hook != null) {
|
|
109
|
-
const result = hook(event.payload);
|
|
110
|
-
const parsedPayload = JSON.parse(event.payload);
|
|
111
|
-
const originalHookId = parsedPayload?.hook_id;
|
|
112
|
-
if (originalHookId) {
|
|
113
|
-
// result must be a map to fit with react native allowed types
|
|
114
|
-
// Check if hook is a promise/async function
|
|
115
|
-
if (result instanceof Promise) {
|
|
116
|
-
result
|
|
117
|
-
.then((result) => {
|
|
118
|
-
ScreebModule.onHookResult(originalHookId, { result });
|
|
119
|
-
})
|
|
120
|
-
.catch((error) => {
|
|
121
|
-
console.error(error);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
ScreebModule.onHookResult(originalHookId, { result });
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare function initSdk(androidChannelId: string, iosChannelId: string, userId?: string, properties?: Map<string, any>, hooks?: any, isDebugMode?: boolean, language?: string): any;
|
|
2
|
-
export declare function setIdentity(userId: string, properties?: Map<string, any>): any;
|
|
3
|
-
export declare function setProperties(properties?: Map<string, any>): any;
|
|
4
|
-
export declare function assignGroup(type: string | null, name: string, properties?: Map<string, any>): any;
|
|
5
|
-
export declare function unassignGroup(type: string | null, name: string, properties?: Map<string, any>): any;
|
|
6
|
-
export declare function trackEvent(name: string, properties?: Map<string, any>): any;
|
|
7
|
-
export declare function trackScreen(name: string, properties?: Map<string, any>): any;
|
|
8
|
-
export declare function startSurvey(surveyId: string, allowMultipleResponses?: boolean, hiddenFields?: Map<string, any>, ignoreSurveyStatus?: boolean, hooks?: any, language?: string): any;
|
|
9
|
-
export declare function debug(): any;
|
|
10
|
-
export declare function debugTargeting(): any;
|
|
11
|
-
export declare function resetIdentity(): any;
|
|
12
|
-
export declare function closeSdk(): any;
|
|
13
|
-
export declare function closeSurvey(): any;
|