@oplacrm/om-react-native 0.0.0-stage → 0.1.1
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 +108 -2
- package/bare.d.ts +1 -0
- package/bare.js +1 -0
- package/lib/bare.d.ts +21 -0
- package/lib/bare.js +66 -0
- package/lib/core.d.ts +135 -0
- package/lib/core.js +370 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.js +32 -0
- package/package.json +54 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OplaCRM
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,109 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Opla Marketing SDK cho React Native
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SDK theo dõi khách trong app di động, giống tracker trên website. Dữ liệu đi vào cùng chỗ với dữ liệu web, nên chấm điểm, hành trình, kịch bản và Kho khách hàng của OM dùng được ngay.
|
|
4
|
+
|
|
5
|
+
## Chuẩn bị trong OM
|
|
6
|
+
|
|
7
|
+
Vào **Cài đặt → Tích hợp → Website → App di động (React Native)**:
|
|
8
|
+
|
|
9
|
+
1. Thêm mã app: bundle id trên iOS và package name trên Android, ví dụ `vn.congty.app`. Danh sách trống thì OM **không nhận** dữ liệu từ app nào.
|
|
10
|
+
2. Chép `scriptId` và `endpoint` trong đoạn mã mẫu.
|
|
11
|
+
|
|
12
|
+
## Cài đặt
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @oplacrm/om-react-native @react-native-async-storage/async-storage
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
SDK viết hoàn toàn bằng JavaScript, nên không cần `pod install`, `expo prebuild` hay build lại phần native, trừ khi app phải cài thêm AsyncStorage.
|
|
19
|
+
|
|
20
|
+
## Dùng
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { Opla } from '@oplacrm/om-react-native';
|
|
24
|
+
|
|
25
|
+
// App.tsx: gọi một lần, càng sớm càng tốt
|
|
26
|
+
Opla.init({
|
|
27
|
+
scriptId: '<script id>',
|
|
28
|
+
appId: 'vn.congty.app',
|
|
29
|
+
appVersion: '2.4.1',
|
|
30
|
+
endpoint: 'https://marketing.oplacrm.com',
|
|
31
|
+
// requireConsent: true, // nếu app hỏi người dùng đồng ý trước
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
Opla.screen('Hồ sơ vay'); // mỗi lần đổi màn hình
|
|
35
|
+
Opla.step('vay_tieu_dung', 'ekyc'); // bước của hồ sơ (vay, mở tài khoản, mua bảo hiểm…)
|
|
36
|
+
Opla.track('bam_tu_van', { goi: 'vay_50tr' }); // sự kiện tự đặt
|
|
37
|
+
Opla.identify({ email, phone, name }); // sau khi người dùng đăng nhập
|
|
38
|
+
Opla.setPushToken(fcmToken); // token push (FCM / APNs), null khi không còn
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Khi người dùng đăng xuất, gọi `Opla.reset()`. Người đăng nhập sau trên cùng máy sẽ được tính là người khác, không bị gộp vào người trước.
|
|
42
|
+
|
|
43
|
+
### App dùng MMKV (không dùng AsyncStorage)
|
|
44
|
+
|
|
45
|
+
Import từ `/bare` và truyền vào chỗ lưu trữ của app. Với cách này, app không cần cài AsyncStorage:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { createOpla, mmkvStorage } from '@oplacrm/om-react-native/bare';
|
|
49
|
+
import { MMKV } from 'react-native-mmkv';
|
|
50
|
+
|
|
51
|
+
export const Opla = createOpla(mmkvStorage(new MMKV()));
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Mọi lệnh vẫn như trên. Bất kỳ chỗ lưu trữ nào có `getItem`, `setItem`, `removeItem` (trả về Promise) cũng dùng được với `createOpla`.
|
|
55
|
+
|
|
56
|
+
### Màn hình với React Navigation
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const ref = useNavigationContainerRef();
|
|
60
|
+
<NavigationContainer
|
|
61
|
+
ref={ref}
|
|
62
|
+
onReady={() => Opla.screen(ref.getCurrentRoute()?.name ?? 'Home')}
|
|
63
|
+
onStateChange={() => Opla.screen(ref.getCurrentRoute()?.name ?? 'Home')}
|
|
64
|
+
>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Nên đặt tên màn hình dễ đọc vì OM hiện đúng tên này trên dòng thời gian của khách. **Không đưa thông tin cá nhân vào tên màn hình hoặc tên sự kiện.**
|
|
68
|
+
|
|
69
|
+
### Bước hồ sơ
|
|
70
|
+
|
|
71
|
+
`Opla.step(flow, step)` gửi sự kiện `step` với `{ flow, step }`. Gọi mỗi khi khách tới một bước, ví dụ:
|
|
72
|
+
|
|
73
|
+
| flow | step |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `vay_tieu_dung` | `bat_dau`, `thong_tin`, `ekyc`, `nop`, `duyet` |
|
|
76
|
+
| `mo_tai_khoan` | `bat_dau`, `ekyc`, `xong` |
|
|
77
|
+
|
|
78
|
+
Kịch bản OM dựa vào các bước này để biết khách dừng ở đâu (cứu hồ sơ bỏ dở).
|
|
79
|
+
|
|
80
|
+
## SDK tự làm gì
|
|
81
|
+
|
|
82
|
+
- **Id thiết bị:** tạo một lần, lưu trong AsyncStorage.
|
|
83
|
+
- **Phiên:** sau 30 phút không hoạt động thì lần mở sau là phiên mới, giống web.
|
|
84
|
+
- **Thời gian trên màn hình:** gửi khi đổi màn hình hoặc khi app vào nền.
|
|
85
|
+
- **Deep link:** link mở app có `utm_*`, `gclid`, `fbclid`… thì nguồn và chiến dịch được gắn cho phiên. Các tham số khác của link, như token, không được gửi.
|
|
86
|
+
- **Mất mạng:** dữ liệu chờ trong hàng đợi (tối đa 200 mục, giữ cả khi tắt app) và được gửi lại khi có mạng. Lưu ý: OM ghi giờ lúc dữ liệu tới máy chủ.
|
|
87
|
+
- **Không tự thu:** SDK chỉ gửi những gì app gọi, không đọc nội dung ô nhập liệu.
|
|
88
|
+
|
|
89
|
+
## Đồng ý (Nghị định 13)
|
|
90
|
+
|
|
91
|
+
Với `requireConsent: true`, trước khi người dùng đồng ý:
|
|
92
|
+
- SDK không lưu gì trên máy.
|
|
93
|
+
- SDK chỉ gửi lượt xem màn hình ẩn danh. Không gửi sự kiện, đăng nhập hay token push.
|
|
94
|
+
|
|
95
|
+
Gọi `Opla.consent(true)` khi người dùng đồng ý, hoặc `Opla.consent(false)` khi từ chối. Gọi `Opla.optout()` để ngừng hẳn theo dõi trên máy và xoá id.
|
|
96
|
+
|
|
97
|
+
## Phát triển
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npm install
|
|
101
|
+
npm run build # → lib/
|
|
102
|
+
npm test # test của src/core.ts (không cần React Native)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`src/core.ts` không phụ thuộc React Native: lưu trữ, mạng, đồng hồ và thông tin máy được truyền vào. `src/index.ts` nối các phần đó với React Native (AsyncStorage, AppState, Linking, Platform).
|
|
106
|
+
|
|
107
|
+
## Giấy phép
|
|
108
|
+
|
|
109
|
+
MIT, xem [LICENSE](LICENSE).
|
package/bare.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/bare';
|
package/bare.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./lib/bare');
|
package/lib/bare.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Identity, KeyValueStorage, OplaOptions, Props } from './core';
|
|
2
|
+
export { mmkvStorage } from './core';
|
|
3
|
+
export type { MMKVLike } from './core';
|
|
4
|
+
export type { Identity, KeyValueStorage, OplaOptions, Props } from './core';
|
|
5
|
+
export { OplaTracker } from './core';
|
|
6
|
+
export type OplaApi = ReturnType<typeof createOpla>;
|
|
7
|
+
/** The SDK over the given storage. Make it once, at module level. */
|
|
8
|
+
export declare function createOpla(storage: KeyValueStorage): {
|
|
9
|
+
/** Call once, as early as possible (App.tsx). */
|
|
10
|
+
init(opts: OplaOptions): Promise<void>;
|
|
11
|
+
screen: (name: string) => void;
|
|
12
|
+
step: (flow: string, step: string, props?: Props) => void;
|
|
13
|
+
track: (name: string, props?: Props) => void;
|
|
14
|
+
identify: (who: Identity) => void;
|
|
15
|
+
setPushToken: (token: string | null) => void;
|
|
16
|
+
consent: (yes: boolean) => void;
|
|
17
|
+
reset: () => void;
|
|
18
|
+
optout: () => void;
|
|
19
|
+
handleUrl: (url: string | null | undefined) => void;
|
|
20
|
+
flush: () => Promise<void>;
|
|
21
|
+
};
|
package/lib/bare.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OplaTracker = exports.mmkvStorage = void 0;
|
|
4
|
+
exports.createOpla = createOpla;
|
|
5
|
+
/**
|
|
6
|
+
* The SDK without AsyncStorage, for an app that keeps its data elsewhere (MMKV…):
|
|
7
|
+
*
|
|
8
|
+
* import { createOpla, mmkvStorage } from '@oplacrm/om-react-native/bare';
|
|
9
|
+
* export const Opla = createOpla(mmkvStorage(storage)); // storage = new MMKV()
|
|
10
|
+
*
|
|
11
|
+
* Nothing here imports @react-native-async-storage/async-storage, so the app does not need it.
|
|
12
|
+
*/
|
|
13
|
+
const react_native_1 = require("react-native");
|
|
14
|
+
const core_1 = require("./core");
|
|
15
|
+
var core_2 = require("./core");
|
|
16
|
+
Object.defineProperty(exports, "mmkvStorage", { enumerable: true, get: function () { return core_2.mmkvStorage; } });
|
|
17
|
+
var core_3 = require("./core");
|
|
18
|
+
Object.defineProperty(exports, "OplaTracker", { enumerable: true, get: function () { return core_3.OplaTracker; } });
|
|
19
|
+
function device() {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const c = ((_a = react_native_1.Platform.constants) !== null && _a !== void 0 ? _a : {});
|
|
22
|
+
const os = react_native_1.Platform.OS === 'ios' ? 'ios' : 'android';
|
|
23
|
+
const model = os === 'android' ? [(_b = c.Brand) !== null && _b !== void 0 ? _b : c.Manufacturer, c.Model].filter(Boolean).join(' ') || null : null;
|
|
24
|
+
return {
|
|
25
|
+
os,
|
|
26
|
+
osVersion: react_native_1.Platform.Version == null ? null : String(react_native_1.Platform.Version),
|
|
27
|
+
model,
|
|
28
|
+
tablet: os === 'ios' ? !!react_native_1.Platform.isPad : false,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** The SDK over the given storage. Make it once, at module level. */
|
|
32
|
+
function createOpla(storage) {
|
|
33
|
+
const t = new core_1.OplaTracker({ storage, fetch: (url, init) => fetch(url, init), now: () => Date.now(), device: device() });
|
|
34
|
+
let started = false;
|
|
35
|
+
return {
|
|
36
|
+
/** Call once, as early as possible (App.tsx). */
|
|
37
|
+
init(opts) {
|
|
38
|
+
const p = t.init(opts);
|
|
39
|
+
if (started)
|
|
40
|
+
return p;
|
|
41
|
+
started = true;
|
|
42
|
+
let state = react_native_1.AppState.currentState;
|
|
43
|
+
react_native_1.AppState.addEventListener('change', (next) => {
|
|
44
|
+
if (state === 'active' && next !== 'active')
|
|
45
|
+
t.background();
|
|
46
|
+
if (state !== 'active' && next === 'active')
|
|
47
|
+
t.foreground();
|
|
48
|
+
state = next;
|
|
49
|
+
});
|
|
50
|
+
// the link that opened the app, and the ones that bring it back
|
|
51
|
+
react_native_1.Linking.getInitialURL().then((u) => t.handleUrl(u)).catch(() => undefined);
|
|
52
|
+
react_native_1.Linking.addEventListener('url', (e) => t.handleUrl(e.url));
|
|
53
|
+
return p;
|
|
54
|
+
},
|
|
55
|
+
screen: (name) => t.screen(name),
|
|
56
|
+
step: (flow, step, props) => t.step(flow, step, props),
|
|
57
|
+
track: (name, props) => t.track(name, props),
|
|
58
|
+
identify: (who) => t.identify(who),
|
|
59
|
+
setPushToken: (token) => t.setPushToken(token),
|
|
60
|
+
consent: (yes) => t.consent(yes),
|
|
61
|
+
reset: () => t.reset(),
|
|
62
|
+
optout: () => t.optout(),
|
|
63
|
+
handleUrl: (url) => t.handleUrl(url),
|
|
64
|
+
flush: () => t.flush(),
|
|
65
|
+
};
|
|
66
|
+
}
|
package/lib/core.d.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tracker of the Opla Marketing (OM) app SDK, without React Native: storage, network, clock and the phone come in from
|
|
3
|
+
* index.ts (or from a test). It sends the same hits as tracker.js to POST <endpoint>/c, with `app` and an app:// address
|
|
4
|
+
* (api/src/app-hit-core.ts), so OM records app sessions, screens and events as it does web pages.
|
|
5
|
+
*
|
|
6
|
+
* - Device id (`u`): made once and kept in the app's storage, like the opla_uid cookie.
|
|
7
|
+
* - Session (`sid`): a new one after 30 minutes without activity, as on the web.
|
|
8
|
+
* - Time on a screen: sent as `leave` when the screen changes or the app goes to the background.
|
|
9
|
+
* - Hits wait in a queue kept in storage and are sent in order; a network error keeps them for later.
|
|
10
|
+
* A hit the server refuses (400, 403) is dropped. The server dates a hit when it arrives.
|
|
11
|
+
* - requireConsent: until consent(true), nothing is kept on the phone and only anonymous screen views are sent (`a: 1`).
|
|
12
|
+
* - Nothing is collected by itself: the SDK sends only what the app calls.
|
|
13
|
+
*/
|
|
14
|
+
export interface KeyValueStorage {
|
|
15
|
+
getItem(key: string): Promise<string | null>;
|
|
16
|
+
setItem(key: string, value: string): Promise<void>;
|
|
17
|
+
removeItem(key: string): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface DeviceInfo {
|
|
20
|
+
os: 'ios' | 'android';
|
|
21
|
+
osVersion?: string | null;
|
|
22
|
+
model?: string | null;
|
|
23
|
+
tablet?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface OplaOptions {
|
|
26
|
+
/** The tracking script id (OM → Cài đặt → Tích hợp → Website). */
|
|
27
|
+
scriptId: string;
|
|
28
|
+
/** iOS bundle id / Android package name; must be in the script's app list. */
|
|
29
|
+
appId: string;
|
|
30
|
+
appVersion?: string;
|
|
31
|
+
/** The OM server, e.g. https://marketing.oplacrm.com */
|
|
32
|
+
endpoint: string;
|
|
33
|
+
/** Ask the user first: anonymous until consent(true). */
|
|
34
|
+
requireConsent?: boolean;
|
|
35
|
+
debug?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface Env {
|
|
38
|
+
storage: KeyValueStorage;
|
|
39
|
+
fetch: (url: string, init: {
|
|
40
|
+
method: string;
|
|
41
|
+
body: string;
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
}) => Promise<{
|
|
44
|
+
status: number;
|
|
45
|
+
}>;
|
|
46
|
+
now: () => number;
|
|
47
|
+
device: DeviceInfo;
|
|
48
|
+
log?: (...a: unknown[]) => void;
|
|
49
|
+
}
|
|
50
|
+
export type Props = Record<string, unknown>;
|
|
51
|
+
export interface Identity {
|
|
52
|
+
email?: string;
|
|
53
|
+
phone?: string;
|
|
54
|
+
name?: string;
|
|
55
|
+
company?: string;
|
|
56
|
+
jobTitle?: string;
|
|
57
|
+
}
|
|
58
|
+
type Hit = Record<string, unknown> & {
|
|
59
|
+
t: string;
|
|
60
|
+
};
|
|
61
|
+
export declare const SESSION_MS: number;
|
|
62
|
+
export declare const MAX_QUEUE = 200;
|
|
63
|
+
export declare function uuid(): string;
|
|
64
|
+
/** The campaign part of a deep link (utm_*, gclid…), as a query string; '' when there is none. */
|
|
65
|
+
export declare function campaignOf(url: string | null | undefined): string;
|
|
66
|
+
export declare class OplaTracker {
|
|
67
|
+
private readonly env;
|
|
68
|
+
private opts;
|
|
69
|
+
private ready;
|
|
70
|
+
private uid;
|
|
71
|
+
private sid;
|
|
72
|
+
private lastSeen;
|
|
73
|
+
private consentState;
|
|
74
|
+
private optedOut;
|
|
75
|
+
private queue;
|
|
76
|
+
private sending;
|
|
77
|
+
private retryAt;
|
|
78
|
+
private screenName;
|
|
79
|
+
/** the address the current screen's view was sent with (campaign included), which its `leave` must repeat */
|
|
80
|
+
private screenHref;
|
|
81
|
+
private screenSince;
|
|
82
|
+
private screenMs;
|
|
83
|
+
private campaign;
|
|
84
|
+
private identified;
|
|
85
|
+
private pushToken;
|
|
86
|
+
constructor(env: Env);
|
|
87
|
+
init(opts: OplaOptions): Promise<void>;
|
|
88
|
+
private load;
|
|
89
|
+
/** Anonymous: the app asks for consent and the user has not said yes. */
|
|
90
|
+
private get anon();
|
|
91
|
+
/** A screen was shown. Call it on every screen change (React Navigation: onStateChange). */
|
|
92
|
+
screen(name: string): void;
|
|
93
|
+
/** A step of an application (vay tiêu dùng, mở tài khoản…): the event `step` with {flow, step}. */
|
|
94
|
+
step(flow: string, step: string, props?: Props): void;
|
|
95
|
+
track(name: string, props?: Props): void;
|
|
96
|
+
/** The signed-in user: OM joins this install with the person known by the same email or phone. */
|
|
97
|
+
identify(who: Identity): void;
|
|
98
|
+
/** The push token of this install (FCM / APNs); null when the app has none any more. */
|
|
99
|
+
setPushToken(token: string | null): void;
|
|
100
|
+
/** The user's answer to the app's consent question. */
|
|
101
|
+
consent(yes: boolean): void;
|
|
102
|
+
/**
|
|
103
|
+
* The user signed out: forget who they were. The next hits come from a new device id, so a different person signing in
|
|
104
|
+
* on the same phone is not joined to the one before. Consent and opt-out stay.
|
|
105
|
+
*/
|
|
106
|
+
reset(): void;
|
|
107
|
+
/** Stop tracking on this phone, for good. */
|
|
108
|
+
optout(): void;
|
|
109
|
+
/** A deep link that opened the app: its utm / ad click id go with the next session. */
|
|
110
|
+
handleUrl(url: string | null | undefined): void;
|
|
111
|
+
/** The app went to the background: the time on the screen, and send what waits. */
|
|
112
|
+
background(): void;
|
|
113
|
+
/** The app came back. After 30 minutes away it is a new session, which starts on the current screen. */
|
|
114
|
+
foreground(): void;
|
|
115
|
+
/** Sends what waits in the queue. */
|
|
116
|
+
flush(): Promise<void>;
|
|
117
|
+
/** Hits waiting to be sent (for tests and debugging). */
|
|
118
|
+
pending(): readonly Hit[];
|
|
119
|
+
private after;
|
|
120
|
+
private leaveScreen;
|
|
121
|
+
private screenUrl;
|
|
122
|
+
private send;
|
|
123
|
+
private forget;
|
|
124
|
+
private save;
|
|
125
|
+
private debug;
|
|
126
|
+
}
|
|
127
|
+
/** What an MMKV instance offers (react-native-mmkv 2.x and 3.x). */
|
|
128
|
+
export interface MMKVLike {
|
|
129
|
+
getString(key: string): string | undefined;
|
|
130
|
+
set(key: string, value: string): void;
|
|
131
|
+
delete(key: string): void;
|
|
132
|
+
}
|
|
133
|
+
/** MMKV as the SDK's storage. Keys start with `opla.`. */
|
|
134
|
+
export declare function mmkvStorage(m: MMKVLike): KeyValueStorage;
|
|
135
|
+
export {};
|
package/lib/core.js
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The tracker of the Opla Marketing (OM) app SDK, without React Native: storage, network, clock and the phone come in from
|
|
4
|
+
* index.ts (or from a test). It sends the same hits as tracker.js to POST <endpoint>/c, with `app` and an app:// address
|
|
5
|
+
* (api/src/app-hit-core.ts), so OM records app sessions, screens and events as it does web pages.
|
|
6
|
+
*
|
|
7
|
+
* - Device id (`u`): made once and kept in the app's storage, like the opla_uid cookie.
|
|
8
|
+
* - Session (`sid`): a new one after 30 minutes without activity, as on the web.
|
|
9
|
+
* - Time on a screen: sent as `leave` when the screen changes or the app goes to the background.
|
|
10
|
+
* - Hits wait in a queue kept in storage and are sent in order; a network error keeps them for later.
|
|
11
|
+
* A hit the server refuses (400, 403) is dropped. The server dates a hit when it arrives.
|
|
12
|
+
* - requireConsent: until consent(true), nothing is kept on the phone and only anonymous screen views are sent (`a: 1`).
|
|
13
|
+
* - Nothing is collected by itself: the SDK sends only what the app calls.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.OplaTracker = exports.MAX_QUEUE = exports.SESSION_MS = void 0;
|
|
17
|
+
exports.uuid = uuid;
|
|
18
|
+
exports.campaignOf = campaignOf;
|
|
19
|
+
exports.mmkvStorage = mmkvStorage;
|
|
20
|
+
exports.SESSION_MS = 30 * 60 * 1000;
|
|
21
|
+
exports.MAX_QUEUE = 200;
|
|
22
|
+
const K = { uid: 'opla.uid', sid: 'opla.sid', seen: 'opla.seen', consent: 'opla.consent', optout: 'opla.optout', queue: 'opla.queue' };
|
|
23
|
+
/** Query keys of a campaign link worth keeping for the session (utm and the ad click ids the server reads). */
|
|
24
|
+
const CAMPAIGN = /^(utm_\w+|gclid|gbraid|wbraid|fbclid|ttclid|msclkid)$/;
|
|
25
|
+
function uuid() {
|
|
26
|
+
const c = globalThis.crypto;
|
|
27
|
+
if (c === null || c === void 0 ? void 0 : c.randomUUID)
|
|
28
|
+
return c.randomUUID();
|
|
29
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {
|
|
30
|
+
const r = (Math.random() * 16) | 0;
|
|
31
|
+
return (ch === 'x' ? r : (r & 3) | 8).toString(16);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** The campaign part of a deep link (utm_*, gclid…), as a query string; '' when there is none. */
|
|
35
|
+
function campaignOf(url) {
|
|
36
|
+
if (!url)
|
|
37
|
+
return '';
|
|
38
|
+
const i = url.indexOf('?');
|
|
39
|
+
if (i < 0)
|
|
40
|
+
return '';
|
|
41
|
+
const q = url.slice(i + 1).split('#')[0];
|
|
42
|
+
const keep = q.split('&').filter((kv) => CAMPAIGN.test(decodeURIComponent(kv.split('=')[0] || '')));
|
|
43
|
+
return keep.join('&');
|
|
44
|
+
}
|
|
45
|
+
class OplaTracker {
|
|
46
|
+
constructor(env) {
|
|
47
|
+
this.env = env;
|
|
48
|
+
this.opts = null;
|
|
49
|
+
this.ready = null;
|
|
50
|
+
this.uid = '';
|
|
51
|
+
this.sid = '';
|
|
52
|
+
this.lastSeen = 0;
|
|
53
|
+
this.consentState = null;
|
|
54
|
+
this.optedOut = false;
|
|
55
|
+
this.queue = [];
|
|
56
|
+
this.sending = false;
|
|
57
|
+
this.retryAt = 0;
|
|
58
|
+
this.screenName = null;
|
|
59
|
+
/** the address the current screen's view was sent with (campaign included), which its `leave` must repeat */
|
|
60
|
+
this.screenHref = '';
|
|
61
|
+
this.screenSince = 0;
|
|
62
|
+
this.screenMs = 0;
|
|
63
|
+
this.campaign = '';
|
|
64
|
+
this.identified = '';
|
|
65
|
+
}
|
|
66
|
+
init(opts) {
|
|
67
|
+
if (this.ready)
|
|
68
|
+
return this.ready;
|
|
69
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.scriptId) || !opts.appId || !opts.endpoint)
|
|
70
|
+
throw new Error('Opla.init: scriptId, appId and endpoint are required');
|
|
71
|
+
this.opts = { ...opts, endpoint: opts.endpoint.replace(/\/+$/, ''), appId: opts.appId.toLowerCase() };
|
|
72
|
+
this.ready = this.load();
|
|
73
|
+
return this.ready;
|
|
74
|
+
}
|
|
75
|
+
async load() {
|
|
76
|
+
const s = this.env.storage;
|
|
77
|
+
const [uid, sid, seen, consent, optout, queue] = await Promise.all([K.uid, K.sid, K.seen, K.consent, K.optout, K.queue].map((k) => s.getItem(k).catch(() => null)));
|
|
78
|
+
this.optedOut = optout === '1';
|
|
79
|
+
this.consentState = consent === '1' || consent === '0' ? consent : null;
|
|
80
|
+
try {
|
|
81
|
+
const q = queue ? JSON.parse(queue) : [];
|
|
82
|
+
if (Array.isArray(q))
|
|
83
|
+
this.queue = q.slice(-exports.MAX_QUEUE);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
/* a broken queue is dropped */
|
|
87
|
+
}
|
|
88
|
+
if (this.anon) {
|
|
89
|
+
this.uid = uuid(); // in memory only
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this.uid = uid || uuid();
|
|
93
|
+
if (!uid)
|
|
94
|
+
await this.save(K.uid, this.uid);
|
|
95
|
+
if (sid && seen && this.env.now() - Number(seen) < exports.SESSION_MS) {
|
|
96
|
+
this.sid = sid;
|
|
97
|
+
this.lastSeen = Number(seen);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
this.debug('init', { uid: this.uid, anon: this.anon, queued: this.queue.length });
|
|
101
|
+
void this.flush();
|
|
102
|
+
}
|
|
103
|
+
/** Anonymous: the app asks for consent and the user has not said yes. */
|
|
104
|
+
get anon() {
|
|
105
|
+
var _a;
|
|
106
|
+
return !!((_a = this.opts) === null || _a === void 0 ? void 0 : _a.requireConsent) && this.consentState !== '1';
|
|
107
|
+
}
|
|
108
|
+
// ------------------------------------------------------------------ public API
|
|
109
|
+
/** A screen was shown. Call it on every screen change (React Navigation: onStateChange). */
|
|
110
|
+
screen(name) {
|
|
111
|
+
void this.after(() => {
|
|
112
|
+
const n = String(name || '').slice(0, 200);
|
|
113
|
+
if (!n)
|
|
114
|
+
return;
|
|
115
|
+
this.leaveScreen();
|
|
116
|
+
this.screenName = n;
|
|
117
|
+
this.screenMs = 0;
|
|
118
|
+
this.screenSince = this.env.now();
|
|
119
|
+
this.send({ t: 'pageview', title: n });
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/** A step of an application (vay tiêu dùng, mở tài khoản…): the event `step` with {flow, step}. */
|
|
123
|
+
step(flow, step, props) {
|
|
124
|
+
this.track('step', { ...(props !== null && props !== void 0 ? props : {}), flow: String(flow).slice(0, 100), step: String(step).slice(0, 100) });
|
|
125
|
+
}
|
|
126
|
+
track(name, props) {
|
|
127
|
+
void this.after(() => {
|
|
128
|
+
if (!name || this.anon)
|
|
129
|
+
return;
|
|
130
|
+
this.send({ t: 'event', n: String(name).slice(0, 100), p: props !== null && props !== void 0 ? props : null });
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/** The signed-in user: OM joins this install with the person known by the same email or phone. */
|
|
134
|
+
identify(who) {
|
|
135
|
+
void this.after(() => {
|
|
136
|
+
if (!who || typeof who !== 'object' || this.anon)
|
|
137
|
+
return;
|
|
138
|
+
const key = JSON.stringify(who);
|
|
139
|
+
if (key === this.identified)
|
|
140
|
+
return;
|
|
141
|
+
this.identified = key;
|
|
142
|
+
this.send({ t: 'identify', i: who });
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/** The push token of this install (FCM / APNs); null when the app has none any more. */
|
|
146
|
+
setPushToken(token) {
|
|
147
|
+
void this.after(() => {
|
|
148
|
+
this.pushToken = token;
|
|
149
|
+
if (this.anon)
|
|
150
|
+
return;
|
|
151
|
+
this.send({ t: 'device', pt: token });
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/** The user's answer to the app's consent question. */
|
|
155
|
+
consent(yes) {
|
|
156
|
+
void this.after(async () => {
|
|
157
|
+
var _a;
|
|
158
|
+
const was = this.anon;
|
|
159
|
+
this.consentState = yes ? '1' : '0';
|
|
160
|
+
await this.save(K.consent, this.consentState);
|
|
161
|
+
if (!((_a = this.opts) === null || _a === void 0 ? void 0 : _a.requireConsent))
|
|
162
|
+
return; // only recorded and sent along (c)
|
|
163
|
+
if (was && !this.anon) {
|
|
164
|
+
// from anonymous to full: a kept id, a new session, the current screen again
|
|
165
|
+
this.uid = uuid();
|
|
166
|
+
await this.save(K.uid, this.uid);
|
|
167
|
+
this.sid = '';
|
|
168
|
+
if (this.screenName)
|
|
169
|
+
this.send({ t: 'pageview', title: this.screenName });
|
|
170
|
+
if (this.pushToken !== undefined)
|
|
171
|
+
this.send({ t: 'device', pt: this.pushToken });
|
|
172
|
+
}
|
|
173
|
+
else if (!was && this.anon) {
|
|
174
|
+
await this.forget();
|
|
175
|
+
this.uid = uuid();
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The user signed out: forget who they were. The next hits come from a new device id, so a different person signing in
|
|
181
|
+
* on the same phone is not joined to the one before. Consent and opt-out stay.
|
|
182
|
+
*/
|
|
183
|
+
reset() {
|
|
184
|
+
void this.after(async () => {
|
|
185
|
+
this.leaveScreen();
|
|
186
|
+
// hits still waiting were made by the one who left and keep their id
|
|
187
|
+
this.uid = uuid();
|
|
188
|
+
this.sid = '';
|
|
189
|
+
this.identified = '';
|
|
190
|
+
this.pushToken = undefined;
|
|
191
|
+
await this.save(K.uid, this.uid);
|
|
192
|
+
await Promise.all([K.sid, K.seen].map((k) => this.env.storage.removeItem(k).catch(() => undefined)));
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/** Stop tracking on this phone, for good. */
|
|
196
|
+
optout() {
|
|
197
|
+
void this.after(async () => {
|
|
198
|
+
this.optedOut = true;
|
|
199
|
+
await this.save(K.optout, '1');
|
|
200
|
+
await this.forget();
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/** A deep link that opened the app: its utm / ad click id go with the next session. */
|
|
204
|
+
handleUrl(url) {
|
|
205
|
+
const c = campaignOf(url);
|
|
206
|
+
if (!c)
|
|
207
|
+
return;
|
|
208
|
+
void this.after(() => {
|
|
209
|
+
this.campaign = c;
|
|
210
|
+
// a campaign link starts a new visit, as a new landing does on the web
|
|
211
|
+
this.sid = '';
|
|
212
|
+
if (this.screenName)
|
|
213
|
+
this.send({ t: 'pageview', title: this.screenName });
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/** The app went to the background: the time on the screen, and send what waits. */
|
|
217
|
+
background() {
|
|
218
|
+
void this.after(() => {
|
|
219
|
+
this.leaveScreen();
|
|
220
|
+
this.screenSince = 0;
|
|
221
|
+
return this.flush();
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/** The app came back. After 30 minutes away it is a new session, which starts on the current screen. */
|
|
225
|
+
foreground() {
|
|
226
|
+
void this.after(() => {
|
|
227
|
+
if (!this.screenName)
|
|
228
|
+
return;
|
|
229
|
+
this.screenSince = this.env.now();
|
|
230
|
+
if (!this.sid || this.env.now() - this.lastSeen >= exports.SESSION_MS) {
|
|
231
|
+
this.screenMs = 0;
|
|
232
|
+
this.send({ t: 'pageview', title: this.screenName });
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
/** Sends what waits in the queue. */
|
|
237
|
+
async flush() {
|
|
238
|
+
if (!this.opts || this.sending || this.optedOut)
|
|
239
|
+
return;
|
|
240
|
+
if (this.env.now() < this.retryAt)
|
|
241
|
+
return;
|
|
242
|
+
this.sending = true;
|
|
243
|
+
try {
|
|
244
|
+
while (this.queue.length) {
|
|
245
|
+
const hit = this.queue[0];
|
|
246
|
+
let status = 0;
|
|
247
|
+
try {
|
|
248
|
+
status = (await this.env.fetch(this.opts.endpoint + '/c', {
|
|
249
|
+
method: 'POST',
|
|
250
|
+
body: JSON.stringify(hit),
|
|
251
|
+
headers: { 'Content-Type': 'text/plain' },
|
|
252
|
+
})).status;
|
|
253
|
+
}
|
|
254
|
+
catch (e) {
|
|
255
|
+
this.debug('network error, kept for later', e);
|
|
256
|
+
}
|
|
257
|
+
if (status === 0 || status === 429 || status >= 500) {
|
|
258
|
+
this.retryAt = this.env.now() + 30000;
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
if (status >= 400)
|
|
262
|
+
this.debug('refused by the server', status, hit);
|
|
263
|
+
this.queue.shift();
|
|
264
|
+
}
|
|
265
|
+
await this.save(K.queue, JSON.stringify(this.queue));
|
|
266
|
+
}
|
|
267
|
+
finally {
|
|
268
|
+
this.sending = false;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/** Hits waiting to be sent (for tests and debugging). */
|
|
272
|
+
pending() {
|
|
273
|
+
return this.queue;
|
|
274
|
+
}
|
|
275
|
+
// ------------------------------------------------------------------ inside
|
|
276
|
+
async after(fn) {
|
|
277
|
+
if (!this.ready) {
|
|
278
|
+
this.debug('Opla.init has not been called');
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
await this.ready;
|
|
282
|
+
if (this.optedOut)
|
|
283
|
+
return;
|
|
284
|
+
await fn();
|
|
285
|
+
}
|
|
286
|
+
leaveScreen() {
|
|
287
|
+
if (!this.screenName || !this.screenSince)
|
|
288
|
+
return;
|
|
289
|
+
this.screenMs += this.env.now() - this.screenSince;
|
|
290
|
+
this.screenSince = 0;
|
|
291
|
+
this.send({ t: 'leave', d: this.screenMs, title: this.screenName });
|
|
292
|
+
}
|
|
293
|
+
screenUrl() {
|
|
294
|
+
var _a;
|
|
295
|
+
const o = this.opts;
|
|
296
|
+
const path = encodeURIComponent((_a = this.screenName) !== null && _a !== void 0 ? _a : '').replace(/%2F/gi, '/');
|
|
297
|
+
return `app://${o.appId}/${path}`;
|
|
298
|
+
}
|
|
299
|
+
send(h) {
|
|
300
|
+
var _a, _b, _c, _d, _e;
|
|
301
|
+
const o = this.opts;
|
|
302
|
+
const now = this.env.now();
|
|
303
|
+
if (this.anon && h.t !== 'pageview' && h.t !== 'leave')
|
|
304
|
+
return;
|
|
305
|
+
let url = h.t === 'leave' && this.screenHref ? this.screenHref : this.screenUrl();
|
|
306
|
+
if (!this.sid || now - this.lastSeen >= exports.SESSION_MS) {
|
|
307
|
+
this.sid = uuid();
|
|
308
|
+
// the campaign goes on the first hit of the session (the server reads utm from the landing address)
|
|
309
|
+
if (this.campaign)
|
|
310
|
+
url += '?' + this.campaign;
|
|
311
|
+
this.campaign = '';
|
|
312
|
+
}
|
|
313
|
+
this.lastSeen = now;
|
|
314
|
+
if (h.t === 'pageview')
|
|
315
|
+
this.screenHref = url;
|
|
316
|
+
const d = this.env.device;
|
|
317
|
+
const body = {
|
|
318
|
+
s: o.scriptId,
|
|
319
|
+
u: this.uid,
|
|
320
|
+
sid: this.sid,
|
|
321
|
+
url,
|
|
322
|
+
g: 1,
|
|
323
|
+
app: { id: o.appId, os: d.os, v: (_a = o.appVersion) !== null && _a !== void 0 ? _a : null, osv: (_b = d.osVersion) !== null && _b !== void 0 ? _b : null, model: (_c = d.model) !== null && _c !== void 0 ? _c : null, tab: d.tablet ? 1 : 0 },
|
|
324
|
+
...h,
|
|
325
|
+
};
|
|
326
|
+
if (this.anon)
|
|
327
|
+
body.a = 1;
|
|
328
|
+
if (this.consentState)
|
|
329
|
+
body.c = +this.consentState;
|
|
330
|
+
this.queue.push(body);
|
|
331
|
+
if (this.queue.length > exports.MAX_QUEUE)
|
|
332
|
+
this.queue.splice(0, this.queue.length - exports.MAX_QUEUE);
|
|
333
|
+
if (!this.anon) {
|
|
334
|
+
void this.save(K.sid, this.sid);
|
|
335
|
+
void this.save(K.seen, String(now));
|
|
336
|
+
}
|
|
337
|
+
this.debug('hit', h.t, (_e = (_d = h.title) !== null && _d !== void 0 ? _d : h.n) !== null && _e !== void 0 ? _e : '');
|
|
338
|
+
void this.flush();
|
|
339
|
+
}
|
|
340
|
+
async forget() {
|
|
341
|
+
this.queue = [];
|
|
342
|
+
this.sid = '';
|
|
343
|
+
this.identified = '';
|
|
344
|
+
await Promise.all([K.uid, K.sid, K.seen, K.queue].map((k) => this.env.storage.removeItem(k).catch(() => undefined)));
|
|
345
|
+
}
|
|
346
|
+
async save(k, v) {
|
|
347
|
+
if (this.anon && k !== K.consent && k !== K.optout)
|
|
348
|
+
return; // nothing on the phone before consent
|
|
349
|
+
try {
|
|
350
|
+
await this.env.storage.setItem(k, v);
|
|
351
|
+
}
|
|
352
|
+
catch {
|
|
353
|
+
/* storage full or gone: keep working from memory */
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
debug(...a) {
|
|
357
|
+
var _a, _b;
|
|
358
|
+
if ((_a = this.opts) === null || _a === void 0 ? void 0 : _a.debug)
|
|
359
|
+
((_b = this.env.log) !== null && _b !== void 0 ? _b : console.log)('[Opla]', ...a);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
exports.OplaTracker = OplaTracker;
|
|
363
|
+
/** MMKV as the SDK's storage. Keys start with `opla.`. */
|
|
364
|
+
function mmkvStorage(m) {
|
|
365
|
+
return {
|
|
366
|
+
getItem: async (k) => { var _a; return (_a = m.getString(k)) !== null && _a !== void 0 ? _a : null; },
|
|
367
|
+
setItem: async (k, v) => m.set(k, v),
|
|
368
|
+
removeItem: async (k) => m.delete(k),
|
|
369
|
+
};
|
|
370
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './bare';
|
|
2
|
+
export declare const Opla: {
|
|
3
|
+
init(opts: import("./core").OplaOptions): Promise<void>;
|
|
4
|
+
screen: (name: string) => void;
|
|
5
|
+
step: (flow: string, step: string, props?: import("./core").Props) => void;
|
|
6
|
+
track: (name: string, props?: import("./core").Props) => void;
|
|
7
|
+
identify: (who: import("./core").Identity) => void;
|
|
8
|
+
setPushToken: (token: string | null) => void;
|
|
9
|
+
consent: (yes: boolean) => void;
|
|
10
|
+
reset: () => void;
|
|
11
|
+
optout: () => void;
|
|
12
|
+
handleUrl: (url: string | null | undefined) => void;
|
|
13
|
+
flush: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
export default Opla;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Opla = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* Opla Marketing (OM) SDK for React Native.
|
|
20
|
+
*
|
|
21
|
+
* import { Opla } from '@oplacrm/om-react-native';
|
|
22
|
+
* Opla.init({ scriptId, appId: 'vn.congty.app', appVersion: '1.0.0', endpoint: 'https://marketing.oplacrm.com' });
|
|
23
|
+
* Opla.screen('Hồ sơ vay');
|
|
24
|
+
*
|
|
25
|
+
* Keeps its data in @react-native-async-storage/async-storage. An app using MMKV or another store imports
|
|
26
|
+
* '@oplacrm/om-react-native/bare' instead (bare.ts). See README.md.
|
|
27
|
+
*/
|
|
28
|
+
const async_storage_1 = require("@react-native-async-storage/async-storage");
|
|
29
|
+
const bare_1 = require("./bare");
|
|
30
|
+
__exportStar(require("./bare"), exports);
|
|
31
|
+
exports.Opla = (0, bare_1.createOpla)(async_storage_1.default);
|
|
32
|
+
exports.default = exports.Opla;
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oplacrm/om-react-native",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Opla Marketing (OM) SDK for React Native: screens, events, application steps and sign-ins of an app, tracked in OM like a website.",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"bare.js",
|
|
10
|
+
"bare.d.ts",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc -p tsconfig.json",
|
|
17
|
+
"test": "tsc -p tsconfig.test.json && node --test build-test/test/core.test.js",
|
|
18
|
+
"prepublishOnly": "npm test && npm run build"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@react-native-async-storage/async-storage": ">=1.17.0",
|
|
22
|
+
"react-native": ">=0.70.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^22.0.0",
|
|
26
|
+
"typescript": "^5.6.0"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/opla-hq/go-marketing.git",
|
|
31
|
+
"directory": "sdk/react-native"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"react-native",
|
|
35
|
+
"analytics",
|
|
36
|
+
"tracking",
|
|
37
|
+
"opla",
|
|
38
|
+
"marketing"
|
|
39
|
+
],
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"types": "./lib/index.d.ts",
|
|
43
|
+
"default": "./lib/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./bare": {
|
|
46
|
+
"types": "./lib/bare.d.ts",
|
|
47
|
+
"default": "./lib/bare.js"
|
|
48
|
+
},
|
|
49
|
+
"./package.json": "./package.json"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"@react-native-async-storage/async-storage": {
|
|
53
|
+
"optional": true
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|