posthog-react-native 1.1.3 → 2.0.0-alpha7

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 (129) hide show
  1. package/README.md +9 -0
  2. package/lib/index.cjs.js +1761 -0
  3. package/lib/index.cjs.js.map +1 -0
  4. package/lib/index.d.ts +211 -0
  5. package/lib/index.esm.js +1725 -0
  6. package/lib/index.esm.js.map +1 -0
  7. package/lib/node_modules/tslib/tslib.es6.d.ts +35 -0
  8. package/lib/posthog-core/src/eventemitter.d.ts +8 -0
  9. package/lib/posthog-core/src/index.d.ts +84 -0
  10. package/lib/posthog-core/src/lz-string.d.ts +8 -0
  11. package/lib/posthog-core/src/types.d.ts +68 -0
  12. package/lib/posthog-core/src/utils.d.ts +13 -0
  13. package/lib/posthog-react-native/index.d.ts +10 -0
  14. package/lib/posthog-react-native/src/PostHogProvider.d.ts +13 -0
  15. package/lib/posthog-react-native/src/PosthogContext.d.ts +5 -0
  16. package/lib/posthog-react-native/src/autocapture.d.ts +3 -0
  17. package/lib/posthog-react-native/src/hooks/useFeatureFlag.d.ts +1 -0
  18. package/lib/posthog-react-native/src/hooks/useFeatureFlags.d.ts +3 -0
  19. package/lib/posthog-react-native/src/hooks/useLifecycleTracker.d.ts +2 -0
  20. package/lib/posthog-react-native/src/hooks/useNavigationTracker.d.ts +5 -0
  21. package/lib/posthog-react-native/src/hooks/usePostHog.d.ts +2 -0
  22. package/lib/posthog-react-native/src/legacy.d.ts +4 -0
  23. package/lib/posthog-react-native/src/optional-imports.d.ts +6 -0
  24. package/lib/posthog-react-native/src/posthog-rn.d.ts +14 -0
  25. package/lib/posthog-react-native/src/storage.d.ts +8 -0
  26. package/lib/posthog-react-native/src/types.d.ts +12 -0
  27. package/package.json +35 -51
  28. package/RNPostHog.podspec +0 -21
  29. package/android/build.gradle +0 -46
  30. package/android/src/main/AndroidManifest.xml +0 -1
  31. package/android/src/main/java/com/posthog/reactnative/core/RNPostHogModule.kt +0 -249
  32. package/android/src/main/java/com/posthog/reactnative/core/RNPostHogPackage.kt +0 -44
  33. package/build/cjs/__mocks__/bridge.d.ts +0 -14
  34. package/build/cjs/__mocks__/bridge.js +0 -15
  35. package/build/cjs/__mocks__/bridge.js.map +0 -1
  36. package/build/cjs/__tests__/bridge.spec.d.ts +0 -1
  37. package/build/cjs/__tests__/bridge.spec.js +0 -19
  38. package/build/cjs/__tests__/bridge.spec.js.map +0 -1
  39. package/build/cjs/__tests__/configuration.spec.d.ts +0 -1
  40. package/build/cjs/__tests__/configuration.spec.js +0 -131
  41. package/build/cjs/__tests__/configuration.spec.js.map +0 -1
  42. package/build/cjs/__tests__/index.spec.d.ts +0 -1
  43. package/build/cjs/__tests__/index.spec.js +0 -9
  44. package/build/cjs/__tests__/index.spec.js.map +0 -1
  45. package/build/cjs/__tests__/posthog.spec.d.ts +0 -1
  46. package/build/cjs/__tests__/posthog.spec.js +0 -192
  47. package/build/cjs/__tests__/posthog.spec.js.map +0 -1
  48. package/build/cjs/bridge.d.ts +0 -50
  49. package/build/cjs/bridge.js +0 -9
  50. package/build/cjs/bridge.js.map +0 -1
  51. package/build/cjs/configuration.d.ts +0 -3
  52. package/build/cjs/configuration.js +0 -94
  53. package/build/cjs/configuration.js.map +0 -1
  54. package/build/cjs/index.d.ts +0 -5
  55. package/build/cjs/index.js +0 -6
  56. package/build/cjs/index.js.map +0 -1
  57. package/build/cjs/make-pkg.d.ts +0 -1
  58. package/build/cjs/make-pkg.js +0 -5
  59. package/build/cjs/make-pkg.js.map +0 -1
  60. package/build/cjs/middleware.d.ts +0 -41
  61. package/build/cjs/middleware.js +0 -114
  62. package/build/cjs/middleware.js.map +0 -1
  63. package/build/cjs/posthog.d.ts +0 -228
  64. package/build/cjs/posthog.js +0 -309
  65. package/build/cjs/posthog.js.map +0 -1
  66. package/build/cjs/utils.d.ts +0 -1
  67. package/build/cjs/utils.js +0 -7
  68. package/build/cjs/utils.js.map +0 -1
  69. package/build/cjs/wrapper.d.ts +0 -22
  70. package/build/cjs/wrapper.js +0 -114
  71. package/build/cjs/wrapper.js.map +0 -1
  72. package/build/esm/__mocks__/bridge.d.ts +0 -14
  73. package/build/esm/__mocks__/bridge.js +0 -13
  74. package/build/esm/__mocks__/bridge.js.map +0 -1
  75. package/build/esm/__tests__/bridge.spec.d.ts +0 -1
  76. package/build/esm/__tests__/bridge.spec.js +0 -19
  77. package/build/esm/__tests__/bridge.spec.js.map +0 -1
  78. package/build/esm/__tests__/configuration.spec.d.ts +0 -1
  79. package/build/esm/__tests__/configuration.spec.js +0 -129
  80. package/build/esm/__tests__/configuration.spec.js.map +0 -1
  81. package/build/esm/__tests__/index.spec.d.ts +0 -1
  82. package/build/esm/__tests__/index.spec.js +0 -7
  83. package/build/esm/__tests__/index.spec.js.map +0 -1
  84. package/build/esm/__tests__/posthog.spec.d.ts +0 -1
  85. package/build/esm/__tests__/posthog.spec.js +0 -190
  86. package/build/esm/__tests__/posthog.spec.js.map +0 -1
  87. package/build/esm/bridge.d.ts +0 -50
  88. package/build/esm/bridge.js +0 -7
  89. package/build/esm/bridge.js.map +0 -1
  90. package/build/esm/configuration.d.ts +0 -3
  91. package/build/esm/configuration.js +0 -92
  92. package/build/esm/configuration.js.map +0 -1
  93. package/build/esm/index.d.ts +0 -5
  94. package/build/esm/index.js +0 -4
  95. package/build/esm/index.js.map +0 -1
  96. package/build/esm/make-pkg.d.ts +0 -1
  97. package/build/esm/make-pkg.js +0 -3
  98. package/build/esm/make-pkg.js.map +0 -1
  99. package/build/esm/middleware.d.ts +0 -41
  100. package/build/esm/middleware.js +0 -112
  101. package/build/esm/middleware.js.map +0 -1
  102. package/build/esm/posthog.d.ts +0 -228
  103. package/build/esm/posthog.js +0 -307
  104. package/build/esm/posthog.js.map +0 -1
  105. package/build/esm/utils.d.ts +0 -1
  106. package/build/esm/utils.js +0 -4
  107. package/build/esm/utils.js.map +0 -1
  108. package/build/esm/wrapper.d.ts +0 -22
  109. package/build/esm/wrapper.js +0 -112
  110. package/build/esm/wrapper.js.map +0 -1
  111. package/build/package.json +0 -3
  112. package/ios/RNPostHog/RNPostHog.h +0 -9
  113. package/ios/RNPostHog/RNPostHog.m +0 -128
  114. package/ios/RNPostHog.xcodeproj/project.pbxproj +0 -336
  115. package/ios/RNPostHog.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  116. package/src/__mocks__/bridge.ts +0 -12
  117. package/src/__tests__/bridge.spec.ts +0 -23
  118. package/src/__tests__/configuration.spec.ts +0 -79
  119. package/src/__tests__/index.spec.ts +0 -7
  120. package/src/__tests__/posthog.spec.ts +0 -106
  121. package/src/bridge.ts +0 -61
  122. package/src/configuration.ts +0 -61
  123. package/src/index.ts +0 -5
  124. package/src/make-pkg.ts +0 -3
  125. package/src/middleware.ts +0 -128
  126. package/src/modules.d.ts +0 -2
  127. package/src/posthog.ts +0 -305
  128. package/src/utils.ts +0 -3
  129. package/src/wrapper.ts +0 -61
@@ -1,307 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- return new (P || (P = Promise))(function (resolve, reject) {
3
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
6
- step((generator = generator.apply(thisArg, _arguments || [])).next());
7
- });
8
- };
9
- var __generator = (this && this.__generator) || function (thisArg, body) {
10
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
11
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
- function verb(n) { return function (v) { return step([n, v]); }; }
13
- function step(op) {
14
- if (f) throw new TypeError("Generator is already executing.");
15
- while (_) try {
16
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
17
- if (y = 0, t) op = [op[0] & 2, t.value];
18
- switch (op[0]) {
19
- case 0: case 1: t = op; break;
20
- case 4: _.label++; return { value: op[1], done: false };
21
- case 5: _.label++; y = op[1]; op = [0]; continue;
22
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
23
- default:
24
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
25
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
26
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
27
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
28
- if (t[2]) _.ops.pop();
29
- _.trys.pop(); continue;
30
- }
31
- op = body.call(thisArg, _);
32
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
33
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
34
- }
35
- };
36
- import Bridge from './bridge';
37
- import { configure } from './configuration';
38
- import { MiddlewareChain } from './middleware';
39
- import { NativeWrapper } from './wrapper';
40
- // prettier-ignore
41
- export var PostHog;
42
- (function (PostHog) {
43
- var Client = /** @class */ (function () {
44
- function Client() {
45
- var _this = this;
46
- /**
47
- * Whether the client is ready to send events to PostHog.
48
- *
49
- * This becomes `true` when `.setup()` succeeds.
50
- * All calls will be queued until it becomes `true`.
51
- */
52
- this.ready = false;
53
- this.wrapper = new NativeWrapper(this, function (err) {
54
- return _this.handleError(err);
55
- });
56
- this.handlers = [];
57
- this.middlewares = new MiddlewareChain(this.wrapper);
58
- }
59
- /**
60
- * Catch React-Native bridge errors
61
- *
62
- * These errors are emitted when calling the native counterpart.
63
- * This only applies to methods with no return value (`Promise<void>`),
64
- * methods like `getAnonymousId` do reject promises.
65
- */
66
- Client.prototype.catch = function (handler) {
67
- this.handlers.push(handler);
68
- return this;
69
- };
70
- Client.prototype.middleware = function (middleware) {
71
- this.middlewares.add(middleware);
72
- return this;
73
- };
74
- /**
75
- * Use the native configuration.
76
- *
77
- * You'll need to call this method when you configure PostHog's singleton
78
- * using the native API.
79
- */
80
- Client.prototype.useNativeConfiguration = function () {
81
- if (this.ready) {
82
- throw new Error('PostHog has already been configured');
83
- }
84
- this.wrapper.ready();
85
- return this;
86
- };
87
- /**
88
- * Setup the PostHog module. All calls made before are queued
89
- * and only executed if the configuration was successful.
90
- *
91
- * ```js
92
- * await posthog.setup('YOUR_API_KEY', {
93
- * captureAppLifecycleEvents: true,
94
- * ios: {
95
- * capturePushNotifications: true
96
- * }
97
- * })
98
- * ```
99
- *
100
- * @param apiKey Your PostHog.com API key
101
- * @param configuration An optional {@link Configuration} object.
102
- */
103
- Client.prototype.setup = function (apiKey, configuration) {
104
- if (configuration === void 0) { configuration = {}; }
105
- return __awaiter(this, void 0, void 0, function () {
106
- var _a, _b;
107
- return __generator(this, function (_c) {
108
- switch (_c.label) {
109
- case 0:
110
- _b = (_a = Bridge).setup;
111
- return [4 /*yield*/, configure(apiKey, configuration)];
112
- case 1: return [4 /*yield*/, _b.apply(_a, [_c.sent()])];
113
- case 2:
114
- _c.sent();
115
- this.wrapper.ready();
116
- return [2 /*return*/];
117
- }
118
- });
119
- });
120
- };
121
- /**
122
- * Record the actions your users perform.
123
- *
124
- * When a user performs an action in your app, you'll want to capture that action for later analysis.
125
- * Use the event name to say what the user did, and properties to specify any interesting details of the action.
126
- *
127
- * @param event The name of the event you're capturing.
128
- * We recommend using human-readable names like `Played a Song` or `Updated Status`.
129
- * @param properties A dictionary of properties for the event.
130
- * If the event was 'Added to Shopping Cart', it might have properties like price, productType, etc.
131
- */
132
- Client.prototype.capture = function (event, properties) {
133
- if (properties === void 0) { properties = {}; }
134
- return __awaiter(this, void 0, void 0, function () {
135
- return __generator(this, function (_a) {
136
- switch (_a.label) {
137
- case 0: return [4 /*yield*/, this.middlewares.run('capture', { event: event, properties: properties })];
138
- case 1:
139
- _a.sent();
140
- return [2 /*return*/];
141
- }
142
- });
143
- });
144
- };
145
- /**
146
- * Record the screens or views your users see.
147
- *
148
- * When a user views a screen in your app, you'll want to record that here.
149
- *
150
- * @param screen The title of the screen being viewed.
151
- * We recommend using human-readable names like 'Photo Feed' or 'Completed Purchase Screen'.
152
- * @param properties A dictionary of properties for the screen view event.
153
- * If the event was 'Added to Shopping Cart', it might have properties like price, productType, etc.
154
- */
155
- Client.prototype.screen = function (screen, properties) {
156
- if (properties === void 0) { properties = {}; }
157
- return __awaiter(this, void 0, void 0, function () {
158
- return __generator(this, function (_a) {
159
- switch (_a.label) {
160
- case 0: return [4 /*yield*/, this.middlewares.run('screen', { screen: screen, properties: properties })];
161
- case 1:
162
- _a.sent();
163
- return [2 /*return*/];
164
- }
165
- });
166
- });
167
- };
168
- /**
169
- * Associate a user with their unique ID and record traits about them.
170
- *
171
- * When you learn more about who your user is, you can record that information with identify.
172
- *
173
- * @param distinctId database ID (or email address) for this user.
174
- * If you don't have a userId but want to record traits, you should pass nil.
175
- * @param properties A dictionary of properties you know about the user. Things like: email, name, plan, etc.
176
- */
177
- Client.prototype.identify = function (distinctId, properties) {
178
- if (properties === void 0) { properties = {}; }
179
- return __awaiter(this, void 0, void 0, function () {
180
- return __generator(this, function (_a) {
181
- switch (_a.label) {
182
- case 0: return [4 /*yield*/, this.middlewares.run('identify', { distinctId: distinctId, properties: properties })];
183
- case 1:
184
- _a.sent();
185
- return [2 /*return*/];
186
- }
187
- });
188
- });
189
- };
190
- /**
191
- * Merge two user identities, effectively connecting two sets of user data as one.
192
- *
193
- * When you learn more about who the group is, you can record that information with group.
194
- *
195
- * @param alias The existing ID you want to link to the current distinct ID.
196
- */
197
- Client.prototype.alias = function (alias) {
198
- return __awaiter(this, void 0, void 0, function () {
199
- return __generator(this, function (_a) {
200
- switch (_a.label) {
201
- case 0: return [4 /*yield*/, this.middlewares.run('alias', { alias: alias })];
202
- case 1:
203
- _a.sent();
204
- return [2 /*return*/];
205
- }
206
- });
207
- });
208
- };
209
- /**
210
- * Reset any user state that is cached on the device.
211
- *
212
- * This is useful when a user logs out and you want to clear the identity.
213
- * It will clear any traits or userId's cached on the device.
214
- */
215
- Client.prototype.reset = function () {
216
- return __awaiter(this, void 0, void 0, function () {
217
- return __generator(this, function (_a) {
218
- switch (_a.label) {
219
- case 0: return [4 /*yield*/, this.wrapper.run('reset', function (reset) { return reset(); })];
220
- case 1:
221
- _a.sent();
222
- return [2 /*return*/];
223
- }
224
- });
225
- });
226
- };
227
- /**
228
- * Trigger an upload of all queued events.
229
- *
230
- * This is useful when you want to force all messages queued on the device to be uploaded.
231
- * Please note that not all integrations respond to this method.
232
- */
233
- Client.prototype.flush = function () {
234
- return __awaiter(this, void 0, void 0, function () {
235
- return __generator(this, function (_a) {
236
- switch (_a.label) {
237
- case 0: return [4 /*yield*/, this.wrapper.run('flush', function (flush) { return flush(); })];
238
- case 1:
239
- _a.sent();
240
- return [2 /*return*/];
241
- }
242
- });
243
- });
244
- };
245
- /**
246
- * Enable the sending of posthog data. Enabled by default.
247
- *
248
- * Occasionally used in conjunction with disable user opt-out handling.
249
- */
250
- Client.prototype.enable = function () {
251
- return __awaiter(this, void 0, void 0, function () {
252
- return __generator(this, function (_a) {
253
- switch (_a.label) {
254
- case 0: return [4 /*yield*/, this.wrapper.run('enable', function (enable) { return enable(); })];
255
- case 1:
256
- _a.sent();
257
- return [2 /*return*/];
258
- }
259
- });
260
- });
261
- };
262
- /**
263
- * Completely disable the sending of any posthog data.
264
- *
265
- * If you have a way for users to actively or passively (sometimes based on location) opt-out of
266
- * posthog data collection, you can use this method to turn off all data collection.
267
- */
268
- Client.prototype.disable = function () {
269
- return __awaiter(this, void 0, void 0, function () {
270
- return __generator(this, function (_a) {
271
- switch (_a.label) {
272
- case 0: return [4 /*yield*/, this.wrapper.run('disable', function (disable) { return disable(); })];
273
- case 1:
274
- _a.sent();
275
- return [2 /*return*/];
276
- }
277
- });
278
- });
279
- };
280
- /** Retrieve the anonymousId. */
281
- Client.prototype.getAnonymousId = function () {
282
- return __awaiter(this, void 0, void 0, function () {
283
- return __generator(this, function (_a) {
284
- switch (_a.label) {
285
- case 0: return [4 /*yield*/, this.wrapper.wait()];
286
- case 1:
287
- _a.sent();
288
- return [2 /*return*/, Bridge.getAnonymousId()];
289
- }
290
- });
291
- });
292
- };
293
- Client.prototype.handleError = function (error) {
294
- var handlers = this.handlers;
295
- if (!handlers.length) {
296
- console.error('Uncaught PostHog error', error);
297
- throw error;
298
- }
299
- else {
300
- handlers.forEach(function (handler) { return handler(error); });
301
- }
302
- };
303
- return Client;
304
- }());
305
- PostHog.Client = Client;
306
- })(PostHog || (PostHog = {}));
307
- //# sourceMappingURL=posthog.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"posthog.js","sourceRoot":"","sources":["../../src/posthog.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,MAAmB,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAc,eAAe,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAgB,aAAa,EAAE,MAAM,WAAW,CAAA;AAEvD,kBAAkB;AAClB,MAAM,KAAQ,OAAO,CA0SpB;AA1SD,WAAc,OAAO;IAkHpB;QAAA;YAAA,iBAuLC;YAtLA;;;;;eAKG;YACa,UAAK,GAAG,KAAK,CAAA;YAEZ,YAAO,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,UAAA,GAAG;gBACrD,OAAA,KAAI,CAAC,WAAW,CAAC,GAAG,CAAC;YAArB,CAAqB,CACrB,CAAA;YACgB,aAAQ,GAAmB,EAAE,CAAA;YAC7B,gBAAW,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QA0KjE,CAAC;QAxKA;;;;;;WAMG;QACI,sBAAK,GAAZ,UAAa,OAAqB;YACjC,I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AuD,CAAA;;;;;SACvD;QAED,gCAAgC;QACnB,+BAAc,GAA3B;;;;gCACC,qBAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAA;;4BAAzB,SAAyB,CAAA;4BAEzB,sBAAO,MAAM,CAAC,cAAc,EAAE,EAAA;;;;SAC9B;QAEO,4BAAW,GAAnB,UAAoB,KAAY;YACvB,IAAA,wBAAQ,CAAS;YAEzB,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAA;gBAC9C,MAAM,KAAK,CAAA;aACX;iBAAM;gBACN,QAAQ,CAAC,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,KAAK,CAAC,EAAd,CAAc,CAAC,CAAA;aAC3C;QACF,CAAC;QACF,aAAC;IAAD,CAAC,AAvLD,IAuLC;IAvLY,cAAM,SAuLlB,CAAA;AACF,CAAC,EA1Sa,OAAO,KAAP,OAAO,QA0SpB"}
@@ -1 +0,0 @@
1
- export declare function assertNever(never: never): void;
@@ -1,4 +0,0 @@
1
- export function assertNever(never) {
2
- throw new Error('Expected never, got ' + never);
3
- }
4
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,KAAY;IACvC,MAAM,IAAI,KAAK,CAAC,sBAAsB,GAAG,KAAK,CAAC,CAAA;AAChD,CAAC"}
@@ -1,22 +0,0 @@
1
- import { Bridge } from './bridge';
2
- export interface NativeDelegate {
3
- ready: boolean;
4
- }
5
- export declare type ErrorHandler = (err: Error) => void;
6
- export declare class NativeWrapper<T extends NativeDelegate> {
7
- private readonly delegate;
8
- private readonly handler;
9
- private readonly queue;
10
- constructor(delegate: T, handler: ErrorHandler, queue?: Array<() => void>);
11
- /**
12
- * Run a bridge method.
13
- * It first waits for `.setup()` or `.useNativeConfiguration()` to be
14
- * called and redirects exceptions to `handler`.
15
- * @param method Name of the method to call.
16
- * @param caller Function with the bridge function as first argument.
17
- */
18
- run<M extends keyof Bridge>(method: M, caller: (fn: Bridge[M]) => Promise<void>): Promise<void>;
19
- /** Waits for `.setup()` or `.useNativeConfiguration()` to be called. */
20
- wait(): Promise<{} | undefined>;
21
- ready(): void;
22
- }
@@ -1,112 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- return new (P || (P = Promise))(function (resolve, reject) {
3
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
6
- step((generator = generator.apply(thisArg, _arguments || [])).next());
7
- });
8
- };
9
- var __generator = (this && this.__generator) || function (thisArg, body) {
10
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
11
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
- function verb(n) { return function (v) { return step([n, v]); }; }
13
- function step(op) {
14
- if (f) throw new TypeError("Generator is already executing.");
15
- while (_) try {
16
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
17
- if (y = 0, t) op = [op[0] & 2, t.value];
18
- switch (op[0]) {
19
- case 0: case 1: t = op; break;
20
- case 4: _.label++; return { value: op[1], done: false };
21
- case 5: _.label++; y = op[1]; op = [0]; continue;
22
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
23
- default:
24
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
25
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
26
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
27
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
28
- if (t[2]) _.ops.pop();
29
- _.trys.pop(); continue;
30
- }
31
- op = body.call(thisArg, _);
32
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
33
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
34
- }
35
- };
36
- import bridge from './bridge';
37
- var NativeWrapper = /** @class */ (function () {
38
- function NativeWrapper(delegate, handler, queue) {
39
- if (queue === void 0) { queue = []; }
40
- this.delegate = delegate;
41
- this.handler = handler;
42
- this.queue = queue;
43
- }
44
- /**
45
- * Run a bridge method.
46
- * It first waits for `.setup()` or `.useNativeConfiguration()` to be
47
- * called and redirects exceptions to `handler`.
48
- * @param method Name of the method to call.
49
- * @param caller Function with the bridge function as first argument.
50
- */
51
- NativeWrapper.prototype.run = function (method, caller) {
52
- return __awaiter(this, void 0, void 0, function () {
53
- function run() {
54
- return __awaiter(this, void 0, void 0, function () {
55
- var err_1;
56
- return __generator(this, function (_a) {
57
- switch (_a.label) {
58
- case 0:
59
- _a.trys.push([0, 2, , 3]);
60
- return [4 /*yield*/, caller(bridge[method])];
61
- case 1:
62
- _a.sent();
63
- return [3 /*break*/, 3];
64
- case 2:
65
- err_1 = _a.sent();
66
- return [2 /*return*/, handler(err_1)];
67
- case 3: return [2 /*return*/];
68
- }
69
- });
70
- });
71
- }
72
- var _a, delegate, handler, queue;
73
- return __generator(this, function (_b) {
74
- switch (_b.label) {
75
- case 0:
76
- _a = this, delegate = _a.delegate, handler = _a.handler, queue = _a.queue;
77
- if (!delegate.ready) return [3 /*break*/, 2];
78
- return [4 /*yield*/, run()];
79
- case 1:
80
- _b.sent();
81
- return [3 /*break*/, 3];
82
- case 2:
83
- queue.push(run);
84
- _b.label = 3;
85
- case 3: return [2 /*return*/];
86
- }
87
- });
88
- });
89
- };
90
- /** Waits for `.setup()` or `.useNativeConfiguration()` to be called. */
91
- NativeWrapper.prototype.wait = function () {
92
- return __awaiter(this, void 0, void 0, function () {
93
- var _this = this;
94
- return __generator(this, function (_a) {
95
- if (this.delegate.ready) {
96
- return [2 /*return*/];
97
- }
98
- return [2 /*return*/, new Promise(function (resolve) { return _this.queue.push(resolve); })];
99
- });
100
- });
101
- };
102
- NativeWrapper.prototype.ready = function () {
103
- var _a = this, delegate = _a.delegate, queue = _a.queue;
104
- delegate.ready = true;
105
- while (queue.length) {
106
- queue.shift()();
107
- }
108
- };
109
- return NativeWrapper;
110
- }());
111
- export { NativeWrapper };
112
- //# sourceMappingURL=wrapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../src/wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,MAAkB,MAAM,UAAU,CAAA;AAOzC;IACC,uBACkB,QAAW,EACX,OAAqB,EACrB,KAA6B;QAA7B,sBAAA,EAAA,UAA6B;QAF7B,aAAQ,GAAR,QAAQ,CAAG;QACX,YAAO,GAAP,OAAO,CAAc;QACrB,UAAK,GAAL,KAAK,CAAwB;IAC5C,CAAC;IAEJ;;;;;;OAMG;IACU,2BAAG,GAAhB,UACC,MAAS,EACT,MAAwC;;YAUxC,SAAe,GAAG;;;;;;;gCAEhB,qBAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAA;;gCAA5B,SAA4B,CAAA;;;;gCAE5B,sBAAO,OAAO,CAAC,KAAG,CAAC,EAAA;;;;;aAEpB;;;;;wBAdK,KAA+B,IAAI,EAAjC,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,KAAK,WAAA,CAAS;6BAErC,QAAQ,CAAC,KAAK,EAAd,wBAAc;wBACjB,qBAAM,GAAG,EAAE,EAAA;;wBAAX,SAAW,CAAA;;;wBAEX,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;;;;;;KAUhB;IAED,wEAAwE;IAC3D,4BAAI,GAAjB;;;;gBACC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE;oBACxB,sBAAM;iBACN;gBAED,sBAAO,IAAI,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,KAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAxB,CAAwB,CAAC,EAAA;;;KACvD;IAEM,6BAAK,GAAZ;QACO,IAAA,SAA0B,EAAxB,sBAAQ,EAAE,gBAAc,CAAA;QAEhC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAA;QAErB,OAAO,KAAK,CAAC,MAAM,EAAE;YACpB,KAAK,CAAC,KAAK,EAAG,EAAE,CAAA;SAChB;IACF,CAAC;IACF,oBAAC;AAAD,CAAC,AArDD,IAqDC"}
@@ -1,3 +0,0 @@
1
- {
2
- "version": "1.1.3"
3
- }
@@ -1,9 +0,0 @@
1
- #if __has_include("RCTBridgeModule.h")
2
- #import "RCTBridgeModule.h"
3
- #else
4
- #import <React/RCTBridgeModule.h>
5
- #endif
6
-
7
- @interface RNPostHog: NSObject<RCTBridgeModule>
8
-
9
- @end
@@ -1,128 +0,0 @@
1
- #import "RNPostHog.h"
2
-
3
- #import <PostHog/PHGPostHog.h>
4
- #import <React/RCTBridge.h>
5
-
6
- @implementation RNPostHog
7
-
8
- +(void)initialize {
9
- [super initialize];
10
- }
11
-
12
- RCT_EXPORT_MODULE()
13
-
14
- @synthesize bridge = _bridge;
15
-
16
- static NSString* singletonJsonConfig = nil;
17
-
18
- RCT_EXPORT_METHOD(
19
- setup:(NSDictionary*)options
20
- :(RCTPromiseResolveBlock)resolver
21
- :(RCTPromiseRejectBlock)rejecter
22
- ) {
23
- NSString* json = options[@"json"];
24
-
25
- if(singletonJsonConfig != nil) {
26
- if([json isEqualToString:singletonJsonConfig]) {
27
- return resolver(nil);
28
- }
29
- else {
30
- #if DEBUG
31
- return resolver(self);
32
- #else
33
- return rejecter(@"E_POSTHOG_RECONFIGURED", @"PostHog Client was allocated multiple times, please check your environment.", nil);
34
- #endif
35
- }
36
- }
37
-
38
- PHGPostHogConfiguration* config = [PHGPostHogConfiguration configurationWithApiKey:options[@"apiKey"] host:options[@"host"]];
39
-
40
- config.recordScreenViews = [options[@"recordScreenViews"] boolValue];
41
- config.captureApplicationLifecycleEvents = [options[@"captureApplicationLifecycleEvents"] boolValue];
42
- config.captureDeepLinks = [options[@"captureDeepLinks"] boolValue];
43
- config.flushAt = [options[@"flushAt"] integerValue];
44
- config.flushInterval = [options[@"flushInterval"] integerValue];
45
-
46
- config.capturePushNotifications = [options[@"ios"][@"capturePushNotifications"] boolValue];
47
- config.captureInAppPurchases = [options[@"ios"][@"captureInAppPurchases"] boolValue];
48
- config.shouldUseBluetooth = [options[@"ios"][@"shouldUseBluetooth"] boolValue];
49
- config.shouldUseLocationServices = [options[@"ios"][@"shouldUseLocationServices"] boolValue];
50
- config.maxQueueSize = [options[@"ios"][@"maxQueueSize"] integerValue];
51
-
52
- config.libraryName = options[@"context"][@"$lib"];
53
- config.libraryVersion = options[@"context"][@"$lib_version"];
54
-
55
- [PHGPostHog debug:[options[@"debug"] boolValue]];
56
-
57
- @try {
58
- [PHGPostHog setupWithConfiguration:config];
59
- }
60
- @catch(NSError* error) {
61
- return rejecter(@"E_POSTHOG_ERROR", @"Unexpected native Analtyics error", error);
62
- }
63
-
64
- // On iOS we use method swizzling to intercept lifecycle events
65
- // However, React-Native calls our library after applicationDidFinishLaunchingWithOptions: is called
66
- // We fix this by manually calling this method at setup-time
67
- if(config.captureApplicationLifecycleEvents) {
68
- SEL selector = @selector(_applicationDidFinishLaunchingWithOptions:);
69
-
70
- if ([PHGPostHog.sharedPostHog respondsToSelector:selector]) {
71
- [PHGPostHog.sharedPostHog performSelector:selector
72
- withObject:_bridge.launchOptions];
73
- }
74
- }
75
-
76
- singletonJsonConfig = json;
77
- return resolver(nil);
78
- }
79
-
80
- - (NSDictionary*)withContextAndIntegrations :(NSDictionary*)context :(NSDictionary*)integrations {
81
- return @{ @"context": context, @"integrations": integrations ?: @{}};
82
- }
83
-
84
-
85
- RCT_EXPORT_METHOD(capture:(NSString*)event :(NSDictionary*)properties) {
86
- [PHGPostHog.sharedPostHog capture:event
87
- properties:properties];
88
- }
89
-
90
- RCT_EXPORT_METHOD(screen:(NSString*)screenTitle :(NSDictionary*)properties) {
91
- [PHGPostHog.sharedPostHog screen:screenTitle
92
- properties:properties];
93
- }
94
-
95
- RCT_EXPORT_METHOD(identify:(NSString*)distinctId :(NSDictionary*)properties) {
96
- [PHGPostHog.sharedPostHog identify:distinctId
97
- properties:properties];
98
- }
99
-
100
- RCT_EXPORT_METHOD(alias:(NSString*)alias) {
101
- [PHGPostHog.sharedPostHog alias:alias];
102
- }
103
-
104
- RCT_EXPORT_METHOD(reset) {
105
- [PHGPostHog.sharedPostHog reset];
106
- }
107
-
108
- RCT_EXPORT_METHOD(flush) {
109
- [PHGPostHog.sharedPostHog flush];
110
- }
111
-
112
- RCT_EXPORT_METHOD(enable) {
113
- [PHGPostHog.sharedPostHog enable];
114
- }
115
-
116
- RCT_EXPORT_METHOD(disable) {
117
- [PHGPostHog.sharedPostHog disable];
118
- }
119
-
120
- RCT_EXPORT_METHOD(
121
- getAnonymousId:(RCTPromiseResolveBlock)resolver
122
- :(RCTPromiseRejectBlock)rejecter)
123
- {
124
- NSString *anonymousId = [PHGPostHog.sharedPostHog getAnonymousId];
125
- resolver(anonymousId);
126
- }
127
-
128
- @end