@teardown/react-native 2.0.29 → 2.0.32
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/README.md +22 -19
- package/docs/adapters/device/basic.mdx +7 -7
- package/docs/adapters/device/device-info.mdx +8 -8
- package/docs/adapters/device/expo.mdx +10 -10
- package/docs/adapters/device/index.mdx +51 -20
- package/docs/adapters/notifications/expo.mdx +64 -30
- package/docs/adapters/notifications/firebase.mdx +61 -27
- package/docs/adapters/notifications/index.mdx +120 -39
- package/docs/adapters/notifications/wix.mdx +61 -27
- package/docs/advanced.mdx +99 -3
- package/docs/api-reference.mdx +177 -12
- package/docs/core-concepts.mdx +31 -13
- package/docs/force-updates.mdx +18 -8
- package/docs/hooks-reference.mdx +9 -6
- package/docs/identity.mdx +46 -6
- package/docs/logging.mdx +5 -15
- package/package.json +5 -5
- package/src/clients/api/api.client.ts +4 -0
- package/src/clients/device/device.client.ts +9 -0
- package/src/clients/events/events.client.ts +102 -0
- package/src/clients/events/index.ts +1 -0
- package/src/clients/force-update/force-update.client.ts +27 -10
- package/src/clients/identity/identity.client.test.ts +2 -1
- package/src/clients/identity/identity.client.ts +274 -50
- package/src/clients/logging/logging.client.ts +0 -24
- package/src/exports/index.ts +1 -0
- package/src/hooks/use-force-update.ts +14 -0
- package/src/teardown.core.ts +42 -3
package/src/exports/index.ts
CHANGED
|
@@ -19,6 +19,11 @@ export interface UseForceUpdateResult {
|
|
|
19
19
|
* Whether the the current version is out of date and is forced to be updated.
|
|
20
20
|
*/
|
|
21
21
|
isUpdateRequired: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Release notes for the update, if available.
|
|
24
|
+
* Only present when there's an update (update_available, update_recommended, or update_required).
|
|
25
|
+
*/
|
|
26
|
+
releaseNotes: string | null;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
export const useForceUpdate = (): UseForceUpdateResult => {
|
|
@@ -35,10 +40,19 @@ export const useForceUpdate = (): UseForceUpdateResult => {
|
|
|
35
40
|
const isUpdateRecommended = versionStatus.type === "update_recommended";
|
|
36
41
|
const isUpdateAvailable = isUpdateRequired || isUpdateRecommended || versionStatus.type === "update_available";
|
|
37
42
|
|
|
43
|
+
// Extract release notes from update status types
|
|
44
|
+
const releaseNotes =
|
|
45
|
+
versionStatus.type === "update_available" ||
|
|
46
|
+
versionStatus.type === "update_recommended" ||
|
|
47
|
+
versionStatus.type === "update_required"
|
|
48
|
+
? (versionStatus.releaseNotes ?? null)
|
|
49
|
+
: null;
|
|
50
|
+
|
|
38
51
|
return {
|
|
39
52
|
versionStatus,
|
|
40
53
|
isUpdateRequired,
|
|
41
54
|
isUpdateRecommended,
|
|
42
55
|
isUpdateAvailable,
|
|
56
|
+
releaseNotes,
|
|
43
57
|
};
|
|
44
58
|
};
|
package/src/teardown.core.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ApiClient } from "./clients/api";
|
|
2
2
|
import { DeviceClient, type DeviceClientOptions } from "./clients/device/device.client";
|
|
3
|
+
import { EventsClient } from "./clients/events";
|
|
3
4
|
import { ForceUpdateClient, type ForceUpdateClientOptions } from "./clients/force-update";
|
|
4
5
|
import { IdentityClient } from "./clients/identity";
|
|
5
6
|
import { type Logger, LoggingClient, type LogLevel } from "./clients/logging";
|
|
7
|
+
import type { NotificationAdapter } from "./clients/notifications/adapters/notifications.adapter-interface";
|
|
8
|
+
import { NotificationsClient } from "./clients/notifications/notifications.client";
|
|
6
9
|
import { type StorageAdapter, StorageClient } from "./clients/storage";
|
|
7
10
|
import { UtilsClient } from "./clients/utils/utils.client";
|
|
8
11
|
|
|
@@ -10,10 +13,15 @@ export type TeardownCoreOptions = {
|
|
|
10
13
|
org_id: string;
|
|
11
14
|
project_id: string;
|
|
12
15
|
api_key: string;
|
|
13
|
-
|
|
16
|
+
/** Environment slug (e.g. "production", "staging", "development") */
|
|
17
|
+
environment_slug?: string;
|
|
18
|
+
/** Custom ingest API URL for local/staging environments */
|
|
19
|
+
ingestUrl?: string;
|
|
14
20
|
storageAdapter: StorageAdapter;
|
|
15
21
|
deviceAdapter: DeviceClientOptions["adapter"];
|
|
16
22
|
forceUpdate?: ForceUpdateClientOptions;
|
|
23
|
+
/** Optional notification adapter for push notification support */
|
|
24
|
+
notificationAdapter?: NotificationAdapter;
|
|
17
25
|
};
|
|
18
26
|
|
|
19
27
|
export class TeardownCore {
|
|
@@ -23,8 +31,10 @@ export class TeardownCore {
|
|
|
23
31
|
public readonly api: ApiClient;
|
|
24
32
|
private readonly storage: StorageClient;
|
|
25
33
|
public readonly device: DeviceClient;
|
|
34
|
+
public readonly events: EventsClient;
|
|
26
35
|
public readonly identity: IdentityClient;
|
|
27
36
|
public readonly forceUpdate: ForceUpdateClient;
|
|
37
|
+
public readonly notifications?: NotificationsClient;
|
|
28
38
|
|
|
29
39
|
constructor(private readonly options: TeardownCoreOptions) {
|
|
30
40
|
this.options = options;
|
|
@@ -46,12 +56,32 @@ export class TeardownCore {
|
|
|
46
56
|
org_id: this.options.org_id,
|
|
47
57
|
project_id: this.options.project_id,
|
|
48
58
|
api_key: this.options.api_key,
|
|
49
|
-
environment_slug: "production",
|
|
59
|
+
environment_slug: this.options.environment_slug ?? "production",
|
|
60
|
+
ingestUrl: this.options.ingestUrl,
|
|
50
61
|
});
|
|
51
62
|
this.device = new DeviceClient(this.logging, this.utils, this.storage, {
|
|
52
63
|
adapter: this.options.deviceAdapter,
|
|
53
64
|
});
|
|
54
|
-
|
|
65
|
+
|
|
66
|
+
// Create events client after device (needs device for deviceId)
|
|
67
|
+
this.events = new EventsClient(this.logging, this.api, this.device);
|
|
68
|
+
|
|
69
|
+
// Create notifications client before identity so it can be passed in
|
|
70
|
+
if (this.options.notificationAdapter) {
|
|
71
|
+
this.notifications = new NotificationsClient(this.logging, this.storage, {
|
|
72
|
+
adapter: this.options.notificationAdapter,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.identity = new IdentityClient(
|
|
77
|
+
this.logging,
|
|
78
|
+
this.utils,
|
|
79
|
+
this.storage,
|
|
80
|
+
this.api,
|
|
81
|
+
this.device,
|
|
82
|
+
this.events,
|
|
83
|
+
this.notifications
|
|
84
|
+
);
|
|
55
85
|
this.forceUpdate = new ForceUpdateClient(this.logging, this.storage, this.identity, this.options.forceUpdate);
|
|
56
86
|
|
|
57
87
|
void this.initialize()
|
|
@@ -67,10 +97,19 @@ export class TeardownCore {
|
|
|
67
97
|
// Wait for all storage hydration to complete
|
|
68
98
|
this.logger.debug("Waiting for storage to be ready");
|
|
69
99
|
await this.storage.whenReady();
|
|
100
|
+
|
|
101
|
+
// Initialize notifications first so token is available for identify
|
|
102
|
+
if (this.notifications) {
|
|
103
|
+
this.logger.debug("Initializing notifications");
|
|
104
|
+
await this.notifications.initialize();
|
|
105
|
+
this.logger.debug("Notifications initialized");
|
|
106
|
+
}
|
|
107
|
+
|
|
70
108
|
// Initialize identity (loads from storage, then identifies if needed)
|
|
71
109
|
this.logger.debug("Initializing identity");
|
|
72
110
|
await this.identity.initialize();
|
|
73
111
|
this.logger.debug("Identity initialized");
|
|
112
|
+
|
|
74
113
|
// Then initialize force update (subscribes to identity events)
|
|
75
114
|
this.logger.debug("Initializing force update");
|
|
76
115
|
this.forceUpdate.initialize();
|