@grafana/faro-react-native 1.4.0 → 1.4.1

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.
@@ -124,12 +124,12 @@ function makeRNConfig(config, preloadedMobileMeta, appSymbolsBundleId) {
124
124
  var instrumentations = buildInstrumentations(config);
125
125
  var installationId = (_c = config.app.installationId) !== null && _c !== void 0 ? _c : preloadedAppMeta === null || preloadedAppMeta === void 0 ? void 0 : preloadedAppMeta.installationId;
126
126
  var releaseBundleFilename = config.releaseBundleFilename;
127
- // Merge bundleId (from config, Metro, or DeviceInfo) with preloaded app meta
128
127
  var bundleIdValue = resolveAppBundleId(config.app, (_d = config.app) === null || _d === void 0 ? void 0 : _d.name, appSymbolsBundleId);
129
- var appMetasIfPresent = preloadedAppMeta || bundleIdValue
130
- ? [{ app: __assign(__assign({}, preloadedAppMeta), (bundleIdValue && { bundleId: bundleIdValue })) }]
131
- : [];
132
- return __assign(__assign({ app: __assign(__assign({}, config.app), (installationId && { installationId: installationId })) }, (preloadedMobileMeta != null && {
128
+ var app = __assign(__assign(__assign(__assign({}, preloadedAppMeta), config.app), (installationId && { installationId: installationId })), (bundleIdValue && { bundleId: bundleIdValue }));
129
+ // Core merges metadata shallowly. Supply the complete app object so native
130
+ // metadata cannot replace configured fields such as version and environment.
131
+ var appMetasIfPresent = preloadedAppMeta || bundleIdValue ? [{ app: app }] : [];
132
+ return __assign(__assign({ app: app }, (preloadedMobileMeta != null && {
133
133
  preloadedMobileMeta: preloadedMobileMeta.meta,
134
134
  preloadedSessionDeviceAttributes: preloadedMobileMeta.sessionAttributes,
135
135
  })), { dedupe: (_e = config.dedupe) !== null && _e !== void 0 ? _e : true, globalObjectKey: (_f = config.globalObjectKey) !== null && _f !== void 0 ? _f : faro_core_1.defaultGlobalObjectKey, internalLoggerLevel: (_g = config.internalLoggerLevel) !== null && _g !== void 0 ? _g : internalLogger_1.InternalLoggerLevel.ERROR, isolate: (_h = config.isolate) !== null && _h !== void 0 ? _h : false, parseStacktrace: (_j = config.parseStacktrace) !== null && _j !== void 0 ? _j : createParseStacktrace(releaseBundleFilename), paused: (_k = config.paused) !== null && _k !== void 0 ? _k : false, preventGlobalExposure: (_l = config.preventGlobalExposure) !== null && _l !== void 0 ? _l : false, unpatchedConsole: (_m = config.unpatchedConsole) !== null && _m !== void 0 ? _m : faro_core_1.defaultUnpatchedConsole, batching: {
@@ -1 +1 @@
1
- {"version":3,"file":"makeRNConfig.js","sourceRoot":"","sources":["../../../src/config/makeRNConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA,oCAyDC;AAlKD,gDAAqF;AAGrF,gFAAsF;AAEtF,gGAA2G;AAC3G,oDAAkE;AAClE,8DAAqE;AACrE,sCAA4C;AAC5C,0CAAgD;AAChD,oCAA0C;AAC1C,iDAAyD;AACzD,6CAAqD;AACrD,iDAAyD;AAEzD,iEAAgE;AAGhE,IAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AAEnE;;;;;;GAMG;AACH,SAAS,kBAAkB,CACzB,SAA8B,EAC9B,OAA2B,EAC3B,kBAA2B;IAE3B,IAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC,QAAQ,CAAC;IAC5B,CAAC;IACD,IAAM,OAAO,GAAG,IAAA,2CAAwB,EAAC,OAAO,CAAC,CAAC;IAClD,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,MAAyB;;IACxC,IAAA,KAA0D,MAAM,iBAAX,EAArD,gBAAgB,mBAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAA,CAAY;IAEzE,IAAI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grafana/faro-core';\nimport type { Config, MetaApp } from '@grafana/faro-core';\n\nimport { getStackFramesFromError } from '../instrumentations/errors/stackTraceParser';\nimport type { PreloadedMobileMeta } from '../instrumentations/session/sessionAttributes';\nimport { defaultSessionTrackingConfig } from '../instrumentations/session/sessionManager/sessionConstants';\nimport { InternalLoggerLevel, LogLevel } from '../internalLogger';\nimport { getMetroInjectedBundleId } from '../metas/appBuildIdentity';\nimport { getPageMeta } from '../metas/page';\nimport { getScreenMeta } from '../metas/screen';\nimport { getSdkMeta } from '../metas/sdk';\nimport { ConsoleTransport } from '../transports/console';\nimport { FetchTransport } from '../transports/fetch';\nimport { OfflineTransport } from '../transports/offline';\n\nimport { getRNInstrumentations } from './getRNInstrumentations';\nimport type { ReactNativeConfig, ReactNativeFullConfig } from './types';\n\nconst DEFAULT_OFFLINE_CACHE_MS = 3 * 24 * 60 * 60 * 1000; // 3 days\n\n/**\n * Resolves `meta.app.bundleId` when it is not already supplied by faro-core from\n * the Metro preamble (`registerInitialMetas` / `__faroBundleId_<appName>`).\n *\n * Priority: explicit `config.app.bundleId` → Metro preamble (core) → DeviceInfo\n * fallback (`applicationId@versionCode@versionName`, same shape Gradle/Metro use).\n */\nfunction resolveAppBundleId(\n configApp: MetaApp | undefined,\n appName: string | undefined,\n appSymbolsBundleId?: string\n): string | undefined {\n if (configApp?.bundleId) {\n return configApp.bundleId;\n }\n const metroId = getMetroInjectedBundleId(appName);\n if (metroId) {\n return metroId;\n }\n return appSymbolsBundleId;\n}\n\n/**\n * Builds transports. FetchTransport is always added when url is provided.\n * User can enable offline and console via enableTransports.\n */\nfunction buildTransports(config: ReactNativeConfig): Config['transports'] {\n const { enableTransports = { offline: false, console: false } } = config;\n\n if (!config.url) {\n throw new Error('url is required. Provide the Faro collector URL.');\n }\n\n const builtTransports: Config['transports'] = [];\n\n if (enableTransports.offline) {\n builtTransports.push(\n new OfflineTransport({\n maxCacheDurationMs: DEFAULT_OFFLINE_CACHE_MS,\n })\n );\n }\n\n builtTransports.push(\n new FetchTransport({\n url: config.url,\n apiKey: config.apiKey,\n })\n );\n\n if (enableTransports.console) {\n builtTransports.push(new ConsoleTransport({ level: LogLevel.DEBUG }));\n }\n\n const extraTransports = config.transports ?? [];\n return [...builtTransports, ...extraTransports];\n}\n\n/**\n * Builds instrumentations from config flags.\n */\nfunction buildInstrumentations(config: ReactNativeConfig): Config['instrumentations'] {\n const baseInstrumentations = getRNInstrumentations(config);\n const extraInstrumentations = config.instrumentations ?? [];\n return [...baseInstrumentations, ...extraInstrumentations];\n}\n\n/**\n * React Native stacktrace parser. Uses getStackFramesFromError for RN-specific formats.\n */\nfunction createParseStacktrace(releaseBundleFilename: string | undefined): Config['parseStacktrace'] {\n return (err) => ({\n frames: getStackFramesFromError(err, { releaseBundleFilename }),\n });\n}\n\n/**\n * Creates a full Faro config from React Native flag-based config.\n *\n * Based on flags, builds instrumentations and transports automatically.\n * Client just enables what they need; makeRNConfig does the rest.\n *\n * @param preloadedMobileMeta Device/session fields and structured mobile meta (passed from async `initializeFaro`).\n * @param appSymbolsBundleId Encoded `meta.app.bundleId` for server-side symbol retrace.\n */\nexport function makeRNConfig(\n config: ReactNativeConfig,\n preloadedMobileMeta?: PreloadedMobileMeta,\n appSymbolsBundleId?: string\n): ReactNativeFullConfig {\n const { app: preloadedAppMeta, ...structuredMobileMeta } = preloadedMobileMeta?.meta ?? {};\n const mobileMetas = Object.keys(structuredMobileMeta).length > 0 ? [structuredMobileMeta] : [];\n const defaultMetas = [getSdkMeta(), getPageMeta(), getScreenMeta(), ...mobileMetas];\n const customMetas = config.metas ?? [];\n const transports = buildTransports(config);\n const instrumentations = buildInstrumentations(config);\n const installationId = config.app.installationId ?? preloadedAppMeta?.installationId;\n\n const releaseBundleFilename = config.releaseBundleFilename;\n // Merge bundleId (from config, Metro, or DeviceInfo) with preloaded app meta\n const bundleIdValue = resolveAppBundleId(config.app, config.app?.name, appSymbolsBundleId);\n const appMetasIfPresent =\n preloadedAppMeta || bundleIdValue\n ? [{ app: { ...preloadedAppMeta, ...(bundleIdValue && { bundleId: bundleIdValue }) } }]\n : [];\n\n return {\n app: {\n ...config.app,\n ...(installationId && { installationId }),\n },\n ...(preloadedMobileMeta != null && {\n preloadedMobileMeta: preloadedMobileMeta.meta,\n preloadedSessionDeviceAttributes: preloadedMobileMeta.sessionAttributes,\n }),\n dedupe: config.dedupe ?? true,\n globalObjectKey: config.globalObjectKey ?? defaultGlobalObjectKey,\n internalLoggerLevel: config.internalLoggerLevel ?? InternalLoggerLevel.ERROR,\n isolate: config.isolate ?? false,\n parseStacktrace: config.parseStacktrace ?? createParseStacktrace(releaseBundleFilename),\n paused: config.paused ?? false,\n preventGlobalExposure: config.preventGlobalExposure ?? false,\n unpatchedConsole: config.unpatchedConsole ?? defaultUnpatchedConsole,\n batching: {\n enabled: false,\n sendTimeout: 250,\n itemLimit: 50,\n },\n sessionTracking: {\n ...defaultSessionTrackingConfig,\n ...config.sessionTracking,\n },\n metas: [...defaultMetas, ...customMetas, ...appMetasIfPresent],\n instrumentations,\n transports,\n ignoreUrls: config.ignoreUrls ?? [],\n ignoreErrors: config.ignoreErrors,\n beforeSend: config.beforeSend,\n preserveOriginalError: config.preserveOriginalError,\n userActionsInstrumentation: config.userActionsOptions,\n consoleInstrumentation: config.consoleCaptureOptions,\n };\n}\n"]}
1
+ {"version":3,"file":"makeRNConfig.js","sourceRoot":"","sources":["../../../src/config/makeRNConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA,oCA0DC;AAnKD,gDAAqF;AAGrF,gFAAsF;AAEtF,gGAA2G;AAC3G,oDAAkE;AAClE,8DAAqE;AACrE,sCAA4C;AAC5C,0CAAgD;AAChD,oCAA0C;AAC1C,iDAAyD;AACzD,6CAAqD;AACrD,iDAAyD;AAEzD,iEAAgE;AAGhE,IAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,S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AAE,MAAA,MAAM,CAAC,gBAAgB,mCAAI,mCAAuB,EACpE,QAAQ,EAAE;YACR,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,GAAG;YAChB,SAAS,EAAE,EAAE;SACd,EACD,eAAe,wBACV,+CAA4B,GAC5B,MAAM,CAAC,eAAe,GAE3B,KAAK,gDAAM,YAAY,SAAK,WAAW,SAAK,iBAAiB,SAC7D,gBAAgB,kBAAA,EAChB,UAAU,YAAA,EACV,UAAU,EAAE,MAAA,MAAM,CAAC,UAAU,mCAAI,EAAE,EACnC,YAAY,EAAE,MAAM,CAAC,YAAY,EACjC,UAAU,EAAE,MAAM,CAAC,UAAU,EAC7B,qBAAqB,EAAE,MAAM,CAAC,qBAAqB,EACnD,0BAA0B,EAAE,MAAM,CAAC,kBAAkB,EACrD,sBAAsB,EAAE,MAAM,CAAC,qBAAqB,IACpD;AACJ,CAAC","sourcesContent":["import { defaultGlobalObjectKey, defaultUnpatchedConsole } from '@grafana/faro-core';\nimport type { Config, MetaApp } from '@grafana/faro-core';\n\nimport { getStackFramesFromError } from '../instrumentations/errors/stackTraceParser';\nimport type { PreloadedMobileMeta } from '../instrumentations/session/sessionAttributes';\nimport { defaultSessionTrackingConfig } from '../instrumentations/session/sessionManager/sessionConstants';\nimport { InternalLoggerLevel, LogLevel } from '../internalLogger';\nimport { getMetroInjectedBundleId } from '../metas/appBuildIdentity';\nimport { getPageMeta } from '../metas/page';\nimport { getScreenMeta } from '../metas/screen';\nimport { getSdkMeta } from '../metas/sdk';\nimport { ConsoleTransport } from '../transports/console';\nimport { FetchTransport } from '../transports/fetch';\nimport { OfflineTransport } from '../transports/offline';\n\nimport { getRNInstrumentations } from './getRNInstrumentations';\nimport type { ReactNativeConfig, ReactNativeFullConfig } from './types';\n\nconst DEFAULT_OFFLINE_CACHE_MS = 3 * 24 * 60 * 60 * 1000; // 3 days\n\n/**\n * Resolves `meta.app.bundleId` when it is not already supplied by faro-core from\n * the Metro preamble (`registerInitialMetas` / `__faroBundleId_<appName>`).\n *\n * Priority: explicit `config.app.bundleId` → Metro preamble (core) → DeviceInfo\n * fallback (`applicationId@versionCode@versionName`, same shape Gradle/Metro use).\n */\nfunction resolveAppBundleId(\n configApp: MetaApp | undefined,\n appName: string | undefined,\n appSymbolsBundleId?: string\n): string | undefined {\n if (configApp?.bundleId) {\n return configApp.bundleId;\n }\n const metroId = getMetroInjectedBundleId(appName);\n if (metroId) {\n return metroId;\n }\n return appSymbolsBundleId;\n}\n\n/**\n * Builds transports. FetchTransport is always added when url is provided.\n * User can enable offline and console via enableTransports.\n */\nfunction buildTransports(config: ReactNativeConfig): Config['transports'] {\n const { enableTransports = { offline: false, console: false } } = config;\n\n if (!config.url) {\n throw new Error('url is required. Provide the Faro collector URL.');\n }\n\n const builtTransports: Config['transports'] = [];\n\n if (enableTransports.offline) {\n builtTransports.push(\n new OfflineTransport({\n maxCacheDurationMs: DEFAULT_OFFLINE_CACHE_MS,\n })\n );\n }\n\n builtTransports.push(\n new FetchTransport({\n url: config.url,\n apiKey: config.apiKey,\n })\n );\n\n if (enableTransports.console) {\n builtTransports.push(new ConsoleTransport({ level: LogLevel.DEBUG }));\n }\n\n const extraTransports = config.transports ?? [];\n return [...builtTransports, ...extraTransports];\n}\n\n/**\n * Builds instrumentations from config flags.\n */\nfunction buildInstrumentations(config: ReactNativeConfig): Config['instrumentations'] {\n const baseInstrumentations = getRNInstrumentations(config);\n const extraInstrumentations = config.instrumentations ?? [];\n return [...baseInstrumentations, ...extraInstrumentations];\n}\n\n/**\n * React Native stacktrace parser. Uses getStackFramesFromError for RN-specific formats.\n */\nfunction createParseStacktrace(releaseBundleFilename: string | undefined): Config['parseStacktrace'] {\n return (err) => ({\n frames: getStackFramesFromError(err, { releaseBundleFilename }),\n });\n}\n\n/**\n * Creates a full Faro config from React Native flag-based config.\n *\n * Based on flags, builds instrumentations and transports automatically.\n * Client just enables what they need; makeRNConfig does the rest.\n *\n * @param preloadedMobileMeta Device/session fields and structured mobile meta (passed from async `initializeFaro`).\n * @param appSymbolsBundleId Encoded `meta.app.bundleId` for server-side symbol retrace.\n */\nexport function makeRNConfig(\n config: ReactNativeConfig,\n preloadedMobileMeta?: PreloadedMobileMeta,\n appSymbolsBundleId?: string\n): ReactNativeFullConfig {\n const { app: preloadedAppMeta, ...structuredMobileMeta } = preloadedMobileMeta?.meta ?? {};\n const mobileMetas = Object.keys(structuredMobileMeta).length > 0 ? [structuredMobileMeta] : [];\n const defaultMetas = [getSdkMeta(), getPageMeta(), getScreenMeta(), ...mobileMetas];\n const customMetas = config.metas ?? [];\n const transports = buildTransports(config);\n const instrumentations = buildInstrumentations(config);\n const installationId = config.app.installationId ?? preloadedAppMeta?.installationId;\n\n const releaseBundleFilename = config.releaseBundleFilename;\n const bundleIdValue = resolveAppBundleId(config.app, config.app?.name, appSymbolsBundleId);\n const app = {\n ...preloadedAppMeta,\n ...config.app,\n ...(installationId && { installationId }),\n ...(bundleIdValue && { bundleId: bundleIdValue }),\n };\n // Core merges metadata shallowly. Supply the complete app object so native\n // metadata cannot replace configured fields such as version and environment.\n const appMetasIfPresent = preloadedAppMeta || bundleIdValue ? [{ app }] : [];\n\n return {\n app,\n ...(preloadedMobileMeta != null && {\n preloadedMobileMeta: preloadedMobileMeta.meta,\n preloadedSessionDeviceAttributes: preloadedMobileMeta.sessionAttributes,\n }),\n dedupe: config.dedupe ?? true,\n globalObjectKey: config.globalObjectKey ?? defaultGlobalObjectKey,\n internalLoggerLevel: config.internalLoggerLevel ?? InternalLoggerLevel.ERROR,\n isolate: config.isolate ?? false,\n parseStacktrace: config.parseStacktrace ?? createParseStacktrace(releaseBundleFilename),\n paused: config.paused ?? false,\n preventGlobalExposure: config.preventGlobalExposure ?? false,\n unpatchedConsole: config.unpatchedConsole ?? defaultUnpatchedConsole,\n batching: {\n enabled: false,\n sendTimeout: 250,\n itemLimit: 50,\n },\n sessionTracking: {\n ...defaultSessionTrackingConfig,\n ...config.sessionTracking,\n },\n metas: [...defaultMetas, ...customMetas, ...appMetasIfPresent],\n instrumentations,\n transports,\n ignoreUrls: config.ignoreUrls ?? [],\n ignoreErrors: config.ignoreErrors,\n beforeSend: config.beforeSend,\n preserveOriginalError: config.preserveOriginalError,\n userActionsInstrumentation: config.userActionsOptions,\n consoleInstrumentation: config.consoleCaptureOptions,\n };\n}\n"]}
@@ -5,5 +5,5 @@ exports.FARO_REACT_NATIVE_NPM_VERSION = exports.FARO_REACT_NATIVE_NPM_NAME = voi
5
5
  * NPM package identity for this build. Generated by scripts/sync-faro-rn-package-meta.mjs - do not edit.
6
6
  */
7
7
  exports.FARO_REACT_NATIVE_NPM_NAME = '@grafana/faro-react-native';
8
- exports.FARO_REACT_NATIVE_NPM_VERSION = '1.4.0';
8
+ exports.FARO_REACT_NATIVE_NPM_VERSION = '1.4.1';
9
9
  //# sourceMappingURL=faroRNPackageMeta.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"faroRNPackageMeta.js","sourceRoot":"","sources":["../../../src/generated/faroRNPackageMeta.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,0BAA0B,GAAG,4BAAqC,CAAC;AACnE,QAAA,6BAA6B,GAAG,OAAgB,CAAC","sourcesContent":["/**\n * NPM package identity for this build. Generated by scripts/sync-faro-rn-package-meta.mjs - do not edit.\n */\nexport const FARO_REACT_NATIVE_NPM_NAME = '@grafana/faro-react-native' as const;\nexport const FARO_REACT_NATIVE_NPM_VERSION = '1.4.0' as const;\n"]}
1
+ {"version":3,"file":"faroRNPackageMeta.js","sourceRoot":"","sources":["../../../src/generated/faroRNPackageMeta.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,0BAA0B,GAAG,4BAAqC,CAAC;AACnE,QAAA,6BAA6B,GAAG,OAAgB,CAAC","sourcesContent":["/**\n * NPM package identity for this build. Generated by scripts/sync-faro-rn-package-meta.mjs - do not edit.\n */\nexport const FARO_REACT_NATIVE_NPM_NAME = '@grafana/faro-react-native' as const;\nexport const FARO_REACT_NATIVE_NPM_VERSION = '1.4.1' as const;\n"]}
@@ -101,12 +101,12 @@ export function makeRNConfig(config, preloadedMobileMeta, appSymbolsBundleId) {
101
101
  const instrumentations = buildInstrumentations(config);
102
102
  const installationId = (_c = config.app.installationId) !== null && _c !== void 0 ? _c : preloadedAppMeta === null || preloadedAppMeta === void 0 ? void 0 : preloadedAppMeta.installationId;
103
103
  const releaseBundleFilename = config.releaseBundleFilename;
104
- // Merge bundleId (from config, Metro, or DeviceInfo) with preloaded app meta
105
104
  const bundleIdValue = resolveAppBundleId(config.app, (_d = config.app) === null || _d === void 0 ? void 0 : _d.name, appSymbolsBundleId);
106
- const appMetasIfPresent = preloadedAppMeta || bundleIdValue
107
- ? [{ app: Object.assign(Object.assign({}, preloadedAppMeta), (bundleIdValue && { bundleId: bundleIdValue })) }]
108
- : [];
109
- return Object.assign(Object.assign({ app: Object.assign(Object.assign({}, config.app), (installationId && { installationId })) }, (preloadedMobileMeta != null && {
105
+ const app = Object.assign(Object.assign(Object.assign(Object.assign({}, preloadedAppMeta), config.app), (installationId && { installationId })), (bundleIdValue && { bundleId: bundleIdValue }));
106
+ // Core merges metadata shallowly. Supply the complete app object so native
107
+ // metadata cannot replace configured fields such as version and environment.
108
+ const appMetasIfPresent = preloadedAppMeta || bundleIdValue ? [{ app }] : [];
109
+ return Object.assign(Object.assign({ app }, (preloadedMobileMeta != null && {
110
110
  preloadedMobileMeta: preloadedMobileMeta.meta,
111
111
  preloadedSessionDeviceAttributes: preloadedMobileMeta.sessionAttributes,
112
112
  })), { dedupe: (_e = config.dedupe) !== null && _e !== void 0 ? _e : true, globalObjectKey: (_f = config.globalObjectKey) !== null && _f !== void 0 ? _f : defaultGlobalObjectKey, internalLoggerLevel: (_g = config.internalLoggerLevel) !== null && _g !== void 0 ? _g : InternalLoggerLevel.ERROR, isolate: (_h = config.isolate) !== null && _h !== void 0 ? _h : false, parseStacktrace: (_j = config.parseStacktrace) !== null && _j !== void 0 ? _j : createParseStacktrace(releaseBundleFilename), paused: (_k = config.paused) !== null && _k !== void 0 ? _k : false, preventGlobalExposure: (_l = config.preventGlobalExposure) !== null && _l !== void 0 ? _l : false, unpatchedConsole: (_m = config.unpatchedConsole) !== null && _m !== void 0 ? _m : defaultUnpatchedConsole, batching: {
@@ -1 +1 @@
1
- {"version":3,"file":"makeRNConfig.js","sourceRoot":"","sources":["../../../src/config/makeRNConfig.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAGrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAEtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,6DAA6D,CAAC;AAC3G,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AAEnE;;;;;;GAMG;AACH,SAAS,kBAAkB,CACzB,SAA8B,EAC9B,OAA2B,EAC3B,kBAA2B;IAE3B,IAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC,QAAQ,CAAC;IAC5B,CAAC;IACD,M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AG,iBAAiB,CAAC,EAC9D,gBAAgB;QAChB,UAAU,EACV,UAAU,EAAE,MAAA,MAAM,CAAC,UAAU,mCAAI,EAAE,EACnC,YAAY,EAAE,MAAM,CAAC,YAAY,EACjC,UAAU,EAAE,MAAM,CAAC,UAAU,EAC7B,qBAAqB,EAAE,MAAM,CAAC,qBAAqB,EACnD,0BAA0B,EAAE,MAAM,CAAC,kBAAkB,EACrD,sBAAsB,EAAE,MAAM,CAAC,qBAAqB,IACpD;AACJ,CAAC","sourcesContent":["import { defaultGlobalObjectKey, defaultUnpatchedConsole } from '@grafana/faro-core';\nimport type { Config, MetaApp } from '@grafana/faro-core';\n\nimport { getStackFramesFromError } from '../instrumentations/errors/stackTraceParser';\nimport type { PreloadedMobileMeta } from '../instrumentations/session/sessionAttributes';\nimport { defaultSessionTrackingConfig } from '../instrumentations/session/sessionManager/sessionConstants';\nimport { InternalLoggerLevel, LogLevel } from '../internalLogger';\nimport { getMetroInjectedBundleId } from '../metas/appBuildIdentity';\nimport { getPageMeta } from '../metas/page';\nimport { getScreenMeta } from '../metas/screen';\nimport { getSdkMeta } from '../metas/sdk';\nimport { ConsoleTransport } from '../transports/console';\nimport { FetchTransport } from '../transports/fetch';\nimport { OfflineTransport } from '../transports/offline';\n\nimport { getRNInstrumentations } from './getRNInstrumentations';\nimport type { ReactNativeConfig, ReactNativeFullConfig } from './types';\n\nconst DEFAULT_OFFLINE_CACHE_MS = 3 * 24 * 60 * 60 * 1000; // 3 days\n\n/**\n * Resolves `meta.app.bundleId` when it is not already supplied by faro-core from\n * the Metro preamble (`registerInitialMetas` / `__faroBundleId_<appName>`).\n *\n * Priority: explicit `config.app.bundleId` → Metro preamble (core) → DeviceInfo\n * fallback (`applicationId@versionCode@versionName`, same shape Gradle/Metro use).\n */\nfunction resolveAppBundleId(\n configApp: MetaApp | undefined,\n appName: string | undefined,\n appSymbolsBundleId?: string\n): string | undefined {\n if (configApp?.bundleId) {\n return configApp.bundleId;\n }\n const metroId = getMetroInjectedBundleId(appName);\n if (metroId) {\n return metroId;\n }\n return appSymbolsBundleId;\n}\n\n/**\n * Builds transports. FetchTransport is always added when url is provided.\n * User can enable offline and console via enableTransports.\n */\nfunction buildTransports(config: ReactNativeConfig): Config['transports'] {\n const { enableTransports = { offline: false, console: false } } = config;\n\n if (!config.url) {\n throw new Error('url is required. Provide the Faro collector URL.');\n }\n\n const builtTransports: Config['transports'] = [];\n\n if (enableTransports.offline) {\n builtTransports.push(\n new OfflineTransport({\n maxCacheDurationMs: DEFAULT_OFFLINE_CACHE_MS,\n })\n );\n }\n\n builtTransports.push(\n new FetchTransport({\n url: config.url,\n apiKey: config.apiKey,\n })\n );\n\n if (enableTransports.console) {\n builtTransports.push(new ConsoleTransport({ level: LogLevel.DEBUG }));\n }\n\n const extraTransports = config.transports ?? [];\n return [...builtTransports, ...extraTransports];\n}\n\n/**\n * Builds instrumentations from config flags.\n */\nfunction buildInstrumentations(config: ReactNativeConfig): Config['instrumentations'] {\n const baseInstrumentations = getRNInstrumentations(config);\n const extraInstrumentations = config.instrumentations ?? [];\n return [...baseInstrumentations, ...extraInstrumentations];\n}\n\n/**\n * React Native stacktrace parser. Uses getStackFramesFromError for RN-specific formats.\n */\nfunction createParseStacktrace(releaseBundleFilename: string | undefined): Config['parseStacktrace'] {\n return (err) => ({\n frames: getStackFramesFromError(err, { releaseBundleFilename }),\n });\n}\n\n/**\n * Creates a full Faro config from React Native flag-based config.\n *\n * Based on flags, builds instrumentations and transports automatically.\n * Client just enables what they need; makeRNConfig does the rest.\n *\n * @param preloadedMobileMeta Device/session fields and structured mobile meta (passed from async `initializeFaro`).\n * @param appSymbolsBundleId Encoded `meta.app.bundleId` for server-side symbol retrace.\n */\nexport function makeRNConfig(\n config: ReactNativeConfig,\n preloadedMobileMeta?: PreloadedMobileMeta,\n appSymbolsBundleId?: string\n): ReactNativeFullConfig {\n const { app: preloadedAppMeta, ...structuredMobileMeta } = preloadedMobileMeta?.meta ?? {};\n const mobileMetas = Object.keys(structuredMobileMeta).length > 0 ? [structuredMobileMeta] : [];\n const defaultMetas = [getSdkMeta(), getPageMeta(), getScreenMeta(), ...mobileMetas];\n const customMetas = config.metas ?? [];\n const transports = buildTransports(config);\n const instrumentations = buildInstrumentations(config);\n const installationId = config.app.installationId ?? preloadedAppMeta?.installationId;\n\n const releaseBundleFilename = config.releaseBundleFilename;\n // Merge bundleId (from config, Metro, or DeviceInfo) with preloaded app meta\n const bundleIdValue = resolveAppBundleId(config.app, config.app?.name, appSymbolsBundleId);\n const appMetasIfPresent =\n preloadedAppMeta || bundleIdValue\n ? [{ app: { ...preloadedAppMeta, ...(bundleIdValue && { bundleId: bundleIdValue }) } }]\n : [];\n\n return {\n app: {\n ...config.app,\n ...(installationId && { installationId }),\n },\n ...(preloadedMobileMeta != null && {\n preloadedMobileMeta: preloadedMobileMeta.meta,\n preloadedSessionDeviceAttributes: preloadedMobileMeta.sessionAttributes,\n }),\n dedupe: config.dedupe ?? true,\n globalObjectKey: config.globalObjectKey ?? defaultGlobalObjectKey,\n internalLoggerLevel: config.internalLoggerLevel ?? InternalLoggerLevel.ERROR,\n isolate: config.isolate ?? false,\n parseStacktrace: config.parseStacktrace ?? createParseStacktrace(releaseBundleFilename),\n paused: config.paused ?? false,\n preventGlobalExposure: config.preventGlobalExposure ?? false,\n unpatchedConsole: config.unpatchedConsole ?? defaultUnpatchedConsole,\n batching: {\n enabled: false,\n sendTimeout: 250,\n itemLimit: 50,\n },\n sessionTracking: {\n ...defaultSessionTrackingConfig,\n ...config.sessionTracking,\n },\n metas: [...defaultMetas, ...customMetas, ...appMetasIfPresent],\n instrumentations,\n transports,\n ignoreUrls: config.ignoreUrls ?? [],\n ignoreErrors: config.ignoreErrors,\n beforeSend: config.beforeSend,\n preserveOriginalError: config.preserveOriginalError,\n userActionsInstrumentation: config.userActionsOptions,\n consoleInstrumentation: config.consoleCaptureOptions,\n };\n}\n"]}
1
+ {"version":3,"file":"makeRNConfig.js","sourceRoot":"","sources":["../../../src/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EAAE,MAAM,CAAC,qBAAqB,EACnD,0BAA0B,EAAE,MAAM,CAAC,kBAAkB,EACrD,sBAAsB,EAAE,MAAM,CAAC,qBAAqB,IACpD;AACJ,CAAC","sourcesContent":["import { defaultGlobalObjectKey, defaultUnpatchedConsole } from '@grafana/faro-core';\nimport type { Config, MetaApp } from '@grafana/faro-core';\n\nimport { getStackFramesFromError } from '../instrumentations/errors/stackTraceParser';\nimport type { PreloadedMobileMeta } from '../instrumentations/session/sessionAttributes';\nimport { defaultSessionTrackingConfig } from '../instrumentations/session/sessionManager/sessionConstants';\nimport { InternalLoggerLevel, LogLevel } from '../internalLogger';\nimport { getMetroInjectedBundleId } from '../metas/appBuildIdentity';\nimport { getPageMeta } from '../metas/page';\nimport { getScreenMeta } from '../metas/screen';\nimport { getSdkMeta } from '../metas/sdk';\nimport { ConsoleTransport } from '../transports/console';\nimport { FetchTransport } from '../transports/fetch';\nimport { OfflineTransport } from '../transports/offline';\n\nimport { getRNInstrumentations } from './getRNInstrumentations';\nimport type { ReactNativeConfig, ReactNativeFullConfig } from './types';\n\nconst DEFAULT_OFFLINE_CACHE_MS = 3 * 24 * 60 * 60 * 1000; // 3 days\n\n/**\n * Resolves `meta.app.bundleId` when it is not already supplied by faro-core from\n * the Metro preamble (`registerInitialMetas` / `__faroBundleId_<appName>`).\n *\n * Priority: explicit `config.app.bundleId` → Metro preamble (core) → DeviceInfo\n * fallback (`applicationId@versionCode@versionName`, same shape Gradle/Metro use).\n */\nfunction resolveAppBundleId(\n configApp: MetaApp | undefined,\n appName: string | undefined,\n appSymbolsBundleId?: string\n): string | undefined {\n if (configApp?.bundleId) {\n return configApp.bundleId;\n }\n const metroId = getMetroInjectedBundleId(appName);\n if (metroId) {\n return metroId;\n }\n return appSymbolsBundleId;\n}\n\n/**\n * Builds transports. FetchTransport is always added when url is provided.\n * User can enable offline and console via enableTransports.\n */\nfunction buildTransports(config: ReactNativeConfig): Config['transports'] {\n const { enableTransports = { offline: false, console: false } } = config;\n\n if (!config.url) {\n throw new Error('url is required. Provide the Faro collector URL.');\n }\n\n const builtTransports: Config['transports'] = [];\n\n if (enableTransports.offline) {\n builtTransports.push(\n new OfflineTransport({\n maxCacheDurationMs: DEFAULT_OFFLINE_CACHE_MS,\n })\n );\n }\n\n builtTransports.push(\n new FetchTransport({\n url: config.url,\n apiKey: config.apiKey,\n })\n );\n\n if (enableTransports.console) {\n builtTransports.push(new ConsoleTransport({ level: LogLevel.DEBUG }));\n }\n\n const extraTransports = config.transports ?? [];\n return [...builtTransports, ...extraTransports];\n}\n\n/**\n * Builds instrumentations from config flags.\n */\nfunction buildInstrumentations(config: ReactNativeConfig): Config['instrumentations'] {\n const baseInstrumentations = getRNInstrumentations(config);\n const extraInstrumentations = config.instrumentations ?? [];\n return [...baseInstrumentations, ...extraInstrumentations];\n}\n\n/**\n * React Native stacktrace parser. Uses getStackFramesFromError for RN-specific formats.\n */\nfunction createParseStacktrace(releaseBundleFilename: string | undefined): Config['parseStacktrace'] {\n return (err) => ({\n frames: getStackFramesFromError(err, { releaseBundleFilename }),\n });\n}\n\n/**\n * Creates a full Faro config from React Native flag-based config.\n *\n * Based on flags, builds instrumentations and transports automatically.\n * Client just enables what they need; makeRNConfig does the rest.\n *\n * @param preloadedMobileMeta Device/session fields and structured mobile meta (passed from async `initializeFaro`).\n * @param appSymbolsBundleId Encoded `meta.app.bundleId` for server-side symbol retrace.\n */\nexport function makeRNConfig(\n config: ReactNativeConfig,\n preloadedMobileMeta?: PreloadedMobileMeta,\n appSymbolsBundleId?: string\n): ReactNativeFullConfig {\n const { app: preloadedAppMeta, ...structuredMobileMeta } = preloadedMobileMeta?.meta ?? {};\n const mobileMetas = Object.keys(structuredMobileMeta).length > 0 ? [structuredMobileMeta] : [];\n const defaultMetas = [getSdkMeta(), getPageMeta(), getScreenMeta(), ...mobileMetas];\n const customMetas = config.metas ?? [];\n const transports = buildTransports(config);\n const instrumentations = buildInstrumentations(config);\n const installationId = config.app.installationId ?? preloadedAppMeta?.installationId;\n\n const releaseBundleFilename = config.releaseBundleFilename;\n const bundleIdValue = resolveAppBundleId(config.app, config.app?.name, appSymbolsBundleId);\n const app = {\n ...preloadedAppMeta,\n ...config.app,\n ...(installationId && { installationId }),\n ...(bundleIdValue && { bundleId: bundleIdValue }),\n };\n // Core merges metadata shallowly. Supply the complete app object so native\n // metadata cannot replace configured fields such as version and environment.\n const appMetasIfPresent = preloadedAppMeta || bundleIdValue ? [{ app }] : [];\n\n return {\n app,\n ...(preloadedMobileMeta != null && {\n preloadedMobileMeta: preloadedMobileMeta.meta,\n preloadedSessionDeviceAttributes: preloadedMobileMeta.sessionAttributes,\n }),\n dedupe: config.dedupe ?? true,\n globalObjectKey: config.globalObjectKey ?? defaultGlobalObjectKey,\n internalLoggerLevel: config.internalLoggerLevel ?? InternalLoggerLevel.ERROR,\n isolate: config.isolate ?? false,\n parseStacktrace: config.parseStacktrace ?? createParseStacktrace(releaseBundleFilename),\n paused: config.paused ?? false,\n preventGlobalExposure: config.preventGlobalExposure ?? false,\n unpatchedConsole: config.unpatchedConsole ?? defaultUnpatchedConsole,\n batching: {\n enabled: false,\n sendTimeout: 250,\n itemLimit: 50,\n },\n sessionTracking: {\n ...defaultSessionTrackingConfig,\n ...config.sessionTracking,\n },\n metas: [...defaultMetas, ...customMetas, ...appMetasIfPresent],\n instrumentations,\n transports,\n ignoreUrls: config.ignoreUrls ?? [],\n ignoreErrors: config.ignoreErrors,\n beforeSend: config.beforeSend,\n preserveOriginalError: config.preserveOriginalError,\n userActionsInstrumentation: config.userActionsOptions,\n consoleInstrumentation: config.consoleCaptureOptions,\n };\n}\n"]}
@@ -2,5 +2,5 @@
2
2
  * NPM package identity for this build. Generated by scripts/sync-faro-rn-package-meta.mjs - do not edit.
3
3
  */
4
4
  export const FARO_REACT_NATIVE_NPM_NAME = '@grafana/faro-react-native';
5
- export const FARO_REACT_NATIVE_NPM_VERSION = '1.4.0';
5
+ export const FARO_REACT_NATIVE_NPM_VERSION = '1.4.1';
6
6
  //# sourceMappingURL=faroRNPackageMeta.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"faroRNPackageMeta.js","sourceRoot":"","sources":["../../../src/generated/faroRNPackageMeta.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,4BAAqC,CAAC;AAChF,MAAM,CAAC,MAAM,6BAA6B,GAAG,OAAgB,CAAC","sourcesContent":["/**\n * NPM package identity for this build. Generated by scripts/sync-faro-rn-package-meta.mjs - do not edit.\n */\nexport const FARO_REACT_NATIVE_NPM_NAME = '@grafana/faro-react-native' as const;\nexport const FARO_REACT_NATIVE_NPM_VERSION = '1.4.0' as const;\n"]}
1
+ {"version":3,"file":"faroRNPackageMeta.js","sourceRoot":"","sources":["../../../src/generated/faroRNPackageMeta.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,4BAAqC,CAAC;AAChF,MAAM,CAAC,MAAM,6BAA6B,GAAG,OAAgB,CAAC","sourcesContent":["/**\n * NPM package identity for this build. Generated by scripts/sync-faro-rn-package-meta.mjs - do not edit.\n */\nexport const FARO_REACT_NATIVE_NPM_NAME = '@grafana/faro-react-native' as const;\nexport const FARO_REACT_NATIVE_NPM_VERSION = '1.4.1' as const;\n"]}
@@ -2,4 +2,4 @@
2
2
  * NPM package identity for this build. Generated by scripts/sync-faro-rn-package-meta.mjs - do not edit.
3
3
  */
4
4
  export declare const FARO_REACT_NATIVE_NPM_NAME: "@grafana/faro-react-native";
5
- export declare const FARO_REACT_NATIVE_NPM_VERSION: "1.4.0";
5
+ export declare const FARO_REACT_NATIVE_NPM_VERSION: "1.4.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/faro-react-native",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Faro instrumentations, metas, transports for React Native.",
5
5
  "keywords": [
6
6
  "observability",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "38d87a3474585e1177c38d2e9acd04860a4236e6"
89
+ "gitHead": "a48a98201d411ccd8e5d01fad00239cb4727979e"
90
90
  }
@@ -117,18 +117,19 @@ export function makeRNConfig(
117
117
  const installationId = config.app.installationId ?? preloadedAppMeta?.installationId;
118
118
 
119
119
  const releaseBundleFilename = config.releaseBundleFilename;
120
- // Merge bundleId (from config, Metro, or DeviceInfo) with preloaded app meta
121
120
  const bundleIdValue = resolveAppBundleId(config.app, config.app?.name, appSymbolsBundleId);
122
- const appMetasIfPresent =
123
- preloadedAppMeta || bundleIdValue
124
- ? [{ app: { ...preloadedAppMeta, ...(bundleIdValue && { bundleId: bundleIdValue }) } }]
125
- : [];
121
+ const app = {
122
+ ...preloadedAppMeta,
123
+ ...config.app,
124
+ ...(installationId && { installationId }),
125
+ ...(bundleIdValue && { bundleId: bundleIdValue }),
126
+ };
127
+ // Core merges metadata shallowly. Supply the complete app object so native
128
+ // metadata cannot replace configured fields such as version and environment.
129
+ const appMetasIfPresent = preloadedAppMeta || bundleIdValue ? [{ app }] : [];
126
130
 
127
131
  return {
128
- app: {
129
- ...config.app,
130
- ...(installationId && { installationId }),
131
- },
132
+ app,
132
133
  ...(preloadedMobileMeta != null && {
133
134
  preloadedMobileMeta: preloadedMobileMeta.meta,
134
135
  preloadedSessionDeviceAttributes: preloadedMobileMeta.sessionAttributes,
@@ -2,4 +2,4 @@
2
2
  * NPM package identity for this build. Generated by scripts/sync-faro-rn-package-meta.mjs - do not edit.
3
3
  */
4
4
  export const FARO_REACT_NATIVE_NPM_NAME = '@grafana/faro-react-native' as const;
5
- export const FARO_REACT_NATIVE_NPM_VERSION = '1.4.0' as const;
5
+ export const FARO_REACT_NATIVE_NPM_VERSION = '1.4.1' as const;
@@ -1,4 +1,4 @@
1
- import { VERSION } from '@grafana/faro-core';
1
+ import { getTransportBody, VERSION } from '@grafana/faro-core';
2
2
  import { mockConfig, MockTransport } from '@grafana/faro-test-utils';
3
3
 
4
4
  import packageJson from '../package.json';
@@ -6,6 +6,7 @@ import packageJson from '../package.json';
6
6
  import { initializeFaro } from './initialize';
7
7
  import { SessionInstrumentation } from './instrumentations/session';
8
8
  import * as sessionAttributes from './instrumentations/session/sessionAttributes';
9
+ import * as appBuildIdentity from './metas/appBuildIdentity';
9
10
 
10
11
  describe('initializeFaro', () => {
11
12
  const preambleKey = '__faroBundleId_test';
@@ -21,6 +22,62 @@ describe('initializeFaro', () => {
21
22
  delete (globalThis as Record<string, unknown>)[preambleKey];
22
23
  });
23
24
 
25
+ it.each([
26
+ {
27
+ source: 'explicit',
28
+ explicit: 'explicit-bundle',
29
+ metro: 'metro-bundle',
30
+ native: 'native-bundle',
31
+ expected: 'explicit-bundle',
32
+ },
33
+ { source: 'Metro', metro: 'metro-bundle', native: 'native-bundle', expected: 'metro-bundle' },
34
+ { source: 'native', native: 'native-bundle', expected: 'native-bundle' },
35
+ { source: 'unavailable', expected: undefined },
36
+ { source: 'native without preloaded app', native: 'native-bundle', expected: 'native-bundle', preloaded: false },
37
+ { source: 'unavailable without preloaded app', expected: undefined, preloaded: false },
38
+ ])(
39
+ 'preserves configured app metadata in emitted telemetry with $source bundle identity',
40
+ async ({ explicit, metro, native, expected, preloaded = true }) => {
41
+ const mobileSpy = jest.spyOn(sessionAttributes, 'loadMobileMetaForInit').mockResolvedValue({
42
+ sessionAttributes: sessionAttributes.minimalSessionDeviceAttributes(),
43
+ meta: preloaded ? { app: { installationId: 'preloaded-installation' } } : {},
44
+ });
45
+ const bundleSpy = jest.spyOn(appBuildIdentity, 'loadAppSymbolsBundleIdForInit').mockResolvedValue(native);
46
+ if (metro) {
47
+ (globalThis as Record<string, unknown>)[preambleKey] = metro;
48
+ }
49
+ const app = {
50
+ name: 'test',
51
+ version: '1.0.42',
52
+ environment: 'production',
53
+ namespace: 'test-namespace',
54
+ release: 'release-42',
55
+ installationId: 'configured-installation',
56
+ ...(explicit && { bundleId: explicit }),
57
+ };
58
+ const transport = new MockTransport();
59
+ try {
60
+ const faro = await initializeFaro(
61
+ mockConfig({
62
+ url: 'http://localhost:12345/collect',
63
+ app,
64
+ transports: [transport],
65
+ sessionTracking: { enabled: true, persistent: false },
66
+ })
67
+ );
68
+ transport.items = [];
69
+ faro.api.pushEvent('app_metadata_regression');
70
+ expect(transport.items).toHaveLength(1);
71
+ const expectedApp = { ...app, ...(expected && { bundleId: expected }) };
72
+ expect(faro.metas.value.app).toEqual(expectedApp);
73
+ expect(JSON.parse(JSON.stringify(getTransportBody(transport.items))).meta.app).toEqual(expectedApp);
74
+ } finally {
75
+ mobileSpy.mockRestore();
76
+ bundleSpy.mockRestore();
77
+ }
78
+ }
79
+ );
80
+
24
81
  it('should initialize Faro', async () => {
25
82
  const transport = new MockTransport();
26
83
  const faro = await initializeFaro(
@@ -145,7 +202,11 @@ describe('initializeFaro', () => {
145
202
  expect(faro.metas.value.sdk?.name).toBe('faro-react-native');
146
203
  expect(faro.metas.value.sdk?.version).toBe(VERSION);
147
204
  expect(faro.metas.value.sdk?.integrations).toEqual([{ name: packageJson.name, version: packageJson.version }]);
148
- expect(faro.metas.value.app?.installationId).toBe('preloaded-installation-id');
205
+ expect(faro.metas.value.app).toMatchObject({
206
+ name: 'test',
207
+ version: '1.0.0',
208
+ installationId: 'preloaded-installation-id',
209
+ });
149
210
  expect(faro.metas.value.device?.model_identifier).toBe('test-model-identifier');
150
211
  expect(faro.metas.value.os?.name).toBe('iOS');
151
212
  expect(faro.metas.value.session?.attributes?.['react_native_version']).toBe('0.0.1');