expo-facebook-analytics 1.0.0

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 (46) hide show
  1. package/README.md +242 -0
  2. package/android/build.gradle +60 -0
  3. package/android/src/main/java/com/nitrofbanalytics/HybridFacebookAnalytics.kt +139 -0
  4. package/app.plugin.js +1 -0
  5. package/expo-facebook-analytics.podspec +31 -0
  6. package/ios/HybridFacebookAnalytics.swift +135 -0
  7. package/lib/index.d.ts +58 -0
  8. package/lib/index.js +138 -0
  9. package/lib/specs/FacebookAnalytics.nitro.d.ts +20 -0
  10. package/lib/specs/FacebookAnalytics.nitro.js +2 -0
  11. package/lib/types.d.ts +65 -0
  12. package/lib/types.js +52 -0
  13. package/nitro.json +19 -0
  14. package/nitrogen/generated/.gitattributes +1 -0
  15. package/nitrogen/generated/android/NitroFBAnalytics+autolinking.cmake +81 -0
  16. package/nitrogen/generated/android/NitroFBAnalytics+autolinking.gradle +27 -0
  17. package/nitrogen/generated/android/NitroFBAnalyticsOnLoad.cpp +44 -0
  18. package/nitrogen/generated/android/NitroFBAnalyticsOnLoad.hpp +25 -0
  19. package/nitrogen/generated/android/c++/JHybridFacebookAnalyticsSpec.cpp +157 -0
  20. package/nitrogen/generated/android/c++/JHybridFacebookAnalyticsSpec.hpp +79 -0
  21. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitrofbanalytics/HybridFacebookAnalyticsSpec.kt +110 -0
  22. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitrofbanalytics/NitroFBAnalyticsOnLoad.kt +35 -0
  23. package/nitrogen/generated/ios/NitroFBAnalytics+autolinking.rb +60 -0
  24. package/nitrogen/generated/ios/NitroFBAnalytics-Swift-Cxx-Bridge.cpp +49 -0
  25. package/nitrogen/generated/ios/NitroFBAnalytics-Swift-Cxx-Bridge.hpp +171 -0
  26. package/nitrogen/generated/ios/NitroFBAnalytics-Swift-Cxx-Umbrella.hpp +47 -0
  27. package/nitrogen/generated/ios/NitroFBAnalyticsAutolinking.mm +33 -0
  28. package/nitrogen/generated/ios/NitroFBAnalyticsAutolinking.swift +26 -0
  29. package/nitrogen/generated/ios/c++/HybridFacebookAnalyticsSpecSwift.cpp +11 -0
  30. package/nitrogen/generated/ios/c++/HybridFacebookAnalyticsSpecSwift.hpp +167 -0
  31. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  32. package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +54 -0
  33. package/nitrogen/generated/ios/swift/HybridFacebookAnalyticsSpec.swift +69 -0
  34. package/nitrogen/generated/ios/swift/HybridFacebookAnalyticsSpec_cxx.swift +410 -0
  35. package/nitrogen/generated/shared/c++/HybridFacebookAnalyticsSpec.cpp +34 -0
  36. package/nitrogen/generated/shared/c++/HybridFacebookAnalyticsSpec.hpp +78 -0
  37. package/package.json +66 -0
  38. package/plugin/build/index.d.ts +13 -0
  39. package/plugin/build/index.js +42 -0
  40. package/plugin/build/withFacebookAnalyticsAndroid.d.ts +14 -0
  41. package/plugin/build/withFacebookAnalyticsAndroid.js +67 -0
  42. package/plugin/build/withFacebookAnalyticsIOS.d.ts +16 -0
  43. package/plugin/build/withFacebookAnalyticsIOS.js +96 -0
  44. package/src/index.ts +161 -0
  45. package/src/specs/FacebookAnalytics.nitro.ts +47 -0
  46. package/src/types.ts +67 -0
@@ -0,0 +1,410 @@
1
+ ///
2
+ /// HybridFacebookAnalyticsSpec_cxx.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * A class implementation that bridges HybridFacebookAnalyticsSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridFacebookAnalyticsSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::fbanalytics::bridge::swift`)
23
+ * from `NitroFBAnalytics-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.fbanalytics.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridFacebookAnalyticsSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridFacebookAnalyticsSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridFacebookAnalyticsSpec_
37
+
38
+ /**
39
+ * Create a new `HybridFacebookAnalyticsSpec_cxx` that wraps the given `HybridFacebookAnalyticsSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridFacebookAnalyticsSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridFacebookAnalyticsSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridFacebookAnalyticsSpec() -> any HybridFacebookAnalyticsSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridFacebookAnalyticsSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridFacebookAnalyticsSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridFacebookAnalyticsSpec_cxx {
70
+ return Unmanaged<HybridFacebookAnalyticsSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridFacebookAnalyticsSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridFacebookAnalyticsSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if Bool(fromCxx: cachedCxxPart) {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridFacebookAnalyticsSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridFacebookAnalyticsSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Compares this object with the given [other] object for reference equality.
101
+ */
102
+ @inline(__always)
103
+ public func equals(other: HybridFacebookAnalyticsSpec_cxx) -> Bool {
104
+ return self.__implementation === other.__implementation
105
+ }
106
+
107
+ /**
108
+ * Call dispose() on the Swift class.
109
+ * This _may_ be called manually from JS.
110
+ */
111
+ @inline(__always)
112
+ public func dispose() {
113
+ self.__implementation.dispose()
114
+ }
115
+
116
+ /**
117
+ * Call toString() on the Swift class.
118
+ */
119
+ @inline(__always)
120
+ public func toString() -> String {
121
+ return self.__implementation.toString()
122
+ }
123
+
124
+ // Properties
125
+
126
+
127
+ // Methods
128
+ @inline(__always)
129
+ public final func logEvent(eventName: std.string, valueToSum: Double, params: bridge.std__unordered_map_std__string__std__string_) -> bridge.Result_void_ {
130
+ do {
131
+ try self.__implementation.logEvent(eventName: String(eventName), valueToSum: valueToSum, params: { () -> Dictionary<String, String> in
132
+ var __dictionary = Dictionary<String, String>(minimumCapacity: params.size())
133
+ let __keys = bridge.get_std__unordered_map_std__string__std__string__keys(params)
134
+ for __key in __keys {
135
+ let __value = bridge.get_std__unordered_map_std__string__std__string__value(params, __key)
136
+ __dictionary[String(__key)] = String(__value)
137
+ }
138
+ return __dictionary
139
+ }())
140
+ return bridge.create_Result_void_()
141
+ } catch (let __error) {
142
+ let __exceptionPtr = __error.toCpp()
143
+ return bridge.create_Result_void_(__exceptionPtr)
144
+ }
145
+ }
146
+
147
+ @inline(__always)
148
+ public final func logEventWithoutParams(eventName: std.string, valueToSum: Double) -> bridge.Result_void_ {
149
+ do {
150
+ try self.__implementation.logEventWithoutParams(eventName: String(eventName), valueToSum: valueToSum)
151
+ return bridge.create_Result_void_()
152
+ } catch (let __error) {
153
+ let __exceptionPtr = __error.toCpp()
154
+ return bridge.create_Result_void_(__exceptionPtr)
155
+ }
156
+ }
157
+
158
+ @inline(__always)
159
+ public final func logPurchase(amount: Double, currency: std.string, params: bridge.std__unordered_map_std__string__std__string_) -> bridge.Result_void_ {
160
+ do {
161
+ try self.__implementation.logPurchase(amount: amount, currency: String(currency), params: { () -> Dictionary<String, String> in
162
+ var __dictionary = Dictionary<String, String>(minimumCapacity: params.size())
163
+ let __keys = bridge.get_std__unordered_map_std__string__std__string__keys(params)
164
+ for __key in __keys {
165
+ let __value = bridge.get_std__unordered_map_std__string__std__string__value(params, __key)
166
+ __dictionary[String(__key)] = String(__value)
167
+ }
168
+ return __dictionary
169
+ }())
170
+ return bridge.create_Result_void_()
171
+ } catch (let __error) {
172
+ let __exceptionPtr = __error.toCpp()
173
+ return bridge.create_Result_void_(__exceptionPtr)
174
+ }
175
+ }
176
+
177
+ @inline(__always)
178
+ public final func logPushNotificationOpen(payload: bridge.std__unordered_map_std__string__std__string_) -> bridge.Result_void_ {
179
+ do {
180
+ try self.__implementation.logPushNotificationOpen(payload: { () -> Dictionary<String, String> in
181
+ var __dictionary = Dictionary<String, String>(minimumCapacity: payload.size())
182
+ let __keys = bridge.get_std__unordered_map_std__string__std__string__keys(payload)
183
+ for __key in __keys {
184
+ let __value = bridge.get_std__unordered_map_std__string__std__string__value(payload, __key)
185
+ __dictionary[String(__key)] = String(__value)
186
+ }
187
+ return __dictionary
188
+ }())
189
+ return bridge.create_Result_void_()
190
+ } catch (let __error) {
191
+ let __exceptionPtr = __error.toCpp()
192
+ return bridge.create_Result_void_(__exceptionPtr)
193
+ }
194
+ }
195
+
196
+ @inline(__always)
197
+ public final func setUserID(userID: std.string) -> bridge.Result_void_ {
198
+ do {
199
+ try self.__implementation.setUserID(userID: String(userID))
200
+ return bridge.create_Result_void_()
201
+ } catch (let __error) {
202
+ let __exceptionPtr = __error.toCpp()
203
+ return bridge.create_Result_void_(__exceptionPtr)
204
+ }
205
+ }
206
+
207
+ @inline(__always)
208
+ public final func clearUserID() -> bridge.Result_void_ {
209
+ do {
210
+ try self.__implementation.clearUserID()
211
+ return bridge.create_Result_void_()
212
+ } catch (let __error) {
213
+ let __exceptionPtr = __error.toCpp()
214
+ return bridge.create_Result_void_(__exceptionPtr)
215
+ }
216
+ }
217
+
218
+ @inline(__always)
219
+ public final func getUserID() -> bridge.Result_std__optional_std__string__ {
220
+ do {
221
+ let __result = try self.__implementation.getUserID()
222
+ let __resultCpp = { () -> bridge.std__optional_std__string_ in
223
+ if let __unwrappedValue = __result {
224
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
225
+ } else {
226
+ return .init()
227
+ }
228
+ }()
229
+ return bridge.create_Result_std__optional_std__string__(__resultCpp)
230
+ } catch (let __error) {
231
+ let __exceptionPtr = __error.toCpp()
232
+ return bridge.create_Result_std__optional_std__string__(__exceptionPtr)
233
+ }
234
+ }
235
+
236
+ @inline(__always)
237
+ public final func setUserData(email: bridge.std__optional_std__string_, firstName: bridge.std__optional_std__string_, lastName: bridge.std__optional_std__string_, phone: bridge.std__optional_std__string_, dateOfBirth: bridge.std__optional_std__string_, gender: bridge.std__optional_std__string_, city: bridge.std__optional_std__string_, state: bridge.std__optional_std__string_, zip: bridge.std__optional_std__string_, country: bridge.std__optional_std__string_) -> bridge.Result_void_ {
238
+ do {
239
+ try self.__implementation.setUserData(email: { () -> String? in
240
+ if bridge.has_value_std__optional_std__string_(email) {
241
+ let __unwrapped = bridge.get_std__optional_std__string_(email)
242
+ return String(__unwrapped)
243
+ } else {
244
+ return nil
245
+ }
246
+ }(), firstName: { () -> String? in
247
+ if bridge.has_value_std__optional_std__string_(firstName) {
248
+ let __unwrapped = bridge.get_std__optional_std__string_(firstName)
249
+ return String(__unwrapped)
250
+ } else {
251
+ return nil
252
+ }
253
+ }(), lastName: { () -> String? in
254
+ if bridge.has_value_std__optional_std__string_(lastName) {
255
+ let __unwrapped = bridge.get_std__optional_std__string_(lastName)
256
+ return String(__unwrapped)
257
+ } else {
258
+ return nil
259
+ }
260
+ }(), phone: { () -> String? in
261
+ if bridge.has_value_std__optional_std__string_(phone) {
262
+ let __unwrapped = bridge.get_std__optional_std__string_(phone)
263
+ return String(__unwrapped)
264
+ } else {
265
+ return nil
266
+ }
267
+ }(), dateOfBirth: { () -> String? in
268
+ if bridge.has_value_std__optional_std__string_(dateOfBirth) {
269
+ let __unwrapped = bridge.get_std__optional_std__string_(dateOfBirth)
270
+ return String(__unwrapped)
271
+ } else {
272
+ return nil
273
+ }
274
+ }(), gender: { () -> String? in
275
+ if bridge.has_value_std__optional_std__string_(gender) {
276
+ let __unwrapped = bridge.get_std__optional_std__string_(gender)
277
+ return String(__unwrapped)
278
+ } else {
279
+ return nil
280
+ }
281
+ }(), city: { () -> String? in
282
+ if bridge.has_value_std__optional_std__string_(city) {
283
+ let __unwrapped = bridge.get_std__optional_std__string_(city)
284
+ return String(__unwrapped)
285
+ } else {
286
+ return nil
287
+ }
288
+ }(), state: { () -> String? in
289
+ if bridge.has_value_std__optional_std__string_(state) {
290
+ let __unwrapped = bridge.get_std__optional_std__string_(state)
291
+ return String(__unwrapped)
292
+ } else {
293
+ return nil
294
+ }
295
+ }(), zip: { () -> String? in
296
+ if bridge.has_value_std__optional_std__string_(zip) {
297
+ let __unwrapped = bridge.get_std__optional_std__string_(zip)
298
+ return String(__unwrapped)
299
+ } else {
300
+ return nil
301
+ }
302
+ }(), country: { () -> String? in
303
+ if bridge.has_value_std__optional_std__string_(country) {
304
+ let __unwrapped = bridge.get_std__optional_std__string_(country)
305
+ return String(__unwrapped)
306
+ } else {
307
+ return nil
308
+ }
309
+ }())
310
+ return bridge.create_Result_void_()
311
+ } catch (let __error) {
312
+ let __exceptionPtr = __error.toCpp()
313
+ return bridge.create_Result_void_(__exceptionPtr)
314
+ }
315
+ }
316
+
317
+ @inline(__always)
318
+ public final func getAnonymousID() -> bridge.Result_std__shared_ptr_Promise_std__optional_std__string____ {
319
+ do {
320
+ let __result = try self.__implementation.getAnonymousID()
321
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__optional_std__string___ in
322
+ let __promise = bridge.create_std__shared_ptr_Promise_std__optional_std__string___()
323
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__optional_std__string___(__promise)
324
+ __result
325
+ .then({ __result in __promiseHolder.resolve({ () -> bridge.std__optional_std__string_ in
326
+ if let __unwrappedValue = __result {
327
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
328
+ } else {
329
+ return .init()
330
+ }
331
+ }()) })
332
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
333
+ return __promise
334
+ }()
335
+ return bridge.create_Result_std__shared_ptr_Promise_std__optional_std__string____(__resultCpp)
336
+ } catch (let __error) {
337
+ let __exceptionPtr = __error.toCpp()
338
+ return bridge.create_Result_std__shared_ptr_Promise_std__optional_std__string____(__exceptionPtr)
339
+ }
340
+ }
341
+
342
+ @inline(__always)
343
+ public final func getAdvertiserID() -> bridge.Result_std__shared_ptr_Promise_std__optional_std__string____ {
344
+ do {
345
+ let __result = try self.__implementation.getAdvertiserID()
346
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__optional_std__string___ in
347
+ let __promise = bridge.create_std__shared_ptr_Promise_std__optional_std__string___()
348
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__optional_std__string___(__promise)
349
+ __result
350
+ .then({ __result in __promiseHolder.resolve({ () -> bridge.std__optional_std__string_ in
351
+ if let __unwrappedValue = __result {
352
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
353
+ } else {
354
+ return .init()
355
+ }
356
+ }()) })
357
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
358
+ return __promise
359
+ }()
360
+ return bridge.create_Result_std__shared_ptr_Promise_std__optional_std__string____(__resultCpp)
361
+ } catch (let __error) {
362
+ let __exceptionPtr = __error.toCpp()
363
+ return bridge.create_Result_std__shared_ptr_Promise_std__optional_std__string____(__exceptionPtr)
364
+ }
365
+ }
366
+
367
+ @inline(__always)
368
+ public final func setFlushBehavior(flushBehavior: std.string) -> bridge.Result_void_ {
369
+ do {
370
+ try self.__implementation.setFlushBehavior(flushBehavior: String(flushBehavior))
371
+ return bridge.create_Result_void_()
372
+ } catch (let __error) {
373
+ let __exceptionPtr = __error.toCpp()
374
+ return bridge.create_Result_void_(__exceptionPtr)
375
+ }
376
+ }
377
+
378
+ @inline(__always)
379
+ public final func flush() -> bridge.Result_void_ {
380
+ do {
381
+ try self.__implementation.flush()
382
+ return bridge.create_Result_void_()
383
+ } catch (let __error) {
384
+ let __exceptionPtr = __error.toCpp()
385
+ return bridge.create_Result_void_(__exceptionPtr)
386
+ }
387
+ }
388
+
389
+ @inline(__always)
390
+ public final func setPushNotificationsDeviceToken(token: std.string) -> bridge.Result_void_ {
391
+ do {
392
+ try self.__implementation.setPushNotificationsDeviceToken(token: String(token))
393
+ return bridge.create_Result_void_()
394
+ } catch (let __error) {
395
+ let __exceptionPtr = __error.toCpp()
396
+ return bridge.create_Result_void_(__exceptionPtr)
397
+ }
398
+ }
399
+
400
+ @inline(__always)
401
+ public final func setPushNotificationsRegistrationId(registrationId: std.string) -> bridge.Result_void_ {
402
+ do {
403
+ try self.__implementation.setPushNotificationsRegistrationId(registrationId: String(registrationId))
404
+ return bridge.create_Result_void_()
405
+ } catch (let __error) {
406
+ let __exceptionPtr = __error.toCpp()
407
+ return bridge.create_Result_void_(__exceptionPtr)
408
+ }
409
+ }
410
+ }
@@ -0,0 +1,34 @@
1
+ ///
2
+ /// HybridFacebookAnalyticsSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridFacebookAnalyticsSpec.hpp"
9
+
10
+ namespace margelo::nitro::fbanalytics {
11
+
12
+ void HybridFacebookAnalyticsSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("logEvent", &HybridFacebookAnalyticsSpec::logEvent);
18
+ prototype.registerHybridMethod("logEventWithoutParams", &HybridFacebookAnalyticsSpec::logEventWithoutParams);
19
+ prototype.registerHybridMethod("logPurchase", &HybridFacebookAnalyticsSpec::logPurchase);
20
+ prototype.registerHybridMethod("logPushNotificationOpen", &HybridFacebookAnalyticsSpec::logPushNotificationOpen);
21
+ prototype.registerHybridMethod("setUserID", &HybridFacebookAnalyticsSpec::setUserID);
22
+ prototype.registerHybridMethod("clearUserID", &HybridFacebookAnalyticsSpec::clearUserID);
23
+ prototype.registerHybridMethod("getUserID", &HybridFacebookAnalyticsSpec::getUserID);
24
+ prototype.registerHybridMethod("setUserData", &HybridFacebookAnalyticsSpec::setUserData);
25
+ prototype.registerHybridMethod("getAnonymousID", &HybridFacebookAnalyticsSpec::getAnonymousID);
26
+ prototype.registerHybridMethod("getAdvertiserID", &HybridFacebookAnalyticsSpec::getAdvertiserID);
27
+ prototype.registerHybridMethod("setFlushBehavior", &HybridFacebookAnalyticsSpec::setFlushBehavior);
28
+ prototype.registerHybridMethod("flush", &HybridFacebookAnalyticsSpec::flush);
29
+ prototype.registerHybridMethod("setPushNotificationsDeviceToken", &HybridFacebookAnalyticsSpec::setPushNotificationsDeviceToken);
30
+ prototype.registerHybridMethod("setPushNotificationsRegistrationId", &HybridFacebookAnalyticsSpec::setPushNotificationsRegistrationId);
31
+ });
32
+ }
33
+
34
+ } // namespace margelo::nitro::fbanalytics
@@ -0,0 +1,78 @@
1
+ ///
2
+ /// HybridFacebookAnalyticsSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+
17
+
18
+ #include <string>
19
+ #include <unordered_map>
20
+ #include <optional>
21
+ #include <NitroModules/Promise.hpp>
22
+
23
+ namespace margelo::nitro::fbanalytics {
24
+
25
+ using namespace margelo::nitro;
26
+
27
+ /**
28
+ * An abstract base class for `FacebookAnalytics`
29
+ * Inherit this class to create instances of `HybridFacebookAnalyticsSpec` in C++.
30
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
31
+ * @example
32
+ * ```cpp
33
+ * class HybridFacebookAnalytics: public HybridFacebookAnalyticsSpec {
34
+ * public:
35
+ * HybridFacebookAnalytics(...): HybridObject(TAG) { ... }
36
+ * // ...
37
+ * };
38
+ * ```
39
+ */
40
+ class HybridFacebookAnalyticsSpec: public virtual HybridObject {
41
+ public:
42
+ // Constructor
43
+ explicit HybridFacebookAnalyticsSpec(): HybridObject(TAG) { }
44
+
45
+ // Destructor
46
+ ~HybridFacebookAnalyticsSpec() override = default;
47
+
48
+ public:
49
+ // Properties
50
+
51
+
52
+ public:
53
+ // Methods
54
+ virtual void logEvent(const std::string& eventName, double valueToSum, const std::unordered_map<std::string, std::string>& params) = 0;
55
+ virtual void logEventWithoutParams(const std::string& eventName, double valueToSum) = 0;
56
+ virtual void logPurchase(double amount, const std::string& currency, const std::unordered_map<std::string, std::string>& params) = 0;
57
+ virtual void logPushNotificationOpen(const std::unordered_map<std::string, std::string>& payload) = 0;
58
+ virtual void setUserID(const std::string& userID) = 0;
59
+ virtual void clearUserID() = 0;
60
+ virtual std::optional<std::string> getUserID() = 0;
61
+ virtual void setUserData(const std::optional<std::string>& email, const std::optional<std::string>& firstName, const std::optional<std::string>& lastName, const std::optional<std::string>& phone, const std::optional<std::string>& dateOfBirth, const std::optional<std::string>& gender, const std::optional<std::string>& city, const std::optional<std::string>& state, const std::optional<std::string>& zip, const std::optional<std::string>& country) = 0;
62
+ virtual std::shared_ptr<Promise<std::optional<std::string>>> getAnonymousID() = 0;
63
+ virtual std::shared_ptr<Promise<std::optional<std::string>>> getAdvertiserID() = 0;
64
+ virtual void setFlushBehavior(const std::string& flushBehavior) = 0;
65
+ virtual void flush() = 0;
66
+ virtual void setPushNotificationsDeviceToken(const std::string& token) = 0;
67
+ virtual void setPushNotificationsRegistrationId(const std::string& registrationId) = 0;
68
+
69
+ protected:
70
+ // Hybrid Setup
71
+ void loadHybridMethods() override;
72
+
73
+ protected:
74
+ // Tag for logging
75
+ static constexpr auto TAG = "FacebookAnalytics";
76
+ };
77
+
78
+ } // namespace margelo::nitro::fbanalytics
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "expo-facebook-analytics",
3
+ "version": "1.0.0",
4
+ "description": "High-performance Facebook Analytics for React Native using Nitro Modules",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "source": "src/index.ts",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/jasperaelvoet/expo-facebook-analytics.git"
11
+ },
12
+ "author": "Jasper Aelvoet",
13
+ "bugs": {
14
+ "url": "https://github.com/jasperaelvoet/expo-facebook-analytics/issues"
15
+ },
16
+ "homepage": "https://github.com/jasperaelvoet/expo-facebook-analytics#readme",
17
+ "files": [
18
+ "src",
19
+ "lib",
20
+ "nitrogen/generated",
21
+ "ios",
22
+ "android",
23
+ "plugin/build",
24
+ "app.plugin.js",
25
+ "expo-facebook-analytics.podspec",
26
+ "nitro.json"
27
+ ],
28
+ "scripts": {
29
+ "build": "bun tsc",
30
+ "build:plugin": "bun tsc --project plugin/tsconfig.json",
31
+ "nitrogen": "nitrogen",
32
+ "prepare": "bun run build && bun run build:plugin",
33
+ "clean": "rm -rf lib plugin/build",
34
+ "test": "bun test",
35
+ "check": "biome check .",
36
+ "check:fix": "biome check --write ."
37
+ },
38
+ "keywords": [
39
+ "react-native",
40
+ "expo",
41
+ "facebook",
42
+ "analytics",
43
+ "app-events",
44
+ "nitro-modules"
45
+ ],
46
+ "license": "MIT",
47
+ "peerDependencies": {
48
+ "react": "*",
49
+ "react-native": "*",
50
+ "react-native-nitro-modules": ">=0.33.2",
51
+ "expo": ">=55.0.4"
52
+ },
53
+ "peerDependenciesMeta": {
54
+ "expo": {
55
+ "optional": true
56
+ }
57
+ },
58
+ "devDependencies": {
59
+ "@biomejs/biome": "2.4.5",
60
+ "@expo/config-plugins": "^55.0.6",
61
+ "@types/bun": "^1.3.10",
62
+ "nitrogen": "0.33.2",
63
+ "react-native-nitro-modules": "0.33.2",
64
+ "typescript": "^5.9.3"
65
+ }
66
+ }
@@ -0,0 +1,13 @@
1
+ import { type ConfigPlugin } from "@expo/config-plugins";
2
+ export type ConfigProps = {
3
+ appID: string;
4
+ clientToken: string;
5
+ displayName?: string;
6
+ scheme?: string;
7
+ isAutoInitEnabled?: boolean;
8
+ autoLogAppEventsEnabled?: boolean;
9
+ advertiserIDCollectionEnabled?: boolean;
10
+ iosUserTrackingPermission?: string | false;
11
+ };
12
+ declare const _default: ConfigPlugin<ConfigProps | undefined>;
13
+ export default _default;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config_plugins_1 = require("@expo/config-plugins");
4
+ const withFacebookAnalyticsAndroid_1 = require("./withFacebookAnalyticsAndroid");
5
+ const withFacebookAnalyticsIOS_1 = require("./withFacebookAnalyticsIOS");
6
+ const pkg = require("../../package.json");
7
+ const withFacebookAnalytics = (config, props) => {
8
+ if (!props) {
9
+ throw new Error("expo-facebook-analytics plugin requires props: { appID, clientToken }");
10
+ }
11
+ const { appID, clientToken, displayName, scheme = `fb${props.appID}`, isAutoInitEnabled = true, autoLogAppEventsEnabled = true, advertiserIDCollectionEnabled = true, iosUserTrackingPermission, } = props;
12
+ if (!appID) {
13
+ throw new Error('Missing required "appID" in plugin config.');
14
+ }
15
+ if (!clientToken) {
16
+ throw new Error('Missing required "clientToken" in plugin config.');
17
+ }
18
+ const resolvedProps = {
19
+ appID,
20
+ clientToken,
21
+ displayName: displayName || config.name || "",
22
+ scheme,
23
+ isAutoInitEnabled,
24
+ autoLogAppEventsEnabled,
25
+ advertiserIDCollectionEnabled,
26
+ iosUserTrackingPermission,
27
+ };
28
+ // Android
29
+ config = (0, withFacebookAnalyticsAndroid_1.withFacebookAppIdString)(config, resolvedProps);
30
+ config = (0, withFacebookAnalyticsAndroid_1.withFacebookManifest)(config, resolvedProps);
31
+ config = (0, withFacebookAnalyticsAndroid_1.withAndroidPermissions)(config, resolvedProps);
32
+ // iOS
33
+ config = (0, withFacebookAnalyticsIOS_1.withFacebookIOS)(config, resolvedProps);
34
+ config = (0, withFacebookAnalyticsIOS_1.withFacebookAppDelegate)(config, resolvedProps);
35
+ config = (0, withFacebookAnalyticsIOS_1.withUserTrackingPermission)(config, resolvedProps);
36
+ config = (0, withFacebookAnalyticsIOS_1.withSKAdNetworkIdentifiers)(config, [
37
+ "v9wttpbfk9.skadnetwork",
38
+ "n38lu8286q.skadnetwork",
39
+ ]);
40
+ return config;
41
+ };
42
+ exports.default = (0, config_plugins_1.createRunOncePlugin)(withFacebookAnalytics, pkg.name, pkg.version);
@@ -0,0 +1,14 @@
1
+ import { type ConfigPlugin } from "@expo/config-plugins";
2
+ type ResolvedProps = {
3
+ appID: string;
4
+ clientToken: string;
5
+ displayName: string;
6
+ scheme: string;
7
+ isAutoInitEnabled: boolean;
8
+ autoLogAppEventsEnabled: boolean;
9
+ advertiserIDCollectionEnabled: boolean;
10
+ };
11
+ export declare const withFacebookAppIdString: ConfigPlugin<ResolvedProps>;
12
+ export declare const withFacebookManifest: ConfigPlugin<ResolvedProps>;
13
+ export declare const withAndroidPermissions: ConfigPlugin<ResolvedProps>;
14
+ export {};