@rootnode-app/react-native 0.1.3 → 0.2.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.
package/dist/index.d.ts CHANGED
@@ -47,6 +47,8 @@ declare class RootnodeClient {
47
47
  private postPushToken;
48
48
  private makeStorage;
49
49
  private makeContext;
50
+ /** Auto-track push opens: emits push_opened with the campaign id. */
51
+ private watchPushOpens;
50
52
  private watchAppState;
51
53
  }
52
54
  export declare const Rootnode: RootnodeClient;
package/dist/index.js CHANGED
@@ -154,6 +154,7 @@ class RootnodeClient {
154
154
  });
155
155
  }
156
156
  if (cfg.apiKey) {
157
+ this.watchPushOpens();
157
158
  this.core = new core_1.RootnodeCore({
158
159
  apiKey: cfg.apiKey,
159
160
  host,
@@ -332,6 +333,30 @@ class RootnodeClient {
332
333
  return ctx;
333
334
  };
334
335
  }
336
+ /** Auto-track push opens: emits push_opened with the campaign id. */
337
+ watchPushOpens() {
338
+ try {
339
+ const Notifications = loadNotifications();
340
+ if (!Notifications?.addNotificationResponseReceivedListener)
341
+ return;
342
+ Notifications.addNotificationResponseReceivedListener((res) => {
343
+ try {
344
+ const data = res?.notification?.request?.content?.data ?? {};
345
+ this.core?.capture('push_opened', {
346
+ ...(data._rn_campaign ? { _rn_campaign: String(data._rn_campaign) } : {}),
347
+ ...(typeof data.screen === 'string' ? { screen: data.screen } : {}),
348
+ });
349
+ void this.core?.flush();
350
+ }
351
+ catch {
352
+ /* tracking must never break the tap */
353
+ }
354
+ });
355
+ }
356
+ catch {
357
+ /* no notifications module = no open tracking */
358
+ }
359
+ }
335
360
  watchAppState() {
336
361
  try {
337
362
  const RN = warned(loadReactNative(), 'react-native', this.cfg.onError);
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@rootnode-app/react-native",
3
- "version": "0.1.3",
4
- "description": "Rootnode for React Native / Expo apps: crash reporting, analytics, sessions and push registration — one install, one init.",
3
+ "version": "0.2.0",
4
+ "description": "Rootnode for React Native / Expo apps: crash reporting, analytics, sessions and push registration \u2014 one install, one init.",
5
5
  "license": "MIT",
6
- "author": "Doğan Aktı",
6
+ "author": "Do\u011fan Akt\u0131",
7
7
  "homepage": "https://rootnode.app/docs/integration.md",
8
8
  "repository": {
9
9
  "type": "git",
@@ -34,4 +34,4 @@
34
34
  "vitest": "^2.1.9",
35
35
  "esbuild": "^0.24.0"
36
36
  }
37
- }
37
+ }