@attentive-mobile/attentive-react-native-sdk 0.1.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/LICENSE +20 -0
- package/README.md +140 -0
- package/android/build.gradle +92 -0
- package/android/github.properties +2 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/attentivereactnativesdk/AttentiveReactNativeSdkModule.java +195 -0
- package/android/src/main/java/com/attentivereactnativesdk/AttentiveReactNativeSdkPackage.java +28 -0
- package/attentive-react-native-sdk.podspec +36 -0
- package/ios/AttentiveReactNativeSdk.h +18 -0
- package/ios/AttentiveReactNativeSdk.mm +85 -0
- package/ios/AttentiveReactNativeSdk.xcodeproj/project.pbxproj +276 -0
- package/ios/AttentiveReactNativeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/AttentiveReactNativeSdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/AttentiveReactNativeSdk.xcodeproj/project.xcworkspace/xcuserdata/wdavis.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/AttentiveReactNativeSdk.xcodeproj/xcuserdata/wdavis.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/attentive-sdk-umbrella.h +23 -0
- package/lib/commonjs/eventTypes.js +2 -0
- package/lib/commonjs/eventTypes.js.map +1 -0
- package/lib/commonjs/index.js +50 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/eventTypes.js +2 -0
- package/lib/module/eventTypes.js.map +1 -0
- package/lib/module/index.js +42 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/eventTypes.d.ts +36 -0
- package/lib/typescript/eventTypes.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +30 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +162 -0
- package/src/eventTypes.tsx +42 -0
- package/src/index.tsx +77 -0
package/package.json
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@attentive-mobile/attentive-react-native-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React Native Module for the Attentive 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
|
+
"*.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",
|
|
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
|
+
"attentive",
|
|
41
|
+
"react-native",
|
|
42
|
+
"ios",
|
|
43
|
+
"android"
|
|
44
|
+
],
|
|
45
|
+
"repository": "https://github.com/attentive-mobile/attentive-react-native-sdk",
|
|
46
|
+
"author": "Attentive <epd-accounts+npm@attentivemobile.com> (https://www.attentive.com)",
|
|
47
|
+
"contributors": ["Wyatt Davis"],
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/attentive-mobile/attentive-react-native-sdk/issues"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://github.com/attentive-mobile/attentive-react-native-sdk#readme",
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"registry": "https://registry.npmjs.org/"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@evilmartians/lefthook": "^1.2.2",
|
|
58
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
59
|
+
"@react-native-community/eslint-config": "^3.0.2",
|
|
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.70.0",
|
|
64
|
+
"commitlint": "^17.0.2",
|
|
65
|
+
"del-cli": "^5.0.0",
|
|
66
|
+
"eslint": "^8.4.1",
|
|
67
|
+
"eslint-config-prettier": "^8.5.0",
|
|
68
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
69
|
+
"jest": "^28.1.1",
|
|
70
|
+
"pod-install": "^0.1.0",
|
|
71
|
+
"prettier": "^2.0.5",
|
|
72
|
+
"react": "18.2.0",
|
|
73
|
+
"react-native": "0.71.5",
|
|
74
|
+
"react-native-builder-bob": "^0.20.4",
|
|
75
|
+
"release-it": "^15.0.0",
|
|
76
|
+
"typescript": "^4.5.2"
|
|
77
|
+
},
|
|
78
|
+
"resolutions": {
|
|
79
|
+
"@types/react": "17.0.21"
|
|
80
|
+
},
|
|
81
|
+
"peerDependencies": {
|
|
82
|
+
"react": "*",
|
|
83
|
+
"react-native": "*"
|
|
84
|
+
},
|
|
85
|
+
"engines": {
|
|
86
|
+
"node": ">= 18.0.0"
|
|
87
|
+
},
|
|
88
|
+
"packageManager": "^yarn@1.22.15",
|
|
89
|
+
"jest": {
|
|
90
|
+
"preset": "react-native",
|
|
91
|
+
"modulePathIgnorePatterns": [
|
|
92
|
+
"<rootDir>/example/node_modules",
|
|
93
|
+
"<rootDir>/lib/"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"commitlint": {
|
|
97
|
+
"extends": [
|
|
98
|
+
"@commitlint/config-conventional"
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
"release-it": {
|
|
102
|
+
"git": {
|
|
103
|
+
"commitMessage": "chore: release ${version}",
|
|
104
|
+
"tagName": "v${version}"
|
|
105
|
+
},
|
|
106
|
+
"npm": {
|
|
107
|
+
"publish": true
|
|
108
|
+
},
|
|
109
|
+
"github": {
|
|
110
|
+
"release": true
|
|
111
|
+
},
|
|
112
|
+
"plugins": {
|
|
113
|
+
"@release-it/conventional-changelog": {
|
|
114
|
+
"preset": "angular"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"eslintConfig": {
|
|
119
|
+
"root": true,
|
|
120
|
+
"extends": [
|
|
121
|
+
"@react-native-community",
|
|
122
|
+
"prettier"
|
|
123
|
+
],
|
|
124
|
+
"rules": {
|
|
125
|
+
"prettier/prettier": [
|
|
126
|
+
"error",
|
|
127
|
+
{
|
|
128
|
+
"quoteProps": "consistent",
|
|
129
|
+
"singleQuote": true,
|
|
130
|
+
"tabWidth": 2,
|
|
131
|
+
"trailingComma": "es5",
|
|
132
|
+
"useTabs": false
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"eslintIgnore": [
|
|
138
|
+
"node_modules/",
|
|
139
|
+
"lib/"
|
|
140
|
+
],
|
|
141
|
+
"prettier": {
|
|
142
|
+
"quoteProps": "consistent",
|
|
143
|
+
"singleQuote": true,
|
|
144
|
+
"tabWidth": 2,
|
|
145
|
+
"trailingComma": "es5",
|
|
146
|
+
"useTabs": false
|
|
147
|
+
},
|
|
148
|
+
"react-native-builder-bob": {
|
|
149
|
+
"source": "src",
|
|
150
|
+
"output": "lib",
|
|
151
|
+
"targets": [
|
|
152
|
+
"commonjs",
|
|
153
|
+
"module",
|
|
154
|
+
[
|
|
155
|
+
"typescript",
|
|
156
|
+
{
|
|
157
|
+
"project": "tsconfig.build.json"
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type Item = {
|
|
2
|
+
productId: string;
|
|
3
|
+
productVariantId: string;
|
|
4
|
+
price: Price;
|
|
5
|
+
productImage?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
quantity?: number;
|
|
8
|
+
category?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type Price = {
|
|
12
|
+
price: string;
|
|
13
|
+
currency: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type Order = {
|
|
17
|
+
orderId: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type Cart = {
|
|
21
|
+
cartId?: string;
|
|
22
|
+
cartCoupon?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type ProductViewEvent = {
|
|
26
|
+
items: Item[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type AddToCartEvent = {
|
|
30
|
+
items: Item[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type PurchaseEvent = {
|
|
34
|
+
items: Item[];
|
|
35
|
+
order: Order;
|
|
36
|
+
cart?: Cart;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type CustomEvent = {
|
|
40
|
+
type: string;
|
|
41
|
+
properties: Record<string, string>;
|
|
42
|
+
};
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
import type {
|
|
3
|
+
AddToCartEvent,
|
|
4
|
+
ProductViewEvent,
|
|
5
|
+
PurchaseEvent,
|
|
6
|
+
CustomEvent,
|
|
7
|
+
} from './eventTypes';
|
|
8
|
+
|
|
9
|
+
const LINKING_ERROR =
|
|
10
|
+
`The package 'attentive-react-native-sdk' doesn't seem to be linked. Make sure: \n\n` +
|
|
11
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
12
|
+
'- You rebuilt the app after installing the package\n' +
|
|
13
|
+
'- You are not using Expo Go\n';
|
|
14
|
+
|
|
15
|
+
const AttentiveReactNativeSdk = NativeModules.AttentiveReactNativeSdk
|
|
16
|
+
? NativeModules.AttentiveReactNativeSdk
|
|
17
|
+
: new Proxy(
|
|
18
|
+
{},
|
|
19
|
+
{
|
|
20
|
+
get() {
|
|
21
|
+
throw new Error(LINKING_ERROR);
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export enum Mode {
|
|
27
|
+
Production = 'production',
|
|
28
|
+
Debug = 'debug',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type AttentiveConfiguration = {
|
|
32
|
+
attentiveDomain: string;
|
|
33
|
+
mode: Mode;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type UserIdentifiers = {
|
|
37
|
+
phone?: string;
|
|
38
|
+
email?: string;
|
|
39
|
+
klaviyoId?: string;
|
|
40
|
+
shopifyId?: string;
|
|
41
|
+
clientUserId?: string;
|
|
42
|
+
customIdentifiers?: { [key: string]: string };
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export class Attentive {
|
|
46
|
+
static initialize(configuration: AttentiveConfiguration): void {
|
|
47
|
+
AttentiveReactNativeSdk.initialize(configuration);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static identify(userIdentifiers: UserIdentifiers): void {
|
|
51
|
+
AttentiveReactNativeSdk.identify(userIdentifiers);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static clearUser(): void {
|
|
55
|
+
AttentiveReactNativeSdk.clearUser();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static triggerCreative(): void {
|
|
59
|
+
AttentiveReactNativeSdk.triggerCreative();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static recordProductViewEvent(productViewEvent: ProductViewEvent): void {
|
|
63
|
+
AttentiveReactNativeSdk.recordProductViewEvent(productViewEvent);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static recordAddToCartEvent(addToCartEvent: AddToCartEvent): void {
|
|
67
|
+
AttentiveReactNativeSdk.recordAddToCartEvent(addToCartEvent);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static recordPurchaseEvent(purchaseEvent: PurchaseEvent): void {
|
|
71
|
+
AttentiveReactNativeSdk.recordPurchaseEvent(purchaseEvent);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static recordCustomEvent(customEvent: CustomEvent): void {
|
|
75
|
+
AttentiveReactNativeSdk.recordCustomEvent(customEvent);
|
|
76
|
+
}
|
|
77
|
+
}
|