@screeb/react-native 2.0.2 → 2.0.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.
@@ -123,6 +123,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
123
123
  dependencies {
124
124
  // noinspection GradleDynamicVersion
125
125
  api 'com.facebook.react:react-native:+'
126
- implementation "app.screeb.sdk:survey:2.0.3"
126
+ implementation "app.screeb.sdk:survey:2.0.7"
127
127
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22"
128
128
  }
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.closeSdk = exports.resetIdentity = exports.debugTargeting = exports.debug = exports.startSurvey = exports.trackScreen = exports.trackEvent = exports.unassignGroup = exports.assignGroup = exports.setProperties = exports.setIdentity = exports.initSdk = void 0;
4
+ const react_native_1 = require("react-native");
5
+ const LINKING_ERROR = `The package '@screeb/react-native' doesn't seem to be linked. Make sure: \n\n` +
6
+ react_native_1.Platform.select({ ios: "- You have run 'pod install'\n", default: "" }) +
7
+ "- You rebuilt the app after installing the package\n" +
8
+ "- You are not using Expo managed workflow\n";
9
+ const ScreebModule = react_native_1.NativeModules.ScreebModule
10
+ ? react_native_1.NativeModules.ScreebModule
11
+ : new Proxy({}, {
12
+ get() {
13
+ throw new Error(LINKING_ERROR);
14
+ },
15
+ });
16
+ let hooksRegistry = new Map();
17
+ function initSdk(androidChannelId, iosChannelId, userId, properties, hooks) {
18
+ const emitter = react_native_1.Platform.OS === "ios"
19
+ ? new react_native_1.NativeEventEmitter(react_native_1.NativeModules.ScreebModule)
20
+ : react_native_1.DeviceEventEmitter;
21
+ emitter.addListener("ScreebEvent", handleEvent);
22
+ let mapHooksId = undefined;
23
+ if (hooks != null) {
24
+ mapHooksId = new Object();
25
+ Object.keys(hooks).map((key) => {
26
+ if (key == "version") {
27
+ mapHooksId = { ...mapHooksId, version: hooks[key] };
28
+ }
29
+ else {
30
+ // Random id
31
+ let uuid = Date.now().toString() + Math.random().toString();
32
+ hooksRegistry.set(uuid, hooks[key]);
33
+ mapHooksId = { ...mapHooksId, [key]: uuid };
34
+ }
35
+ });
36
+ }
37
+ if (react_native_1.Platform.OS === "ios") {
38
+ return ScreebModule.initSdk(iosChannelId, userId, properties, mapHooksId);
39
+ }
40
+ else {
41
+ return ScreebModule.initSdk(androidChannelId, userId, properties, mapHooksId);
42
+ }
43
+ }
44
+ exports.initSdk = initSdk;
45
+ function setIdentity(userId, properties) {
46
+ return ScreebModule.setIdentity(userId, properties);
47
+ }
48
+ exports.setIdentity = setIdentity;
49
+ function setProperties(properties) {
50
+ return ScreebModule.setProperties(properties);
51
+ }
52
+ exports.setProperties = setProperties;
53
+ function assignGroup(type, name, properties) {
54
+ return ScreebModule.assignGroup(type, name, properties);
55
+ }
56
+ exports.assignGroup = assignGroup;
57
+ function unassignGroup(type, name, properties) {
58
+ return ScreebModule.unassignGroup(type, name, properties);
59
+ }
60
+ exports.unassignGroup = unassignGroup;
61
+ function trackEvent(name, properties) {
62
+ return ScreebModule.trackEvent(name, properties);
63
+ }
64
+ exports.trackEvent = trackEvent;
65
+ function trackScreen(name, properties) {
66
+ return ScreebModule.trackScreen(name, properties);
67
+ }
68
+ exports.trackScreen = trackScreen;
69
+ function startSurvey(surveyId, allowMultipleResponses, hiddenFields, ignoreSurveyStatus, hooks) {
70
+ let mapHooksId = undefined;
71
+ if (hooks != undefined) {
72
+ mapHooksId = new Object();
73
+ Object.keys(hooks).map((key) => {
74
+ if (key == "version") {
75
+ mapHooksId = { ...mapHooksId, version: hooks[key] };
76
+ }
77
+ else {
78
+ // Random id
79
+ let uuid = Date.now().toString() + Math.random().toString();
80
+ hooksRegistry.set(uuid, hooks[key]);
81
+ mapHooksId = { ...mapHooksId, [key]: uuid };
82
+ }
83
+ });
84
+ }
85
+ return ScreebModule.startSurvey(surveyId, allowMultipleResponses ?? true, hiddenFields, ignoreSurveyStatus ?? true, mapHooksId);
86
+ }
87
+ exports.startSurvey = startSurvey;
88
+ function debug() {
89
+ return ScreebModule.debug();
90
+ }
91
+ exports.debug = debug;
92
+ function debugTargeting() {
93
+ return ScreebModule.debugTargeting();
94
+ }
95
+ exports.debugTargeting = debugTargeting;
96
+ function resetIdentity() {
97
+ return ScreebModule.resetIdentity();
98
+ }
99
+ exports.resetIdentity = resetIdentity;
100
+ function closeSdk() {
101
+ return ScreebModule.closeSdk();
102
+ }
103
+ exports.closeSdk = closeSdk;
104
+ function handleEvent(event) {
105
+ if (event?.hookId != null) {
106
+ let hook = hooksRegistry.get(event.hookId);
107
+ if (hook != null) {
108
+ hook(event.payload);
109
+ }
110
+ }
111
+ }
@@ -0,0 +1,96 @@
1
+ import { DeviceEventEmitter, NativeEventEmitter, NativeModules, Platform, } from "react-native";
2
+ const LINKING_ERROR = `The package '@screeb/react-native' doesn't seem to be linked. Make sure: \n\n` +
3
+ Platform.select({ ios: "- You have run 'pod install'\n", default: "" }) +
4
+ "- You rebuilt the app after installing the package\n" +
5
+ "- You are not using Expo managed workflow\n";
6
+ const ScreebModule = NativeModules.ScreebModule
7
+ ? NativeModules.ScreebModule
8
+ : new Proxy({}, {
9
+ get() {
10
+ throw new Error(LINKING_ERROR);
11
+ },
12
+ });
13
+ let hooksRegistry = new Map();
14
+ export function initSdk(androidChannelId, iosChannelId, userId, properties, hooks) {
15
+ const emitter = Platform.OS === "ios"
16
+ ? new NativeEventEmitter(NativeModules.ScreebModule)
17
+ : DeviceEventEmitter;
18
+ emitter.addListener("ScreebEvent", handleEvent);
19
+ let mapHooksId = undefined;
20
+ if (hooks != null) {
21
+ mapHooksId = new Object();
22
+ Object.keys(hooks).map((key) => {
23
+ if (key == "version") {
24
+ mapHooksId = { ...mapHooksId, version: hooks[key] };
25
+ }
26
+ else {
27
+ // Random id
28
+ let uuid = Date.now().toString() + Math.random().toString();
29
+ hooksRegistry.set(uuid, hooks[key]);
30
+ mapHooksId = { ...mapHooksId, [key]: uuid };
31
+ }
32
+ });
33
+ }
34
+ if (Platform.OS === "ios") {
35
+ return ScreebModule.initSdk(iosChannelId, userId, properties, mapHooksId);
36
+ }
37
+ else {
38
+ return ScreebModule.initSdk(androidChannelId, userId, properties, mapHooksId);
39
+ }
40
+ }
41
+ export function setIdentity(userId, properties) {
42
+ return ScreebModule.setIdentity(userId, properties);
43
+ }
44
+ export function setProperties(properties) {
45
+ return ScreebModule.setProperties(properties);
46
+ }
47
+ export function assignGroup(type, name, properties) {
48
+ return ScreebModule.assignGroup(type, name, properties);
49
+ }
50
+ export function unassignGroup(type, name, properties) {
51
+ return ScreebModule.unassignGroup(type, name, properties);
52
+ }
53
+ export function trackEvent(name, properties) {
54
+ return ScreebModule.trackEvent(name, properties);
55
+ }
56
+ export function trackScreen(name, properties) {
57
+ return ScreebModule.trackScreen(name, properties);
58
+ }
59
+ export function startSurvey(surveyId, allowMultipleResponses, hiddenFields, ignoreSurveyStatus, hooks) {
60
+ let mapHooksId = undefined;
61
+ if (hooks != undefined) {
62
+ mapHooksId = new Object();
63
+ Object.keys(hooks).map((key) => {
64
+ if (key == "version") {
65
+ mapHooksId = { ...mapHooksId, version: hooks[key] };
66
+ }
67
+ else {
68
+ // Random id
69
+ let uuid = Date.now().toString() + Math.random().toString();
70
+ hooksRegistry.set(uuid, hooks[key]);
71
+ mapHooksId = { ...mapHooksId, [key]: uuid };
72
+ }
73
+ });
74
+ }
75
+ return ScreebModule.startSurvey(surveyId, allowMultipleResponses ?? true, hiddenFields, ignoreSurveyStatus ?? true, mapHooksId);
76
+ }
77
+ export function debug() {
78
+ return ScreebModule.debug();
79
+ }
80
+ export function debugTargeting() {
81
+ return ScreebModule.debugTargeting();
82
+ }
83
+ export function resetIdentity() {
84
+ return ScreebModule.resetIdentity();
85
+ }
86
+ export function closeSdk() {
87
+ return ScreebModule.closeSdk();
88
+ }
89
+ function handleEvent(event) {
90
+ if (event?.hookId != null) {
91
+ let hook = hooksRegistry.get(event.hookId);
92
+ if (hook != null) {
93
+ hook(event.payload);
94
+ }
95
+ }
96
+ }
@@ -0,0 +1,12 @@
1
+ export declare function initSdk(androidChannelId: string, iosChannelId: string, userId?: string, properties?: Map<string, any>, hooks?: any): 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): 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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@screeb/react-native",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Continuous Product Discovery",
5
5
  "scripts": {
6
6
  "clean": "rm -rf lib/",
@@ -55,5 +55,8 @@
55
55
  "react": "*",
56
56
  "react-native": "*"
57
57
  },
58
- "types": "./lib/typescript/index.d.ts"
58
+ "types": "./lib/typescript/index.d.ts",
59
+ "devDependencies": {
60
+ "typescript": "^5.1.6"
61
+ }
59
62
  }