@wasto/cms-components 1.5.10 → 1.5.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 (98) hide show
  1. package/README.md +47 -47
  2. package/dist/index.d.mts +103 -2
  3. package/dist/index.d.ts +103 -2
  4. package/dist/index.js +2861 -2442
  5. package/dist/index.mjs +3651 -3227
  6. package/package.json +2 -2
  7. package/src/components/announcement-modal/AnnouncementModal.tsx +183 -183
  8. package/src/components/article/Article.tsx +21 -21
  9. package/src/components/article/ArticleCard.tsx +81 -81
  10. package/src/components/article/ArticleExcerpts.tsx +80 -80
  11. package/src/components/article/ArticleList.tsx +114 -114
  12. package/src/components/article/ArticleMarkdown.tsx +170 -170
  13. package/src/components/article/ArticleReaderModal.tsx +93 -93
  14. package/src/components/article/ArticleSingle.tsx +57 -57
  15. package/src/components/bottom-tab/BottomTab.tsx +392 -392
  16. package/src/components/button/Button.tsx +154 -154
  17. package/src/components/challenge/Badges.tsx +84 -84
  18. package/src/components/challenge/BadgesModal.tsx +166 -166
  19. package/src/components/challenge/Challenge.tsx +380 -380
  20. package/src/components/challenge/ChallengeModal.tsx +231 -231
  21. package/src/components/challenge/ChallengeVignette.tsx +249 -249
  22. package/src/components/challenge/ChallengesModal.tsx +243 -243
  23. package/src/components/challenge/QuizModal.tsx +381 -381
  24. package/src/components/challenge/ResultModal.tsx +144 -144
  25. package/src/components/chat/Chat.tsx +928 -928
  26. package/src/components/collection-calendar/CollectionCalendar.tsx +274 -274
  27. package/src/components/columns/Columns.tsx +33 -33
  28. package/src/components/consignes-modal/ConsignesModal.tsx +267 -267
  29. package/src/components/content-inset/ContentInset.tsx +33 -33
  30. package/src/components/header/Header.tsx +391 -391
  31. package/src/components/image/Image.tsx +15 -15
  32. package/src/components/image/ImageFrame.tsx +102 -102
  33. package/src/components/image/ImageMedia.tsx +31 -31
  34. package/src/components/image/ImageUrl.tsx +30 -30
  35. package/src/components/locations-map/LocationSheet.tsx +417 -417
  36. package/src/components/locations-map/LocationsMap.native.tsx +260 -260
  37. package/src/components/locations-map/LocationsMap.tsx +13 -13
  38. package/src/components/locations-map/LocationsMap.web.tsx +10 -10
  39. package/src/components/locations-map/LocationsMapShell.tsx +527 -527
  40. package/src/components/locations-map/LocationsMapView.tsx +108 -108
  41. package/src/components/locations-map/LocationsMapView.web.tsx +331 -331
  42. package/src/components/nav-button/NavButton.tsx +59 -59
  43. package/src/components/next-collection/NextCollection.tsx +636 -621
  44. package/src/components/notifications/NotificationsScreen.tsx +247 -247
  45. package/src/components/page/Page.tsx +102 -64
  46. package/src/components/parapraph/Paragraph.tsx +67 -67
  47. package/src/components/profile/ProfileScreen.tsx +236 -236
  48. package/src/components/recycling-info/RecyclingInfo.tsx +189 -189
  49. package/src/components/safe-area/OptionalSafeAreaProvider.tsx +17 -17
  50. package/src/components/search/Search.tsx +320 -320
  51. package/src/components/select-street-modal/SelectStreetModal.tsx +475 -475
  52. package/src/components/title/Title.tsx +100 -100
  53. package/src/components/vision/Vision.tsx +447 -447
  54. package/src/components/vision/VisionActionCard.tsx +117 -117
  55. package/src/components/vision/VisionCapture.tsx +30 -30
  56. package/src/components/vision/VisionTapOverlay.tsx +122 -122
  57. package/src/contexts/AnnouncementsContext.tsx +171 -171
  58. package/src/contexts/AppDataContext.tsx +458 -0
  59. package/src/contexts/ChallengesContext.tsx +182 -182
  60. package/src/contexts/LocalContext.tsx +227 -227
  61. package/src/contexts/ThemeContext.tsx +37 -37
  62. package/src/contexts/WastoContext.tsx +130 -127
  63. package/src/helpers/blogPost.ts +72 -72
  64. package/src/helpers/generateQuizQuestions.ts +247 -247
  65. package/src/helpers/getContrastColor.ts +18 -18
  66. package/src/helpers/haptics.ts +20 -20
  67. package/src/helpers/hoursSchedule.ts +230 -230
  68. package/src/helpers/htmlContentToMarkdown.ts +114 -114
  69. package/src/helpers/layout.ts +54 -54
  70. package/src/helpers/loadLinearGradient.ts +22 -22
  71. package/src/helpers/mapLocations.ts +170 -0
  72. package/src/helpers/maquetteTheme.ts +76 -76
  73. package/src/helpers/markdownUnderlinePlugin.ts +32 -32
  74. package/src/helpers/nextCollection.ts +122 -0
  75. package/src/helpers/normalizeWasteTypeRecyclingInfo.ts +80 -80
  76. package/src/helpers/publicMediaUrl.ts +8 -8
  77. package/src/helpers/resolveApiAssetUrl.ts +21 -21
  78. package/src/helpers/systemRoutes.ts +7 -7
  79. package/src/helpers/themeStyles.ts +114 -114
  80. package/src/helpers/ttlCache.ts +41 -0
  81. package/src/helpers/useSafeAreaPadding.ts +14 -14
  82. package/src/hooks/useBadges.ts +100 -100
  83. package/src/hooks/useBlogPosts.ts +109 -105
  84. package/src/hooks/useChallenges.ts +110 -110
  85. package/src/hooks/useCities.ts +56 -56
  86. package/src/hooks/useCityAnnouncements.ts +118 -118
  87. package/src/hooks/useCollectionCalendar.ts +421 -421
  88. package/src/hooks/useColumns.ts +19 -19
  89. package/src/hooks/useConsignes.ts +62 -62
  90. package/src/hooks/useLocations.ts +120 -248
  91. package/src/hooks/useNextCollection.ts +163 -238
  92. package/src/hooks/useRecyclingInfo.ts +90 -90
  93. package/src/hooks/useWastoClient.ts +16 -16
  94. package/src/index.ts +149 -142
  95. package/src/navigation/NavigationContext.tsx +56 -56
  96. package/src/sentry/initSentry.ts +120 -120
  97. package/src/types/Theme.ts +72 -72
  98. package/src/types/css-modules.d.ts +1 -1
package/src/index.ts CHANGED
@@ -1,142 +1,149 @@
1
- export {
2
- Article,
3
- type ArticleProps,
4
- type ArticleDisplayMode
5
- } from "./components/article/Article"
6
- export {
7
- Challenge,
8
- type ChallengeProps
9
- } from "./components/challenge/Challenge"
10
- export {
11
- ChallengeVignette,
12
- type ChallengeVignetteProps
13
- } from "./components/challenge/ChallengeVignette"
14
- export {
15
- Chat,
16
- type ChatProps
17
- } from "./components/chat/Chat"
18
- export {
19
- CollectionCalendar,
20
- type CollectionCalendarProps
21
- } from "./components/collection-calendar/CollectionCalendar"
22
- export {
23
- Columns,
24
- type ColumnsProps,
25
- type ColumnsColumnCount
26
- } from "./components/columns/Columns"
27
- export {
28
- Image,
29
- ImageProps,
30
- } from "./components/image/Image"
31
- export {
32
- LocationsMap,
33
- type LocationsMapProps
34
- } from "./components/locations-map/LocationsMap"
35
- export {
36
- NextCollection,
37
- type NextCollectionProps
38
- } from "./components/next-collection/NextCollection"
39
- export {
40
- Page,
41
- type PageProps
42
- } from "./components/page/Page"
43
- export {
44
- ContentInset,
45
- type ContentInsetProps
46
- } from "./components/content-inset/ContentInset"
47
- export {
48
- Paragraph,
49
- type PararaphProps
50
- } from "./components/parapraph/Paragraph"
51
- export {
52
- RecyclingInfo,
53
- type RecyclingInfoProps
54
- } from "./components/recycling-info/RecyclingInfo"
55
- export {
56
- Search,
57
- type SearchProps
58
- } from "./components/search/Search"
59
- export {
60
- Title,
61
- type TitleProps,
62
- type TitleLevel
63
- } from "./components/title/Title"
64
- export {
65
- Header,
66
- type HeaderProps,
67
- type AppHeaderConfig,
68
- type AppHeaderElement,
69
- type AppHeaderLogoElement,
70
- type AppHeaderTitleElement,
71
- type AppHeaderActionElement,
72
- type AppHeaderSlot,
73
- } from "./components/header/Header"
74
- export {
75
- BottomTab,
76
- type BottomTabProps
77
- } from "./components/bottom-tab/BottomTab"
78
- export {
79
- NotificationsScreen,
80
- } from "./components/notifications/NotificationsScreen"
81
- export {
82
- ProfileScreen,
83
- } from "./components/profile/ProfileScreen"
84
- export {
85
- Vision,
86
- type VisionProps,
87
- type VisionCaptureResult,
88
- } from "./components/vision/Vision"
89
- export {
90
- type VisionSuggestion,
91
- type VisionActionCardProps,
92
- } from "./components/vision/VisionActionCard"
93
-
94
- export {
95
- WastoProvider,
96
- useWasto,
97
- type WastoProviderProps,
98
- type WastoContextType,
99
- } from "./contexts/WastoContext"
100
-
101
- export {
102
- initWastoSentry,
103
- wrapWithSentry,
104
- reportError,
105
- isWastoSentryActive,
106
- type WastoSentryConfig,
107
- type WastoErrorContext,
108
- } from "./sentry/initSentry"
109
-
110
- export { useWastoClient } from "./hooks/useWastoClient"
111
-
112
- export type {
113
- Theme,
114
- ResolvedTheme,
115
- ThemeShadowStyle,
116
- } from "./types/Theme"
117
-
118
- export {
119
- resolveTheme,
120
- cardStyle,
121
- softCardStyle,
122
- groupedSectionStyle,
123
- coloredShadow,
124
- } from "./helpers/themeStyles"
125
-
126
- export {
127
- SPACE,
128
- MAQUETTE_RADII,
129
- MAQUETTE_COLORS,
130
- } from "./helpers/layout"
131
-
132
- export { SYSTEM_ROUTES, type SystemRouteKey } from "./helpers/systemRoutes"
133
-
134
- export { createMaquetteTheme } from "./helpers/maquetteTheme"
135
-
136
- export {
137
- NavigationProvider,
138
- useAppNavigation,
139
- useOptionalAppNavigation,
140
- type NavigationApi,
141
- type NavigationProviderProps,
142
- } from "./navigation/NavigationContext"
1
+ export {
2
+ Article,
3
+ type ArticleProps,
4
+ type ArticleDisplayMode
5
+ } from "./components/article/Article"
6
+ export {
7
+ Challenge,
8
+ type ChallengeProps
9
+ } from "./components/challenge/Challenge"
10
+ export {
11
+ ChallengeVignette,
12
+ type ChallengeVignetteProps
13
+ } from "./components/challenge/ChallengeVignette"
14
+ export {
15
+ Chat,
16
+ type ChatProps
17
+ } from "./components/chat/Chat"
18
+ export {
19
+ CollectionCalendar,
20
+ type CollectionCalendarProps
21
+ } from "./components/collection-calendar/CollectionCalendar"
22
+ export {
23
+ Columns,
24
+ type ColumnsProps,
25
+ type ColumnsColumnCount
26
+ } from "./components/columns/Columns"
27
+ export {
28
+ Image,
29
+ ImageProps,
30
+ } from "./components/image/Image"
31
+ export {
32
+ LocationsMap,
33
+ type LocationsMapProps
34
+ } from "./components/locations-map/LocationsMap"
35
+ export {
36
+ NextCollection,
37
+ type NextCollectionProps
38
+ } from "./components/next-collection/NextCollection"
39
+ export {
40
+ Page,
41
+ type PageProps
42
+ } from "./components/page/Page"
43
+ export {
44
+ ContentInset,
45
+ type ContentInsetProps
46
+ } from "./components/content-inset/ContentInset"
47
+ export {
48
+ Paragraph,
49
+ type PararaphProps
50
+ } from "./components/parapraph/Paragraph"
51
+ export {
52
+ RecyclingInfo,
53
+ type RecyclingInfoProps
54
+ } from "./components/recycling-info/RecyclingInfo"
55
+ export {
56
+ Search,
57
+ type SearchProps
58
+ } from "./components/search/Search"
59
+ export {
60
+ Title,
61
+ type TitleProps,
62
+ type TitleLevel
63
+ } from "./components/title/Title"
64
+ export {
65
+ Header,
66
+ type HeaderProps,
67
+ type AppHeaderConfig,
68
+ type AppHeaderElement,
69
+ type AppHeaderLogoElement,
70
+ type AppHeaderTitleElement,
71
+ type AppHeaderActionElement,
72
+ type AppHeaderSlot,
73
+ } from "./components/header/Header"
74
+ export {
75
+ BottomTab,
76
+ type BottomTabProps
77
+ } from "./components/bottom-tab/BottomTab"
78
+ export {
79
+ NotificationsScreen,
80
+ } from "./components/notifications/NotificationsScreen"
81
+ export {
82
+ ProfileScreen,
83
+ } from "./components/profile/ProfileScreen"
84
+ export {
85
+ Vision,
86
+ type VisionProps,
87
+ type VisionCaptureResult,
88
+ } from "./components/vision/Vision"
89
+ export {
90
+ type VisionSuggestion,
91
+ type VisionActionCardProps,
92
+ } from "./components/vision/VisionActionCard"
93
+
94
+ export {
95
+ WastoProvider,
96
+ useWasto,
97
+ type WastoProviderProps,
98
+ type WastoContextType,
99
+ } from "./contexts/WastoContext"
100
+
101
+ export {
102
+ useAppData,
103
+ useOptionalAppData,
104
+ NEXT_EVENTS_DAY_RADIUS,
105
+ type AppDataContextType,
106
+ } from "./contexts/AppDataContext"
107
+
108
+ export {
109
+ initWastoSentry,
110
+ wrapWithSentry,
111
+ reportError,
112
+ isWastoSentryActive,
113
+ type WastoSentryConfig,
114
+ type WastoErrorContext,
115
+ } from "./sentry/initSentry"
116
+
117
+ export { useWastoClient } from "./hooks/useWastoClient"
118
+
119
+ export type {
120
+ Theme,
121
+ ResolvedTheme,
122
+ ThemeShadowStyle,
123
+ } from "./types/Theme"
124
+
125
+ export {
126
+ resolveTheme,
127
+ cardStyle,
128
+ softCardStyle,
129
+ groupedSectionStyle,
130
+ coloredShadow,
131
+ } from "./helpers/themeStyles"
132
+
133
+ export {
134
+ SPACE,
135
+ MAQUETTE_RADII,
136
+ MAQUETTE_COLORS,
137
+ } from "./helpers/layout"
138
+
139
+ export { SYSTEM_ROUTES, type SystemRouteKey } from "./helpers/systemRoutes"
140
+
141
+ export { createMaquetteTheme } from "./helpers/maquetteTheme"
142
+
143
+ export {
144
+ NavigationProvider,
145
+ useAppNavigation,
146
+ useOptionalAppNavigation,
147
+ type NavigationApi,
148
+ type NavigationProviderProps,
149
+ } from "./navigation/NavigationContext"
@@ -1,56 +1,56 @@
1
- import {
2
- createContext,
3
- useContext,
4
- useMemo,
5
- type PropsWithChildren,
6
- type ReactNode,
7
- } from "react";
8
-
9
- /**
10
- * Host-agnostic navigation API.
11
- * Expo Router apps pass `router.push` / `router.back`;
12
- * React Navigation apps pass `navigation.navigate` / `goBack`.
13
- */
14
- export type NavigationApi = {
15
- push: (href: string) => void;
16
- canGoBack?: () => boolean;
17
- goBack?: () => void;
18
- };
19
-
20
- const NavigationContext = createContext<NavigationApi | null>(null);
21
-
22
- export type NavigationProviderProps = PropsWithChildren & {
23
- value: NavigationApi;
24
- };
25
-
26
- export function NavigationProvider({ value, children }: NavigationProviderProps): ReactNode {
27
- const memo = useMemo(
28
- () => ({
29
- push: value.push,
30
- canGoBack: value.canGoBack,
31
- goBack: value.goBack,
32
- }),
33
- [value.push, value.canGoBack, value.goBack],
34
- );
35
-
36
- return (
37
- <NavigationContext.Provider value={memo}>
38
- {children}
39
- </NavigationContext.Provider>
40
- );
41
- }
42
-
43
- export function useAppNavigation(): NavigationApi {
44
- const nav = useContext(NavigationContext);
45
- if (!nav) {
46
- throw new Error(
47
- "[cms-components] NavigationProvider is required (wrap the app root).",
48
- );
49
- }
50
- return nav;
51
- }
52
-
53
- /** Soft read — returns null when no provider (e.g. isolated component tests). */
54
- export function useOptionalAppNavigation(): NavigationApi | null {
55
- return useContext(NavigationContext);
56
- }
1
+ import {
2
+ createContext,
3
+ useContext,
4
+ useMemo,
5
+ type PropsWithChildren,
6
+ type ReactNode,
7
+ } from "react";
8
+
9
+ /**
10
+ * Host-agnostic navigation API.
11
+ * Expo Router apps pass `router.push` / `router.back`;
12
+ * React Navigation apps pass `navigation.navigate` / `goBack`.
13
+ */
14
+ export type NavigationApi = {
15
+ push: (href: string) => void;
16
+ canGoBack?: () => boolean;
17
+ goBack?: () => void;
18
+ };
19
+
20
+ const NavigationContext = createContext<NavigationApi | null>(null);
21
+
22
+ export type NavigationProviderProps = PropsWithChildren & {
23
+ value: NavigationApi;
24
+ };
25
+
26
+ export function NavigationProvider({ value, children }: NavigationProviderProps): ReactNode {
27
+ const memo = useMemo(
28
+ () => ({
29
+ push: value.push,
30
+ canGoBack: value.canGoBack,
31
+ goBack: value.goBack,
32
+ }),
33
+ [value.push, value.canGoBack, value.goBack],
34
+ );
35
+
36
+ return (
37
+ <NavigationContext.Provider value={memo}>
38
+ {children}
39
+ </NavigationContext.Provider>
40
+ );
41
+ }
42
+
43
+ export function useAppNavigation(): NavigationApi {
44
+ const nav = useContext(NavigationContext);
45
+ if (!nav) {
46
+ throw new Error(
47
+ "[cms-components] NavigationProvider is required (wrap the app root).",
48
+ );
49
+ }
50
+ return nav;
51
+ }
52
+
53
+ /** Soft read — returns null when no provider (e.g. isolated component tests). */
54
+ export function useOptionalAppNavigation(): NavigationApi | null {
55
+ return useContext(NavigationContext);
56
+ }
@@ -1,120 +1,120 @@
1
- import type { ComponentType } from "react";
2
-
3
- export type WastoSentryConfig = {
4
- dsn?: string;
5
- enabled?: boolean | string;
6
- environment?: string;
7
- debug?: boolean | string;
8
- release?: string;
9
- appId?: string;
10
- };
11
-
12
- export type WastoErrorContext = Record<string, unknown> & {
13
- source?: string;
14
- };
15
-
16
- type SentryModule = typeof import("@sentry/react-native");
17
-
18
- let sentryModule: SentryModule | null | undefined;
19
- let initialized = false;
20
- let active = false;
21
-
22
- function parseFlag(value: boolean | string | undefined, defaultWhenDsn: boolean): boolean {
23
- if (typeof value === "boolean") return value;
24
- const raw = String(value ?? "")
25
- .trim()
26
- .toLowerCase();
27
- if (raw === "true" || raw === "1" || raw === "yes") return true;
28
- if (raw === "false" || raw === "0" || raw === "no") return false;
29
- return defaultWhenDsn;
30
- }
31
-
32
- function loadSentry(): SentryModule | null {
33
- if (sentryModule !== undefined) return sentryModule;
34
- try {
35
- // Optional peer: apps without the package still load cms-components.
36
- // eslint-disable-next-line @typescript-eslint/no-require-imports
37
- sentryModule = require("@sentry/react-native") as SentryModule;
38
- } catch {
39
- sentryModule = null;
40
- }
41
- return sentryModule;
42
- }
43
-
44
- /**
45
- * Initialize Sentry for GitLab Error Tracking (DSN from env).
46
- * No-op when DSN is empty, disabled, or `@sentry/react-native` is missing.
47
- */
48
- export function initWastoSentry(config: WastoSentryConfig = {}): boolean {
49
- const dsn = (config.dsn ?? "").trim();
50
- const enabled = Boolean(dsn) && parseFlag(config.enabled, true);
51
- if (!enabled || !dsn) {
52
- active = false;
53
- return false;
54
- }
55
-
56
- const Sentry = loadSentry();
57
- if (!Sentry) {
58
- active = false;
59
- if (__DEV__) {
60
- console.warn(
61
- "[wasto] @sentry/react-native is not installed; error tracking disabled",
62
- );
63
- }
64
- return false;
65
- }
66
-
67
- if (!initialized) {
68
- Sentry.init({
69
- dsn,
70
- enabled: true,
71
- debug: parseFlag(config.debug, false),
72
- environment: (config.environment || "production").trim() || "production",
73
- release: (config.release || "").trim() || undefined,
74
- // GitLab Error Tracking: keep payload minimal (exceptions / messages).
75
- tracesSampleRate: 0,
76
- enableAutoSessionTracking: false,
77
- sendDefaultPii: false,
78
- });
79
- initialized = true;
80
- }
81
-
82
- if (config.appId) {
83
- Sentry.setTag("appId", config.appId);
84
- }
85
-
86
- active = true;
87
- return true;
88
- }
89
-
90
- export function isWastoSentryActive(): boolean {
91
- return active;
92
- }
93
-
94
- export function reportError(error: unknown, context?: WastoErrorContext): void {
95
- if (!active) return;
96
- const Sentry = loadSentry();
97
- if (!Sentry) return;
98
-
99
- Sentry.withScope((scope) => {
100
- if (context) {
101
- for (const [key, value] of Object.entries(context)) {
102
- if (value === undefined) continue;
103
- if (key === "source" && typeof value === "string") {
104
- scope.setTag("source", value);
105
- } else {
106
- scope.setExtra(key, value);
107
- }
108
- }
109
- }
110
- Sentry.captureException(error instanceof Error ? error : new Error(String(error)));
111
- });
112
- }
113
-
114
- export function wrapWithSentry<P extends Record<string, unknown>>(
115
- Component: ComponentType<P>,
116
- ): ComponentType<P> {
117
- const Sentry = loadSentry();
118
- if (!Sentry?.wrap) return Component;
119
- return Sentry.wrap(Component) as ComponentType<P>;
120
- }
1
+ import type { ComponentType } from "react";
2
+
3
+ export type WastoSentryConfig = {
4
+ dsn?: string;
5
+ enabled?: boolean | string;
6
+ environment?: string;
7
+ debug?: boolean | string;
8
+ release?: string;
9
+ appId?: string;
10
+ };
11
+
12
+ export type WastoErrorContext = Record<string, unknown> & {
13
+ source?: string;
14
+ };
15
+
16
+ type SentryModule = typeof import("@sentry/react-native");
17
+
18
+ let sentryModule: SentryModule | null | undefined;
19
+ let initialized = false;
20
+ let active = false;
21
+
22
+ function parseFlag(value: boolean | string | undefined, defaultWhenDsn: boolean): boolean {
23
+ if (typeof value === "boolean") return value;
24
+ const raw = String(value ?? "")
25
+ .trim()
26
+ .toLowerCase();
27
+ if (raw === "true" || raw === "1" || raw === "yes") return true;
28
+ if (raw === "false" || raw === "0" || raw === "no") return false;
29
+ return defaultWhenDsn;
30
+ }
31
+
32
+ function loadSentry(): SentryModule | null {
33
+ if (sentryModule !== undefined) return sentryModule;
34
+ try {
35
+ // Optional peer: apps without the package still load cms-components.
36
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
37
+ sentryModule = require("@sentry/react-native") as SentryModule;
38
+ } catch {
39
+ sentryModule = null;
40
+ }
41
+ return sentryModule;
42
+ }
43
+
44
+ /**
45
+ * Initialize Sentry for GitLab Error Tracking (DSN from env).
46
+ * No-op when DSN is empty, disabled, or `@sentry/react-native` is missing.
47
+ */
48
+ export function initWastoSentry(config: WastoSentryConfig = {}): boolean {
49
+ const dsn = (config.dsn ?? "").trim();
50
+ const enabled = Boolean(dsn) && parseFlag(config.enabled, true);
51
+ if (!enabled || !dsn) {
52
+ active = false;
53
+ return false;
54
+ }
55
+
56
+ const Sentry = loadSentry();
57
+ if (!Sentry) {
58
+ active = false;
59
+ if (__DEV__) {
60
+ console.warn(
61
+ "[wasto] @sentry/react-native is not installed; error tracking disabled",
62
+ );
63
+ }
64
+ return false;
65
+ }
66
+
67
+ if (!initialized) {
68
+ Sentry.init({
69
+ dsn,
70
+ enabled: true,
71
+ debug: parseFlag(config.debug, false),
72
+ environment: (config.environment || "production").trim() || "production",
73
+ release: (config.release || "").trim() || undefined,
74
+ // GitLab Error Tracking: keep payload minimal (exceptions / messages).
75
+ tracesSampleRate: 0,
76
+ enableAutoSessionTracking: false,
77
+ sendDefaultPii: false,
78
+ });
79
+ initialized = true;
80
+ }
81
+
82
+ if (config.appId) {
83
+ Sentry.setTag("appId", config.appId);
84
+ }
85
+
86
+ active = true;
87
+ return true;
88
+ }
89
+
90
+ export function isWastoSentryActive(): boolean {
91
+ return active;
92
+ }
93
+
94
+ export function reportError(error: unknown, context?: WastoErrorContext): void {
95
+ if (!active) return;
96
+ const Sentry = loadSentry();
97
+ if (!Sentry) return;
98
+
99
+ Sentry.withScope((scope) => {
100
+ if (context) {
101
+ for (const [key, value] of Object.entries(context)) {
102
+ if (value === undefined) continue;
103
+ if (key === "source" && typeof value === "string") {
104
+ scope.setTag("source", value);
105
+ } else {
106
+ scope.setExtra(key, value);
107
+ }
108
+ }
109
+ }
110
+ Sentry.captureException(error instanceof Error ? error : new Error(String(error)));
111
+ });
112
+ }
113
+
114
+ export function wrapWithSentry<P extends Record<string, unknown>>(
115
+ Component: ComponentType<P>,
116
+ ): ComponentType<P> {
117
+ const Sentry = loadSentry();
118
+ if (!Sentry?.wrap) return Component;
119
+ return Sentry.wrap(Component) as ComponentType<P>;
120
+ }