Skip to content

Commit 7968d35

Browse files
authored
feat: update api (#2)
1 parent 7aa3f46 commit 7968d35

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function App() {
5050
}, []);
5151

5252
useEffect(() => {
53-
Birch.identifier = userId
53+
Birch.setIdentifier(userId);
5454
}, [userId]);
5555
}
5656
```
@@ -77,7 +77,7 @@ Birch.setConsole(true);
7777
```
7878

7979
```typescript
80-
const useConsole = await Birch.console();
80+
const useConsole = await Birch.getConsole();
8181
```
8282

8383
### Remote
@@ -88,7 +88,7 @@ Birch.setRemote(true);
8888
```
8989

9090
```typescript
91-
const remote = await Birch.remote()
91+
const remote = await Birch.getRemote()
9292
```
9393

9494
### Level
@@ -99,7 +99,7 @@ Birch.setLevel(Level.Trace)
9999
```
100100

101101
```typescript
102-
const level = await Birch.level();
102+
const level = await Birch.getLevel();
103103
```
104104

105105
### Synchronous
@@ -110,7 +110,7 @@ Birch.setSynchronous(true);
110110
```
111111

112112
```typescript
113-
const sync = await Birch.synchronous();
113+
const sync = await Birch.getSynchronous();
114114
```
115115

116116
### Debug
@@ -123,7 +123,7 @@ Birch.setDebug(true);
123123
```
124124

125125
```typescript
126-
const debug = await Birch.debug();
126+
const debug = await Birch.getDebug();
127127
```
128128

129129
### Encryption
@@ -154,6 +154,10 @@ To comply with different sets of regulations such as GDPR or CCPA, you may be re
154154
Birch.setOptOut(true);
155155
```
156156

157+
```typescript
158+
const optOut = await Birch.getOptOut();
159+
```
160+
157161
### Log Scrubbing
158162

159163
Birch comes preconfigured with an email and password scrubber to ensure sensitive data is __NOT__ logged. Emails and passwords are replaced with `[FILTERED]` at the logger level so the data never reaches Birch servers.

example/src/App.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ export default function App() {
3434
});
3535

3636
(async () => {
37-
setDebug(await Birch.debug());
38-
setLevel(await Birch.level());
39-
setConsoleLog(await Birch.console());
40-
setRemote(await Birch.remote());
41-
setSynchronous(await Birch.synchronous());
37+
setDebug(await Birch.getDebug());
38+
setLevel(await Birch.getLevel());
39+
setConsoleLog(await Birch.getConsole());
40+
setRemote(await Birch.getRemote());
41+
setSynchronous(await Birch.getSynchronous());
4242
})();
4343
}, [setDebug, setLevel, setConsoleLog, setRemote, setSynchronous]);
4444

4545
const toggleDebug = useCallback(
4646
async (_e: GestureResponderEvent) => {
47-
const value = await Birch.debug();
47+
const value = await Birch.getDebug();
4848
Birch.setDebug(!value);
4949
setDebug(!value);
5050
},
@@ -53,7 +53,7 @@ export default function App() {
5353

5454
const toggleLevel = useCallback(
5555
async (_e: GestureResponderEvent) => {
56-
const value = await Birch.level();
56+
const value = await Birch.getLevel();
5757
switch (value) {
5858
case Level.Trace:
5959
Birch.setLevel(Level.Debug);
@@ -90,7 +90,7 @@ export default function App() {
9090

9191
const toggleConsole = useCallback(
9292
async (_e: GestureResponderEvent) => {
93-
const value = await Birch.console();
93+
const value = await Birch.getConsole();
9494
Birch.setConsole(!value);
9595
setConsoleLog(!value);
9696
},
@@ -99,7 +99,7 @@ export default function App() {
9999

100100
const toggleRemote = useCallback(
101101
async (_e: GestureResponderEvent) => {
102-
const value = await Birch.remote();
102+
const value = await Birch.getRemote();
103103
Birch.setRemote(!value);
104104
setRemote(!value);
105105
},
@@ -108,7 +108,7 @@ export default function App() {
108108

109109
const toggleSynchronous = useCallback(
110110
async (_e: GestureResponderEvent) => {
111-
const value = await Birch.synchronous();
111+
const value = await Birch.getSynchronous();
112112
Birch.setSynchronous(!value);
113113
setSynchronous(!value);
114114
},
@@ -136,7 +136,7 @@ export default function App() {
136136
}, []);
137137

138138
const printCurrentLevel = useCallback(async (_e: GestureResponderEvent) => {
139-
console.log(await Birch.currentLevel());
139+
console.log(await Birch.getCurrentLevel());
140140
}, []);
141141

142142
return (

src/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,46 +45,46 @@ function Birch() {
4545
let scrubbers: Array<Scrubber> = [];
4646

4747
const obj = {
48-
debug: async (): Promise<boolean> => {
48+
getDebug: async (): Promise<boolean> => {
4949
return await RNBirch.debug();
5050
},
5151
setDebug: (value: boolean) => {
5252
RNBirch.setDebug(value);
5353
},
54-
optOut: async (): Promise<boolean> => {
54+
getOptOut: async (): Promise<boolean> => {
5555
return await RNBirch.optOut();
5656
},
5757
setOptOut: (value: boolean) => {
5858
RNBirch.setOptOut(value);
5959
},
60-
uuid: async (): Promise<string> => {
60+
getUuid: async (): Promise<string> => {
6161
return await RNBirch.uuid();
6262
},
63-
identifier: async (): Promise<string> => {
63+
getIdentifier: async (): Promise<string> => {
6464
return await RNBirch.identifier();
6565
},
6666
setIdentifier: (value?: string) => {
6767
RNBirch.setIdentifier(value);
6868
},
69-
customProperties: async (): Promise<Record<string, string>> => {
69+
getCustomProperties: async (): Promise<Record<string, string>> => {
7070
return await RNBirch.customProperties();
7171
},
7272
setCustomProperties: (value: Record<string, string>) => {
7373
RNBirch.setCustomProperties(value);
7474
},
75-
console: async (): Promise<boolean> => {
75+
getConsole: async (): Promise<boolean> => {
7676
return await RNBirch.console();
7777
},
7878
setConsole: (value: boolean) => {
7979
RNBirch.setConsole(value);
8080
},
81-
remote: async (): Promise<boolean> => {
81+
getRemote: async (): Promise<boolean> => {
8282
return await RNBirch.remote();
8383
},
8484
setRemote: (value: boolean) => {
8585
RNBirch.setRemote(value);
8686
},
87-
level: async (): Promise<Level | undefined> => {
87+
getLevel: async (): Promise<Level | undefined> => {
8888
const level = await RNBirch.level();
8989
return level !== undefined ? (level as Level) : undefined;
9090
},
@@ -95,11 +95,11 @@ function Birch() {
9595
RNBirch.setLevel(value as number);
9696
}
9797
},
98-
currentLevel: async (): Promise<Level | undefined> => {
98+
getCurrentLevel: async (): Promise<Level | undefined> => {
9999
const level = await RNBirch.currentLevel();
100100
return level !== undefined ? (level as Level) : undefined;
101101
},
102-
synchronous: async (): Promise<boolean> => {
102+
getSynchronous: async (): Promise<boolean> => {
103103
return await RNBirch.synchronous();
104104
},
105105
setSynchronous: (value: boolean) => {
@@ -163,8 +163,8 @@ function Birch() {
163163
};
164164

165165
const log = async (level: Level, message: string) => {
166-
const current = await obj.currentLevel();
167-
const allowConsole = await obj.console();
166+
const current = await obj.getCurrentLevel();
167+
const allowConsole = await obj.getConsole();
168168

169169
if (allowConsole && current !== undefined && level >= current) {
170170
switch (level) {

0 commit comments

Comments
 (0)