@agrid/agrid-react-native 4.12.11

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.
Files changed (151) hide show
  1. package/README.md +691 -0
  2. package/dist/AgridContext.d.ts +5 -0
  3. package/dist/AgridContext.js +1 -0
  4. package/dist/AgridContext.js.map +1 -0
  5. package/dist/AgridProvider.d.ts +86 -0
  6. package/dist/AgridProvider.js +1 -0
  7. package/dist/AgridProvider.js.map +1 -0
  8. package/dist/agrid-rn.d.ts +612 -0
  9. package/dist/agrid-rn.js +1 -0
  10. package/dist/agrid-rn.js.map +1 -0
  11. package/dist/autocapture.d.ts +4 -0
  12. package/dist/autocapture.js +1 -0
  13. package/dist/autocapture.js.map +1 -0
  14. package/dist/error-tracking/index.d.ts +27 -0
  15. package/dist/error-tracking/index.js +1 -0
  16. package/dist/error-tracking/index.js.map +1 -0
  17. package/dist/error-tracking/utils.d.ts +5 -0
  18. package/dist/error-tracking/utils.js +1 -0
  19. package/dist/error-tracking/utils.js.map +1 -0
  20. package/dist/frameworks/wix-navigation.d.ts +3 -0
  21. package/dist/frameworks/wix-navigation.js +1 -0
  22. package/dist/frameworks/wix-navigation.js.map +1 -0
  23. package/dist/hooks/useAgrid.d.ts +2 -0
  24. package/dist/hooks/useAgrid.js +1 -0
  25. package/dist/hooks/useAgrid.js.map +1 -0
  26. package/dist/hooks/useFeatureFlag.d.ts +5 -0
  27. package/dist/hooks/useFeatureFlag.js +1 -0
  28. package/dist/hooks/useFeatureFlag.js.map +1 -0
  29. package/dist/hooks/useFeatureFlags.d.ts +3 -0
  30. package/dist/hooks/useFeatureFlags.js +1 -0
  31. package/dist/hooks/useFeatureFlags.js.map +1 -0
  32. package/dist/hooks/useNavigationTracker.d.ts +6 -0
  33. package/dist/hooks/useNavigationTracker.js +1 -0
  34. package/dist/hooks/useNavigationTracker.js.map +1 -0
  35. package/dist/index.d.ts +10 -0
  36. package/dist/index.js +1 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/native-deps.d.ts +4 -0
  39. package/dist/native-deps.js +1 -0
  40. package/dist/native-deps.js.map +1 -0
  41. package/dist/optional/OptionalAsyncStorage.d.ts +2 -0
  42. package/dist/optional/OptionalAsyncStorage.js +1 -0
  43. package/dist/optional/OptionalAsyncStorage.js.map +1 -0
  44. package/dist/optional/OptionalExpoApplication.d.ts +2 -0
  45. package/dist/optional/OptionalExpoApplication.js +1 -0
  46. package/dist/optional/OptionalExpoApplication.js.map +1 -0
  47. package/dist/optional/OptionalExpoDevice.d.ts +2 -0
  48. package/dist/optional/OptionalExpoDevice.js +1 -0
  49. package/dist/optional/OptionalExpoDevice.js.map +1 -0
  50. package/dist/optional/OptionalExpoFileSystem.d.ts +2 -0
  51. package/dist/optional/OptionalExpoFileSystem.js +1 -0
  52. package/dist/optional/OptionalExpoFileSystem.js.map +1 -0
  53. package/dist/optional/OptionalExpoFileSystemLegacy.d.ts +2 -0
  54. package/dist/optional/OptionalExpoFileSystemLegacy.js +1 -0
  55. package/dist/optional/OptionalExpoFileSystemLegacy.js.map +1 -0
  56. package/dist/optional/OptionalExpoLocalization.d.ts +2 -0
  57. package/dist/optional/OptionalExpoLocalization.js +1 -0
  58. package/dist/optional/OptionalExpoLocalization.js.map +1 -0
  59. package/dist/optional/OptionalReactNativeDeviceInfo.d.ts +2 -0
  60. package/dist/optional/OptionalReactNativeDeviceInfo.js +1 -0
  61. package/dist/optional/OptionalReactNativeDeviceInfo.js.map +1 -0
  62. package/dist/optional/OptionalReactNativeLocalize.d.ts +13 -0
  63. package/dist/optional/OptionalReactNativeLocalize.js +1 -0
  64. package/dist/optional/OptionalReactNativeLocalize.js.map +1 -0
  65. package/dist/optional/OptionalReactNativeNavigation.d.ts +2 -0
  66. package/dist/optional/OptionalReactNativeNavigation.js +1 -0
  67. package/dist/optional/OptionalReactNativeNavigation.js.map +1 -0
  68. package/dist/optional/OptionalReactNativeNavigationWix.d.ts +2 -0
  69. package/dist/optional/OptionalReactNativeNavigationWix.js +1 -0
  70. package/dist/optional/OptionalReactNativeNavigationWix.js.map +1 -0
  71. package/dist/optional/OptionalReactNativeSafeArea.d.ts +2 -0
  72. package/dist/optional/OptionalReactNativeSafeArea.js +1 -0
  73. package/dist/optional/OptionalReactNativeSafeArea.js.map +1 -0
  74. package/dist/optional/OptionalSessionReplay.d.ts +2 -0
  75. package/dist/optional/OptionalSessionReplay.js +1 -0
  76. package/dist/optional/OptionalSessionReplay.js.map +1 -0
  77. package/dist/storage.d.ts +21 -0
  78. package/dist/storage.js +1 -0
  79. package/dist/storage.js.map +1 -0
  80. package/dist/surveys/AgridSurveyProvider.d.ts +16 -0
  81. package/dist/surveys/AgridSurveyProvider.js +1 -0
  82. package/dist/surveys/AgridSurveyProvider.js.map +1 -0
  83. package/dist/surveys/components/BottomSection.d.ts +8 -0
  84. package/dist/surveys/components/BottomSection.js +1 -0
  85. package/dist/surveys/components/BottomSection.js.map +1 -0
  86. package/dist/surveys/components/Cancel.d.ts +5 -0
  87. package/dist/surveys/components/Cancel.js +1 -0
  88. package/dist/surveys/components/Cancel.js.map +1 -0
  89. package/dist/surveys/components/ConfirmationMessage.d.ts +12 -0
  90. package/dist/surveys/components/ConfirmationMessage.js +1 -0
  91. package/dist/surveys/components/ConfirmationMessage.js.map +1 -0
  92. package/dist/surveys/components/QuestionHeader.d.ts +6 -0
  93. package/dist/surveys/components/QuestionHeader.js +1 -0
  94. package/dist/surveys/components/QuestionHeader.js.map +1 -0
  95. package/dist/surveys/components/QuestionTypes.d.ts +26 -0
  96. package/dist/surveys/components/QuestionTypes.js +1 -0
  97. package/dist/surveys/components/QuestionTypes.js.map +1 -0
  98. package/dist/surveys/components/SurveyModal.d.ts +9 -0
  99. package/dist/surveys/components/SurveyModal.js +1 -0
  100. package/dist/surveys/components/SurveyModal.js.map +1 -0
  101. package/dist/surveys/components/Surveys.d.ts +13 -0
  102. package/dist/surveys/components/Surveys.js +1 -0
  103. package/dist/surveys/components/Surveys.js.map +1 -0
  104. package/dist/surveys/getActiveMatchingSurveys.d.ts +2 -0
  105. package/dist/surveys/getActiveMatchingSurveys.js +1 -0
  106. package/dist/surveys/getActiveMatchingSurveys.js.map +1 -0
  107. package/dist/surveys/icons.d.ts +8 -0
  108. package/dist/surveys/icons.js +1 -0
  109. package/dist/surveys/icons.js.map +1 -0
  110. package/dist/surveys/index.d.ts +6 -0
  111. package/dist/surveys/index.js +1 -0
  112. package/dist/surveys/index.js.map +1 -0
  113. package/dist/surveys/surveys-utils.d.ts +30 -0
  114. package/dist/surveys/surveys-utils.js +1 -0
  115. package/dist/surveys/surveys-utils.js.map +1 -0
  116. package/dist/surveys/useActivatedSurveys.d.ts +3 -0
  117. package/dist/surveys/useActivatedSurveys.js +1 -0
  118. package/dist/surveys/useActivatedSurveys.js.map +1 -0
  119. package/dist/surveys/useSurveyStorage.d.ts +8 -0
  120. package/dist/surveys/useSurveyStorage.js +1 -0
  121. package/dist/surveys/useSurveyStorage.js.map +1 -0
  122. package/dist/tooling/agridMetroSerializer.d.ts +17 -0
  123. package/dist/tooling/agridMetroSerializer.js +1 -0
  124. package/dist/tooling/agridMetroSerializer.js.map +1 -0
  125. package/dist/tooling/metroconfig.d.ts +15 -0
  126. package/dist/tooling/metroconfig.js +1 -0
  127. package/dist/tooling/metroconfig.js.map +1 -0
  128. package/dist/tooling/utils.d.ts +58 -0
  129. package/dist/tooling/utils.js +1 -0
  130. package/dist/tooling/utils.js.map +1 -0
  131. package/dist/tooling/vendor/expo/expoconfig.d.ts +23 -0
  132. package/dist/tooling/vendor/expo/expoconfig.js +1 -0
  133. package/dist/tooling/vendor/expo/expoconfig.js.map +1 -0
  134. package/dist/tooling/vendor/metro/countLines.d.ts +2 -0
  135. package/dist/tooling/vendor/metro/countLines.js +1 -0
  136. package/dist/tooling/vendor/metro/countLines.js.map +1 -0
  137. package/dist/tooling/vendor/metro/utils.d.ts +22 -0
  138. package/dist/tooling/vendor/metro/utils.js +1 -0
  139. package/dist/tooling/vendor/metro/utils.js.map +1 -0
  140. package/dist/types.d.ts +150 -0
  141. package/dist/types.js +1 -0
  142. package/dist/types.js.map +1 -0
  143. package/dist/utils.d.ts +20 -0
  144. package/dist/utils.js +1 -0
  145. package/dist/utils.js.map +1 -0
  146. package/dist/version.d.ts +1 -0
  147. package/dist/version.js +1 -0
  148. package/dist/version.js.map +1 -0
  149. package/package.json +134 -0
  150. package/tooling/agrid-xcode.sh +111 -0
  151. package/tooling/agrid.gradle +312 -0
@@ -0,0 +1,612 @@
1
+ import { JsonType, PostHogCaptureOptions, PostHogCore, PostHogCoreOptions, PostHogEventProperties, PostHogFetchOptions, PostHogFetchResponse, PostHogPersistedProperty, SurveyResponse } from '@agrid/core';
2
+ import { AgridAutocaptureOptions, AgridCustomAppProperties, AgridCustomStorage, AgridSessionReplayConfig } from './types';
3
+ import { OptionalReactNativeSessionReplay } from './optional/OptionalSessionReplay';
4
+ import { ErrorTrackingOptions } from './error-tracking';
5
+ export { PostHogPersistedProperty };
6
+ export interface AgridOptions extends PostHogCoreOptions {
7
+ /** Allows you to provide the storage type. By default 'file'.
8
+ * 'file' will try to load the best available storage, the provided 'customStorage', 'customAsyncStorage' or in-memory storage.
9
+ */
10
+ persistence?: 'memory' | 'file';
11
+ /** Allows you to provide your own implementation of the common information about your App or a function to modify the default App properties generated */
12
+ customAppProperties?: AgridCustomAppProperties | ((properties: AgridCustomAppProperties) => AgridCustomAppProperties);
13
+ /** Allows you to provide a custom asynchronous storage such as async-storage, expo-file-system or a synchronous storage such as mmkv.
14
+ * If not provided, Agrid will attempt to use the best available storage via optional peer dependencies (async-storage, expo-file-system).
15
+ * If `persistence` is set to 'memory', this option will be ignored.
16
+ */
17
+ customStorage?: AgridCustomStorage;
18
+ /** Captures app lifecycle events such as Application Installed, Application Updated, Application Opened, Application Became Active and Application Backgrounded.
19
+ * By default is false.
20
+ * Application Installed and Application Updated events are not supported with persistence set to 'memory'.
21
+ */
22
+ captureAppLifecycleEvents?: boolean;
23
+ /**
24
+ * Enable Recording of Session Replays for Android and iOS
25
+ * Requires Record user sessions to be enabled in the Agrid Project Settings
26
+ * Defaults to false
27
+ */
28
+ enableSessionReplay?: boolean;
29
+ /**
30
+ * Configuration for Session Replay
31
+ */
32
+ sessionReplayConfig?: AgridSessionReplayConfig;
33
+ /**
34
+ * If enabled, the session id ($session_id) will be persisted across app restarts.
35
+ * This is an option for back compatibility, so your current data isn't skewed with the new version of the SDK.
36
+ * If this is false, the session id will be always reset on app restart.
37
+ * Defaults to false
38
+ */
39
+ enablePersistSessionIdAcrossRestart?: boolean;
40
+ /**
41
+ * Error Tracking Configuration
42
+ */
43
+ errorTracking?: ErrorTrackingOptions;
44
+ /**
45
+ * Automatically include common device and app properties in feature flag evaluation.
46
+ *
47
+ * When enabled, the following properties are sent with every /flags request:
48
+ * - $app_version: App version
49
+ * - $app_build: App build number
50
+ * - $app_namespace: App bundle identifier / namespace
51
+ * - $os_name: Operating system name
52
+ * - $os_version: Operating system version
53
+ * - $device_type: Device type (Mobile, Desktop, Web)
54
+ * - $lib: Name of the SDK library
55
+ * - $lib_version: Version of the SDK library
56
+ *
57
+ * This ensures feature flags that rely on these properties work correctly
58
+ * without waiting for server-side processing of identify() calls.
59
+ *
60
+ * @default true
61
+ */
62
+ setDefaultPersonProperties?: boolean;
63
+ }
64
+ export declare class Agrid extends PostHogCore {
65
+ private _persistence;
66
+ private _storage;
67
+ private _appProperties;
68
+ private _currentSessionId?;
69
+ private _enableSessionReplay?;
70
+ private _disableSurveys;
71
+ private _disableRemoteConfig;
72
+ private _errorTracking;
73
+ private _surveysReadyPromise;
74
+ private _surveysReady;
75
+ private _setDefaultPersonProperties;
76
+ /**
77
+ * Creates a new Agrid instance for React Native. You can find all configuration options in the [React Native SDK docs](https://agrid.com/docs/libraries/react-native#configuration-options).
78
+ *
79
+ * If you prefer not to use the AgridProvider, you can initialize Agrid in its own file and import the instance from there.
80
+ *
81
+ * {@label Initialization}
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * // agrid.ts
86
+ * import Agrid from 'agrid-react-native'
87
+ *
88
+ * export const agrid = new Agrid('<ph_project_api_key>', {
89
+ * host: '<ph_client_api_host>'
90
+ * })
91
+ *
92
+ * // Then you can access Agrid by importing your instance
93
+ * // Another file:
94
+ * import { agrid } from './agrid'
95
+ *
96
+ * export function MyApp1() {
97
+ * useEffect(async () => {
98
+ * agrid.capture('event_name')
99
+ * }, [agrid])
100
+ *
101
+ * return <View>Your app code</View>
102
+ * }
103
+ * ```
104
+ *
105
+ * @public
106
+ *
107
+ * @param apiKey - Your Agrid API key
108
+ * @param options - Agrid configuration options
109
+ */
110
+ constructor(apiKey: string, options?: AgridOptions);
111
+ /**
112
+ *
113
+ * @internal
114
+ *
115
+ */
116
+ ready(): Promise<void>;
117
+ getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
118
+ setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
119
+ fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse>;
120
+ getLibraryId(): string;
121
+ getLibraryVersion(): string;
122
+ getCustomUserAgent(): string;
123
+ getCommonEventProperties(): PostHogEventProperties;
124
+ /**
125
+ * Registers super properties that are sent with every event.
126
+ *
127
+ * Super properties are properties associated with events that are set once and then sent with every capture call.
128
+ * They persist across sessions and are stored locally.
129
+ *
130
+ * {@label Capture}
131
+ *
132
+ * @example
133
+ * ```js
134
+ * // register super properties
135
+ * agrid.register({
136
+ * 'icecream pref': 'vanilla',
137
+ * team_id: 22,
138
+ * })
139
+ * ```
140
+ *
141
+ * @public
142
+ *
143
+ * @param properties An associative array of properties to store about the user
144
+ */
145
+ register(properties: PostHogEventProperties): Promise<void>;
146
+ /**
147
+ * Removes a super property so it won't be sent with future events.
148
+ *
149
+ * Super Properties are persisted across sessions so you have to explicitly remove them if they are no longer relevant.
150
+ *
151
+ * {@label Capture}
152
+ *
153
+ * @example
154
+ * ```js
155
+ * // remove a super property
156
+ * agrid.unregister('icecream pref')
157
+ * ```
158
+ *
159
+ * @public
160
+ *
161
+ * @param property The name of the super property to remove
162
+ */
163
+ unregister(property: string): Promise<void>;
164
+ /**
165
+ * Resets the user's ID and anonymous ID after logout.
166
+ *
167
+ * To reset the user's ID and anonymous ID, call reset. Usually you would do this right after the user logs out.
168
+ * This also clears all stored super properties and more.
169
+ *
170
+ * {@label Identification}
171
+ *
172
+ * @example
173
+ * ```js
174
+ * // reset after logout
175
+ * agrid.reset()
176
+ * ```
177
+ *
178
+ * @public
179
+ */
180
+ reset(): void;
181
+ /**
182
+ * Helper to extract and set default person properties from app properties
183
+ *
184
+ * @private
185
+ *
186
+ * @param reloadFeatureFlags Whether to reload feature flags after setting the properties. Defaults to true.
187
+ */
188
+ private _setDefaultPersonPropertiesForFlags;
189
+ /**
190
+ * Manually flushes the event queue.
191
+ *
192
+ * You can set the number of events in the configuration that should queue before flushing.
193
+ * Setting this to 1 will send events immediately and will use more battery. This is set to 20 by default.
194
+ * You can also manually flush the queue. If a flush is already in progress it returns a promise for the existing flush.
195
+ *
196
+ * {@label Capture}
197
+ *
198
+ * @example
199
+ * ```js
200
+ * // manually flush the queue
201
+ * await agrid.flush()
202
+ * ```
203
+ *
204
+ * @public
205
+ *
206
+ * @returns Promise that resolves when the flush is complete
207
+ */
208
+ flush(): Promise<void>;
209
+ /**
210
+ * Opts the user in to data capture.
211
+ *
212
+ * By default, Agrid has tracking enabled unless it is forcefully disabled by default using the option { defaultOptIn: false }.
213
+ * Once this has been called it is persisted and will be respected until optOut is called again or the reset function is called.
214
+ *
215
+ * {@label Privacy}
216
+ *
217
+ * @example
218
+ * ```js
219
+ * // opt in to tracking
220
+ * agrid.optIn()
221
+ * ```
222
+ *
223
+ * @public
224
+ */
225
+ optIn(): Promise<void>;
226
+ /**
227
+ * Opts the user out of data capture.
228
+ *
229
+ * You can completely opt-out users from data capture. Once this has been called it is persisted and will be respected until optIn is called again or the reset function is called.
230
+ *
231
+ * {@label Privacy}
232
+ *
233
+ * @example
234
+ * ```js
235
+ * // opt out of tracking
236
+ * agrid.optOut()
237
+ * ```
238
+ *
239
+ * @public
240
+ */
241
+ optOut(): Promise<void>;
242
+ /**
243
+ * Checks if a feature flag is enabled for the current user.
244
+ *
245
+ * Defaults to undefined if not loaded yet or if there was a problem loading.
246
+ *
247
+ * {@label Feature flags}
248
+ *
249
+ * @example
250
+ * ```js
251
+ * // check if feature flag is enabled
252
+ * const isEnabled = agrid.isFeatureEnabled('key-for-your-boolean-flag')
253
+ * ```
254
+ *
255
+ * @public
256
+ *
257
+ * @param key The feature flag key
258
+ * @returns True if enabled, false if disabled, undefined if not loaded
259
+ */
260
+ isFeatureEnabled(key: string): boolean | undefined;
261
+ /**
262
+ * Gets the value of a feature flag for the current user.
263
+ *
264
+ * Defaults to undefined if not loaded yet or if there was a problem loading.
265
+ * Multivariant feature flags are returned as a string.
266
+ *
267
+ * {@label Feature flags}
268
+ *
269
+ * @example
270
+ * ```js
271
+ * // get feature flag value
272
+ * const value = agrid.getFeatureFlag('key-for-your-boolean-flag')
273
+ * ```
274
+ *
275
+ * @public
276
+ *
277
+ * @param key The feature flag key
278
+ * @returns The feature flag value or undefined if not loaded
279
+ */
280
+ getFeatureFlag(key: string): boolean | string | undefined;
281
+ /**
282
+ * Gets the payload of a feature flag for the current user.
283
+ *
284
+ * Returns JsonType or undefined if not loaded yet or if there was a problem loading.
285
+ *
286
+ * {@label Feature flags}
287
+ *
288
+ * @example
289
+ * ```js
290
+ * // get feature flag payload
291
+ * const payload = agrid.getFeatureFlagPayload('key-for-your-multivariate-flag')
292
+ * ```
293
+ *
294
+ * @public
295
+ *
296
+ * @param key The feature flag key
297
+ * @returns The feature flag payload or undefined if not loaded
298
+ */
299
+ getFeatureFlagPayload(key: string): JsonType | undefined;
300
+ /**
301
+ * Reloads feature flags from the server.
302
+ *
303
+ * Agrid loads feature flags when instantiated and refreshes whenever methods are called that affect the flag.
304
+ * If you want to manually trigger a refresh, you can call this method.
305
+ *
306
+ * {@label Feature flags}
307
+ *
308
+ * @example
309
+ * ```js
310
+ * // reload feature flags
311
+ * agrid.reloadFeatureFlags()
312
+ * ```
313
+ *
314
+ * @public
315
+ */
316
+ reloadFeatureFlags(): void;
317
+ /**
318
+ * Reloads feature flags from the server asynchronously.
319
+ *
320
+ * Agrid loads feature flags when instantiated and refreshes whenever methods are called that affect the flag.
321
+ * If you want to manually trigger a refresh and get the result, you can call this method.
322
+ *
323
+ * {@label Feature flags}
324
+ *
325
+ * @example
326
+ * ```js
327
+ * // reload feature flags and get result
328
+ * agrid.reloadFeatureFlagsAsync().then((refreshedFlags) => console.log(refreshedFlags))
329
+ * ```
330
+ *
331
+ * @public
332
+ *
333
+ * @returns Promise that resolves with the refreshed flags
334
+ */
335
+ reloadFeatureFlagsAsync(): Promise<Record<string, boolean | string> | undefined>;
336
+ /**
337
+ * Associates the current user with a group.
338
+ *
339
+ * Group analytics allows you to associate the events for that person's session with a group (e.g. teams, organizations, etc.).
340
+ * This is a paid feature and is not available on the open-source or free cloud plan.
341
+ *
342
+ * {@label Group analytics}
343
+ *
344
+ * @example
345
+ * ```js
346
+ * // associate with a group
347
+ * agrid.group('company', 'company_id_in_your_db')
348
+ * ```
349
+ *
350
+ * @example
351
+ * ```js
352
+ * // associate with a group and update properties
353
+ * agrid.group('company', 'company_id_in_your_db', {
354
+ * name: 'Awesome Inc.',
355
+ * employees: 11,
356
+ * })
357
+ * ```
358
+ *
359
+ * @public
360
+ *
361
+ * @param groupType The type of group (e.g. 'company', 'team')
362
+ * @param groupKey The unique identifier for the group
363
+ * @param properties Optional properties to set for the group
364
+ */
365
+ group(groupType: string, groupKey: string, properties?: PostHogEventProperties): void;
366
+ /**
367
+ * Assigns an alias to the current user.
368
+ *
369
+ * Sometimes, you want to assign multiple distinct IDs to a single user. This is helpful when your primary distinct ID is inaccessible.
370
+ * For example, if a distinct ID used on the frontend is not available in your backend.
371
+ *
372
+ * {@label Identification}
373
+ *
374
+ * @example
375
+ * ```js
376
+ * // set alias for current user
377
+ * agrid.alias('distinct_id')
378
+ * ```
379
+ *
380
+ * @public
381
+ *
382
+ * @param alias The alias to assign to the current user
383
+ */
384
+ alias(alias: string): void;
385
+ /**
386
+ * Gets the current user's distinct ID.
387
+ *
388
+ * You may find it helpful to get the current user's distinct ID. For example, to check whether you've already called identify for a user or not.
389
+ * This returns either the ID automatically generated by Agrid or the ID that has been passed by a call to identify().
390
+ *
391
+ * {@label Identification}
392
+ *
393
+ * @example
394
+ * ```js
395
+ * // get current distinct ID
396
+ * const distinctId = agrid.getDistinctId()
397
+ * ```
398
+ *
399
+ * @public
400
+ *
401
+ * @returns The current user's distinct ID
402
+ */
403
+ getDistinctId(): string;
404
+ /**
405
+ * Sets person properties for feature flag evaluation.
406
+ *
407
+ * Sometimes, you might want to evaluate feature flags using properties that haven't been ingested yet, or were set incorrectly earlier.
408
+ * You can do so by setting properties the flag depends on with this call. These are set for the entire session.
409
+ * Successive calls are additive: all properties you set are combined together and sent for flag evaluation.
410
+ *
411
+ * {@label Feature flags}
412
+ *
413
+ * @example
414
+ * ```js
415
+ * // set person properties for flags
416
+ * agrid.setPersonPropertiesForFlags({'property1': 'value', property2: 'value2'})
417
+ * ```
418
+ *
419
+ * @public
420
+ *
421
+ * @param properties The person properties to set for flag evaluation
422
+ * @param reloadFeatureFlags Whether to reload feature flags after setting the properties. Defaults to true.
423
+ */
424
+ setPersonPropertiesForFlags(properties: Record<string, string>, reloadFeatureFlags?: boolean): void;
425
+ /**
426
+ * Resets person properties for feature flag evaluation.
427
+ *
428
+ *
429
+ * {@label Feature flags}
430
+ *
431
+ * @example
432
+ * ```js
433
+ * // reset person properties for flags
434
+ * agrid.resetPersonPropertiesForFlags()
435
+ * ```
436
+ *
437
+ * @public
438
+ *
439
+ * @param reloadFeatureFlags Whether to reload feature flags after setting the properties. Defaults to true.
440
+ */
441
+ resetPersonPropertiesForFlags(reloadFeatureFlags?: boolean): void;
442
+ /**
443
+ * Sets group properties for feature flag evaluation.
444
+ *
445
+ * These properties are automatically attached to the current group (set via agrid.group()).
446
+ * When you change the group, these properties are reset.
447
+ *
448
+ * {@label Feature flags}
449
+ *
450
+ * @example
451
+ * ```js
452
+ * // set group properties for flags
453
+ * agrid.setGroupPropertiesForFlags({'company': {'property1': 'value', property2: 'value2'}})
454
+ * ```
455
+ *
456
+ * @public
457
+ *
458
+ * @param properties The group properties to set for flag evaluation
459
+ * @param reloadFeatureFlags Whether to reload feature flags after setting the properties. Defaults to true.
460
+ */
461
+ setGroupPropertiesForFlags(properties: Record<string, Record<string, string>>, reloadFeatureFlags?: boolean): void;
462
+ /**
463
+ * Resets group properties for feature flag evaluation.
464
+ *
465
+ * {@label Feature flags}
466
+ *
467
+ * @example
468
+ * ```js
469
+ * // reset group properties for flags
470
+ * agrid.resetGroupPropertiesForFlags()
471
+ * ```
472
+ *
473
+ * @public
474
+ *
475
+ * @param reloadFeatureFlags Whether to reload feature flags after setting the properties. Defaults to true.
476
+ */
477
+ resetGroupPropertiesForFlags(reloadFeatureFlags?: boolean): void;
478
+ /**
479
+ * Captures a screen view event.
480
+ *
481
+ * @remarks
482
+ * This function requires a name. You may also pass in an optional properties object.
483
+ * Screen name is automatically registered for the session and will be included in subsequent events.
484
+ *
485
+ * {@label Capture}
486
+ *
487
+ * @example
488
+ * ```js
489
+ * // Basic screen capture
490
+ * agrid.screen('dashboard')
491
+ * ```
492
+ *
493
+ * @example
494
+ * ```js
495
+ * // Screen capture with properties
496
+ * agrid.screen('dashboard', {
497
+ * background: 'blue',
498
+ * hero: 'superhog',
499
+ * })
500
+ * ```
501
+ *
502
+ * @public
503
+ *
504
+ * @param name - The name of the screen
505
+ * @param properties - Optional properties to include with the screen event
506
+ * @param options - Optional capture options
507
+ */
508
+ screen(name: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): Promise<void>;
509
+ _isEnableSessionReplay(): boolean;
510
+ _resetSessionId(reactNativeSessionReplay: typeof OptionalReactNativeSessionReplay | undefined, sessionId: string): void;
511
+ getSessionId(): string;
512
+ resetSessionId(): void;
513
+ /**
514
+ * Associates events with a specific user. Learn more about [identifying users](https://agrid.com/docs/product-analytics/identify)
515
+ *
516
+ * {@label Identification}
517
+ *
518
+ * @example
519
+ * ```js
520
+ * // Basic identify
521
+ * agrid.identify('distinctID', {
522
+ * email: 'user@agrid.com',
523
+ * name: 'My Name'
524
+ * })
525
+ * ```
526
+ *
527
+ * @example
528
+ * ```js
529
+ * // Using $set and $set_once
530
+ * agrid.identify('distinctID', {
531
+ * $set: {
532
+ * email: 'user@agrid.com',
533
+ * name: 'My Name'
534
+ * },
535
+ * $set_once: {
536
+ * date_of_first_log_in: '2024-03-01'
537
+ * }
538
+ * })
539
+ * ```
540
+ *
541
+ * @public
542
+ *
543
+ * @param distinctId - A unique identifier for your user. Typically either their email or database ID.
544
+ * @param properties - Optional dictionary with key:value pairs to set the person properties
545
+ * @param options - Optional capture options
546
+ */
547
+ identify(distinctId?: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): void;
548
+ /**
549
+ * Capture a caught exception manually
550
+ *
551
+ * {@label Error tracking}
552
+ *
553
+ * @public
554
+ *
555
+ * @example
556
+ * ```js
557
+ * // Capture a caught exception
558
+ * try {
559
+ * // something that might throw
560
+ * } catch (error) {
561
+ * agrid.captureException(error)
562
+ * }
563
+ * ```
564
+ *
565
+ * @example
566
+ * ```js
567
+ * // With additional properties
568
+ * agrid.captureException(error, {
569
+ * customProperty: 'value',
570
+ * anotherProperty: ['I', 'can be a list'],
571
+ * ...
572
+ * })
573
+ * ```
574
+ *
575
+ * @param {Error} error The error to capture
576
+ * @param {Object} [additionalProperties] Any additional properties to add to the error event
577
+ * @returns {void}
578
+ */
579
+ captureException(error: Error | unknown, additionalProperties?: PostHogEventProperties): void;
580
+ initReactNativeNavigation(options: AgridAutocaptureOptions): boolean;
581
+ getSurveys(): Promise<SurveyResponse['surveys']>;
582
+ /**
583
+ * Returns a promise that resolves when surveys are ready to be loaded.
584
+ * If surveys are already loaded and ready to go, returns a resolved promise instead.
585
+ * @internal
586
+ */
587
+ _onSurveysReady(): Promise<void>;
588
+ private _surveysReadyResolve;
589
+ /**
590
+ * Helper function to cache surveys to storage with consistent logging
591
+ */
592
+ private _cacheSurveys;
593
+ /**
594
+ * Internal method to notify that surveys are ready
595
+ */
596
+ private _notifySurveysReady;
597
+ /**
598
+ * Handle surveys from remote config response
599
+ */
600
+ private _handleSurveysFromRemoteConfig;
601
+ /**
602
+ * Load flags AND handle surveys from the flags response (only when remote config is disabled)
603
+ */
604
+ private _flagsAsyncWithSurveys;
605
+ /**
606
+ * Internal method to load surveys from API (when remote config is disabled)
607
+ */
608
+ private _loadSurveysFromAPI;
609
+ private startSessionReplay;
610
+ private captureAppLifecycleEvents;
611
+ private persistAppVersion;
612
+ }
@@ -0,0 +1 @@
1
+ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.Agrid=void 0;Object.defineProperty(exports,"PostHogPersistedProperty",{enumerable:true,get:function get(){return _core.PostHogPersistedProperty;}});var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _get2=_interopRequireDefault(require("@babel/runtime/helpers/get"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _reactNative=require("react-native");var _core=require("@agrid/core");var _storage=require("./storage");var _version=require("./version");var _nativeDeps=require("./native-deps");var _wixNavigation=require("./frameworks/wix-navigation");var _OptionalSessionReplay=require("./optional/OptionalSessionReplay");var _errorTracking=require("./error-tracking");function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _callSuper(t,o,e){return o=(0,_getPrototypeOf2["default"])(o),(0,_possibleConstructorReturn2["default"])(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],(0,_getPrototypeOf2["default"])(t).constructor):o.apply(t,e));}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=(0,_get2["default"])((0,_getPrototypeOf2["default"])(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}var Agrid=exports.Agrid=function(_PostHogCore){function Agrid(apiKey,options){var _this;(0,_classCallCheck2["default"])(this,Agrid);var _a,_b,_c,_d,_e;_this=_callSuper(this,Agrid,[apiKey,options]);_this._appProperties={};_this._surveysReadyPromise=null;_this._surveysReady=false;_this._surveysReadyResolve=null;_this._isInitialized=false;_this._persistence=(_a=options===null||options===void 0?void 0:options.persistence)!==null&&_a!==void 0?_a:'file';_this._disableSurveys=(_b=options===null||options===void 0?void 0:options.disableSurveys)!==null&&_b!==void 0?_b:false;_this._disableRemoteConfig=(_c=options===null||options===void 0?void 0:options.disableRemoteConfig)!==null&&_c!==void 0?_c:false;_this._errorTracking=new _errorTracking.ErrorTracking(_this,options===null||options===void 0?void 0:options.errorTracking,_this._logger);_this._setDefaultPersonProperties=(_d=options===null||options===void 0?void 0:options.setDefaultPersonProperties)!==null&&_d!==void 0?_d:true;_this._appProperties=typeof(options===null||options===void 0?void 0:options.customAppProperties)==='function'?options.customAppProperties((0,_nativeDeps.getAppProperties)()):(options===null||options===void 0?void 0:options.customAppProperties)||(0,_nativeDeps.getAppProperties)();_reactNative.AppState.addEventListener('change',function(state){if(state==='unknown'){return;}void _this.flush()["catch"](function(){var _ref=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(err){return _regenerator["default"].wrap(function(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=1;return(0,_core.logFlushError)(err);case 1:case"end":return _context.stop();}},_callee);}));return function(_x3){return _ref.apply(this,arguments);};}());if(state==='active'){_this.getSessionId();}});var storagePromise;if(_this._persistence==='file'){_this._storage=new _storage.AgridRNStorage((_e=options===null||options===void 0?void 0:options.customStorage)!==null&&_e!==void 0?_e:(0,_nativeDeps.buildOptimisiticAsyncStorage)());storagePromise=_this._storage.preloadPromise;}else{_this._storage=new _storage.AgridRNSyncMemoryStorage();}if(storagePromise){storagePromise["catch"](function(error){console.error('Agrid storage initialization failed:',error);});}var initAfterStorage=function initAfterStorage(){var enablePersistSessionIdAcrossRestart=options===null||options===void 0?void 0:options.enablePersistSessionIdAcrossRestart;if(!enablePersistSessionIdAcrossRestart){_this.setPersistedProperty(_core.PostHogPersistedProperty.SessionId,null);_this.setPersistedProperty(_core.PostHogPersistedProperty.SessionLastTimestamp,null);_this.setPersistedProperty(_core.PostHogPersistedProperty.SessionStartTimestamp,null);}_this.setupBootstrap(options);if(_this._setDefaultPersonProperties){_this._setDefaultPersonPropertiesForFlags(false);}_this._isInitialized=true;if(_this._disableRemoteConfig===false){_this.reloadRemoteConfigAsync().then(function(response){if(response){_this._handleSurveysFromRemoteConfig(response);}})["catch"](function(error){_this._logger.error('Error loading remote config:',error);})["finally"](function(){_this._notifySurveysReady();});}else{_this._logger.info('Remote config is disabled.');if((options===null||options===void 0?void 0:options.preloadFeatureFlags)!==false){_this._logger.info('Feature flags will be preloaded from Flags API.');_this._flagsAsyncWithSurveys()["catch"](function(error){_this._logger.error('Error loading flags with surveys:',error);})["finally"](function(){_this._notifySurveysReady();});}else{_this._logger.info('preloadFeatureFlags is disabled, loading surveys from API.');_this._loadSurveysFromAPI()["catch"](function(error){_this._logger.error('Error loading surveys from API:',error);})["finally"](function(){_this._notifySurveysReady();});}}if(options===null||options===void 0?void 0:options.captureAppLifecycleEvents){void _this.captureAppLifecycleEvents();}void _this.persistAppVersion();void _this.startSessionReplay(options);};if(storagePromise){_this._initPromise=storagePromise.then(initAfterStorage);}else{_this._initPromise=Promise.resolve();initAfterStorage();}return _this;}(0,_inherits2["default"])(Agrid,_PostHogCore);return(0,_createClass2["default"])(Agrid,[{key:"ready",value:(function(){var _ready=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(){return _regenerator["default"].wrap(function(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.next=1;return this._initPromise;case 1:case"end":return _context2.stop();}},_callee2,this);}));function ready(){return _ready.apply(this,arguments);}return ready;}())},{key:"getPersistedProperty",value:function getPersistedProperty(key){return this._storage.getItem(key);}},{key:"setPersistedProperty",value:function setPersistedProperty(key,value){return value!==null?this._storage.setItem(key,value):this._storage.removeItem(key);}},{key:"fetch",value:function(_fetch){function fetch(_x,_x2){return _fetch.apply(this,arguments);}fetch.toString=function(){return _fetch.toString();};return fetch;}(function(url,options){return fetch(url,options);})},{key:"getLibraryId",value:function getLibraryId(){return'agrid-react-native';}},{key:"getLibraryVersion",value:function getLibraryVersion(){return _version.version;}},{key:"getCustomUserAgent",value:function getCustomUserAgent(){if(_reactNative.Platform.OS==='web'){return'';}return"".concat(this.getLibraryId(),"/").concat(this.getLibraryVersion());}},{key:"getCommonEventProperties",value:function getCommonEventProperties(){return _objectSpread(_objectSpread(_objectSpread({},_superPropGet(Agrid,"getCommonEventProperties",this,3)([])),this._appProperties),{},{$screen_height:_reactNative.Dimensions.get('screen').height,$screen_width:_reactNative.Dimensions.get('screen').width});}},{key:"register",value:function register(properties){return _superPropGet(Agrid,"register",this,3)([properties]);}},{key:"unregister",value:function unregister(property){return _superPropGet(Agrid,"unregister",this,3)([property]);}},{key:"reset",value:function reset(){_superPropGet(Agrid,"reset",this,3)([]);if(this._setDefaultPersonProperties){this._setDefaultPersonPropertiesForFlags(false);}}},{key:"_setDefaultPersonPropertiesForFlags",value:function _setDefaultPersonPropertiesForFlags(){var _this2=this;var reloadFeatureFlags=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var defaultProps={};var relevantKeys=['$app_version','$app_build','$app_namespace','$os_name','$os_version','$device_type'];relevantKeys.forEach(function(key){var value=_this2._appProperties[key];if(value!==null&&value!==undefined){defaultProps[key]=String(value);}});var commonProps=this.getCommonEventProperties();if(commonProps.$lib){defaultProps.$lib=String(commonProps.$lib);}if(commonProps.$lib_version){defaultProps.$lib_version=String(commonProps.$lib_version);}if(Object.keys(defaultProps).length>0){this.setPersonPropertiesForFlags(defaultProps,reloadFeatureFlags);}}},{key:"flush",value:function flush(){return _superPropGet(Agrid,"flush",this,3)([]);}},{key:"optIn",value:function optIn(){return _superPropGet(Agrid,"optIn",this,3)([]);}},{key:"optOut",value:function optOut(){return _superPropGet(Agrid,"optOut",this,3)([]);}},{key:"isFeatureEnabled",value:function isFeatureEnabled(key){return _superPropGet(Agrid,"isFeatureEnabled",this,3)([key]);}},{key:"getFeatureFlag",value:function getFeatureFlag(key){return _superPropGet(Agrid,"getFeatureFlag",this,3)([key]);}},{key:"getFeatureFlagPayload",value:function getFeatureFlagPayload(key){return _superPropGet(Agrid,"getFeatureFlagPayload",this,3)([key]);}},{key:"reloadFeatureFlags",value:function reloadFeatureFlags(){_superPropGet(Agrid,"reloadFeatureFlags",this,3)([]);}},{key:"reloadFeatureFlagsAsync",value:function reloadFeatureFlagsAsync(){return _superPropGet(Agrid,"reloadFeatureFlagsAsync",this,3)([]);}},{key:"group",value:function group(groupType,groupKey,properties){_superPropGet(Agrid,"group",this,3)([groupType,groupKey,properties]);if(properties&&Object.keys(properties).length>0){var propsToCache={};Object.keys(properties).forEach(function(key){var value=properties[key];if(value!==null&&value!==undefined){propsToCache[key]=String(value);}});if(Object.keys(propsToCache).length>0){this.setGroupPropertiesForFlags((0,_defineProperty2["default"])({},groupType,propsToCache));}}}},{key:"alias",value:function alias(_alias){_superPropGet(Agrid,"alias",this,3)([_alias]);}},{key:"getDistinctId",value:function getDistinctId(){return _superPropGet(Agrid,"getDistinctId",this,3)([]);}},{key:"setPersonPropertiesForFlags",value:function setPersonPropertiesForFlags(properties){var reloadFeatureFlags=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;_superPropGet(Agrid,"setPersonPropertiesForFlags",this,3)([properties]);if(reloadFeatureFlags){this.reloadFeatureFlags();}}},{key:"resetPersonPropertiesForFlags",value:function resetPersonPropertiesForFlags(){var reloadFeatureFlags=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;_superPropGet(Agrid,"resetPersonPropertiesForFlags",this,3)([]);if(reloadFeatureFlags){this.reloadFeatureFlags();}}},{key:"setGroupPropertiesForFlags",value:function setGroupPropertiesForFlags(properties){var reloadFeatureFlags=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;_superPropGet(Agrid,"setGroupPropertiesForFlags",this,3)([properties]);if(reloadFeatureFlags){this.reloadFeatureFlags();}}},{key:"resetGroupPropertiesForFlags",value:function resetGroupPropertiesForFlags(){var reloadFeatureFlags=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;_superPropGet(Agrid,"resetGroupPropertiesForFlags",this,3)([]);if(reloadFeatureFlags){this.reloadFeatureFlags();}}},{key:"screen",value:(function(){var _screen=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(name,properties,options){return _regenerator["default"].wrap(function(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=1;return this._initPromise;case 1:this.registerForSession({$screen_name:name});return _context3.abrupt("return",this.capture('$screen',_objectSpread(_objectSpread({},properties),{},{$screen_name:name}),options));case 2:case"end":return _context3.stop();}},_callee3,this);}));function screen(_x4,_x5,_x6){return _screen.apply(this,arguments);}return screen;}())},{key:"_isEnableSessionReplay",value:function _isEnableSessionReplay(){var _a;return!this.isDisabled&&((_a=this._enableSessionReplay)!==null&&_a!==void 0?_a:false);}},{key:"_resetSessionId",value:function _resetSessionId(reactNativeSessionReplay,sessionId){if(reactNativeSessionReplay){reactNativeSessionReplay.endSession();reactNativeSessionReplay.startSession(sessionId);}}},{key:"getSessionId",value:function getSessionId(){var sessionId=_superPropGet(Agrid,"getSessionId",this,3)([]);if(!this._isEnableSessionReplay()){return sessionId;}if(sessionId.length>0&&this._currentSessionId&&sessionId!==this._currentSessionId){if(_OptionalSessionReplay.OptionalReactNativeSessionReplay){try{this._resetSessionId(_OptionalSessionReplay.OptionalReactNativeSessionReplay,String(sessionId));this._logger.info("sessionId rotated from ".concat(this._currentSessionId," to ").concat(sessionId,"."));}catch(e){this._logger.error("Failed to rotate sessionId: ".concat(e,"."));}}this._currentSessionId=sessionId;}else{this._logger.info("sessionId not rotated, sessionId ".concat(sessionId," and currentSessionId ").concat(this._currentSessionId,"."));}return sessionId;}},{key:"resetSessionId",value:function resetSessionId(){_superPropGet(Agrid,"resetSessionId",this,3)([]);if(this._isEnableSessionReplay()&&_OptionalSessionReplay.OptionalReactNativeSessionReplay){try{_OptionalSessionReplay.OptionalReactNativeSessionReplay.endSession();this._logger.info("Session replay ended.");}catch(e){this._logger.error("Session replay failed to end: ".concat(e,"."));}}}},{key:"identify",value:function identify(distinctId,properties,options){var previousDistinctId=this.getDistinctId();_superPropGet(Agrid,"identify",this,3)([distinctId,properties,options]);var userProps=(properties===null||properties===void 0?void 0:properties.$set)||properties;if(userProps&&Object.keys(userProps).length>0){var propsToCache={};Object.entries(userProps).forEach(function(_ref2){var _ref3=(0,_slicedToArray2["default"])(_ref2,2),key=_ref3[0],value=_ref3[1];if(value!==null&&value!==undefined){propsToCache[key]=String(value);}});if(Object.keys(propsToCache).length>0){var shouldReloadFlags=distinctId===previousDistinctId;this.setPersonPropertiesForFlags(propsToCache,shouldReloadFlags);}}if(this._isEnableSessionReplay()&&_OptionalSessionReplay.OptionalReactNativeSessionReplay){try{distinctId=distinctId||previousDistinctId;var anonymousId=this.getAnonymousId();_OptionalSessionReplay.OptionalReactNativeSessionReplay.identify(String(distinctId),String(anonymousId));this._logger.info("Session replay identified with distinctId ".concat(distinctId," and anonymousId ").concat(anonymousId,"."));}catch(e){this._logger.error("Session replay failed to identify: ".concat(e,"."));}}}},{key:"captureException",value:function captureException(error){var additionalProperties=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var syntheticException=new Error('Synthetic Error');this._errorTracking.captureException(error,additionalProperties,{mechanism:{handled:true,type:'generic'},syntheticException:syntheticException});}},{key:"initReactNativeNavigation",value:function initReactNativeNavigation(options){return(0,_wixNavigation.withReactNativeNavigation)(this,options);}},{key:"getSurveys",value:function(){var _getSurveys=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(){var surveys;return _regenerator["default"].wrap(function(_context4){while(1)switch(_context4.prev=_context4.next){case 0:if(!(this._disableSurveys===true)){_context4.next=1;break;}this._logger.info('Loading surveys is disabled.');this._cacheSurveys(null,'disabled in config');return _context4.abrupt("return",[]);case 1:surveys=this.getPersistedProperty(_core.PostHogPersistedProperty.Surveys);if(!(surveys&&surveys.length>0)){_context4.next=2;break;}this._logger.info('Surveys fetched from storage: ',JSON.stringify(surveys));return _context4.abrupt("return",surveys);case 2:this._logger.info('No surveys found in storage');return _context4.abrupt("return",[]);case 3:case"end":return _context4.stop();}},_callee4,this);}));function getSurveys(){return _getSurveys.apply(this,arguments);}return getSurveys;}()},{key:"_onSurveysReady",value:function _onSurveysReady(){var _this3=this;if(this._surveysReady){return Promise.resolve();}if(!this._surveysReadyPromise){this._surveysReadyPromise=new Promise(function(resolve){_this3._surveysReadyResolve=resolve;});}return this._surveysReadyPromise;}},{key:"_cacheSurveys",value:function _cacheSurveys(surveys,source){this.setPersistedProperty(_core.PostHogPersistedProperty.Surveys,surveys);if(surveys&&surveys.length>0){this._logger.info("Surveys cached from ".concat(source,":"),JSON.stringify(surveys));}else if(surveys===null){this._logger.info("Surveys cleared (".concat(source,")"));}else{this._logger.info("No surveys to cache from ".concat(source,")"));}}},{key:"_notifySurveysReady",value:function _notifySurveysReady(){this._surveysReady=true;if(this._surveysReadyResolve){this._surveysReadyResolve();this._surveysReadyResolve=null;this._surveysReadyPromise=null;}}},{key:"_handleSurveysFromRemoteConfig",value:function _handleSurveysFromRemoteConfig(response){if(this._disableSurveys===true){this._logger.info('Loading surveys skipped, disabled.');this._cacheSurveys(null,'remote config (disabled)');return;}var surveys=response.surveys;if(Array.isArray(surveys)&&surveys.length>0){this._cacheSurveys(surveys,'remote config');}else{this._cacheSurveys(null,'remote config');}}},{key:"_flagsAsyncWithSurveys",value:(function(){var _flagsAsyncWithSurveys2=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(){var flagsResponse,surveys,_t;return _regenerator["default"].wrap(function(_context5){while(1)switch(_context5.prev=_context5.next){case 0:_context5.prev=0;_context5.next=1;return this.flagsAsync(true,true);case 1:flagsResponse=_context5.sent;if(!(this._disableRemoteConfig===true)){_context5.next=3;break;}if(!(this._disableSurveys===true)){_context5.next=2;break;}this._logger.info('Loading surveys skipped, disabled.');this._cacheSurveys(null,'flags (disabled)');return _context5.abrupt("return");case 2:surveys=flagsResponse===null||flagsResponse===void 0?void 0:flagsResponse.surveys;if(Array.isArray(surveys)&&surveys.length>0){this._cacheSurveys(surveys,'flags endpoint');}else{this._logger.info('No surveys in flags response');this._cacheSurveys(null,'flags endpoint');}case 3:_context5.next=5;break;case 4:_context5.prev=4;_t=_context5["catch"](0);this._logger.error('Error in _flagsAsyncWithSurveys:',_t);case 5:case"end":return _context5.stop();}},_callee5,this,[[0,4]]);}));function _flagsAsyncWithSurveys(){return _flagsAsyncWithSurveys2.apply(this,arguments);}return _flagsAsyncWithSurveys;}())},{key:"_loadSurveysFromAPI",value:(function(){var _loadSurveysFromAPI2=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(){var surveysFromApi,_t2;return _regenerator["default"].wrap(function(_context6){while(1)switch(_context6.prev=_context6.next){case 0:if(!(this._disableSurveys===true)){_context6.next=1;break;}this._logger.info('Loading surveys skipped, disabled.');this._cacheSurveys(null,'API (disabled)');return _context6.abrupt("return");case 1:_context6.prev=1;_context6.next=2;return _superPropGet(Agrid,"getSurveysStateless",this,3)([]);case 2:surveysFromApi=_context6.sent;if(surveysFromApi&&surveysFromApi.length>0){this._cacheSurveys(surveysFromApi,'API');}else{this._cacheSurveys(null,'API');}_context6.next=4;break;case 3:_context6.prev=3;_t2=_context6["catch"](1);this._logger.error('Error loading surveys from API:',_t2);case 4:case"end":return _context6.stop();}},_callee6,this,[[1,3]]);}));function _loadSurveysFromAPI(){return _loadSurveysFromAPI2.apply(this,arguments);}return _loadSurveysFromAPI;}())},{key:"startSessionReplay",value:function(){var _startSessionReplay=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7(options){var _a,_b,_c,_d,_e,_f,_g,defaultThrottleDelayMs,_ref4,_ref4$maskAllTextInpu,maskAllTextInputs,_ref4$maskAllImages,maskAllImages,_ref4$maskAllSandboxe,maskAllSandboxedViews,_ref4$captureLog,captureLog,_ref4$captureNetworkT,captureNetworkTelemetry,_ref4$iOSdebouncerDel,iOSdebouncerDelayMs,_ref4$androidDebounce,androidDebouncerDelayMs,throttleDelayMs,sdkReplayConfig,sessionReplay,featureFlags,cachedFeatureFlags,cachedSessionReplayConfig,recordingActive,linkedFlag,value,flag,variant,_value,sessionId,sdkOptions,_t3;return _regenerator["default"].wrap(function(_context7){while(1)switch(_context7.prev=_context7.next){case 0:this._enableSessionReplay=options===null||options===void 0?void 0:options.enableSessionReplay;if(this._isEnableSessionReplay()){_context7.next=1;break;}this._logger.info('Session replay is not enabled.');return _context7.abrupt("return");case 1:defaultThrottleDelayMs=1000;_ref4=(_a=options===null||options===void 0?void 0:options.sessionReplayConfig)!==null&&_a!==void 0?_a:{},_ref4$maskAllTextInpu=_ref4.maskAllTextInputs,maskAllTextInputs=_ref4$maskAllTextInpu===void 0?true:_ref4$maskAllTextInpu,_ref4$maskAllImages=_ref4.maskAllImages,maskAllImages=_ref4$maskAllImages===void 0?true:_ref4$maskAllImages,_ref4$maskAllSandboxe=_ref4.maskAllSandboxedViews,maskAllSandboxedViews=_ref4$maskAllSandboxe===void 0?true:_ref4$maskAllSandboxe,_ref4$captureLog=_ref4.captureLog,captureLog=_ref4$captureLog===void 0?true:_ref4$captureLog,_ref4$captureNetworkT=_ref4.captureNetworkTelemetry,captureNetworkTelemetry=_ref4$captureNetworkT===void 0?true:_ref4$captureNetworkT,_ref4$iOSdebouncerDel=_ref4.iOSdebouncerDelayMs,iOSdebouncerDelayMs=_ref4$iOSdebouncerDel===void 0?defaultThrottleDelayMs:_ref4$iOSdebouncerDel,_ref4$androidDebounce=_ref4.androidDebouncerDelayMs,androidDebouncerDelayMs=_ref4$androidDebounce===void 0?defaultThrottleDelayMs:_ref4$androidDebounce;throttleDelayMs=(_c=(_b=options===null||options===void 0?void 0:options.sessionReplayConfig)===null||_b===void 0?void 0:_b.throttleDelayMs)!==null&&_c!==void 0?_c:defaultThrottleDelayMs;if(throttleDelayMs===defaultThrottleDelayMs&&(iOSdebouncerDelayMs!==defaultThrottleDelayMs||androidDebouncerDelayMs!==defaultThrottleDelayMs)){throttleDelayMs=Math.max(iOSdebouncerDelayMs,androidDebouncerDelayMs);}sdkReplayConfig={maskAllTextInputs:maskAllTextInputs,maskAllImages:maskAllImages,maskAllSandboxedViews:maskAllSandboxedViews,captureLog:captureLog,captureNetworkTelemetry:captureNetworkTelemetry,iOSdebouncerDelayMs:iOSdebouncerDelayMs,androidDebouncerDelayMs:androidDebouncerDelayMs,throttleDelayMs:throttleDelayMs};this._logger.info("Session replay SDK config: ".concat(JSON.stringify(sdkReplayConfig)));sessionReplay=(_d=this.getPersistedProperty(_core.PostHogPersistedProperty.SessionReplay))!==null&&_d!==void 0?_d:{};featureFlags=(_e=this.getKnownFeatureFlags())!==null&&_e!==void 0?_e:{};cachedFeatureFlags=(_f=featureFlags)!==null&&_f!==void 0?_f:{};cachedSessionReplayConfig=(_g=sessionReplay)!==null&&_g!==void 0?_g:{};this._logger.info('Session replay feature flags from flags cached config:',JSON.stringify(cachedFeatureFlags));this._logger.info("Session replay session recording from flags cached config: ".concat(JSON.stringify(cachedSessionReplayConfig)));recordingActive=true;linkedFlag=cachedSessionReplayConfig['linkedFlag'];if(typeof linkedFlag==='string'){value=cachedFeatureFlags[linkedFlag];if(typeof value==='boolean'){recordingActive=value;}else if(typeof value==='string'){recordingActive=true;}else{recordingActive=false;}this._logger.info("Session replay '".concat(linkedFlag,"' linked flag value: '").concat(value,"'"));}else if(linkedFlag&&(0,_typeof2["default"])(linkedFlag)==='object'){flag=linkedFlag['flag'];variant=linkedFlag['variant'];if(flag&&variant){_value=cachedFeatureFlags[flag];recordingActive=_value===variant;this._logger.info("Session replay '".concat(flag,"' linked flag variant '").concat(variant,"' and value '").concat(_value,"'"));}else{this._logger.info("Session replay '".concat(flag,"' linked flag variant: '").concat(variant,"' does not exist/quota limited."));recordingActive=false;}}else{this._logger.info("Session replay has no cached linkedFlag.");}if(!recordingActive){_context7.next=12;break;}if(!_OptionalSessionReplay.OptionalReactNativeSessionReplay){_context7.next=10;break;}sessionId=this.getSessionId();if(!(sessionId.length===0)){_context7.next=2;break;}this._logger.warn("Session replay enabled but no sessionId found.");return _context7.abrupt("return");case 2:sdkOptions={apiKey:this.apiKey,host:this.host,debug:this.isDebug,distinctId:this.getDistinctId(),anonymousId:this.getAnonymousId(),sdkVersion:this.getLibraryVersion(),flushAt:this.flushAt};this._logger.info("Session replay sdk options: ".concat(JSON.stringify(sdkOptions)));_context7.prev=3;_context7.next=4;return _OptionalSessionReplay.OptionalReactNativeSessionReplay.isEnabled();case 4:if(_context7.sent){_context7.next=6;break;}_context7.next=5;return _OptionalSessionReplay.OptionalReactNativeSessionReplay.start(String(sessionId),sdkOptions,sdkReplayConfig,cachedSessionReplayConfig);case 5:this._logger.info("Session replay started with sessionId ".concat(sessionId,"."));_context7.next=7;break;case 6:this._resetSessionId(_OptionalSessionReplay.OptionalReactNativeSessionReplay,String(sessionId));this._logger.info("Session replay already started with sessionId ".concat(sessionId,"."));case 7:this._currentSessionId=sessionId;_context7.next=9;break;case 8:_context7.prev=8;_t3=_context7["catch"](3);this._logger.error("Session replay failed to start: ".concat(_t3,"."));case 9:_context7.next=11;break;case 10:this._logger.warn('Session replay enabled but not installed.');case 11:_context7.next=13;break;case 12:this._logger.info('Session replay disabled.');case 13:case"end":return _context7.stop();}},_callee7,this,[[3,8]]);}));function startSessionReplay(_x7){return _startSessionReplay.apply(this,arguments);}return startSessionReplay;}()},{key:"captureAppLifecycleEvents",value:function(){var _captureAppLifecycleEvents=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee8(){var _this4=this;var _a,appBuild,appVersion,isMemoryPersistence,properties,prevAppBuild,prevAppVersion,initialUrl,_t4,_t5,_t6;return _regenerator["default"].wrap(function(_context8){while(1)switch(_context8.prev=_context8.next){case 0:appBuild=this._appProperties.$app_build;appVersion=this._appProperties.$app_version;isMemoryPersistence=this._persistence==='memory';properties={};if(!isMemoryPersistence){prevAppBuild=this.getPersistedProperty(_core.PostHogPersistedProperty.InstalledAppBuild);prevAppVersion=this.getPersistedProperty(_core.PostHogPersistedProperty.InstalledAppVersion);if(!appBuild||!appVersion){this._logger.warn('Agrid could not track installation/update/open, as the build and version were not set. '+'This can happen if some dependencies are not installed correctly, or if you have provided'+'customAppProperties but not included $app_build or $app_version.');}if(appBuild){if(!prevAppBuild){this.capture('Application Installed',properties);}else if(prevAppBuild!==appBuild){this.capture('Application Updated',_objectSpread(_objectSpread(_objectSpread({},(0,_core.maybeAdd)('previous_version',prevAppVersion)),(0,_core.maybeAdd)('previous_build',prevAppBuild)),properties));}}}else{this._logger.warn('Agrid was initialised with persistence set to "memory", capturing native app events (Application Installed and Application Updated) is not supported.');}_context8.next=1;return _reactNative.Linking.getInitialURL();case 1:_t5=_a=_context8.sent;_t4=_t5!==null;if(!_t4){_context8.next=2;break;}_t4=_a!==void 0;case 2:if(!_t4){_context8.next=3;break;}_t6=_a;_context8.next=4;break;case 3:_t6=undefined;case 4:initialUrl=_t6;this.capture('Application Opened',_objectSpread(_objectSpread({},properties),(0,_core.maybeAdd)('url',initialUrl)));_reactNative.AppState.addEventListener('change',function(state){if(state==='active'){_this4.capture('Application Became Active');}else if(state==='background'){_this4.capture('Application Backgrounded');}});case 5:case"end":return _context8.stop();}},_callee8,this);}));function captureAppLifecycleEvents(){return _captureAppLifecycleEvents.apply(this,arguments);}return captureAppLifecycleEvents;}()},{key:"persistAppVersion",value:function(){var _persistAppVersion=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee9(){var appBuild,appVersion;return _regenerator["default"].wrap(function(_context9){while(1)switch(_context9.prev=_context9.next){case 0:appBuild=this._appProperties.$app_build;appVersion=this._appProperties.$app_version;this.setPersistedProperty(_core.PostHogPersistedProperty.InstalledAppBuild,appBuild);this.setPersistedProperty(_core.PostHogPersistedProperty.InstalledAppVersion,appVersion);case 1:case"end":return _context9.stop();}},_callee9,this);}));function persistAppVersion(){return _persistAppVersion.apply(this,arguments);}return persistAppVersion;}()}]);}(_core.PostHogCore);