Skip to content

Commit 1384d3d

Browse files
committed
create readme
1 parent fdf1c2f commit 1384d3d

31 files changed

+1730
-54
lines changed

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
example
2+
node_modules
3+
__tests__
4+
dist
5+
.git

README.md

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,39 @@ npm install pam-react-native
1010

1111
## Usage
1212

13-
1413
```js
15-
import { multiply } from 'pam-react-native';
16-
17-
// ...
18-
19-
const result = multiply(3, 7);
14+
import { View, StyleSheet, Button } from 'react-native';
15+
import { Pam } from 'pam-react-native';
16+
17+
// Initialize Pam
18+
Pam.initialize({
19+
baseApi: 'https://<YOUR_PAM_API_ENDPOINT>.pams.ai',
20+
trackingConsentMessageId: '<consent>', // Generate from PAM Colsole
21+
publicDBAlias: '<public db alias>',
22+
loginDBAlias: '<login db alias>',
23+
loginKey: '<login key>',
24+
});
25+
26+
export default function App() {
27+
return <View>...</View>;
28+
}
2029
```
2130

31+
# Allow Tracking Consent
2232

23-
## Contributing
24-
25-
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
26-
27-
## License
28-
29-
MIT
33+
```js
34+
Pam.allowAllTrackingConsent('2VNmHzWrxPYJj0zDiM1cQGeW2S5');
35+
```
3036

31-
---
37+
# Tracking Event
3238

33-
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
39+
```js
40+
const parameters = {
41+
product_title: 'product1',
42+
quantity: 1,
43+
price: 199,
44+
sku: 'product1-sku-999',
45+
};
46+
47+
Pam.track('add_to_cart', parameters);
48+
```

dist/AppAttentionPlugin.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"use strict";
2+
var __defProp = Object.defineProperty;
3+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4+
var __getOwnPropNames = Object.getOwnPropertyNames;
5+
var __hasOwnProp = Object.prototype.hasOwnProperty;
6+
var __export = (target, all) => {
7+
for (var name in all)
8+
__defProp(target, name, { get: all[name], enumerable: true });
9+
};
10+
var __copyProps = (to, from, except, desc) => {
11+
if (from && typeof from === "object" || typeof from === "function") {
12+
for (let key of __getOwnPropNames(from))
13+
if (!__hasOwnProp.call(to, key) && key !== except)
14+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15+
}
16+
return to;
17+
};
18+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19+
20+
// src/AppAttentionPlugin.ts
21+
var AppAttentionPlugin_exports = {};
22+
__export(AppAttentionPlugin_exports, {
23+
AppAttentionPlugin: () => AppAttentionPlugin
24+
});
25+
module.exports = __toCommonJS(AppAttentionPlugin_exports);
26+
var import_pamtag = require("pamtag");
27+
var import_plugin = require("pamtag/build/types/core/plugin");
28+
var AppAttentionPlugin = class extends import_plugin.Plugin {
29+
initPlugin(pam) {
30+
console.log("AppAttentionPlugin initPlugin", pam);
31+
}
32+
};
33+
// Annotate the CommonJS export names for ESM import in node:
34+
0 && (module.exports = {
35+
AppAttentionPlugin
36+
});

dist/AppAttentionPlugin.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// src/AppAttentionPlugin.ts
2+
import "pamtag";
3+
import { Plugin } from "pamtag/build/types/core/plugin";
4+
var AppAttentionPlugin = class extends Plugin {
5+
initPlugin(pam) {
6+
console.log("AppAttentionPlugin initPlugin", pam);
7+
}
8+
};
9+
export {
10+
AppAttentionPlugin
11+
};

dist/NativePamReactNative.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"use strict";
2+
var __defProp = Object.defineProperty;
3+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4+
var __getOwnPropNames = Object.getOwnPropertyNames;
5+
var __hasOwnProp = Object.prototype.hasOwnProperty;
6+
var __export = (target, all) => {
7+
for (var name in all)
8+
__defProp(target, name, { get: all[name], enumerable: true });
9+
};
10+
var __copyProps = (to, from, except, desc) => {
11+
if (from && typeof from === "object" || typeof from === "function") {
12+
for (let key of __getOwnPropNames(from))
13+
if (!__hasOwnProp.call(to, key) && key !== except)
14+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15+
}
16+
return to;
17+
};
18+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19+
20+
// src/NativePamReactNative.ts
21+
var NativePamReactNative_exports = {};
22+
__export(NativePamReactNative_exports, {
23+
default: () => NativePamReactNative_default
24+
});
25+
module.exports = __toCommonJS(NativePamReactNative_exports);
26+
var import_react_native = require("react-native");
27+
var NativePamReactNative_default = import_react_native.TurboModuleRegistry.getEnforcing("PamReactNative");

dist/NativePamReactNative.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import {
2+
NativePamReactNative_default
3+
} from "./chunk-MKLAQXMO.mjs";
4+
export {
5+
NativePamReactNative_default as default
6+
};

dist/NativeStorageProvider.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
"use strict";
2+
var __create = Object.create;
3+
var __defProp = Object.defineProperty;
4+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5+
var __getOwnPropNames = Object.getOwnPropertyNames;
6+
var __getProtoOf = Object.getPrototypeOf;
7+
var __hasOwnProp = Object.prototype.hasOwnProperty;
8+
var __export = (target, all) => {
9+
for (var name in all)
10+
__defProp(target, name, { get: all[name], enumerable: true });
11+
};
12+
var __copyProps = (to, from, except, desc) => {
13+
if (from && typeof from === "object" || typeof from === "function") {
14+
for (let key of __getOwnPropNames(from))
15+
if (!__hasOwnProp.call(to, key) && key !== except)
16+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17+
}
18+
return to;
19+
};
20+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21+
// If the importer is in node compatibility mode or this is not an ESM
22+
// file that has been converted to a CommonJS file using a Babel-
23+
// compatible transform (i.e. "__esModule" has not been set), then set
24+
// "default" to the CommonJS "module.exports" for node compatibility.
25+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26+
mod
27+
));
28+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29+
30+
// src/NativeStorageProvider.ts
31+
var NativeStorageProvider_exports = {};
32+
__export(NativeStorageProvider_exports, {
33+
NativeStorageProvider: () => NativeStorageProvider
34+
});
35+
module.exports = __toCommonJS(NativeStorageProvider_exports);
36+
var import_storage_provider = require("pamtag/build/types/storage_provider");
37+
var import_async_storage = __toESM(require("@react-native-async-storage/async-storage"));
38+
var NativeStorageProvider = class {
39+
async setLocalStorage(key, value) {
40+
try {
41+
await import_async_storage.default.setItem(`lc_${key}`, value);
42+
console.log("Data saved successfully");
43+
} catch (error) {
44+
console.error("Error saving data:", error);
45+
}
46+
}
47+
async getLocalStorage(key) {
48+
try {
49+
const value = await import_async_storage.default.getItem(`lc_${key}`);
50+
if (value !== null) {
51+
return value;
52+
}
53+
} catch (error) {
54+
}
55+
return null;
56+
}
57+
deleteLocalStorage(key) {
58+
import_async_storage.default.removeItem(`lc_${key}`);
59+
}
60+
setCookie(name, value, hours) {
61+
const expireDate = /* @__PURE__ */ new Date();
62+
if (hours) {
63+
expireDate.setHours(expireDate.getHours() + hours);
64+
}
65+
import_async_storage.default.setItem(`ck_${name}`, value);
66+
import_async_storage.default.setItem(`ck_${name}_expires`, expireDate.getTime().toString());
67+
}
68+
async getCookie(name) {
69+
console.log("getCookie", name);
70+
try {
71+
const value = await import_async_storage.default.getItem(`ck_${name}`);
72+
const expireTimestampStr = await import_async_storage.default.getItem(
73+
`ck_${name}_expires`
74+
);
75+
if (expireTimestampStr === null) {
76+
return null;
77+
}
78+
const expireDate = new Date(parseInt(expireTimestampStr || "0", 10));
79+
const now = /* @__PURE__ */ new Date();
80+
if (expireDate.getTime() < now.getTime()) {
81+
this.deleteCookie(name);
82+
return null;
83+
}
84+
if (value !== null) {
85+
return value;
86+
}
87+
} catch (error) {
88+
console.log("getCookie error", error);
89+
}
90+
return null;
91+
}
92+
deleteCookie(name) {
93+
import_async_storage.default.removeItem(`ck_${name}`);
94+
import_async_storage.default.removeItem(`ck_${name}_expires`);
95+
}
96+
};
97+
// Annotate the CommonJS export names for ESM import in node:
98+
0 && (module.exports = {
99+
NativeStorageProvider
100+
});

dist/NativeStorageProvider.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import {
2+
NativeStorageProvider
3+
} from "./chunk-YQZRJM34.mjs";
4+
export {
5+
NativeStorageProvider
6+
};

dist/PamAPI.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"use strict";
2+
var __defProp = Object.defineProperty;
3+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4+
var __getOwnPropNames = Object.getOwnPropertyNames;
5+
var __hasOwnProp = Object.prototype.hasOwnProperty;
6+
var __export = (target, all) => {
7+
for (var name in all)
8+
__defProp(target, name, { get: all[name], enumerable: true });
9+
};
10+
var __copyProps = (to, from, except, desc) => {
11+
if (from && typeof from === "object" || typeof from === "function") {
12+
for (let key of __getOwnPropNames(from))
13+
if (!__hasOwnProp.call(to, key) && key !== except)
14+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15+
}
16+
return to;
17+
};
18+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19+
20+
// src/PamAPI.ts
21+
var PamAPI_exports = {};
22+
__export(PamAPI_exports, {
23+
PamAPI: () => PamAPI
24+
});
25+
module.exports = __toCommonJS(PamAPI_exports);
26+
var PamAPI = class {
27+
baseApiPath;
28+
constructor(baseApiPath) {
29+
this.baseApiPath = baseApiPath;
30+
}
31+
async loadAppAttention(pageName, contactID) {
32+
if (!contactID) {
33+
return void 0;
34+
}
35+
try {
36+
const response = await fetch(`${this.baseApiPath}/app-attention`, {
37+
method: "POST",
38+
headers: {
39+
"Content-Type": "application/json",
40+
"Accept": "application/json"
41+
},
42+
body: JSON.stringify({
43+
page_name: pageName,
44+
_contact_id: contactID
45+
})
46+
});
47+
console.log("status", response.status);
48+
if (response.status < 200 || response.status > 299) {
49+
return void 0;
50+
}
51+
const data = await response.json();
52+
if (Object.keys(data).length === 0) {
53+
return void 0;
54+
}
55+
return data;
56+
} catch (error) {
57+
console.error("Error:", error.message);
58+
return void 0;
59+
}
60+
}
61+
};
62+
// Annotate the CommonJS export names for ESM import in node:
63+
0 && (module.exports = {
64+
PamAPI
65+
});

dist/PamAPI.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import {
2+
PamAPI
3+
} from "./chunk-JC36NV3G.mjs";
4+
export {
5+
PamAPI
6+
};

dist/__tests__/index.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"use strict";
2+
3+
// src/__tests__/index.test.tsx
4+
it.todo("write a test");

dist/__tests__/index.test.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// src/__tests__/index.test.tsx
2+
it.todo("write a test");

dist/chunk-JC36NV3G.mjs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// src/PamAPI.ts
2+
var PamAPI = class {
3+
baseApiPath;
4+
constructor(baseApiPath) {
5+
this.baseApiPath = baseApiPath;
6+
}
7+
async loadAppAttention(pageName, contactID) {
8+
if (!contactID) {
9+
return void 0;
10+
}
11+
try {
12+
const response = await fetch(`${this.baseApiPath}/app-attention`, {
13+
method: "POST",
14+
headers: {
15+
"Content-Type": "application/json",
16+
"Accept": "application/json"
17+
},
18+
body: JSON.stringify({
19+
page_name: pageName,
20+
_contact_id: contactID
21+
})
22+
});
23+
console.log("status", response.status);
24+
if (response.status < 200 || response.status > 299) {
25+
return void 0;
26+
}
27+
const data = await response.json();
28+
if (Object.keys(data).length === 0) {
29+
return void 0;
30+
}
31+
return data;
32+
} catch (error) {
33+
console.error("Error:", error.message);
34+
return void 0;
35+
}
36+
}
37+
};
38+
39+
export {
40+
PamAPI
41+
};

dist/chunk-MKLAQXMO.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// src/NativePamReactNative.ts
2+
import { TurboModuleRegistry } from "react-native";
3+
var NativePamReactNative_default = TurboModuleRegistry.getEnforcing("PamReactNative");
4+
5+
export {
6+
NativePamReactNative_default
7+
};

0 commit comments

Comments
 (0)