MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / constructor

Method constructor

packages/sdks/react-native/index.ts:55–87  ·  view source on GitHub ↗
(public options: ReactNativeOpenPanelOptions)

Source from the content-addressed store, hash-verified

53 private isOnline = true;
54
55 constructor(public options: ReactNativeOpenPanelOptions) {
56 super({
57 ...options,
58 sdk: 'react-native',
59 sdkVersion: process.env.REACT_NATIVE_VERSION!,
60 });
61
62 this.api.addHeader('User-Agent', Constants.getWebViewUserAgentAsync());
63 this.storage = options.storage;
64
65 if (options.networkInfo) {
66 options.networkInfo.fetch().then(({ isConnected }) => {
67 this.isOnline = isConnected ?? true;
68 });
69 options.networkInfo.addEventListener(({ isConnected }) => {
70 const wasOffline = !this.isOnline;
71 this.isOnline = isConnected ?? true;
72 if (wasOffline && this.isOnline) {
73 this.flush();
74 }
75 });
76 }
77
78 AppState.addEventListener('change', (state) => {
79 if (state === 'active') {
80 this.setDefaultProperties();
81 this.flush();
82 }
83 });
84
85 this.setDefaultProperties();
86 this.loadPersistedQueue();
87 }
88
89 private async setDefaultProperties() {
90 this.setGlobalProperties({

Callers

nothing calls this directly

Calls 7

flushMethod · 0.95
setDefaultPropertiesMethod · 0.95
loadPersistedQueueMethod · 0.95
addEventListenerMethod · 0.80
fetchMethod · 0.65
addHeaderMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected