reteno-react-native-sdk 1.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.
package/package.json ADDED
@@ -0,0 +1,167 @@
1
+ {
2
+ "name": "reteno-react-native-sdk",
3
+ "version": "1.0.0",
4
+ "description": "The Reteno React Native SDK for App Analytics and Engagement.",
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
+ "*.podspec",
17
+ "!lib/typescript/example",
18
+ "!ios/build",
19
+ "!android/build",
20
+ "!android/gradle",
21
+ "!android/gradlew",
22
+ "!android/gradlew.bat",
23
+ "!android/local.properties",
24
+ "!**/__tests__",
25
+ "!**/__fixtures__",
26
+ "!**/__mocks__",
27
+ "!**/.*"
28
+ ],
29
+ "scripts": {
30
+ "test": "jest",
31
+ "typecheck": "tsc --noEmit",
32
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
33
+ "prepack": "bob build",
34
+ "release": "release-it --no-increment",
35
+ "example": "yarn --cwd example",
36
+ "bootstrap": "yarn example && yarn install && yarn example pods",
37
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
38
+ },
39
+ "keywords": [
40
+ "react-native",
41
+ "ios",
42
+ "android"
43
+ ],
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/reteno-com/reteno-react-native-sdk.git"
47
+ },
48
+ "author": "mobile-sdk@reteno.com",
49
+ "license": "MIT",
50
+ "bugs": {
51
+ "url": "https://github.com/reteno-com/reteno-react-native-sdk/issues"
52
+ },
53
+ "directories": {
54
+ "doc": "docs",
55
+ "example": "example"
56
+ },
57
+ "homepage": "https://github.com/reteno-com/reteno-react-native-sdk#readme",
58
+ "publishConfig": {
59
+ "registry": "https://registry.npmjs.org/"
60
+ },
61
+ "devDependencies": {
62
+ "@evilmartians/lefthook": "^1.2.2",
63
+ "@commitlint/config-conventional": "^17.0.2",
64
+ "@react-native-community/eslint-config": "^3.0.2",
65
+ "@release-it/conventional-changelog": "^5.0.0",
66
+ "@types/jest": "^28.1.2",
67
+ "@types/react": "~17.0.21",
68
+ "@types/react-native": "0.70.0",
69
+ "commitlint": "^17.0.2",
70
+ "del-cli": "^5.0.0",
71
+ "eslint": "^8.4.1",
72
+ "eslint-config-prettier": "^8.5.0",
73
+ "eslint-plugin-prettier": "^4.0.0",
74
+ "jest": "^28.1.1",
75
+ "pod-install": "^0.1.0",
76
+ "prettier": "^2.0.5",
77
+ "react": "18.1.0",
78
+ "react-native": "0.70.6",
79
+ "react-native-builder-bob": "^0.20.0",
80
+ "release-it": "^15.0.0",
81
+ "typescript": "^4.5.2"
82
+ },
83
+ "resolutions": {
84
+ "@types/react": "17.0.21"
85
+ },
86
+ "peerDependencies": {
87
+ "react": "*",
88
+ "react-native": "*"
89
+ },
90
+ "engines": {
91
+ "node": ">= 16.0.0"
92
+ },
93
+ "packageManager": "^yarn@1.22.15",
94
+ "jest": {
95
+ "preset": "react-native",
96
+ "modulePathIgnorePatterns": [
97
+ "<rootDir>/example/node_modules",
98
+ "<rootDir>/lib/"
99
+ ]
100
+ },
101
+ "commitlint": {
102
+ "extends": [
103
+ "@commitlint/config-conventional"
104
+ ]
105
+ },
106
+ "release-it": {
107
+ "git": {
108
+ "commitMessage": "chore: release ${version}",
109
+ "tagName": "v${version}"
110
+ },
111
+ "npm": {
112
+ "publish": true
113
+ },
114
+ "github": {
115
+ "release": true
116
+ },
117
+ "plugins": {
118
+ "@release-it/conventional-changelog": {
119
+ "preset": "angular"
120
+ }
121
+ }
122
+ },
123
+ "eslintConfig": {
124
+ "root": true,
125
+ "extends": [
126
+ "@react-native-community",
127
+ "prettier"
128
+ ],
129
+ "rules": {
130
+ "prettier/prettier": [
131
+ "error",
132
+ {
133
+ "quoteProps": "consistent",
134
+ "singleQuote": true,
135
+ "tabWidth": 2,
136
+ "trailingComma": "es5",
137
+ "useTabs": false
138
+ }
139
+ ]
140
+ }
141
+ },
142
+ "eslintIgnore": [
143
+ "node_modules/",
144
+ "lib/"
145
+ ],
146
+ "prettier": {
147
+ "quoteProps": "consistent",
148
+ "singleQuote": true,
149
+ "tabWidth": 2,
150
+ "trailingComma": "es5",
151
+ "useTabs": false
152
+ },
153
+ "react-native-builder-bob": {
154
+ "source": "src",
155
+ "output": "lib",
156
+ "targets": [
157
+ "commonjs",
158
+ "module",
159
+ [
160
+ "typescript",
161
+ {
162
+ "project": "tsconfig.build.json"
163
+ }
164
+ ]
165
+ ]
166
+ }
167
+ }
@@ -0,0 +1,36 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "reteno-react-native-sdk"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => "12.0" }
15
+ s.source = { :git => "https://github.com/reteno-com/reteno-react-native-sdk.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
18
+
19
+ s.dependency 'React-Core'
20
+ s.dependency 'Reteno', '1.3.0'
21
+
22
+ # Don't install the dependencies when we run `pod install` in the old architecture.
23
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
24
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
25
+ s.pod_target_xcconfig = {
26
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
27
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
28
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
29
+ }
30
+ s.dependency "React-Codegen"
31
+ s.dependency "RCT-Folly"
32
+ s.dependency "RCTRequired"
33
+ s.dependency "RCTTypeSafety"
34
+ s.dependency "ReactCommon/turbomodule/core"
35
+ end
36
+ end
package/src/index.tsx ADDED
@@ -0,0 +1,92 @@
1
+ import {
2
+ DeviceEventEmitter,
3
+ NativeEventEmitter,
4
+ NativeModules,
5
+ Platform,
6
+ } from 'react-native';
7
+
8
+ const LINKING_ERROR =
9
+ `The package 'reteno-react-native-sdk' doesn't seem to be linked. Make sure: \n\n` +
10
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
11
+ '- You rebuilt the app after installing the package\n' +
12
+ '- You are not using Expo Go\n';
13
+
14
+ export type Address = {
15
+ region?: string | null;
16
+ town?: string | null;
17
+ address?: string | null;
18
+ postcode?: string | null;
19
+ };
20
+
21
+ type Field = {
22
+ key: string;
23
+ value: string;
24
+ };
25
+
26
+ type Fields = Field[];
27
+
28
+ export type UserAttributes = {
29
+ phone?: string | null;
30
+ email?: string | null;
31
+ firstName?: string | null;
32
+ lastName?: string | null;
33
+ languageCode?: string | null;
34
+ timeZone?: string | null;
35
+ address?: Address | null;
36
+ fields?: Fields | null;
37
+ };
38
+
39
+ export type User = {
40
+ userAttributes?: UserAttributes | null;
41
+ subscriptionKeys?: String[] | null;
42
+ groupNamesInclude?: String[] | null;
43
+ groupNamesExclude?: String[] | null;
44
+ };
45
+
46
+ export type SetUserAttributesPayload = {
47
+ externalUserId: string;
48
+ user: User;
49
+ };
50
+
51
+ const RetenoSdk = NativeModules.RetenoSdk
52
+ ? NativeModules.RetenoSdk
53
+ : new Proxy(
54
+ {},
55
+ {
56
+ get() {
57
+ throw new Error(LINKING_ERROR);
58
+ },
59
+ }
60
+ );
61
+
62
+ export function setDeviceToken(deviceToken: string): Promise<void> {
63
+ return RetenoSdk.setDeviceToken(deviceToken);
64
+ }
65
+
66
+ export function setUserAttributes(
67
+ payload: SetUserAttributesPayload
68
+ ): Promise<void> {
69
+ if (
70
+ !payload.externalUserId ||
71
+ (payload.externalUserId && payload.externalUserId.length === 0)
72
+ ) {
73
+ throw new Error('Missing argument: "externalUserId"');
74
+ }
75
+ return RetenoSdk.setUserAttributes(payload);
76
+ }
77
+
78
+ export function getInitialNotification(): Promise<any> {
79
+ return RetenoSdk.getInitialNotification();
80
+ }
81
+
82
+ const eventEmitter = Platform.select({
83
+ ios: new NativeEventEmitter(RetenoSdk),
84
+ // @ts-ignore
85
+ android: DeviceEventEmitter,
86
+ });
87
+
88
+ export function setOnRetenoPushReceivedListener(
89
+ listener: (event: any) => void
90
+ ) {
91
+ return eventEmitter.addListener('reteno-push-received', listener);
92
+ }