@goliapkg/sentori-expo 5.0.0 → 6.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.
- package/app.plugin.js +165 -14
- package/package.json +6 -6
package/app.plugin.js
CHANGED
|
@@ -4,36 +4,187 @@
|
|
|
4
4
|
* `@goliapkg/sentori-react-native` already exposes
|
|
5
5
|
* `expo-module.config.json` + iOS podspec + Android build.gradle, so
|
|
6
6
|
* Expo Modules autolinking handles the native side without any
|
|
7
|
-
* additional config-plugins work
|
|
8
|
-
* mainly as a marker so users can drop:
|
|
7
|
+
* additional config-plugins work for error / span / replay capture.
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* }
|
|
14
|
-
* }
|
|
9
|
+
* v2.11 — extends the plugin to also wire **push notifications** for
|
|
10
|
+
* apps that opt in. When the host adds `@goliapkg/sentori-expo` to
|
|
11
|
+
* its `app.json` plugins array, prebuild auto-injects:
|
|
15
12
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
13
|
+
* iOS:
|
|
14
|
+
* - Info.plist: UIBackgroundModes ⊇ [remote-notification]
|
|
15
|
+
* - Entitlements: aps-environment = 'production' (Xcode flips to
|
|
16
|
+
* 'development' for debug signing automatically)
|
|
17
|
+
*
|
|
18
|
+
* Android:
|
|
19
|
+
* - AndroidManifest.xml: <uses-permission POST_NOTIFICATIONS>
|
|
20
|
+
* - Root build.gradle: classpath com.google.gms:google-services
|
|
21
|
+
* - App build.gradle: apply google-services + firebase-bom +
|
|
22
|
+
* firebase-messaging
|
|
23
|
+
* - Copies google-services.json from `props.googleServicesFile`
|
|
24
|
+
* (defaults to `./google-services.json` at the host root) to
|
|
25
|
+
* `android/app/google-services.json` on prebuild.
|
|
26
|
+
*
|
|
27
|
+
* Opt out per platform with `{ ios: false }` / `{ android: false }`.
|
|
28
|
+
* Opt out entirely by not including the plugin in `app.json`.
|
|
20
29
|
*
|
|
21
30
|
* The plugin is intentionally CommonJS — Expo's plugin loader uses
|
|
22
31
|
* `require()`.
|
|
23
32
|
*/
|
|
24
|
-
const
|
|
33
|
+
const fs = require('fs')
|
|
34
|
+
const path = require('path')
|
|
35
|
+
const {
|
|
36
|
+
withInfoPlist,
|
|
37
|
+
withEntitlementsPlist,
|
|
38
|
+
withAndroidManifest,
|
|
39
|
+
withProjectBuildGradle,
|
|
40
|
+
withAppBuildGradle,
|
|
41
|
+
withDangerousMod,
|
|
42
|
+
AndroidConfig,
|
|
43
|
+
withPlugins,
|
|
44
|
+
} = require('@expo/config-plugins')
|
|
25
45
|
|
|
26
46
|
const SENTORI_VERSION_KEY = 'SentoriSdkVersion'
|
|
47
|
+
const FIREBASE_BOM_VERSION = '33.5.1'
|
|
48
|
+
const GOOGLE_SERVICES_VERSION = '4.4.2'
|
|
49
|
+
|
|
50
|
+
// ── Existing marker (Sentori SDK version surface) ──────────────────
|
|
27
51
|
|
|
28
52
|
/**
|
|
29
53
|
* @param {import('@expo/config-plugins').ExpoConfig} config
|
|
30
|
-
* @param {{ sdkVersion?: string }}
|
|
54
|
+
* @param {{ sdkVersion?: string }} props
|
|
31
55
|
*/
|
|
32
|
-
const
|
|
56
|
+
const withSentoriVersion = (config, props = {}) => {
|
|
33
57
|
return withInfoPlist(config, (cfg) => {
|
|
34
58
|
cfg.modResults[SENTORI_VERSION_KEY] = props.sdkVersion || '0.1.0'
|
|
35
59
|
return cfg
|
|
36
60
|
})
|
|
37
61
|
}
|
|
38
62
|
|
|
63
|
+
// ── v2.11 iOS push ─────────────────────────────────────────────────
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @param {import('@expo/config-plugins').ExpoConfig} config
|
|
67
|
+
*/
|
|
68
|
+
const withSentoriPushIos = (config) => {
|
|
69
|
+
config = withInfoPlist(config, (cfg) => {
|
|
70
|
+
const modes = Array.isArray(cfg.modResults.UIBackgroundModes)
|
|
71
|
+
? cfg.modResults.UIBackgroundModes
|
|
72
|
+
: []
|
|
73
|
+
if (!modes.includes('remote-notification')) {
|
|
74
|
+
modes.push('remote-notification')
|
|
75
|
+
}
|
|
76
|
+
cfg.modResults.UIBackgroundModes = modes
|
|
77
|
+
return cfg
|
|
78
|
+
})
|
|
79
|
+
config = withEntitlementsPlist(config, (cfg) => {
|
|
80
|
+
if (!cfg.modResults['aps-environment']) {
|
|
81
|
+
// Xcode automatically swaps to 'development' when the build is
|
|
82
|
+
// signed with a development provisioning profile, so this
|
|
83
|
+
// default is correct for both flavors.
|
|
84
|
+
cfg.modResults['aps-environment'] = 'production'
|
|
85
|
+
}
|
|
86
|
+
return cfg
|
|
87
|
+
})
|
|
88
|
+
return config
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// ── v2.11 Android push ─────────────────────────────────────────────
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @param {import('@expo/config-plugins').ExpoConfig} config
|
|
95
|
+
*/
|
|
96
|
+
const withSentoriPushAndroidManifest = (config) => {
|
|
97
|
+
return withAndroidManifest(config, (cfg) => {
|
|
98
|
+
const manifest = cfg.modResults.manifest
|
|
99
|
+
AndroidConfig.Permissions.addPermission(
|
|
100
|
+
manifest,
|
|
101
|
+
'android.permission.POST_NOTIFICATIONS'
|
|
102
|
+
)
|
|
103
|
+
return cfg
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @param {import('@expo/config-plugins').ExpoConfig} config
|
|
109
|
+
*/
|
|
110
|
+
const withSentoriPushAndroidGradle = (config) => {
|
|
111
|
+
// Root build.gradle: add google-services classpath.
|
|
112
|
+
config = withProjectBuildGradle(config, (cfg) => {
|
|
113
|
+
if (cfg.modResults.language === 'groovy') {
|
|
114
|
+
const classpath = `classpath('com.google.gms:google-services:${GOOGLE_SERVICES_VERSION}')`
|
|
115
|
+
if (!cfg.modResults.contents.includes('com.google.gms:google-services')) {
|
|
116
|
+
cfg.modResults.contents = cfg.modResults.contents.replace(
|
|
117
|
+
/(dependencies\s*\{)/,
|
|
118
|
+
`$1\n ${classpath}`
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return cfg
|
|
123
|
+
})
|
|
124
|
+
// App build.gradle: apply plugin + firebase deps.
|
|
125
|
+
config = withAppBuildGradle(config, (cfg) => {
|
|
126
|
+
if (cfg.modResults.language !== 'groovy') return cfg
|
|
127
|
+
let contents = cfg.modResults.contents
|
|
128
|
+
if (!contents.includes('com.google.gms.google-services')) {
|
|
129
|
+
contents += `\napply plugin: 'com.google.gms.google-services'\n`
|
|
130
|
+
}
|
|
131
|
+
if (!contents.includes('firebase-bom')) {
|
|
132
|
+
contents = contents.replace(
|
|
133
|
+
/(dependencies\s*\{)/,
|
|
134
|
+
`$1\n implementation platform('com.google.firebase:firebase-bom:${FIREBASE_BOM_VERSION}')\n implementation 'com.google.firebase:firebase-messaging'`
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
cfg.modResults.contents = contents
|
|
138
|
+
return cfg
|
|
139
|
+
})
|
|
140
|
+
return config
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @param {import('@expo/config-plugins').ExpoConfig} config
|
|
145
|
+
* @param {{ googleServicesFile?: string }} props
|
|
146
|
+
*/
|
|
147
|
+
const withSentoriGoogleServicesJson = (config, props = {}) => {
|
|
148
|
+
return withDangerousMod(config, [
|
|
149
|
+
'android',
|
|
150
|
+
async (cfg) => {
|
|
151
|
+
const srcRel = props.googleServicesFile || './google-services.json'
|
|
152
|
+
const projectRoot = cfg.modRequest.projectRoot
|
|
153
|
+
const src = path.isAbsolute(srcRel) ? srcRel : path.join(projectRoot, srcRel)
|
|
154
|
+
if (!fs.existsSync(src)) {
|
|
155
|
+
// Don't fail the build; warn so the operator notices.
|
|
156
|
+
// eslint-disable-next-line no-console
|
|
157
|
+
console.warn(
|
|
158
|
+
`[sentori-expo] google-services.json not found at ${src}; skipping copy. Push will work once the file is added + prebuild re-runs.`
|
|
159
|
+
)
|
|
160
|
+
return cfg
|
|
161
|
+
}
|
|
162
|
+
const platformRoot = cfg.modRequest.platformProjectRoot
|
|
163
|
+
const dest = path.join(platformRoot, 'app', 'google-services.json')
|
|
164
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true })
|
|
165
|
+
fs.copyFileSync(src, dest)
|
|
166
|
+
return cfg
|
|
167
|
+
},
|
|
168
|
+
])
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ── Composer ───────────────────────────────────────────────────────
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @param {import('@expo/config-plugins').ExpoConfig} config
|
|
175
|
+
* @param {{ sdkVersion?: string, ios?: boolean, android?: boolean, googleServicesFile?: string }} [props]
|
|
176
|
+
*/
|
|
177
|
+
const withSentori = (config, props = {}) => {
|
|
178
|
+
const plugins = [[withSentoriVersion, props]]
|
|
179
|
+
if (props.ios !== false) plugins.push([withSentoriPushIos, props])
|
|
180
|
+
if (props.android !== false) {
|
|
181
|
+
plugins.push(
|
|
182
|
+
[withSentoriPushAndroidManifest, props],
|
|
183
|
+
[withSentoriPushAndroidGradle, props],
|
|
184
|
+
[withSentoriGoogleServicesJson, props]
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
return withPlugins(config, plugins)
|
|
188
|
+
}
|
|
189
|
+
|
|
39
190
|
module.exports = withSentori
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goliapkg/sentori-expo",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Expo adapter for Sentori — Config Plugin marker, expo-application auto-config, EAS post-build helper. Built on @goliapkg/sentori-react-native.",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"author": "GOLIA K.K. <takagi@golia.jp> (https://golia.jp)",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"prepack": "bun run build"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@goliapkg/sentori-react-native": ">=
|
|
49
|
-
"expo": ">=
|
|
50
|
-
"expo-application": ">=
|
|
51
|
-
"react-native": ">=0.
|
|
48
|
+
"@goliapkg/sentori-react-native": ">=3.0.0",
|
|
49
|
+
"expo": ">=55.0.0 <57.0.0",
|
|
50
|
+
"expo-application": ">=55.0.0 <57.0.0",
|
|
51
|
+
"react-native": ">=0.81.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"expo-application": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@expo/config-plugins": "
|
|
59
|
+
"@expo/config-plugins": ">=55.0.0 <57.0.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@goliapkg/sentori-react-native": "workspace:*",
|