posthog-react-native 4.75.0 → 4.76.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/tooling/expoconfig.d.ts +24 -4
- package/dist/tooling/expoconfig.js +1 -1
- package/dist/tooling/expoconfig.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +5 -5
- package/tooling/posthog-xcode.sh +22 -1
- package/tooling/posthog.gradle +13 -1
|
@@ -12,6 +12,7 @@ export type PostHogReleaseMode = 'symbol-set' | 'event';
|
|
|
12
12
|
export declare const POSTHOG_RELEASE_MODES: PostHogReleaseMode[];
|
|
13
13
|
export declare function resolveReleaseModeProp(releaseMode?: string, environmentMode?: string): PostHogReleaseMode | undefined;
|
|
14
14
|
export declare function buildAndroidSkipOnConflictGradleLine(skipOnConflict: boolean): string | null;
|
|
15
|
+
export declare function buildAndroidForceGradleLine(force: boolean): string | null;
|
|
15
16
|
export declare function addPostHogAndroidGradlePluginClasspath(projectBuildGradle: string): {
|
|
16
17
|
contents: string;
|
|
17
18
|
classpathPresent: boolean;
|
|
@@ -29,11 +30,11 @@ export declare function updateMainActivityNewIntentOverride(contents: string, la
|
|
|
29
30
|
type BuildPhase = {
|
|
30
31
|
shellScript: string;
|
|
31
32
|
};
|
|
32
|
-
export declare function modifyExistingXcodeBuildScript(script: BuildPhase | undefined, skipOnConflict?: boolean, releaseMode?: PostHogReleaseMode): void;
|
|
33
|
-
export declare function addPostHogWithBundledScriptsToBundleShellScript(script: string, skipOnConflict?: boolean, releaseMode?: PostHogReleaseMode): string;
|
|
34
|
-
export declare function buildDsymUploadShellScript(includeSource?: boolean, skipOnConflict?: boolean): string;
|
|
33
|
+
export declare function modifyExistingXcodeBuildScript(script: BuildPhase | undefined, skipOnConflict?: boolean, releaseMode?: PostHogReleaseMode, force?: boolean): void;
|
|
34
|
+
export declare function addPostHogWithBundledScriptsToBundleShellScript(script: string, skipOnConflict?: boolean, releaseMode?: PostHogReleaseMode, force?: boolean): string;
|
|
35
|
+
export declare function buildDsymUploadShellScript(includeSource?: boolean, skipOnConflict?: boolean, force?: boolean): string;
|
|
35
36
|
export declare function moveDsymUploadBuildPhaseToEnd(xcodeProject: any): void;
|
|
36
|
-
export declare function addDsymUploadBuildPhase(xcodeProject: any, includeSource?: boolean, skipOnConflict?: boolean): void;
|
|
37
|
+
export declare function addDsymUploadBuildPhase(xcodeProject: any, includeSource?: boolean, skipOnConflict?: boolean, force?: boolean): void;
|
|
37
38
|
export declare function disableUserScriptSandboxing(xcodeProject: any): void;
|
|
38
39
|
export declare function resolveDotenvFileProp(dotenvFile?: string): string | undefined;
|
|
39
40
|
export declare function buildIosDotenvFileBuildSetting(dotenvFile: string): string;
|
|
@@ -93,9 +94,28 @@ type PostHogPluginProps = {
|
|
|
93
94
|
* to `posthog-cli dsym upload` on posthog-ios >= 3.64.7 (with posthog-cli >= 0.7.12) and
|
|
94
95
|
* ignores it on older versions, where dSYM conflicts keep failing the build.
|
|
95
96
|
*
|
|
97
|
+
* Mutually exclusive with `force`: posthog-cli rejects the two flags together, so enabling
|
|
98
|
+
* both stops the prebuild.
|
|
99
|
+
*
|
|
96
100
|
* Default: false.
|
|
97
101
|
*/
|
|
98
102
|
skipOnConflict?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Whether to overwrite uploads whose content already exists in PostHog instead of failing the
|
|
105
|
+
* build.
|
|
106
|
+
*
|
|
107
|
+
* Appends `--force` to `posthog-cli hermes upload` on iOS and Android. When
|
|
108
|
+
* `uploadNativeSymbols` is enabled, also sets `POSTHOG_FORCE=1` in the iOS dSYM upload build
|
|
109
|
+
* phase; posthog-ios's `upload-symbols.sh` forwards it as `--force` to `posthog-cli dsym upload`
|
|
110
|
+
* on versions that read the variable and ignores it on older ones, where dSYM conflicts keep
|
|
111
|
+
* failing the build. `uploadNativeSymbols: { includeSource: true }` already overwrites dSYMs.
|
|
112
|
+
*
|
|
113
|
+
* Mutually exclusive with `skipOnConflict`: posthog-cli rejects the two flags together, so
|
|
114
|
+
* enabling both stops the prebuild.
|
|
115
|
+
*
|
|
116
|
+
* Default: false.
|
|
117
|
+
*/
|
|
118
|
+
force?: boolean;
|
|
99
119
|
/**
|
|
100
120
|
* Path to a dotenv file with POSTHOG_CLI_* credentials (API key, project id,
|
|
101
121
|
* optional host), relative to the project root — or absolute.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.POSTHOG_RELEASE_MODES=void 0;exports.addDsymUploadBuildPhase=addDsymUploadBuildPhase;exports.addPostHogAndroidGradlePluginClasspath=addPostHogAndroidGradlePluginClasspath;exports.addPostHogWithBundledScriptsToBundleShellScript=addPostHogWithBundledScriptsToBundleShellScript;exports.applyDotenvFileBuildSetting=applyDotenvFileBuildSetting;exports.applyPostHogAndroidGradlePlugin=applyPostHogAndroidGradlePlugin;exports.buildAndroidDotenvFileGradleValue=buildAndroidDotenvFileGradleValue;exports.buildAndroidSkipOnConflictGradleLine=buildAndroidSkipOnConflictGradleLine;exports.buildDsymUploadShellScript=buildDsymUploadShellScript;exports.buildIosDotenvFileBuildSetting=buildIosDotenvFileBuildSetting;exports.disableUserScriptSandboxing=disableUserScriptSandboxing;exports.modifyExistingXcodeBuildScript=modifyExistingXcodeBuildScript;exports.moveDsymUploadBuildPhaseToEnd=moveDsymUploadBuildPhaseToEnd;exports.resolveDotenvFileProp=resolveDotenvFileProp;exports.resolveNativeSymbolUpload=resolveNativeSymbolUpload;exports.resolveReleaseModeProp=resolveReleaseModeProp;exports.updateDotenvFileGradleProperties=updateDotenvFileGradleProperties;exports.updateHermesReleaseModeGradleProperties=updateHermesReleaseModeGradleProperties;exports.updateMainActivityNewIntentOverride=updateMainActivityNewIntentOverride;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _excluded=["nextMod"],_excluded2=["nextMod"];function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]};},e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}var fs=require('fs');var path=require('path');var _require=require('@expo/config-plugins'),AndroidConfig=_require.AndroidConfig,withAppBuildGradle=_require.withAppBuildGradle,withBaseMod=_require.withBaseMod,withDangerousMod=_require.withDangerousMod,withGradleProperties=_require.withGradleProperties,withXcodeProject=_require.withXcodeProject;var POSTHOG_ANDROID_GRADLE_PLUGIN_VERSION='1.6.0';var resolvePostHogReactNativePackageJsonPath="[\"node\", \"--print\", \"require('path').join(require('path').dirname(require.resolve('posthog-react-native')), '..', 'tooling', 'posthog.gradle')\"].execute().text.trim()";var POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY='posthogReactNativeSkipOnConflict';var POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY='posthog.hermesReleaseMode';var POSTHOG_RELEASE_MODES=exports.POSTHOG_RELEASE_MODES=['symbol-set','event'];function resolveReleaseModeProp(releaseMode,environmentMode){var trimmed=(releaseMode===null||releaseMode===void 0?void 0:releaseMode.trim())||(environmentMode===null||environmentMode===void 0?void 0:environmentMode.trim());if(!trimmed){return undefined;}if(!POSTHOG_RELEASE_MODES.includes(trimmed)){throw new Error("[posthog-react-native] releaseMode must be one of ".concat(POSTHOG_RELEASE_MODES.join(', '),", was '").concat(trimmed,"'"));}return trimmed;}function buildAndroidSkipOnConflictGradleLine(skipOnConflict){if(!skipOnConflict){return null;}return"project.ext.".concat(POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY," = true");}var withAndroidPlugin=function withAndroidPlugin(config){var skipOnConflict=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return withAppBuildGradle(config,function(config){if(config.modResults.language!=='groovy'){console.warn('Cannot configure PostHog in the app gradle because the build.gradle is not groovy');}var buildGradle=config.modResults.contents;var applyFrom="apply from: new File(".concat(resolvePostHogReactNativePackageJsonPath,")");var skipOnConflictLine=buildAndroidSkipOnConflictGradleLine(skipOnConflict);var applyBlock=skipOnConflictLine?"".concat(skipOnConflictLine,"\n").concat(applyFrom):applyFrom;var skipOnConflictPattern=new RegExp("^project\\.ext\\.".concat(POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY,"\\s*=\\s*(true|false)\\n?"),'m');if(buildGradle.includes(applyFrom)){var contents=buildGradle.replace(skipOnConflictPattern,'');if(skipOnConflictLine){contents=contents.replace(applyFrom,"".concat(skipOnConflictLine,"\n").concat(applyFrom));}config.modResults.contents=contents;return config;}var pattern=/^android\s*\{/m;if(buildGradle.match(pattern)){config.modResults.contents=buildGradle.replace(pattern,"".concat(applyBlock,"\n\nandroid {"));}else{console.warn('PostHog: Could not find "android {" block in build.gradle');}return config;});};function matchingBraceIndex(s,openBraceIndex){var depth=0;for(var i=openBraceIndex;i<s.length;i++){if(s[i]==='{'){depth++;}else if(s[i]==='}'){depth--;if(depth===0){return i;}}}return-1;}function addPostHogAndroidGradlePluginClasspath(projectBuildGradle){if(projectBuildGradle.includes('posthog-android-gradle-plugin')){return{contents:projectBuildGradle,classpathPresent:true};}var classpathLine=" classpath(\"com.posthog:posthog-android-gradle-plugin:".concat(POSTHOG_ANDROID_GRADLE_PLUGIN_VERSION,"\")");var buildscriptMatch=/buildscript\s*\{/.exec(projectBuildGradle);var buildscriptOpenBrace=buildscriptMatch?buildscriptMatch.index+buildscriptMatch[0].length-1:-1;var buildscriptEnd=buildscriptOpenBrace===-1?-1:matchingBraceIndex(projectBuildGradle,buildscriptOpenBrace);var buildscriptBody=buildscriptEnd===-1?'':projectBuildGradle.slice(buildscriptOpenBrace,buildscriptEnd);var dependenciesMatch=buildscriptBody?/dependencies\s*\{/.exec(buildscriptBody):null;if(!dependenciesMatch){console.warn('PostHog: Could not find a buildscript dependencies block in the project build.gradle; '+'skipping the com.posthog.android classpath. Native symbols will not be uploaded.');return{contents:projectBuildGradle,classpathPresent:false};}var insertAt=buildscriptOpenBrace+dependenciesMatch.index+dependenciesMatch[0].length;return{contents:"".concat(projectBuildGradle.slice(0,insertAt),"\n").concat(classpathLine).concat(projectBuildGradle.slice(insertAt)),classpathPresent:true};}function applyPostHogAndroidGradlePlugin(appBuildGradle){if(/apply plugin: ["']com\.posthog\.android["']/.test(appBuildGradle)){return appBuildGradle;}var applyLine='apply plugin: "com.posthog.android"';var appPluginPattern=/^([ \t]*apply plugin: ["']com\.android\.application["'].*)$/m;if(appPluginPattern.test(appBuildGradle)){return appBuildGradle.replace(appPluginPattern,"$1\n".concat(applyLine));}var androidBlockPattern=/^android\s*\{/m;if(androidBlockPattern.test(appBuildGradle)){return appBuildGradle.replace(androidBlockPattern,"".concat(applyLine,"\n\nandroid {"));}console.warn('PostHog: Could not find where to apply com.posthog.android in the app build.gradle');return appBuildGradle;}var withFinalizedProjectBuildGradle=function withFinalizedProjectBuildGradle(config,_action){return withBaseMod(config,{platform:'android',mod:'projectBuildGradle',skipEmptyMod:false,action:function action(config){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){var _config$modRequest,nextMod,modRequest,results;return _regenerator["default"].wrap(function(_context){while(1)switch(_context.prev=_context.next){case 0:_config$modRequest=config.modRequest,nextMod=_config$modRequest.nextMod,modRequest=(0,_objectWithoutProperties2["default"])(_config$modRequest,_excluded);_context.next=1;return nextMod(_objectSpread(_objectSpread({},config),{},{modRequest:modRequest}));case 1:results=_context.sent;return _context.abrupt("return",_action(results));case 2:case"end":return _context.stop();}},_callee);}))();}});};var withAndroidNativeSymbolsPlugin=function withAndroidNativeSymbolsPlugin(config){return withFinalizedProjectBuildGradle(config,function(){var _ref=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(config){var result,appBuildGradle,contents;return _regenerator["default"].wrap(function(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!(config.modResults.language!=='groovy')){_context2.next=1;break;}console.warn('Cannot configure the PostHog Android Gradle plugin because the project build.gradle is not groovy');return _context2.abrupt("return",config);case 1:result=addPostHogAndroidGradlePluginClasspath(config.modResults.contents);if(!(result.contents!==config.modResults.contents)){_context2.next=3;break;}_context2.next=2;return fs.promises.writeFile(config.modResults.path,result.contents);case 2:config.modResults.contents=result.contents;case 3:if(result.classpathPresent){_context2.next=4;break;}return _context2.abrupt("return",config);case 4:_context2.next=5;return AndroidConfig.Paths.getAppBuildGradleAsync(config.modRequest.projectRoot);case 5:appBuildGradle=_context2.sent;if(!(appBuildGradle.language!=='groovy')){_context2.next=6;break;}console.warn('Cannot configure the PostHog Android Gradle plugin because the app build.gradle is not groovy');return _context2.abrupt("return",config);case 6:contents=applyPostHogAndroidGradlePlugin(appBuildGradle.contents);if(!(contents!==appBuildGradle.contents)){_context2.next=7;break;}_context2.next=7;return fs.promises.writeFile(appBuildGradle.path,contents);case 7:return _context2.abrupt("return",config);case 8:case"end":return _context2.stop();}},_callee2);}));return function(_x){return _ref.apply(this,arguments);};}());};var POSTHOG_NEW_INTENT_MARKER='posthog-new-intent';var POSTHOG_NEW_INTENT_BEGIN="// @generated begin ".concat(POSTHOG_NEW_INTENT_MARKER," - posthog-react-native (DO NOT MODIFY)");var POSTHOG_NEW_INTENT_END="// @generated end ".concat(POSTHOG_NEW_INTENT_MARKER);var NEW_INTENT_DOC=" /**\n * Records the intent that reopened the app so getIntent() stays correct.\n *\n * Works around a React Native defect that drops notification taps and deep links arriving while\n * the React context is still starting. Managed by the posthog-react-native Expo config plugin;\n * remove it with { patchMainActivityNewIntent: false } in app.json.\n * https://posthog.com/docs/workflows/push-notifications/react-native\n */";var NEW_INTENT_KOTLIN_BODY=" override fun onNewIntent(intent: android.content.Intent) {\n setIntent(intent)\n super.onNewIntent(intent)\n }";var NEW_INTENT_JAVA_BODY=" @Override\n public void onNewIntent(android.content.Intent intent) {\n setIntent(intent);\n super.onNewIntent(intent);\n }";function newIntentOverrideBlock(language){var body=language==='java'?NEW_INTENT_JAVA_BODY:NEW_INTENT_KOTLIN_BODY;return"\n ".concat(POSTHOG_NEW_INTENT_BEGIN,"\n").concat(NEW_INTENT_DOC,"\n").concat(body,"\n ").concat(POSTHOG_NEW_INTENT_END,"\n");}function escapeRegExp(value){return value.replace(/[.*+?^${}()|[\]\\]/g,'\\$&');}var POSTHOG_NEW_INTENT_BLOCK_PATTERN=new RegExp("\\r?\\n?[ \\t]*".concat(escapeRegExp(POSTHOG_NEW_INTENT_BEGIN),"[\\s\\S]*?").concat(escapeRegExp(POSTHOG_NEW_INTENT_END),"[ \\t]*\\r?\\n"),'g');function literalEnd(s,start,language){var quote=s[start];var raw=quote==='"'&&s.startsWith('"""',start);var i=start+(raw?3:1);while(i<s.length){var c=s[i];if(raw){if(s.startsWith('"""',i)){while(s[i]==='"'){i++;}return i;}}else if(c==='\n'){return-1;}else if(c===quote){return i+1;}if(c==='\\'&&(!raw||language==='java')){i+=2;continue;}if(language==='kt'&"e==='"'&&c==='$'&&s[i+1]==='{'){var close=matchingBraceIndexInSource(s,i+1,language);if(close===-1){return-1;}i=close+1;continue;}i++;}return-1;}function matchingBraceIndexInSource(s,openBraceIndex,language){var depth=0;var i=openBraceIndex;while(i<s.length){var c=s[i];if(c==='/'&&s[i+1]==='/'){var end=s.indexOf('\n',i);i=end===-1?s.length:end;continue;}if(c==='/'&&s[i+1]==='*'){var depthOfComment=1;i+=2;while(i<s.length&&depthOfComment>0){if(language==='kt'&&s[i]==='/'&&s[i+1]==='*'){depthOfComment++;i+=2;continue;}if(s[i]==='*'&&s[i+1]==='/'){depthOfComment--;i+=2;continue;}i++;}if(depthOfComment>0){return-1;}continue;}if(c==='"'||c==="'"){var _end=literalEnd(s,i,language);if(_end===-1){return-1;}i=_end;continue;}if(c==='{'){depth++;}else if(c==='}'){depth--;if(depth===0){return i;}}i++;}return-1;}function maskCommentsAndLiterals(source,language){var out=source.split('');var blank=function blank(from,to){for(var j=from;j<to&&j<out.length;j++){if(out[j]!=='\n'){out[j]=' ';}}};var i=0;while(i<source.length){var c=source[i];if(c==='/'&&source[i+1]==='/'){var end=source.indexOf('\n',i);var stop=end===-1?source.length:end;blank(i,stop);i=stop;continue;}if(c==='/'&&source[i+1]==='*'){var depth=1;var j=i+2;while(j<source.length&&depth>0){if(language==='kt'&&source[j]==='/'&&source[j+1]==='*'){depth++;j+=2;continue;}if(source[j]==='*'&&source[j+1]==='/'){depth--;j+=2;continue;}j++;}blank(i,j);i=j;continue;}if(c==='"'||c==="'"){var _end2=literalEnd(source,i,language);if(_end2===-1){blank(i,source.length);return out.join('');}blank(i,_end2);i=_end2;continue;}i++;}return out.join('');}function mainActivityBody(contents,language){var code=maskCommentsAndLiterals(contents,language);var declaration=/\bclass\s+MainActivity\b/.exec(code);if(!declaration){return undefined;}var searchFrom=declaration.index+declaration[0].length;var open=code.indexOf('{',searchFrom);if(open===-1||!/^[^;{}]*$/.test(code.slice(searchFrom,open))){return undefined;}var depth=0;var close=-1;for(var i=open;i<code.length;i++){if(code[i]==='{'){depth++;}else if(code[i]==='}'){depth--;if(depth===0){close=i;break;}}}return close===-1?undefined:{open:open,close:close};}function updateMainActivityNewIntentOverride(contents,language,enabled){var withoutManagedBlock=contents.replace(POSTHOG_NEW_INTENT_BLOCK_PATTERN,'');if(!enabled){return withoutManagedBlock;}var body=mainActivityBody(withoutManagedBlock,language);if(!body){console.warn('[posthog-react-native] Could not find the MainActivity class body; skipping the onNewIntent '+'override. Notification taps delivered while the React context is starting will be lost.');return withoutManagedBlock;}var codeOnly=maskCommentsAndLiterals(withoutManagedBlock,language);if(/\b(fun|void)\s+onNewIntent\s*\(/.test(codeOnly.slice(body.open,body.close))){console.warn('[posthog-react-native] MainActivity already overrides onNewIntent; leaving it alone. '+'Add `setIntent(intent)` as its first statement so a notification tap that arrives before '+'the React context is ready is not lost, or set `{ patchMainActivityNewIntent: false }` '+'on the plugin to silence this.');return withoutManagedBlock;}return withoutManagedBlock.slice(0,body.open+1)+newIntentOverrideBlock(language)+withoutManagedBlock.slice(body.open+1);}var MAIN_ACTIVITY_SOURCE_ROOTS=['android/app/src/main/java','android/app/src/main/kotlin'];function findMainActivityPath(projectRoot){var _walk=function walk(dir){if(!fs.existsSync(dir)){return undefined;}var _iterator=_createForOfIteratorHelper(fs.readdirSync(dir,{withFileTypes:true})),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var entry=_step.value;var candidate=path.join(dir,entry.name);if(!entry.isDirectory()){if(/^MainActivity\.(kt|java)$/.test(entry.name)){return candidate;}continue;}var hit=_walk(candidate);if(hit){return hit;}}}catch(err){_iterator.e(err);}finally{_iterator.f();}return undefined;};for(var _i=0,_MAIN_ACTIVITY_SOURCE=MAIN_ACTIVITY_SOURCE_ROOTS;_i<_MAIN_ACTIVITY_SOURCE.length;_i++){var sourceRoot=_MAIN_ACTIVITY_SOURCE[_i];var hit=_walk(path.join(projectRoot,sourceRoot));if(hit){return hit;}}return undefined;}var withMainActivityNewIntent=function withMainActivityNewIntent(config,enabled){return withDangerousMod(config,['android',(function(){var _ref2=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(config){var mainActivityPath,contents,updated;return _regenerator["default"].wrap(function(_context3){while(1)switch(_context3.prev=_context3.next){case 0:mainActivityPath=findMainActivityPath(config.modRequest.projectRoot);if(mainActivityPath){_context3.next=1;break;}console.warn('[posthog-react-native] Could not find MainActivity under android/app/src/main/{java,kotlin}; '+'skipping the onNewIntent override. Notification taps delivered while the React context is '+'starting will be lost.');return _context3.abrupt("return",config);case 1:_context3.next=2;return fs.promises.readFile(mainActivityPath,'utf8');case 2:contents=_context3.sent;updated=updateMainActivityNewIntentOverride(contents,mainActivityPath.endsWith('.java')?'java':'kt',enabled);if(!(updated!==contents)){_context3.next=3;break;}_context3.next=3;return fs.promises.writeFile(mainActivityPath,updated);case 3:if(!contents.includes(POSTHOG_NEW_INTENT_BEGIN)&&updated.includes(POSTHOG_NEW_INTENT_BEGIN)){console.warn("[posthog-react-native] Added an onNewIntent override to ".concat(path.relative(config.modRequest.projectRoot,mainActivityPath)," so a notification tap that arrives before the React context is ready is not lost. ")+'Set `{ patchMainActivityNewIntent: false }` on the plugin in app.json to opt out.');}return _context3.abrupt("return",config);case 4:case"end":return _context3.stop();}},_callee3);}));return function(_x2){return _ref2.apply(this,arguments);};}())]);};function modifyExistingXcodeBuildScript(script){var skipOnConflict=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var releaseMode=arguments.length>2?arguments[2]:undefined;if(!(script===null||script===void 0?void 0:script.shellScript)){console.warn("[posthog-react-native] Could not find the 'Bundle React Native code and images' build phase; "+'skipping sourcemap upload setup.');return;}if(!script.shellScript.match(/(packager|scripts)\/react-native-xcode\.sh\b/)){return;}if(script.shellScript.includes('posthog-xcode.sh')){var _code=migrateLegacyPostHogWrapperInvocation(JSON.parse(script.shellScript));script.shellScript=JSON.stringify(updatePostHogBundlePhaseExports(_code,skipOnConflict,releaseMode));return;}if(script.shellScript.includes('posthog-react-native')){return;}var code=JSON.parse(script.shellScript);script.shellScript=JSON.stringify(addPostHogWithBundledScriptsToBundleShellScript(code,skipOnConflict,releaseMode));}var POSTHOG_REACT_NATIVE_XCODE_PATH="`\"$NODE_BINARY\" --print \"require('path').join(require('path').dirname(require.resolve('posthog-react-native')), '..', 'tooling', 'posthog-xcode.sh')\"`";var POSTHOG_SKIP_ON_CONFLICT_EXPORT='export POSTHOG_SKIP_ON_CONFLICT=1';var POSTHOG_RELEASE_MODE_EXPORT_PREFIX='export POSTHOG_RELEASE_MODE=';function buildBundlePhaseExports(skipOnConflict,releaseMode){var exports=[];if(skipOnConflict){exports.push(POSTHOG_SKIP_ON_CONFLICT_EXPORT);}if(releaseMode){exports.push("".concat(POSTHOG_RELEASE_MODE_EXPORT_PREFIX).concat(releaseMode));}return exports;}var REACT_NATIVE_XCODE_LINE=/^([ \t]*)(?![A-Za-z_][A-Za-z0-9_]*=)([^\n]*(?:packager|scripts)\/react-native-xcode\.sh\b[^\n]*)$/m;function migrateLegacyPostHogWrapperInvocation(script){return script.replace("/bin/sh ".concat(POSTHOG_REACT_NATIVE_XCODE_PATH),POSTHOG_REACT_NATIVE_XCODE_PATH);}function updatePostHogBundlePhaseExports(script,skipOnConflict,releaseMode){var _a;var _b;var skipArg='--posthog-skip-on-conflict --';var lines=script.replace(new RegExp("\\s*".concat(skipArg,"\\s*"),'g'),' ').split('\n').filter(function(line){return line.trim()!==POSTHOG_SKIP_ON_CONFLICT_EXPORT;}).filter(function(line){return!line.trim().startsWith(POSTHOG_RELEASE_MODE_EXPORT_PREFIX);});var exports=buildBundlePhaseExports(skipOnConflict,releaseMode);if(exports.length>0){var commandIndex=lines.findIndex(function(line){return line.includes(POSTHOG_REACT_NATIVE_XCODE_PATH);});if(commandIndex!==-1){var indent=(_b=(_a=lines[commandIndex].match(/^[ \t]*/))===null||_a===void 0?void 0:_a[0])!==null&&_b!==void 0?_b:'';lines.splice.apply(lines,[commandIndex,0].concat((0,_toConsumableArray2["default"])(exports.map(function(line){return"".concat(indent).concat(line);}))));}}return lines.join('\n');}function addPostHogWithBundledScriptsToBundleShellScript(script){var skipOnConflict=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var releaseMode=arguments.length>2?arguments[2]:undefined;return script.replace(REACT_NATIVE_XCODE_LINE,function(_match,indent,rnCommand){var exports=buildBundlePhaseExports(skipOnConflict,releaseMode).map(function(line){return"".concat(indent).concat(line,"\n");}).join('');return"".concat(exports).concat(indent).concat(POSTHOG_REACT_NATIVE_XCODE_PATH," ").concat(rnCommand);});}var POSTHOG_DSYM_BUILD_PHASE_NAME='Upload PostHog Debug Symbols';var POSTHOG_DSYM_INPUT_PATH='"$(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)/Contents/Resources/DWARF/$(EXECUTABLE_NAME)"';function buildDsymUploadShellScript(){var includeSource=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var skipOnConflict=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return composeDsymUploadShellScript(includeSource,skipOnConflict);}function composeDsymUploadShellScript(includeSource,skipOnConflict){var lines=['# Upload iOS dSYMs to PostHog so native crashes can be symbolicated.','# upload-symbols.sh ships inside the posthog-ios dependency.'];if(includeSource){lines.push('# Also upload native source files for source-code context around crashes.','export POSTHOG_INCLUDE_SOURCE=1');}if(skipOnConflict){lines.push('# Skip dSYMs that already exist in PostHog with different content instead of failing the build.','export POSTHOG_SKIP_ON_CONFLICT=1');}lines.push('PODS_SCRIPT="${PODS_ROOT}/PostHog/build-tools/upload-symbols.sh"','SPM_SCRIPT="${BUILD_DIR%/Build/*}/SourcePackages/checkouts/posthog-ios/build-tools/upload-symbols.sh"','if [ -f "$PODS_SCRIPT" ]; then',' /bin/sh "$PODS_SCRIPT"','elif [ -f "$SPM_SCRIPT" ]; then',' /bin/sh "$SPM_SCRIPT"','else',' echo "warning: PostHog upload-symbols.sh not found in Pods or SwiftPM checkouts; skipping dSYM upload."','fi');return lines.join('\n');}function legacyDsymReleaseModeLines(releaseMode){return[releaseMode?"POSTHOG_RESOLVED_RELEASE_MODE=\"".concat(releaseMode,"\""):'POSTHOG_RESOLVED_RELEASE_MODE="${POSTHOG_RELEASE_MODE:-}"','case "$POSTHOG_RESOLVED_RELEASE_MODE" in',' ""|symbol-set) ;;',' event)',' # Upload dSYMs without binding them to a release, so each crash resolves its own from the',' # app version and namespace the SDK sends. posthog-ios versions whose upload-symbols.sh',' # does not read this variable ignore it and keep binding the dSYMs.',' export POSTHOG_NO_RELEASE_BIND=1',' ;;',' *)'," echo \"error: posthog release mode must be 'symbol-set' or 'event', was '$POSTHOG_RESOLVED_RELEASE_MODE'\"",' exit 1',' ;;','esac'];}function buildLegacyReleaseModeDsymUploadShellScript(includeSource,skipOnConflict,releaseMode){var lines=composeDsymUploadShellScript(includeSource,skipOnConflict).split('\n');var uploadIndex=lines.findIndex(function(line){return line.startsWith('PODS_SCRIPT=');});lines.splice.apply(lines,[uploadIndex,0].concat((0,_toConsumableArray2["default"])(legacyDsymReleaseModeLines(releaseMode))));return lines.join('\n');}function encodePbxShellScript(script){return'"'+script.replace(/"/g,'\\"')+'"';}function decodePbxShellScript(stored){if(!stored.startsWith('"')||!stored.endsWith('"')){return stored;}return stored.slice(1,-1).replace(/\\(.)/g,function(_match,ch){return ch==='n'?'\n':ch==='t'?'\t':ch;});}function isPluginGeneratedDsymUploadBuildPhase(phase){if(typeof(phase===null||phase===void 0?void 0:phase.shellScript)!=='string'){return false;}var stored=decodePbxShellScript(phase.shellScript);return[false,true].some(function(source){return[false,true].some(function(skip){return stored===buildDsymUploadShellScript(source,skip)||[undefined].concat(POSTHOG_RELEASE_MODES).some(function(mode){return stored===buildLegacyReleaseModeDsymUploadShellScript(source,skip,mode);});});});}function moveDsymUploadBuildPhaseToEnd(xcodeProject){var _a,_b;var existing=xcodeProject.pbxItemByComment(POSTHOG_DSYM_BUILD_PHASE_NAME,'PBXShellScriptBuildPhase');if(!isPluginGeneratedDsymUploadBuildPhase(existing)){return;}var buildPhases=(_b=(_a=xcodeProject.getFirstTarget)===null||_a===void 0?void 0:_a.call(xcodeProject).firstTarget)===null||_b===void 0?void 0:_b.buildPhases;if(Array.isArray(buildPhases)){var phaseIndex=buildPhases.findIndex(function(phase){return phase.comment===POSTHOG_DSYM_BUILD_PHASE_NAME;});if(phaseIndex!==-1&&phaseIndex!==buildPhases.length-1){buildPhases.push.apply(buildPhases,(0,_toConsumableArray2["default"])(buildPhases.splice(phaseIndex,1)));}}}function addDsymUploadBuildPhase(xcodeProject){var includeSource=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var skipOnConflict=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var existing=xcodeProject.pbxItemByComment(POSTHOG_DSYM_BUILD_PHASE_NAME,'PBXShellScriptBuildPhase');if(existing){if(isPluginGeneratedDsymUploadBuildPhase(existing)){existing.shellScript=encodePbxShellScript(buildDsymUploadShellScript(includeSource,skipOnConflict));existing.inputPaths=Array.from(new Set([].concat((0,_toConsumableArray2["default"])(Array.isArray(existing.inputPaths)?existing.inputPaths:[]),[POSTHOG_DSYM_INPUT_PATH])));}}else{xcodeProject.addBuildPhase([],'PBXShellScriptBuildPhase',POSTHOG_DSYM_BUILD_PHASE_NAME,null,{inputPaths:[POSTHOG_DSYM_INPUT_PATH],shellPath:'/bin/sh',shellScript:buildDsymUploadShellScript(includeSource,skipOnConflict)});}moveDsymUploadBuildPhaseToEnd(xcodeProject);}function disableUserScriptSandboxing(xcodeProject){var configurations=xcodeProject.pbxXCBuildConfigurationSection();for(var key in configurations){var configuration=configurations[key];if(configuration&&configuration.buildSettings){configuration.buildSettings.ENABLE_USER_SCRIPT_SANDBOXING='"NO"';}}}var POSTHOG_DOTENV_BUILD_SETTING='POSTHOG_CLI_DOTENV_FILE';var POSTHOG_DOTENV_GRADLE_PROPERTY='posthog.dotenvFile';function normalizeDotenvFileProp(dotenvFile){return dotenvFile.replace(/^\.\//,'');}function resolveDotenvFileProp(dotenvFile){var trimmed=dotenvFile===null||dotenvFile===void 0?void 0:dotenvFile.trim();return trimmed?trimmed:undefined;}function isAbsoluteDotenvPath(dotenvFile){return dotenvFile.startsWith('/')||/^[A-Za-z]:[\\/]/.test(dotenvFile);}function buildIosDotenvFileBuildSetting(dotenvFile){var value=isAbsoluteDotenvPath(dotenvFile)?dotenvFile:"$(SRCROOT)/../".concat(normalizeDotenvFileProp(dotenvFile));return'"'+value.replace(/(["\\])/g,'\\$1')+'"';}function applyDotenvFileBuildSetting(xcodeProject,dotenvFile){var configurations=xcodeProject.pbxXCBuildConfigurationSection();for(var key in configurations){var configuration=configurations[key];if(configuration&&configuration.buildSettings){if(dotenvFile){configuration.buildSettings[POSTHOG_DOTENV_BUILD_SETTING]=buildIosDotenvFileBuildSetting(dotenvFile);}else{delete configuration.buildSettings[POSTHOG_DOTENV_BUILD_SETTING];}}}}function buildAndroidDotenvFileGradleValue(dotenvFile){return isAbsoluteDotenvPath(dotenvFile)?dotenvFile:"../".concat(normalizeDotenvFileProp(dotenvFile));}function updateDotenvFileGradleProperties(properties,dotenvFile){var rest=properties.filter(function(item){return!(item.type==='property'&&item.key===POSTHOG_DOTENV_GRADLE_PROPERTY);});if(!dotenvFile){return rest;}rest.push({type:'property',key:POSTHOG_DOTENV_GRADLE_PROPERTY,value:buildAndroidDotenvFileGradleValue(dotenvFile)});return rest;}function updateHermesReleaseModeGradleProperties(properties,releaseMode){var rest=properties.filter(function(item){return!(item.type==='property'&&item.key===POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY);});if(!releaseMode){return rest;}rest.push({type:'property',key:POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY,value:releaseMode});return rest;}var withPostHogGradleProperties=function withPostHogGradleProperties(config,dotenvFile,releaseMode){return withGradleProperties(config,function(config){config.modResults=updateDotenvFileGradleProperties(config.modResults,dotenvFile);config.modResults=updateHermesReleaseModeGradleProperties(config.modResults,releaseMode);return config;});};function resolveNativeSymbolUpload(prop){if(prop===true){return{enabled:true,includeSource:false};}if(prop&&(0,_typeof2["default"])(prop)==='object'){return{enabled:true,includeSource:prop.includeSource===true};}return{enabled:false,includeSource:false};}var withFinalizedXcodeProject=function withFinalizedXcodeProject(config,_action2){return withBaseMod(config,{platform:'ios',mod:'xcodeproj',action:function action(config){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(){var _config$modRequest2,nextMod,modRequest,results;return _regenerator["default"].wrap(function(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_config$modRequest2=config.modRequest,nextMod=_config$modRequest2.nextMod,modRequest=(0,_objectWithoutProperties2["default"])(_config$modRequest2,_excluded2);_context4.next=1;return nextMod(_objectSpread(_objectSpread({},config),{},{modRequest:modRequest}));case 1:results=_context4.sent;return _context4.abrupt("return",_action2(results));case 2:case"end":return _context4.stop();}},_callee4);}))();}});};var withIosPlugin=function withIosPlugin(config){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var nativeSymbols=resolveNativeSymbolUpload(props.uploadNativeSymbols);config=withXcodeProject(config,function(config){var xcodeProject=config.modResults;var bundleReactNativePhase=xcodeProject.pbxItemByComment('Bundle React Native code and images','PBXShellScriptBuildPhase');modifyExistingXcodeBuildScript(bundleReactNativePhase,props.skipOnConflict===true,props.releaseMode);if(nativeSymbols.enabled){addDsymUploadBuildPhase(xcodeProject,nativeSymbols.includeSource,props.skipOnConflict===true);}applyDotenvFileBuildSetting(xcodeProject,props.dotenvFile);if(props.disableSandboxing!==false){disableUserScriptSandboxing(xcodeProject);console.warn('[posthog-react-native] Setting ENABLE_USER_SCRIPT_SANDBOXING=NO on all Xcode '+'build configurations so sourcemap uploads can resolve git metadata. '+'If your org requires sandboxing to stay enabled, set `{ disableSandboxing: false }` '+'on the plugin in app.json — note that stock Expo projects may fail to build under '+'sandboxing until every script build phase declares its input/output files.');}return config;});if(nativeSymbols.enabled){config=withFinalizedXcodeProject(config,function(config){moveDsymUploadBuildPhaseToEnd(config.modResults);return config;});}return config;};var withPostHogPlugin=function withPostHogPlugin(config){var rawProps=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var props=_objectSpread(_objectSpread({},rawProps),{},{dotenvFile:resolveDotenvFileProp(rawProps.dotenvFile),releaseMode:resolveReleaseModeProp(rawProps.releaseMode,process.env.POSTHOG_RELEASE_MODE)});if(resolveNativeSymbolUpload(props.uploadNativeSymbols).enabled){config=withAndroidNativeSymbolsPlugin(config);}config=withAndroidPlugin(config,props.skipOnConflict===true);config=withPostHogGradleProperties(config,props.dotenvFile,props.releaseMode);config=withMainActivityNewIntent(config,props.patchMainActivityNewIntent!==false);return withIosPlugin(config,props);};var postHogPlugin=function postHogPlugin(config){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return withPostHogPlugin(config,props);};module.exports=postHogPlugin;module.exports.modifyExistingXcodeBuildScript=modifyExistingXcodeBuildScript;module.exports.addPostHogWithBundledScriptsToBundleShellScript=addPostHogWithBundledScriptsToBundleShellScript;module.exports.disableUserScriptSandboxing=disableUserScriptSandboxing;module.exports.buildDsymUploadShellScript=buildDsymUploadShellScript;module.exports.addDsymUploadBuildPhase=addDsymUploadBuildPhase;module.exports.moveDsymUploadBuildPhaseToEnd=moveDsymUploadBuildPhaseToEnd;module.exports.resolveNativeSymbolUpload=resolveNativeSymbolUpload;module.exports.buildAndroidSkipOnConflictGradleLine=buildAndroidSkipOnConflictGradleLine;module.exports.addPostHogAndroidGradlePluginClasspath=addPostHogAndroidGradlePluginClasspath;module.exports.applyPostHogAndroidGradlePlugin=applyPostHogAndroidGradlePlugin;module.exports.buildIosDotenvFileBuildSetting=buildIosDotenvFileBuildSetting;module.exports.applyDotenvFileBuildSetting=applyDotenvFileBuildSetting;module.exports.resolveDotenvFileProp=resolveDotenvFileProp;module.exports.buildAndroidDotenvFileGradleValue=buildAndroidDotenvFileGradleValue;module.exports.updateDotenvFileGradleProperties=updateDotenvFileGradleProperties;module.exports.POSTHOG_RELEASE_MODES=POSTHOG_RELEASE_MODES;module.exports.resolveReleaseModeProp=resolveReleaseModeProp;module.exports.updateHermesReleaseModeGradleProperties=updateHermesReleaseModeGradleProperties;module.exports.updateMainActivityNewIntentOverride=updateMainActivityNewIntentOverride;
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.POSTHOG_RELEASE_MODES=void 0;exports.addDsymUploadBuildPhase=addDsymUploadBuildPhase;exports.addPostHogAndroidGradlePluginClasspath=addPostHogAndroidGradlePluginClasspath;exports.addPostHogWithBundledScriptsToBundleShellScript=addPostHogWithBundledScriptsToBundleShellScript;exports.applyDotenvFileBuildSetting=applyDotenvFileBuildSetting;exports.applyPostHogAndroidGradlePlugin=applyPostHogAndroidGradlePlugin;exports.buildAndroidDotenvFileGradleValue=buildAndroidDotenvFileGradleValue;exports.buildAndroidForceGradleLine=buildAndroidForceGradleLine;exports.buildAndroidSkipOnConflictGradleLine=buildAndroidSkipOnConflictGradleLine;exports.buildDsymUploadShellScript=buildDsymUploadShellScript;exports.buildIosDotenvFileBuildSetting=buildIosDotenvFileBuildSetting;exports.disableUserScriptSandboxing=disableUserScriptSandboxing;exports.modifyExistingXcodeBuildScript=modifyExistingXcodeBuildScript;exports.moveDsymUploadBuildPhaseToEnd=moveDsymUploadBuildPhaseToEnd;exports.resolveDotenvFileProp=resolveDotenvFileProp;exports.resolveNativeSymbolUpload=resolveNativeSymbolUpload;exports.resolveReleaseModeProp=resolveReleaseModeProp;exports.updateDotenvFileGradleProperties=updateDotenvFileGradleProperties;exports.updateHermesReleaseModeGradleProperties=updateHermesReleaseModeGradleProperties;exports.updateMainActivityNewIntentOverride=updateMainActivityNewIntentOverride;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _excluded=["nextMod"],_excluded2=["nextMod"];function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]};},e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,_defineProperty2["default"])(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}var fs=require('fs');var path=require('path');var _require=require('@expo/config-plugins'),AndroidConfig=_require.AndroidConfig,withAppBuildGradle=_require.withAppBuildGradle,withBaseMod=_require.withBaseMod,withDangerousMod=_require.withDangerousMod,withGradleProperties=_require.withGradleProperties,withXcodeProject=_require.withXcodeProject;var POSTHOG_ANDROID_GRADLE_PLUGIN_VERSION='1.6.0';var resolvePostHogReactNativePackageJsonPath="[\"node\", \"--print\", \"require('path').join(require('path').dirname(require.resolve('posthog-react-native')), '..', 'tooling', 'posthog.gradle')\"].execute().text.trim()";var POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY='posthogReactNativeSkipOnConflict';var POSTHOG_ANDROID_FORCE_PROPERTY='posthogReactNativeForce';var POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY='posthog.hermesReleaseMode';var POSTHOG_RELEASE_MODES=exports.POSTHOG_RELEASE_MODES=['symbol-set','event'];function resolveReleaseModeProp(releaseMode,environmentMode){var trimmed=(releaseMode===null||releaseMode===void 0?void 0:releaseMode.trim())||(environmentMode===null||environmentMode===void 0?void 0:environmentMode.trim());if(!trimmed){return undefined;}if(!POSTHOG_RELEASE_MODES.includes(trimmed)){throw new Error("[posthog-react-native] releaseMode must be one of ".concat(POSTHOG_RELEASE_MODES.join(', '),", was '").concat(trimmed,"'"));}return trimmed;}function buildAndroidSkipOnConflictGradleLine(skipOnConflict){if(!skipOnConflict){return null;}return"project.ext.".concat(POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY," = true");}function buildAndroidForceGradleLine(force){if(!force){return null;}return"project.ext.".concat(POSTHOG_ANDROID_FORCE_PROPERTY," = true");}var androidConflictPropertyPattern=function androidConflictPropertyPattern(property){return new RegExp("^project\\.ext\\.".concat(property,"\\s*=\\s*(true|false)\\n?"),'m');};var withAndroidPlugin=function withAndroidPlugin(config){var skipOnConflict=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var force=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;return withAppBuildGradle(config,function(config){if(config.modResults.language!=='groovy'){console.warn('Cannot configure PostHog in the app gradle because the build.gradle is not groovy');}var buildGradle=config.modResults.contents;var applyFrom="apply from: new File(".concat(resolvePostHogReactNativePackageJsonPath,")");var conflictLines=[buildAndroidSkipOnConflictGradleLine(skipOnConflict),buildAndroidForceGradleLine(force)].filter(function(line){return line!==null;}).join('\n');var applyBlock=conflictLines?"".concat(conflictLines,"\n").concat(applyFrom):applyFrom;var conflictPatterns=[androidConflictPropertyPattern(POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY),androidConflictPropertyPattern(POSTHOG_ANDROID_FORCE_PROPERTY)];if(buildGradle.includes(applyFrom)){var contents=conflictPatterns.reduce(function(gradle,pattern){return gradle.replace(pattern,'');},buildGradle);if(conflictLines){contents=contents.replace(applyFrom,"".concat(conflictLines,"\n").concat(applyFrom));}config.modResults.contents=contents;return config;}var pattern=/^android\s*\{/m;if(buildGradle.match(pattern)){config.modResults.contents=buildGradle.replace(pattern,"".concat(applyBlock,"\n\nandroid {"));}else{console.warn('PostHog: Could not find "android {" block in build.gradle');}return config;});};function matchingBraceIndex(s,openBraceIndex){var depth=0;for(var i=openBraceIndex;i<s.length;i++){if(s[i]==='{'){depth++;}else if(s[i]==='}'){depth--;if(depth===0){return i;}}}return-1;}function addPostHogAndroidGradlePluginClasspath(projectBuildGradle){if(projectBuildGradle.includes('posthog-android-gradle-plugin')){return{contents:projectBuildGradle,classpathPresent:true};}var classpathLine=" classpath(\"com.posthog:posthog-android-gradle-plugin:".concat(POSTHOG_ANDROID_GRADLE_PLUGIN_VERSION,"\")");var buildscriptMatch=/buildscript\s*\{/.exec(projectBuildGradle);var buildscriptOpenBrace=buildscriptMatch?buildscriptMatch.index+buildscriptMatch[0].length-1:-1;var buildscriptEnd=buildscriptOpenBrace===-1?-1:matchingBraceIndex(projectBuildGradle,buildscriptOpenBrace);var buildscriptBody=buildscriptEnd===-1?'':projectBuildGradle.slice(buildscriptOpenBrace,buildscriptEnd);var dependenciesMatch=buildscriptBody?/dependencies\s*\{/.exec(buildscriptBody):null;if(!dependenciesMatch){console.warn('PostHog: Could not find a buildscript dependencies block in the project build.gradle; '+'skipping the com.posthog.android classpath. Native symbols will not be uploaded.');return{contents:projectBuildGradle,classpathPresent:false};}var insertAt=buildscriptOpenBrace+dependenciesMatch.index+dependenciesMatch[0].length;return{contents:"".concat(projectBuildGradle.slice(0,insertAt),"\n").concat(classpathLine).concat(projectBuildGradle.slice(insertAt)),classpathPresent:true};}function applyPostHogAndroidGradlePlugin(appBuildGradle){if(/apply plugin: ["']com\.posthog\.android["']/.test(appBuildGradle)){return appBuildGradle;}var applyLine='apply plugin: "com.posthog.android"';var appPluginPattern=/^([ \t]*apply plugin: ["']com\.android\.application["'].*)$/m;if(appPluginPattern.test(appBuildGradle)){return appBuildGradle.replace(appPluginPattern,"$1\n".concat(applyLine));}var androidBlockPattern=/^android\s*\{/m;if(androidBlockPattern.test(appBuildGradle)){return appBuildGradle.replace(androidBlockPattern,"".concat(applyLine,"\n\nandroid {"));}console.warn('PostHog: Could not find where to apply com.posthog.android in the app build.gradle');return appBuildGradle;}var withFinalizedProjectBuildGradle=function withFinalizedProjectBuildGradle(config,_action){return withBaseMod(config,{platform:'android',mod:'projectBuildGradle',skipEmptyMod:false,action:function action(config){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(){var _config$modRequest,nextMod,modRequest,results;return _regenerator["default"].wrap(function(_context){while(1)switch(_context.prev=_context.next){case 0:_config$modRequest=config.modRequest,nextMod=_config$modRequest.nextMod,modRequest=(0,_objectWithoutProperties2["default"])(_config$modRequest,_excluded);_context.next=1;return nextMod(_objectSpread(_objectSpread({},config),{},{modRequest:modRequest}));case 1:results=_context.sent;return _context.abrupt("return",_action(results));case 2:case"end":return _context.stop();}},_callee);}))();}});};var withAndroidNativeSymbolsPlugin=function withAndroidNativeSymbolsPlugin(config){return withFinalizedProjectBuildGradle(config,function(){var _ref=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(config){var result,appBuildGradle,contents;return _regenerator["default"].wrap(function(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!(config.modResults.language!=='groovy')){_context2.next=1;break;}console.warn('Cannot configure the PostHog Android Gradle plugin because the project build.gradle is not groovy');return _context2.abrupt("return",config);case 1:result=addPostHogAndroidGradlePluginClasspath(config.modResults.contents);if(!(result.contents!==config.modResults.contents)){_context2.next=3;break;}_context2.next=2;return fs.promises.writeFile(config.modResults.path,result.contents);case 2:config.modResults.contents=result.contents;case 3:if(result.classpathPresent){_context2.next=4;break;}return _context2.abrupt("return",config);case 4:_context2.next=5;return AndroidConfig.Paths.getAppBuildGradleAsync(config.modRequest.projectRoot);case 5:appBuildGradle=_context2.sent;if(!(appBuildGradle.language!=='groovy')){_context2.next=6;break;}console.warn('Cannot configure the PostHog Android Gradle plugin because the app build.gradle is not groovy');return _context2.abrupt("return",config);case 6:contents=applyPostHogAndroidGradlePlugin(appBuildGradle.contents);if(!(contents!==appBuildGradle.contents)){_context2.next=7;break;}_context2.next=7;return fs.promises.writeFile(appBuildGradle.path,contents);case 7:return _context2.abrupt("return",config);case 8:case"end":return _context2.stop();}},_callee2);}));return function(_x){return _ref.apply(this,arguments);};}());};var POSTHOG_NEW_INTENT_MARKER='posthog-new-intent';var POSTHOG_NEW_INTENT_BEGIN="// @generated begin ".concat(POSTHOG_NEW_INTENT_MARKER," - posthog-react-native (DO NOT MODIFY)");var POSTHOG_NEW_INTENT_END="// @generated end ".concat(POSTHOG_NEW_INTENT_MARKER);var NEW_INTENT_DOC=" /**\n * Records the intent that reopened the app so getIntent() stays correct.\n *\n * Works around a React Native defect that drops notification taps and deep links arriving while\n * the React context is still starting. Managed by the posthog-react-native Expo config plugin;\n * remove it with { patchMainActivityNewIntent: false } in app.json.\n * https://posthog.com/docs/workflows/push-notifications/react-native\n */";var NEW_INTENT_KOTLIN_BODY=" override fun onNewIntent(intent: android.content.Intent) {\n setIntent(intent)\n super.onNewIntent(intent)\n }";var NEW_INTENT_JAVA_BODY=" @Override\n public void onNewIntent(android.content.Intent intent) {\n setIntent(intent);\n super.onNewIntent(intent);\n }";function newIntentOverrideBlock(language){var body=language==='java'?NEW_INTENT_JAVA_BODY:NEW_INTENT_KOTLIN_BODY;return"\n ".concat(POSTHOG_NEW_INTENT_BEGIN,"\n").concat(NEW_INTENT_DOC,"\n").concat(body,"\n ").concat(POSTHOG_NEW_INTENT_END,"\n");}function escapeRegExp(value){return value.replace(/[.*+?^${}()|[\]\\]/g,'\\$&');}var POSTHOG_NEW_INTENT_BLOCK_PATTERN=new RegExp("\\r?\\n?[ \\t]*".concat(escapeRegExp(POSTHOG_NEW_INTENT_BEGIN),"[\\s\\S]*?").concat(escapeRegExp(POSTHOG_NEW_INTENT_END),"[ \\t]*\\r?\\n"),'g');function literalEnd(s,start,language){var quote=s[start];var raw=quote==='"'&&s.startsWith('"""',start);var i=start+(raw?3:1);while(i<s.length){var c=s[i];if(raw){if(s.startsWith('"""',i)){while(s[i]==='"'){i++;}return i;}}else if(c==='\n'){return-1;}else if(c===quote){return i+1;}if(c==='\\'&&(!raw||language==='java')){i+=2;continue;}if(language==='kt'&"e==='"'&&c==='$'&&s[i+1]==='{'){var close=matchingBraceIndexInSource(s,i+1,language);if(close===-1){return-1;}i=close+1;continue;}i++;}return-1;}function matchingBraceIndexInSource(s,openBraceIndex,language){var depth=0;var i=openBraceIndex;while(i<s.length){var c=s[i];if(c==='/'&&s[i+1]==='/'){var end=s.indexOf('\n',i);i=end===-1?s.length:end;continue;}if(c==='/'&&s[i+1]==='*'){var depthOfComment=1;i+=2;while(i<s.length&&depthOfComment>0){if(language==='kt'&&s[i]==='/'&&s[i+1]==='*'){depthOfComment++;i+=2;continue;}if(s[i]==='*'&&s[i+1]==='/'){depthOfComment--;i+=2;continue;}i++;}if(depthOfComment>0){return-1;}continue;}if(c==='"'||c==="'"){var _end=literalEnd(s,i,language);if(_end===-1){return-1;}i=_end;continue;}if(c==='{'){depth++;}else if(c==='}'){depth--;if(depth===0){return i;}}i++;}return-1;}function maskCommentsAndLiterals(source,language){var out=source.split('');var blank=function blank(from,to){for(var j=from;j<to&&j<out.length;j++){if(out[j]!=='\n'){out[j]=' ';}}};var i=0;while(i<source.length){var c=source[i];if(c==='/'&&source[i+1]==='/'){var end=source.indexOf('\n',i);var stop=end===-1?source.length:end;blank(i,stop);i=stop;continue;}if(c==='/'&&source[i+1]==='*'){var depth=1;var j=i+2;while(j<source.length&&depth>0){if(language==='kt'&&source[j]==='/'&&source[j+1]==='*'){depth++;j+=2;continue;}if(source[j]==='*'&&source[j+1]==='/'){depth--;j+=2;continue;}j++;}blank(i,j);i=j;continue;}if(c==='"'||c==="'"){var _end2=literalEnd(source,i,language);if(_end2===-1){blank(i,source.length);return out.join('');}blank(i,_end2);i=_end2;continue;}i++;}return out.join('');}function mainActivityBody(contents,language){var code=maskCommentsAndLiterals(contents,language);var declaration=/\bclass\s+MainActivity\b/.exec(code);if(!declaration){return undefined;}var searchFrom=declaration.index+declaration[0].length;var open=code.indexOf('{',searchFrom);if(open===-1||!/^[^;{}]*$/.test(code.slice(searchFrom,open))){return undefined;}var depth=0;var close=-1;for(var i=open;i<code.length;i++){if(code[i]==='{'){depth++;}else if(code[i]==='}'){depth--;if(depth===0){close=i;break;}}}return close===-1?undefined:{open:open,close:close};}function updateMainActivityNewIntentOverride(contents,language,enabled){var withoutManagedBlock=contents.replace(POSTHOG_NEW_INTENT_BLOCK_PATTERN,'');if(!enabled){return withoutManagedBlock;}var body=mainActivityBody(withoutManagedBlock,language);if(!body){console.warn('[posthog-react-native] Could not find the MainActivity class body; skipping the onNewIntent '+'override. Notification taps delivered while the React context is starting will be lost.');return withoutManagedBlock;}var codeOnly=maskCommentsAndLiterals(withoutManagedBlock,language);if(/\b(fun|void)\s+onNewIntent\s*\(/.test(codeOnly.slice(body.open,body.close))){console.warn('[posthog-react-native] MainActivity already overrides onNewIntent; leaving it alone. '+'Add `setIntent(intent)` as its first statement so a notification tap that arrives before '+'the React context is ready is not lost, or set `{ patchMainActivityNewIntent: false }` '+'on the plugin to silence this.');return withoutManagedBlock;}return withoutManagedBlock.slice(0,body.open+1)+newIntentOverrideBlock(language)+withoutManagedBlock.slice(body.open+1);}var MAIN_ACTIVITY_SOURCE_ROOTS=['android/app/src/main/java','android/app/src/main/kotlin'];function findMainActivityPath(projectRoot){var _walk=function walk(dir){if(!fs.existsSync(dir)){return undefined;}var _iterator=_createForOfIteratorHelper(fs.readdirSync(dir,{withFileTypes:true})),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var entry=_step.value;var candidate=path.join(dir,entry.name);if(!entry.isDirectory()){if(/^MainActivity\.(kt|java)$/.test(entry.name)){return candidate;}continue;}var hit=_walk(candidate);if(hit){return hit;}}}catch(err){_iterator.e(err);}finally{_iterator.f();}return undefined;};for(var _i=0,_MAIN_ACTIVITY_SOURCE=MAIN_ACTIVITY_SOURCE_ROOTS;_i<_MAIN_ACTIVITY_SOURCE.length;_i++){var sourceRoot=_MAIN_ACTIVITY_SOURCE[_i];var hit=_walk(path.join(projectRoot,sourceRoot));if(hit){return hit;}}return undefined;}var withMainActivityNewIntent=function withMainActivityNewIntent(config,enabled){return withDangerousMod(config,['android',(function(){var _ref2=(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(config){var mainActivityPath,contents,updated;return _regenerator["default"].wrap(function(_context3){while(1)switch(_context3.prev=_context3.next){case 0:mainActivityPath=findMainActivityPath(config.modRequest.projectRoot);if(mainActivityPath){_context3.next=1;break;}console.warn('[posthog-react-native] Could not find MainActivity under android/app/src/main/{java,kotlin}; '+'skipping the onNewIntent override. Notification taps delivered while the React context is '+'starting will be lost.');return _context3.abrupt("return",config);case 1:_context3.next=2;return fs.promises.readFile(mainActivityPath,'utf8');case 2:contents=_context3.sent;updated=updateMainActivityNewIntentOverride(contents,mainActivityPath.endsWith('.java')?'java':'kt',enabled);if(!(updated!==contents)){_context3.next=3;break;}_context3.next=3;return fs.promises.writeFile(mainActivityPath,updated);case 3:if(!contents.includes(POSTHOG_NEW_INTENT_BEGIN)&&updated.includes(POSTHOG_NEW_INTENT_BEGIN)){console.warn("[posthog-react-native] Added an onNewIntent override to ".concat(path.relative(config.modRequest.projectRoot,mainActivityPath)," so a notification tap that arrives before the React context is ready is not lost. ")+'Set `{ patchMainActivityNewIntent: false }` on the plugin in app.json to opt out.');}return _context3.abrupt("return",config);case 4:case"end":return _context3.stop();}},_callee3);}));return function(_x2){return _ref2.apply(this,arguments);};}())]);};function modifyExistingXcodeBuildScript(script){var skipOnConflict=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var releaseMode=arguments.length>2?arguments[2]:undefined;var force=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;if(!(script===null||script===void 0?void 0:script.shellScript)){console.warn("[posthog-react-native] Could not find the 'Bundle React Native code and images' build phase; "+'skipping sourcemap upload setup.');return;}if(!script.shellScript.match(/(packager|scripts)\/react-native-xcode\.sh\b/)){return;}if(script.shellScript.includes('posthog-xcode.sh')){var _code=migrateLegacyPostHogWrapperInvocation(JSON.parse(script.shellScript));script.shellScript=JSON.stringify(updatePostHogBundlePhaseExports(_code,skipOnConflict,releaseMode,force));return;}if(script.shellScript.includes('posthog-react-native')){return;}var code=JSON.parse(script.shellScript);script.shellScript=JSON.stringify(addPostHogWithBundledScriptsToBundleShellScript(code,skipOnConflict,releaseMode,force));}var POSTHOG_REACT_NATIVE_XCODE_PATH="`\"$NODE_BINARY\" --print \"require('path').join(require('path').dirname(require.resolve('posthog-react-native')), '..', 'tooling', 'posthog-xcode.sh')\"`";var POSTHOG_SKIP_ON_CONFLICT_EXPORT='export POSTHOG_SKIP_ON_CONFLICT=1';var POSTHOG_FORCE_EXPORT='export POSTHOG_FORCE=1';var POSTHOG_RELEASE_MODE_EXPORT_PREFIX='export POSTHOG_RELEASE_MODE=';function buildBundlePhaseExports(skipOnConflict,releaseMode){var force=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var exports=[];if(skipOnConflict){exports.push(POSTHOG_SKIP_ON_CONFLICT_EXPORT);}if(force){exports.push(POSTHOG_FORCE_EXPORT);}if(releaseMode){exports.push("".concat(POSTHOG_RELEASE_MODE_EXPORT_PREFIX).concat(releaseMode));}return exports;}var REACT_NATIVE_XCODE_LINE=/^([ \t]*)(?![A-Za-z_][A-Za-z0-9_]*=)([^\n]*(?:packager|scripts)\/react-native-xcode\.sh\b[^\n]*)$/m;function migrateLegacyPostHogWrapperInvocation(script){return script.replace("/bin/sh ".concat(POSTHOG_REACT_NATIVE_XCODE_PATH),POSTHOG_REACT_NATIVE_XCODE_PATH);}function updatePostHogBundlePhaseExports(script,skipOnConflict,releaseMode){var force=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;var _a;var _b;var skipArg='--posthog-skip-on-conflict --';var lines=script.replace(new RegExp("\\s*".concat(skipArg,"\\s*"),'g'),' ').split('\n').filter(function(line){return line.trim()!==POSTHOG_SKIP_ON_CONFLICT_EXPORT;}).filter(function(line){return line.trim()!==POSTHOG_FORCE_EXPORT;}).filter(function(line){return!line.trim().startsWith(POSTHOG_RELEASE_MODE_EXPORT_PREFIX);});var exports=buildBundlePhaseExports(skipOnConflict,releaseMode,force);if(exports.length>0){var commandIndex=lines.findIndex(function(line){return line.includes(POSTHOG_REACT_NATIVE_XCODE_PATH);});if(commandIndex!==-1){var indent=(_b=(_a=lines[commandIndex].match(/^[ \t]*/))===null||_a===void 0?void 0:_a[0])!==null&&_b!==void 0?_b:'';lines.splice.apply(lines,[commandIndex,0].concat((0,_toConsumableArray2["default"])(exports.map(function(line){return"".concat(indent).concat(line);}))));}}return lines.join('\n');}function addPostHogWithBundledScriptsToBundleShellScript(script){var skipOnConflict=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var releaseMode=arguments.length>2?arguments[2]:undefined;var force=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;return script.replace(REACT_NATIVE_XCODE_LINE,function(_match,indent,rnCommand){var exports=buildBundlePhaseExports(skipOnConflict,releaseMode,force).map(function(line){return"".concat(indent).concat(line,"\n");}).join('');return"".concat(exports).concat(indent).concat(POSTHOG_REACT_NATIVE_XCODE_PATH," ").concat(rnCommand);});}var POSTHOG_DSYM_BUILD_PHASE_NAME='Upload PostHog Debug Symbols';var POSTHOG_DSYM_INPUT_PATH='"$(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)/Contents/Resources/DWARF/$(EXECUTABLE_NAME)"';function buildDsymUploadShellScript(){var includeSource=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var skipOnConflict=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var force=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;return composeDsymUploadShellScript(includeSource,skipOnConflict,force);}function composeDsymUploadShellScript(includeSource,skipOnConflict,force){var lines=['# Upload iOS dSYMs to PostHog so native crashes can be symbolicated.','# upload-symbols.sh ships inside the posthog-ios dependency.'];if(includeSource){lines.push('# Also upload native source files for source-code context around crashes.','export POSTHOG_INCLUDE_SOURCE=1');}if(skipOnConflict){lines.push('# Skip dSYMs that already exist in PostHog with different content instead of failing the build.','export POSTHOG_SKIP_ON_CONFLICT=1');}if(force){lines.push('# Overwrite dSYMs that already exist in PostHog with different content instead of failing the build.','export POSTHOG_FORCE=1');}lines.push('PODS_SCRIPT="${PODS_ROOT}/PostHog/build-tools/upload-symbols.sh"','SPM_SCRIPT="${BUILD_DIR%/Build/*}/SourcePackages/checkouts/posthog-ios/build-tools/upload-symbols.sh"','if [ -f "$PODS_SCRIPT" ]; then',' /bin/sh "$PODS_SCRIPT"','elif [ -f "$SPM_SCRIPT" ]; then',' /bin/sh "$SPM_SCRIPT"','else',' echo "warning: PostHog upload-symbols.sh not found in Pods or SwiftPM checkouts; skipping dSYM upload."','fi');return lines.join('\n');}function legacyDsymReleaseModeLines(releaseMode){return[releaseMode?"POSTHOG_RESOLVED_RELEASE_MODE=\"".concat(releaseMode,"\""):'POSTHOG_RESOLVED_RELEASE_MODE="${POSTHOG_RELEASE_MODE:-}"','case "$POSTHOG_RESOLVED_RELEASE_MODE" in',' ""|symbol-set) ;;',' event)',' # Upload dSYMs without binding them to a release, so each crash resolves its own from the',' # app version and namespace the SDK sends. posthog-ios versions whose upload-symbols.sh',' # does not read this variable ignore it and keep binding the dSYMs.',' export POSTHOG_NO_RELEASE_BIND=1',' ;;',' *)'," echo \"error: posthog release mode must be 'symbol-set' or 'event', was '$POSTHOG_RESOLVED_RELEASE_MODE'\"",' exit 1',' ;;','esac'];}function buildLegacyReleaseModeDsymUploadShellScript(includeSource,skipOnConflict,releaseMode){var lines=composeDsymUploadShellScript(includeSource,skipOnConflict,false).split('\n');var uploadIndex=lines.findIndex(function(line){return line.startsWith('PODS_SCRIPT=');});lines.splice.apply(lines,[uploadIndex,0].concat((0,_toConsumableArray2["default"])(legacyDsymReleaseModeLines(releaseMode))));return lines.join('\n');}function encodePbxShellScript(script){return'"'+script.replace(/"/g,'\\"')+'"';}function decodePbxShellScript(stored){if(!stored.startsWith('"')||!stored.endsWith('"')){return stored;}return stored.slice(1,-1).replace(/\\(.)/g,function(_match,ch){return ch==='n'?'\n':ch==='t'?'\t':ch;});}function isPluginGeneratedDsymUploadBuildPhase(phase){if(typeof(phase===null||phase===void 0?void 0:phase.shellScript)!=='string'){return false;}var stored=decodePbxShellScript(phase.shellScript);return[false,true].some(function(source){return[false,true].some(function(skip){return[false,true].some(function(force){return stored===buildDsymUploadShellScript(source,skip,force);})||[undefined].concat(POSTHOG_RELEASE_MODES).some(function(mode){return stored===buildLegacyReleaseModeDsymUploadShellScript(source,skip,mode);});});});}function moveDsymUploadBuildPhaseToEnd(xcodeProject){var _a,_b;var existing=xcodeProject.pbxItemByComment(POSTHOG_DSYM_BUILD_PHASE_NAME,'PBXShellScriptBuildPhase');if(!isPluginGeneratedDsymUploadBuildPhase(existing)){return;}var buildPhases=(_b=(_a=xcodeProject.getFirstTarget)===null||_a===void 0?void 0:_a.call(xcodeProject).firstTarget)===null||_b===void 0?void 0:_b.buildPhases;if(Array.isArray(buildPhases)){var phaseIndex=buildPhases.findIndex(function(phase){return phase.comment===POSTHOG_DSYM_BUILD_PHASE_NAME;});if(phaseIndex!==-1&&phaseIndex!==buildPhases.length-1){buildPhases.push.apply(buildPhases,(0,_toConsumableArray2["default"])(buildPhases.splice(phaseIndex,1)));}}}function addDsymUploadBuildPhase(xcodeProject){var includeSource=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var skipOnConflict=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var force=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;var existing=xcodeProject.pbxItemByComment(POSTHOG_DSYM_BUILD_PHASE_NAME,'PBXShellScriptBuildPhase');if(existing){if(isPluginGeneratedDsymUploadBuildPhase(existing)){existing.shellScript=encodePbxShellScript(buildDsymUploadShellScript(includeSource,skipOnConflict,force));existing.inputPaths=Array.from(new Set([].concat((0,_toConsumableArray2["default"])(Array.isArray(existing.inputPaths)?existing.inputPaths:[]),[POSTHOG_DSYM_INPUT_PATH])));}}else{xcodeProject.addBuildPhase([],'PBXShellScriptBuildPhase',POSTHOG_DSYM_BUILD_PHASE_NAME,null,{inputPaths:[POSTHOG_DSYM_INPUT_PATH],shellPath:'/bin/sh',shellScript:buildDsymUploadShellScript(includeSource,skipOnConflict,force)});}moveDsymUploadBuildPhaseToEnd(xcodeProject);}function disableUserScriptSandboxing(xcodeProject){var configurations=xcodeProject.pbxXCBuildConfigurationSection();for(var key in configurations){var configuration=configurations[key];if(configuration&&configuration.buildSettings){configuration.buildSettings.ENABLE_USER_SCRIPT_SANDBOXING='"NO"';}}}var POSTHOG_DOTENV_BUILD_SETTING='POSTHOG_CLI_DOTENV_FILE';var POSTHOG_DOTENV_GRADLE_PROPERTY='posthog.dotenvFile';function normalizeDotenvFileProp(dotenvFile){return dotenvFile.replace(/^\.\//,'');}function resolveDotenvFileProp(dotenvFile){var trimmed=dotenvFile===null||dotenvFile===void 0?void 0:dotenvFile.trim();return trimmed?trimmed:undefined;}function isAbsoluteDotenvPath(dotenvFile){return dotenvFile.startsWith('/')||/^[A-Za-z]:[\\/]/.test(dotenvFile);}function buildIosDotenvFileBuildSetting(dotenvFile){var value=isAbsoluteDotenvPath(dotenvFile)?dotenvFile:"$(SRCROOT)/../".concat(normalizeDotenvFileProp(dotenvFile));return'"'+value.replace(/(["\\])/g,'\\$1')+'"';}function applyDotenvFileBuildSetting(xcodeProject,dotenvFile){var configurations=xcodeProject.pbxXCBuildConfigurationSection();for(var key in configurations){var configuration=configurations[key];if(configuration&&configuration.buildSettings){if(dotenvFile){configuration.buildSettings[POSTHOG_DOTENV_BUILD_SETTING]=buildIosDotenvFileBuildSetting(dotenvFile);}else{delete configuration.buildSettings[POSTHOG_DOTENV_BUILD_SETTING];}}}}function buildAndroidDotenvFileGradleValue(dotenvFile){return isAbsoluteDotenvPath(dotenvFile)?dotenvFile:"../".concat(normalizeDotenvFileProp(dotenvFile));}function updateDotenvFileGradleProperties(properties,dotenvFile){var rest=properties.filter(function(item){return!(item.type==='property'&&item.key===POSTHOG_DOTENV_GRADLE_PROPERTY);});if(!dotenvFile){return rest;}rest.push({type:'property',key:POSTHOG_DOTENV_GRADLE_PROPERTY,value:buildAndroidDotenvFileGradleValue(dotenvFile)});return rest;}function updateHermesReleaseModeGradleProperties(properties,releaseMode){var rest=properties.filter(function(item){return!(item.type==='property'&&item.key===POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY);});if(!releaseMode){return rest;}rest.push({type:'property',key:POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY,value:releaseMode});return rest;}var withPostHogGradleProperties=function withPostHogGradleProperties(config,dotenvFile,releaseMode){return withGradleProperties(config,function(config){config.modResults=updateDotenvFileGradleProperties(config.modResults,dotenvFile);config.modResults=updateHermesReleaseModeGradleProperties(config.modResults,releaseMode);return config;});};function resolveNativeSymbolUpload(prop){if(prop===true){return{enabled:true,includeSource:false};}if(prop&&(0,_typeof2["default"])(prop)==='object'){return{enabled:true,includeSource:prop.includeSource===true};}return{enabled:false,includeSource:false};}var withFinalizedXcodeProject=function withFinalizedXcodeProject(config,_action2){return withBaseMod(config,{platform:'ios',mod:'xcodeproj',action:function action(config){return(0,_asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(){var _config$modRequest2,nextMod,modRequest,results;return _regenerator["default"].wrap(function(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_config$modRequest2=config.modRequest,nextMod=_config$modRequest2.nextMod,modRequest=(0,_objectWithoutProperties2["default"])(_config$modRequest2,_excluded2);_context4.next=1;return nextMod(_objectSpread(_objectSpread({},config),{},{modRequest:modRequest}));case 1:results=_context4.sent;return _context4.abrupt("return",_action2(results));case 2:case"end":return _context4.stop();}},_callee4);}))();}});};var withIosPlugin=function withIosPlugin(config){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var nativeSymbols=resolveNativeSymbolUpload(props.uploadNativeSymbols);config=withXcodeProject(config,function(config){var xcodeProject=config.modResults;var bundleReactNativePhase=xcodeProject.pbxItemByComment('Bundle React Native code and images','PBXShellScriptBuildPhase');modifyExistingXcodeBuildScript(bundleReactNativePhase,props.skipOnConflict===true,props.releaseMode,props.force===true);if(nativeSymbols.enabled){addDsymUploadBuildPhase(xcodeProject,nativeSymbols.includeSource,props.skipOnConflict===true,props.force===true);}applyDotenvFileBuildSetting(xcodeProject,props.dotenvFile);if(props.disableSandboxing!==false){disableUserScriptSandboxing(xcodeProject);console.warn('[posthog-react-native] Setting ENABLE_USER_SCRIPT_SANDBOXING=NO on all Xcode '+'build configurations so sourcemap uploads can resolve git metadata. '+'If your org requires sandboxing to stay enabled, set `{ disableSandboxing: false }` '+'on the plugin in app.json — note that stock Expo projects may fail to build under '+'sandboxing until every script build phase declares its input/output files.');}return config;});if(nativeSymbols.enabled){config=withFinalizedXcodeProject(config,function(config){moveDsymUploadBuildPhaseToEnd(config.modResults);return config;});}return config;};var withPostHogPlugin=function withPostHogPlugin(config){var rawProps=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(rawProps.skipOnConflict===true&&rawProps.force===true){throw new Error('[posthog-react-native] skipOnConflict and force cannot both be enabled: posthog-cli accepts only one of --skip-on-conflict and --force');}var props=_objectSpread(_objectSpread({},rawProps),{},{dotenvFile:resolveDotenvFileProp(rawProps.dotenvFile),releaseMode:resolveReleaseModeProp(rawProps.releaseMode,process.env.POSTHOG_RELEASE_MODE)});if(resolveNativeSymbolUpload(props.uploadNativeSymbols).enabled){config=withAndroidNativeSymbolsPlugin(config);}config=withAndroidPlugin(config,props.skipOnConflict===true,props.force===true);config=withPostHogGradleProperties(config,props.dotenvFile,props.releaseMode);config=withMainActivityNewIntent(config,props.patchMainActivityNewIntent!==false);return withIosPlugin(config,props);};var postHogPlugin=function postHogPlugin(config){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return withPostHogPlugin(config,props);};module.exports=postHogPlugin;module.exports.modifyExistingXcodeBuildScript=modifyExistingXcodeBuildScript;module.exports.addPostHogWithBundledScriptsToBundleShellScript=addPostHogWithBundledScriptsToBundleShellScript;module.exports.disableUserScriptSandboxing=disableUserScriptSandboxing;module.exports.buildDsymUploadShellScript=buildDsymUploadShellScript;module.exports.addDsymUploadBuildPhase=addDsymUploadBuildPhase;module.exports.moveDsymUploadBuildPhaseToEnd=moveDsymUploadBuildPhaseToEnd;module.exports.resolveNativeSymbolUpload=resolveNativeSymbolUpload;module.exports.buildAndroidSkipOnConflictGradleLine=buildAndroidSkipOnConflictGradleLine;module.exports.buildAndroidForceGradleLine=buildAndroidForceGradleLine;module.exports.addPostHogAndroidGradlePluginClasspath=addPostHogAndroidGradlePluginClasspath;module.exports.applyPostHogAndroidGradlePlugin=applyPostHogAndroidGradlePlugin;module.exports.buildIosDotenvFileBuildSetting=buildIosDotenvFileBuildSetting;module.exports.applyDotenvFileBuildSetting=applyDotenvFileBuildSetting;module.exports.resolveDotenvFileProp=resolveDotenvFileProp;module.exports.buildAndroidDotenvFileGradleValue=buildAndroidDotenvFileGradleValue;module.exports.updateDotenvFileGradleProperties=updateDotenvFileGradleProperties;module.exports.POSTHOG_RELEASE_MODES=POSTHOG_RELEASE_MODES;module.exports.resolveReleaseModeProp=resolveReleaseModeProp;module.exports.updateHermesReleaseModeGradleProperties=updateHermesReleaseModeGradleProperties;module.exports.updateMainActivityNewIntentOverride=updateMainActivityNewIntentOverride;
|
|
2
2
|
//# sourceMappingURL=expoconfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expoconfig.js","names":["fs","require","path","_require","AndroidConfig","withAppBuildGradle","withBaseMod","withDangerousMod","withGradleProperties","withXcodeProject","POSTHOG_ANDROID_GRADLE_PLUGIN_VERSION","resolvePostHogReactNativePackageJsonPath","POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY","POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY","POSTHOG_RELEASE_MODES","exports","resolveReleaseModeProp","releaseMode","environmentMode","trimmed","trim","undefined","includes","Error","concat","join","buildAndroidSkipOnConflictGradleLine","skipOnConflict","withAndroidPlugin","config","arguments","length","modResults","language","console","warn","buildGradle","contents","applyFrom","skipOnConflictLine","applyBlock","skipOnConflictPattern","RegExp","replace","pattern","match","matchingBraceIndex","s","openBraceIndex","depth","i","addPostHogAndroidGradlePluginClasspath","projectBuildGradle","classpathPresent","classpathLine","buildscriptMatch","exec","buildscriptOpenBrace","index","buildscriptEnd","buildscriptBody","slice","dependenciesMatch","insertAt","applyPostHogAndroidGradlePlugin","appBuildGradle","test","applyLine","appPluginPattern","androidBlockPattern","withFinalizedProjectBuildGradle","action","platform","mod","skipEmptyMod","_asyncToGenerator2","_regenerator","mark","_callee","_config$modRequest","nextMod","modRequest","results","wrap","_context","prev","next","_objectWithoutProperties2","_excluded","_objectSpread","sent","abrupt","stop","withAndroidNativeSymbolsPlugin","_ref","_callee2","result","_context2","promises","writeFile","Paths","getAppBuildGradleAsync","projectRoot","_x","apply","POSTHOG_NEW_INTENT_MARKER","POSTHOG_NEW_INTENT_BEGIN","POSTHOG_NEW_INTENT_END","NEW_INTENT_DOC","NEW_INTENT_KOTLIN_BODY","NEW_INTENT_JAVA_BODY","newIntentOverrideBlock","body","escapeRegExp","value","POSTHOG_NEW_INTENT_BLOCK_PATTERN","literalEnd","start","quote","raw","startsWith","c","close","matchingBraceIndexInSource","end","indexOf","depthOfComment","maskCommentsAndLiterals","source","out","split","blank","from","to","j","mainActivityBody","code","declaration","searchFrom","open","updateMainActivityNewIntentOverride","enabled","withoutManagedBlock","codeOnly","MAIN_ACTIVITY_SOURCE_ROOTS","findMainActivityPath","walk","dir","existsSync","_iterator","_createForOfIteratorHelper","readdirSync","withFileTypes","_step","n","done","entry","candidate","name","isDirectory","hit","err","e","f","_i","_MAIN_ACTIVITY_SOURCE","sourceRoot","withMainActivityNewIntent","_ref2","_callee3","mainActivityPath","updated","_context3","readFile","endsWith","relative","_x2","modifyExistingXcodeBuildScript","script","shellScript","migrateLegacyPostHogWrapperInvocation","JSON","parse","stringify","updatePostHogBundlePhaseExports","addPostHogWithBundledScriptsToBundleShellScript","POSTHOG_REACT_NATIVE_XCODE_PATH","POSTHOG_SKIP_ON_CONFLICT_EXPORT","POSTHOG_RELEASE_MODE_EXPORT_PREFIX","buildBundlePhaseExports","push","REACT_NATIVE_XCODE_LINE","skipArg","lines","filter","line","commandIndex","findIndex","indent","_b","_a","splice","_toConsumableArray2","map","_match","rnCommand","POSTHOG_DSYM_BUILD_PHASE_NAME","POSTHOG_DSYM_INPUT_PATH","buildDsymUploadShellScript","includeSource","composeDsymUploadShellScript","legacyDsymReleaseModeLines","buildLegacyReleaseModeDsymUploadShellScript","uploadIndex","encodePbxShellScript","decodePbxShellScript","stored","ch","isPluginGeneratedDsymUploadBuildPhase","phase","some","skip","mode","moveDsymUploadBuildPhaseToEnd","xcodeProject","existing","pbxItemByComment","buildPhases","getFirstTarget","call","firstTarget","Array","isArray","phaseIndex","comment","addDsymUploadBuildPhase","inputPaths","Set","addBuildPhase","shellPath","disableUserScriptSandboxing","configurations","pbxXCBuildConfigurationSection","key","configuration","buildSettings","ENABLE_USER_SCRIPT_SANDBOXING","POSTHOG_DOTENV_BUILD_SETTING","POSTHOG_DOTENV_GRADLE_PROPERTY","normalizeDotenvFileProp","dotenvFile","resolveDotenvFileProp","isAbsoluteDotenvPath","buildIosDotenvFileBuildSetting","applyDotenvFileBuildSetting","buildAndroidDotenvFileGradleValue","updateDotenvFileGradleProperties","properties","rest","item","type","updateHermesReleaseModeGradleProperties","withPostHogGradleProperties","resolveNativeSymbolUpload","prop","_typeof2","withFinalizedXcodeProject","_callee4","_config$modRequest2","_context4","_excluded2","withIosPlugin","props","nativeSymbols","uploadNativeSymbols","bundleReactNativePhase","disableSandboxing","withPostHogPlugin","rawProps","process","env","POSTHOG_RELEASE_MODE","patchMainActivityNewIntent","postHogPlugin","module"],"sources":["../../src/tooling/expoconfig.ts"],"sourcesContent":["// Portions of this file are derived from getsentry/sentry-react-native\n// Copyright (c) 2017 Sentry\n// Licensed under the MIT License: https://github.com/getsentry/sentry-react-native/blob/main/LICENSE.md\n\nconst fs = require('fs')\nconst path = require('path')\n\nconst {\n AndroidConfig,\n withAppBuildGradle,\n withBaseMod,\n withDangerousMod,\n withGradleProperties,\n withXcodeProject,\n} = require('@expo/config-plugins')\n\n// com.posthog.android uploads R8 mapping files and injects a matching map-id so native\n// crash stack traces can be deobfuscated. The injected version has to read every gradle\n// property the plugin writes, or that half of the build ignores the option: 1.4.0 is the first\n// version that reads posthog.dotenvFile. 1.6.0 is the first version that ignores\n// posthog.releaseMode with a deprecation warning, so the R8 mapping always binds to the release.\nconst POSTHOG_ANDROID_GRADLE_PLUGIN_VERSION = '1.6.0'\n\nconst resolvePostHogReactNativePackageJsonPath =\n \"[\\\"node\\\", \\\"--print\\\", \\\"require('path').join(require('path').dirname(require.resolve('posthog-react-native')), '..', 'tooling', 'posthog.gradle')\\\"].execute().text.trim()\"\n\nconst POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY = 'posthogReactNativeSkipOnConflict'\n\nconst POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY = 'posthog.hermesReleaseMode'\n\n/**\n * How the release a build belongs to gets associated with the exceptions it reports. This steers\n * the Hermes source map upload only. iOS dSYMs and Android R8 mappings always bind to the release\n * their build creates.\n *\n * `event`, the default, uploads the maps release-independent and lets each event resolve its own\n * release from the app version and namespace the SDK already sends. `symbol-set` stamps the release\n * onto the uploaded maps instead, and an exception inherits the release of the maps its frames\n * resolved against.\n */\nexport type PostHogReleaseMode = 'symbol-set' | 'event'\n\n// Exported so a test can hold the copies in posthog-xcode.sh, posthog.gradle and the generated\n// dSYM phase to this list, because nothing else fails when they drift.\nexport const POSTHOG_RELEASE_MODES: PostHogReleaseMode[] = ['symbol-set', 'event']\n\n// Empty/whitespace-only values (easy to produce from templated app.config values) count as unset\n// and fall through to the next source. A configured mode is written into the bundle phase, and that\n// beats POSTHOG_RELEASE_MODE at build time, so this reads the variable rather than leaving an Expo\n// build with no way to opt out. Undefined means nothing configured a mode: the prebuild then writes\n// nothing, and the build scripts apply the event default themselves, which they can soften to a\n// bound upload when the installed posthog-cli predates the flag. An unrecognized value stops the\n// prebuild rather than falling back, so a typo cannot silently leave a build binding its maps to a\n// release it meant to keep independent.\nexport function resolveReleaseModeProp(releaseMode?: string, environmentMode?: string): PostHogReleaseMode | undefined {\n const trimmed = releaseMode?.trim() || environmentMode?.trim()\n if (!trimmed) {\n return undefined\n }\n if (!POSTHOG_RELEASE_MODES.includes(trimmed as PostHogReleaseMode)) {\n throw new Error(\n `[posthog-react-native] releaseMode must be one of ${POSTHOG_RELEASE_MODES.join(', ')}, was '${trimmed}'`\n )\n }\n return trimmed as PostHogReleaseMode\n}\n\nexport function buildAndroidSkipOnConflictGradleLine(skipOnConflict: boolean): string | null {\n if (!skipOnConflict) {\n return null\n }\n return `project.ext.${POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY} = true`\n}\n\nconst withAndroidPlugin = (config: any, skipOnConflict = false) => {\n return withAppBuildGradle(config, (config: any) => {\n if (config.modResults.language !== 'groovy') {\n console.warn('Cannot configure PostHog in the app gradle because the build.gradle is not groovy')\n }\n\n const buildGradle = config.modResults.contents\n const applyFrom = `apply from: new File(${resolvePostHogReactNativePackageJsonPath})`\n const skipOnConflictLine = buildAndroidSkipOnConflictGradleLine(skipOnConflict)\n const applyBlock = skipOnConflictLine ? `${skipOnConflictLine}\\n${applyFrom}` : applyFrom\n const skipOnConflictPattern = new RegExp(\n `^project\\\\.ext\\\\.${POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY}\\\\s*=\\\\s*(true|false)\\\\n?`,\n 'm'\n )\n\n if (buildGradle.includes(applyFrom)) {\n let contents = buildGradle.replace(skipOnConflictPattern, '')\n if (skipOnConflictLine) {\n contents = contents.replace(applyFrom, `${skipOnConflictLine}\\n${applyFrom}`)\n }\n config.modResults.contents = contents\n return config\n }\n\n // Find the 'android {' block and insert the line directly above it\n const pattern = /^android\\s*\\{/m\n\n if (buildGradle.match(pattern)) {\n config.modResults.contents = buildGradle.replace(pattern, `${applyBlock}\\n\\nandroid {`)\n } else {\n console.warn('PostHog: Could not find \"android {\" block in build.gradle')\n }\n\n return config\n })\n}\n\n// Index of the `}` matching the `{` at openBraceIndex, or -1 if unbalanced. Manual scan\n// (not regex) to avoid ReDoS; counts all braces, fine for the generated gradle we target.\nfunction matchingBraceIndex(s: string, openBraceIndex: number): number {\n let depth = 0\n for (let i = openBraceIndex; i < s.length; i++) {\n if (s[i] === '{') {\n depth++\n } else if (s[i] === '}') {\n depth--\n if (depth === 0) {\n return i\n }\n }\n }\n return -1\n}\n\n// Published to Maven Central (not the Gradle Plugin Portal), so we use the legacy buildscript\n// classpath + apply route. Idempotent. `classpathPresent` tells the caller to only `apply\n// plugin` when the classpath is in the file, else the build can't resolve it.\nexport function addPostHogAndroidGradlePluginClasspath(projectBuildGradle: string): {\n contents: string\n classpathPresent: boolean\n} {\n if (projectBuildGradle.includes('posthog-android-gradle-plugin')) {\n return { contents: projectBuildGradle, classpathPresent: true }\n }\n\n const classpathLine = ` classpath(\"com.posthog:posthog-android-gradle-plugin:${POSTHOG_ANDROID_GRADLE_PLUGIN_VERSION}\")`\n\n // First `dependencies {` inside the `buildscript {}` block. Bounding to the buildscript body\n // avoids a backtracking regex (ReDoS) and mis-placing into a later block (e.g. allprojects).\n const buildscriptMatch = /buildscript\\s*\\{/.exec(projectBuildGradle)\n const buildscriptOpenBrace = buildscriptMatch ? buildscriptMatch.index + buildscriptMatch[0].length - 1 : -1\n const buildscriptEnd = buildscriptOpenBrace === -1 ? -1 : matchingBraceIndex(projectBuildGradle, buildscriptOpenBrace)\n const buildscriptBody = buildscriptEnd === -1 ? '' : projectBuildGradle.slice(buildscriptOpenBrace, buildscriptEnd)\n const dependenciesMatch = buildscriptBody ? /dependencies\\s*\\{/.exec(buildscriptBody) : null\n\n if (!dependenciesMatch) {\n console.warn(\n 'PostHog: Could not find a buildscript dependencies block in the project build.gradle; ' +\n 'skipping the com.posthog.android classpath. Native symbols will not be uploaded.'\n )\n return { contents: projectBuildGradle, classpathPresent: false }\n }\n\n const insertAt = buildscriptOpenBrace + dependenciesMatch.index + dependenciesMatch[0].length\n return {\n contents: `${projectBuildGradle.slice(0, insertAt)}\\n${classpathLine}${projectBuildGradle.slice(insertAt)}`,\n classpathPresent: true,\n }\n}\n\n// Applies the com.posthog.android plugin in the app module. Idempotent.\nexport function applyPostHogAndroidGradlePlugin(appBuildGradle: string): string {\n if (/apply plugin: [\"']com\\.posthog\\.android[\"']/.test(appBuildGradle)) {\n return appBuildGradle\n }\n\n const applyLine = 'apply plugin: \"com.posthog.android\"'\n\n // Apply right after com.android.application so the plugin can hook AGP variants.\n const appPluginPattern = /^([ \\t]*apply plugin: [\"']com\\.android\\.application[\"'].*)$/m\n if (appPluginPattern.test(appBuildGradle)) {\n return appBuildGradle.replace(appPluginPattern, `$1\\n${applyLine}`)\n }\n\n // Fallback: insert directly above the android { } block.\n const androidBlockPattern = /^android\\s*\\{/m\n if (androidBlockPattern.test(appBuildGradle)) {\n return appBuildGradle.replace(androidBlockPattern, `${applyLine}\\n\\nandroid {`)\n }\n\n console.warn('PostHog: Could not find where to apply com.posthog.android in the app build.gradle')\n return appBuildGradle\n}\n\n// Expo's standard mods run their action before the previously registered action. This wrapper\n// deliberately runs its action after the rest of the project Gradle mod chain, so it can safely\n// coordinate the project classpath and app plugin edits without relying on mod-key order.\nconst withFinalizedProjectBuildGradle = (config: any, action: (config: any) => any) => {\n return withBaseMod(config, {\n platform: 'android',\n mod: 'projectBuildGradle',\n skipEmptyMod: false,\n async action(config: any) {\n const { nextMod, ...modRequest } = config.modRequest\n const results = await nextMod({ ...config, modRequest })\n return action(results)\n },\n })\n}\n\nconst withAndroidNativeSymbolsPlugin = (config: any) => {\n return withFinalizedProjectBuildGradle(config, async (config: any) => {\n if (config.modResults.language !== 'groovy') {\n console.warn('Cannot configure the PostHog Android Gradle plugin because the project build.gradle is not groovy')\n return config\n }\n\n const result = addPostHogAndroidGradlePluginClasspath(config.modResults.contents)\n if (result.contents !== config.modResults.contents) {\n // Persist the classpath before applying the app plugin so a failed second write cannot\n // leave an apply line without its matching classpath.\n await fs.promises.writeFile(config.modResults.path, result.contents)\n config.modResults.contents = result.contents\n }\n if (!result.classpathPresent) {\n // No classpath (or no buildscript dependencies block) → applying would break the build.\n return config\n }\n\n const appBuildGradle = await AndroidConfig.Paths.getAppBuildGradleAsync(config.modRequest.projectRoot)\n if (appBuildGradle.language !== 'groovy') {\n console.warn('Cannot configure the PostHog Android Gradle plugin because the app build.gradle is not groovy')\n return config\n }\n\n const contents = applyPostHogAndroidGradlePlugin(appBuildGradle.contents)\n if (contents !== appBuildGradle.contents) {\n await fs.promises.writeFile(appBuildGradle.path, contents)\n }\n return config\n })\n}\n\nconst POSTHOG_NEW_INTENT_MARKER = 'posthog-new-intent'\nconst POSTHOG_NEW_INTENT_BEGIN = `// @generated begin ${POSTHOG_NEW_INTENT_MARKER} - posthog-react-native (DO NOT MODIFY)`\nconst POSTHOG_NEW_INTENT_END = `// @generated end ${POSTHOG_NEW_INTENT_MARKER}`\n\n// `android.content.Intent` is spelled out to keep the block self-contained: adding an import is a\n// second, riskier edit, and the templates we patch do not already import Intent.\nconst NEW_INTENT_DOC = ` /**\n * Records the intent that reopened the app so getIntent() stays correct.\n *\n * Works around a React Native defect that drops notification taps and deep links arriving while\n * the React context is still starting. Managed by the posthog-react-native Expo config plugin;\n * remove it with { patchMainActivityNewIntent: false } in app.json.\n * https://posthog.com/docs/workflows/push-notifications/react-native\n */`\n\nconst NEW_INTENT_KOTLIN_BODY = ` override fun onNewIntent(intent: android.content.Intent) {\n setIntent(intent)\n super.onNewIntent(intent)\n }`\n\nconst NEW_INTENT_JAVA_BODY = ` @Override\n public void onNewIntent(android.content.Intent intent) {\n setIntent(intent);\n super.onNewIntent(intent);\n }`\n\nfunction newIntentOverrideBlock(language: string): string {\n const body = language === 'java' ? NEW_INTENT_JAVA_BODY : NEW_INTENT_KOTLIN_BODY\n return `\\n ${POSTHOG_NEW_INTENT_BEGIN}\\n${NEW_INTENT_DOC}\\n${body}\\n ${POSTHOG_NEW_INTENT_END}\\n`\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n// Lazy body match so two blocks (only reachable from a hand-edited file) are removed separately\n// rather than swallowing everything between them. The `\\r?` on both ends keeps the block removable\n// after an editor or a Windows checkout has normalized the file to CRLF.\nconst POSTHOG_NEW_INTENT_BLOCK_PATTERN = new RegExp(\n `\\\\r?\\\\n?[ \\\\t]*${escapeRegExp(POSTHOG_NEW_INTENT_BEGIN)}[\\\\s\\\\S]*?${escapeRegExp(\n POSTHOG_NEW_INTENT_END\n )}[ \\\\t]*\\\\r?\\\\n`,\n 'g'\n)\n\n// Index just past the string or character literal opening at `start`, or -1 when it never closes.\n// Covers `\"...\"` and `'...'` with backslash escapes (which end at a newline in both languages),\n// `\"\"\"...\"\"\"` raw strings and text blocks, and Kotlin `${...}` templates, whose contents are code\n// that may nest further literals.\nfunction literalEnd(s: string, start: number, language: string): number {\n const quote = s[start]\n const raw = quote === '\"' && s.startsWith('\"\"\"', start)\n let i = start + (raw ? 3 : 1)\n while (i < s.length) {\n const c = s[i]\n if (raw) {\n if (s.startsWith('\"\"\"', i)) {\n // Kotlin closes on the last three of a longer run of quotes.\n while (s[i] === '\"') {\n i++\n }\n return i\n }\n } else if (c === '\\n') {\n return -1\n } else if (c === quote) {\n return i + 1\n }\n if (c === '\\\\' && (!raw || language === 'java')) {\n i += 2\n continue\n }\n if (language === 'kt' && quote === '\"' && c === '$' && s[i + 1] === '{') {\n const close = matchingBraceIndexInSource(s, i + 1, language)\n if (close === -1) {\n return -1\n }\n i = close + 1\n continue\n }\n i++\n }\n return -1\n}\n\n// Index of the `}` matching the `{` at openBraceIndex in Kotlin or Java source, or -1 if\n// unbalanced. Braces inside literals and comments are not structural: a `\"}\"` field before an\n// existing onNewIntent must not end the class early, which would hide that override from the\n// scoped check below and make us insert a duplicate the file no longer compiles with.\nfunction matchingBraceIndexInSource(s: string, openBraceIndex: number, language: string): number {\n let depth = 0\n let i = openBraceIndex\n while (i < s.length) {\n const c = s[i]\n if (c === '/' && s[i + 1] === '/') {\n const end = s.indexOf('\\n', i)\n i = end === -1 ? s.length : end\n continue\n }\n if (c === '/' && s[i + 1] === '*') {\n // Kotlin nests block comments, Java does not: taking the first `*/` in Kotlin would end the\n // comment early and let a commented-out `}` close the class, hiding a real override below it.\n let depthOfComment = 1\n i += 2\n while (i < s.length && depthOfComment > 0) {\n if (language === 'kt' && s[i] === '/' && s[i + 1] === '*') {\n depthOfComment++\n i += 2\n continue\n }\n if (s[i] === '*' && s[i + 1] === '/') {\n depthOfComment--\n i += 2\n continue\n }\n i++\n }\n if (depthOfComment > 0) {\n return -1\n }\n continue\n }\n if (c === '\"' || c === \"'\") {\n const end = literalEnd(s, i, language)\n if (end === -1) {\n return -1\n }\n i = end\n continue\n }\n if (c === '{') {\n depth++\n } else if (c === '}') {\n depth--\n if (depth === 0) {\n return i\n }\n }\n i++\n }\n return -1\n}\n\n// A copy of `source` with the inside of every comment and string/char literal replaced by spaces,\n// keeping length and line breaks so indexes still line up with the original. One pass, so the class\n// declaration, the brace scan and the existing-override check all agree on what is code: a\n// commented-out `class MainActivity`, a `\"}\"` field, or an `onNewIntent` inside a comment are all\n// invisible to every one of them. Kotlin nests block comments and Java does not.\nfunction maskCommentsAndLiterals(source: string, language: string): string {\n const out = source.split('')\n const blank = (from: number, to: number) => {\n for (let j = from; j < to && j < out.length; j++) {\n if (out[j] !== '\\n') {\n out[j] = ' '\n }\n }\n }\n\n let i = 0\n while (i < source.length) {\n const c = source[i]\n if (c === '/' && source[i + 1] === '/') {\n const end = source.indexOf('\\n', i)\n const stop = end === -1 ? source.length : end\n blank(i, stop)\n i = stop\n continue\n }\n if (c === '/' && source[i + 1] === '*') {\n let depth = 1\n let j = i + 2\n while (j < source.length && depth > 0) {\n if (language === 'kt' && source[j] === '/' && source[j + 1] === '*') {\n depth++\n j += 2\n continue\n }\n if (source[j] === '*' && source[j + 1] === '/') {\n depth--\n j += 2\n continue\n }\n j++\n }\n blank(i, j)\n i = j\n continue\n }\n if (c === '\"' || c === \"'\") {\n const end = literalEnd(source, i, language)\n if (end === -1) {\n // Unterminated literal: blank the rest so nothing after it reads as code.\n blank(i, source.length)\n return out.join('')\n }\n blank(i, end)\n i = end\n continue\n }\n i++\n }\n return out.join('')\n}\n\n// The span of MainActivity's body, or undefined when the file does not look like the templates we\n// patch: a supertype list is all we expect between the class name and the opening brace.\nfunction mainActivityBody(contents: string, language: string): { open: number; close: number } | undefined {\n const code = maskCommentsAndLiterals(contents, language)\n const declaration = /\\bclass\\s+MainActivity\\b/.exec(code)\n if (!declaration) {\n return undefined\n }\n const searchFrom = declaration.index + declaration[0].length\n const open = code.indexOf('{', searchFrom)\n if (open === -1 || !/^[^;{}]*$/.test(code.slice(searchFrom, open))) {\n return undefined\n }\n // Unbalanced braces mean we cannot tell where the body ends, so the file is not ours to edit.\n let depth = 0\n let close = -1\n for (let i = open; i < code.length; i++) {\n if (code[i] === '{') {\n depth++\n } else if (code[i] === '}') {\n depth--\n if (depth === 0) {\n close = i\n break\n }\n }\n }\n return close === -1 ? undefined : { open, close }\n}\n\n/**\n * Adds (or, when disabled, removes) the managed `onNewIntent` override in MainActivity.\n *\n * Idempotent: the block is delimited by generated markers and rewritten in place, so repeated\n * prebuilds never stack copies. An app that already overrides `onNewIntent` keeps its own — a\n * second override would not compile, and the one-line `setIntent(intent)` belongs at the top of\n * theirs instead.\n */\nexport function updateMainActivityNewIntentOverride(contents: string, language: string, enabled: boolean): string {\n const withoutManagedBlock = contents.replace(POSTHOG_NEW_INTENT_BLOCK_PATTERN, '')\n if (!enabled) {\n return withoutManagedBlock\n }\n\n const body = mainActivityBody(withoutManagedBlock, language)\n if (!body) {\n console.warn(\n '[posthog-react-native] Could not find the MainActivity class body; skipping the onNewIntent ' +\n 'override. Notification taps delivered while the React context is starting will be lost.'\n )\n return withoutManagedBlock\n }\n\n // Scoped to MainActivity's own body, and matching a declaration rather than the bare token: an\n // onNewIntent on a helper class in the same file, or named in a comment or a string, must not\n // turn the fix off — but every real override of it in either language matches.\n const codeOnly = maskCommentsAndLiterals(withoutManagedBlock, language)\n if (/\\b(fun|void)\\s+onNewIntent\\s*\\(/.test(codeOnly.slice(body.open, body.close))) {\n console.warn(\n '[posthog-react-native] MainActivity already overrides onNewIntent; leaving it alone. ' +\n 'Add `setIntent(intent)` as its first statement so a notification tap that arrives before ' +\n 'the React context is ready is not lost, or set `{ patchMainActivityNewIntent: false }` ' +\n 'on the plugin to silence this.'\n )\n return withoutManagedBlock\n }\n\n return (\n withoutManagedBlock.slice(0, body.open + 1) +\n newIntentOverrideBlock(language) +\n withoutManagedBlock.slice(body.open + 1)\n )\n}\n\n// Expo's own `mainActivity` mod resolves the file with a glob over android/app/src/main/java only,\n// and asserts, so registering it turns sources under src/main/kotlin — or no MainActivity at all —\n// into a hard prebuild failure whose message never mentions PostHog. Look the file up ourselves\n// instead. Dangerous mods run before the standard android chain, so another plugin's\n// withMainActivity still reads (and re-writes) our edit.\nconst MAIN_ACTIVITY_SOURCE_ROOTS = ['android/app/src/main/java', 'android/app/src/main/kotlin']\n\nfunction findMainActivityPath(projectRoot: string): string | undefined {\n const walk = (dir: string): string | undefined => {\n if (!fs.existsSync(dir)) {\n return undefined\n }\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const candidate = path.join(dir, entry.name)\n if (!entry.isDirectory()) {\n if (/^MainActivity\\.(kt|java)$/.test(entry.name)) {\n return candidate\n }\n continue\n }\n const hit = walk(candidate)\n if (hit) {\n return hit\n }\n }\n return undefined\n }\n\n for (const sourceRoot of MAIN_ACTIVITY_SOURCE_ROOTS) {\n const hit = walk(path.join(projectRoot, sourceRoot))\n if (hit) {\n return hit\n }\n }\n return undefined\n}\n\nconst withMainActivityNewIntent = (config: any, enabled: boolean) => {\n return withDangerousMod(config, [\n 'android',\n async (config: any) => {\n const mainActivityPath = findMainActivityPath(config.modRequest.projectRoot)\n if (!mainActivityPath) {\n console.warn(\n '[posthog-react-native] Could not find MainActivity under android/app/src/main/{java,kotlin}; ' +\n 'skipping the onNewIntent override. Notification taps delivered while the React context is ' +\n 'starting will be lost.'\n )\n return config\n }\n\n const contents = await fs.promises.readFile(mainActivityPath, 'utf8')\n const updated = updateMainActivityNewIntentOverride(\n contents,\n mainActivityPath.endsWith('.java') ? 'java' : 'kt',\n enabled\n )\n if (updated !== contents) {\n await fs.promises.writeFile(mainActivityPath, updated)\n }\n // Only when the block is new, so a re-run of an already-patched project stays quiet.\n if (!contents.includes(POSTHOG_NEW_INTENT_BEGIN) && updated.includes(POSTHOG_NEW_INTENT_BEGIN)) {\n console.warn(\n `[posthog-react-native] Added an onNewIntent override to ${path.relative(\n config.modRequest.projectRoot,\n mainActivityPath\n )} so a notification tap that arrives before the React context is ready is not lost. ` +\n 'Set `{ patchMainActivityNewIntent: false }` on the plugin in app.json to opt out.'\n )\n }\n return config\n },\n ])\n}\n\ntype BuildPhase = { shellScript: string }\n\nexport function modifyExistingXcodeBuildScript(\n script: BuildPhase | undefined,\n skipOnConflict = false,\n releaseMode?: PostHogReleaseMode\n): void {\n if (!script?.shellScript) {\n console.warn(\n \"[posthog-react-native] Could not find the 'Bundle React Native code and images' build phase; \" +\n 'skipping sourcemap upload setup.'\n )\n return\n }\n\n if (!script.shellScript.match(/(packager|scripts)\\/react-native-xcode\\.sh\\b/)) {\n return\n }\n\n if (script.shellScript.includes('posthog-xcode.sh')) {\n const code = migrateLegacyPostHogWrapperInvocation(JSON.parse(script.shellScript))\n script.shellScript = JSON.stringify(updatePostHogBundlePhaseExports(code, skipOnConflict, releaseMode))\n return\n }\n\n if (script.shellScript.includes('posthog-react-native')) {\n return\n }\n\n const code = JSON.parse(script.shellScript)\n script.shellScript = JSON.stringify(\n addPostHogWithBundledScriptsToBundleShellScript(code, skipOnConflict, releaseMode)\n )\n}\n\n// Invoked directly so another wrapper receives this script—not /bin/sh—as $1.\n// package.json declares it as a bin target so package managers preserve its executable bit.\nconst POSTHOG_REACT_NATIVE_XCODE_PATH =\n \"`\\\"$NODE_BINARY\\\" --print \\\"require('path').join(require('path').dirname(require.resolve('posthog-react-native')), '..', 'tooling', 'posthog-xcode.sh')\\\"`\"\n\nconst POSTHOG_SKIP_ON_CONFLICT_EXPORT = 'export POSTHOG_SKIP_ON_CONFLICT=1'\nconst POSTHOG_RELEASE_MODE_EXPORT_PREFIX = 'export POSTHOG_RELEASE_MODE='\n\n// Exported before the wrapped command so posthog-xcode.sh — and any outer wrapper that re-invokes\n// it — sees them. posthog-cli reads POSTHOG_RELEASE_MODE itself, so one export covers the hermes\n// clone and upload alike.\nfunction buildBundlePhaseExports(skipOnConflict: boolean, releaseMode?: PostHogReleaseMode): string[] {\n const exports: string[] = []\n if (skipOnConflict) {\n exports.push(POSTHOG_SKIP_ON_CONFLICT_EXPORT)\n }\n if (releaseMode) {\n exports.push(`${POSTHOG_RELEASE_MODE_EXPORT_PREFIX}${releaseMode}`)\n }\n return exports\n}\n\nconst REACT_NATIVE_XCODE_LINE =\n /^([ \\t]*)(?![A-Za-z_][A-Za-z0-9_]*=)([^\\n]*(?:packager|scripts)\\/react-native-xcode\\.sh\\b[^\\n]*)$/m\n\nfunction migrateLegacyPostHogWrapperInvocation(script: string): string {\n return script.replace(`/bin/sh ${POSTHOG_REACT_NATIVE_XCODE_PATH}`, POSTHOG_REACT_NATIVE_XCODE_PATH)\n}\n\n// Rewrites the managed exports on an already-wrapped bundle phase, so changing an option in\n// app.json takes effect without a clean prebuild.\nfunction updatePostHogBundlePhaseExports(\n script: string,\n skipOnConflict: boolean,\n releaseMode?: PostHogReleaseMode\n): string {\n const skipArg = '--posthog-skip-on-conflict --'\n const lines = script\n .replace(new RegExp(`\\\\s*${skipArg}\\\\s*`, 'g'), ' ')\n .split('\\n')\n .filter((line) => line.trim() !== POSTHOG_SKIP_ON_CONFLICT_EXPORT)\n .filter((line) => !line.trim().startsWith(POSTHOG_RELEASE_MODE_EXPORT_PREFIX))\n\n const exports = buildBundlePhaseExports(skipOnConflict, releaseMode)\n if (exports.length > 0) {\n const commandIndex = lines.findIndex((line) => line.includes(POSTHOG_REACT_NATIVE_XCODE_PATH))\n if (commandIndex !== -1) {\n const indent = lines[commandIndex].match(/^[ \\t]*/)?.[0] ?? ''\n lines.splice(commandIndex, 0, ...exports.map((line) => `${indent}${line}`))\n }\n }\n\n return lines.join('\\n')\n}\n\nexport function addPostHogWithBundledScriptsToBundleShellScript(\n script: string,\n skipOnConflict = false,\n releaseMode?: PostHogReleaseMode\n): string {\n // Capture the full RN script invocation. Expo uses a backtick-wrapped\n // node --print command, so matching only up to react-native-xcode.sh cuts the\n // command substitution in half and leaves the generated shell invalid.\n return script.replace(REACT_NATIVE_XCODE_LINE, (_match: string, indent: string, rnCommand: string) => {\n const exports = buildBundlePhaseExports(skipOnConflict, releaseMode)\n .map((line) => `${indent}${line}\\n`)\n .join('')\n return `${exports}${indent}${POSTHOG_REACT_NATIVE_XCODE_PATH} ${rnCommand}`\n })\n}\n\nconst POSTHOG_DSYM_BUILD_PHASE_NAME = 'Upload PostHog Debug Symbols'\nconst POSTHOG_DSYM_INPUT_PATH =\n '\"$(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)/Contents/Resources/DWARF/$(EXECUTABLE_NAME)\"'\n\n// Shell script for the dSYM upload build phase. It locates and runs posthog-ios's\n// upload-symbols.sh (CocoaPods or SwiftPM) rather than re-implementing dSYM upload.\n// `includeSource` (iOS only) opts into POSTHOG_INCLUDE_SOURCE to also upload native source.\nexport function buildDsymUploadShellScript(includeSource = false, skipOnConflict = false): string {\n return composeDsymUploadShellScript(includeSource, skipOnConflict)\n}\n\n// The phase as SDKs without release-mode support wrote it: the same script with no release-mode\n// block. isPluginGeneratedDsymUploadBuildPhase compares against this exact text, so a change here\n// makes the plugin stop recognizing the phases it wrote before, and stop refreshing them.\nfunction composeDsymUploadShellScript(includeSource: boolean, skipOnConflict: boolean): string {\n const lines = [\n '# Upload iOS dSYMs to PostHog so native crashes can be symbolicated.',\n '# upload-symbols.sh ships inside the posthog-ios dependency.',\n ]\n\n if (includeSource) {\n lines.push(\n '# Also upload native source files for source-code context around crashes.',\n 'export POSTHOG_INCLUDE_SOURCE=1'\n )\n }\n\n if (skipOnConflict) {\n lines.push(\n '# Skip dSYMs that already exist in PostHog with different content instead of failing the build.',\n 'export POSTHOG_SKIP_ON_CONFLICT=1'\n )\n }\n\n lines.push(\n 'PODS_SCRIPT=\"${PODS_ROOT}/PostHog/build-tools/upload-symbols.sh\"',\n 'SPM_SCRIPT=\"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/posthog-ios/build-tools/upload-symbols.sh\"',\n 'if [ -f \"$PODS_SCRIPT\" ]; then',\n ' /bin/sh \"$PODS_SCRIPT\"',\n 'elif [ -f \"$SPM_SCRIPT\" ]; then',\n ' /bin/sh \"$SPM_SCRIPT\"',\n 'else',\n ' echo \"warning: PostHog upload-symbols.sh not found in Pods or SwiftPM checkouts; skipping dSYM upload.\"',\n 'fi'\n )\n\n return lines.join('\\n')\n}\n\n// The release-mode block exactly as 4.64.0 through 4.66.x wrote it into the dSYM phase. Its\n// POSTHOG_NO_RELEASE_BIND export still steers the posthog-ios this plugin pins, so a phase carrying\n// the block must stay recognized and get rewritten to the block-free script. Verbatim on purpose.\nfunction legacyDsymReleaseModeLines(releaseMode?: PostHogReleaseMode): string[] {\n return [\n releaseMode\n ? `POSTHOG_RESOLVED_RELEASE_MODE=\"${releaseMode}\"`\n : 'POSTHOG_RESOLVED_RELEASE_MODE=\"${POSTHOG_RELEASE_MODE:-}\"',\n 'case \"$POSTHOG_RESOLVED_RELEASE_MODE\" in',\n ' \"\"|symbol-set) ;;',\n ' event)',\n ' # Upload dSYMs without binding them to a release, so each crash resolves its own from the',\n ' # app version and namespace the SDK sends. posthog-ios versions whose upload-symbols.sh',\n ' # does not read this variable ignore it and keep binding the dSYMs.',\n ' export POSTHOG_NO_RELEASE_BIND=1',\n ' ;;',\n ' *)',\n \" echo \\\"error: posthog release mode must be 'symbol-set' or 'event', was '$POSTHOG_RESOLVED_RELEASE_MODE'\\\"\",\n ' exit 1',\n ' ;;',\n 'esac',\n ]\n}\n\n// The phase as the release-mode era wrote it: the current script with the mode block ahead of the\n// upload lines. Derived from composeDsymUploadShellScript, so the shared lines stay a compatibility\n// contract: a change to them needs the old text kept as a variant, or these phases go unrecognized.\n// The verbatim fixtures in expoconfig.spec.ts hold this derivation to the published 4.66.3 text.\nfunction buildLegacyReleaseModeDsymUploadShellScript(\n includeSource: boolean,\n skipOnConflict: boolean,\n releaseMode?: PostHogReleaseMode\n): string {\n const lines = composeDsymUploadShellScript(includeSource, skipOnConflict).split('\\n')\n const uploadIndex = lines.findIndex((line) => line.startsWith('PODS_SCRIPT='))\n lines.splice(uploadIndex, 0, ...legacyDsymReleaseModeLines(releaseMode))\n return lines.join('\\n')\n}\n\n// xcode's addBuildPhase stores shellScript quote-escaped with literal newlines; in-place\n// refreshes must match or the stored pbxproj representation churns.\nfunction encodePbxShellScript(script: string): string {\n return '\"' + script.replace(/\"/g, '\\\\\"') + '\"'\n}\n\n// Undoes any quoted pbxproj encoding of shellScript. Handles both the literal-newline\n// form xcode's addBuildPhase writes and the \\n-escaped form Xcode itself writes, so a\n// pristine phase is recognized regardless of which tool last serialized the project.\nfunction decodePbxShellScript(stored: string): string {\n if (!stored.startsWith('\"') || !stored.endsWith('\"')) {\n return stored\n }\n return stored.slice(1, -1).replace(/\\\\(.)/g, (_match, ch) => (ch === 'n' ? '\\n' : ch === 't' ? '\\t' : ch))\n}\n\nfunction isPluginGeneratedDsymUploadBuildPhase(phase: any): boolean {\n if (typeof phase?.shellScript !== 'string') {\n return false\n }\n const stored = decodePbxShellScript(phase.shellScript)\n return [false, true].some((source) =>\n [false, true].some(\n (skip) =>\n stored === buildDsymUploadShellScript(source, skip) ||\n [undefined, ...POSTHOG_RELEASE_MODES].some(\n (mode) => stored === buildLegacyReleaseModeDsymUploadShellScript(source, skip, mode)\n )\n )\n )\n}\n\nexport function moveDsymUploadBuildPhaseToEnd(xcodeProject: any): void {\n const existing = xcodeProject.pbxItemByComment(POSTHOG_DSYM_BUILD_PHASE_NAME, 'PBXShellScriptBuildPhase')\n if (!isPluginGeneratedDsymUploadBuildPhase(existing)) {\n return\n }\n\n const buildPhases = xcodeProject.getFirstTarget?.().firstTarget?.buildPhases\n if (Array.isArray(buildPhases)) {\n const phaseIndex = buildPhases.findIndex((phase: any) => phase.comment === POSTHOG_DSYM_BUILD_PHASE_NAME)\n if (phaseIndex !== -1 && phaseIndex !== buildPhases.length - 1) {\n buildPhases.push(...buildPhases.splice(phaseIndex, 1))\n }\n }\n}\n\n// Keeps the upload phase last and declares the main DWARF as an input, matching the native iOS\n// setup guide. Both are required: the input makes Xcode wait for dSYM generation, while placing\n// the phase after extension embedding avoids dependency cycles in apps with app extensions.\n// Re-runs refresh only a still-plugin-generated phase, also one an older SDK wrote, so user\n// customizations remain untouched.\nexport function addDsymUploadBuildPhase(xcodeProject: any, includeSource = false, skipOnConflict = false): void {\n const existing = xcodeProject.pbxItemByComment(POSTHOG_DSYM_BUILD_PHASE_NAME, 'PBXShellScriptBuildPhase')\n if (existing) {\n if (isPluginGeneratedDsymUploadBuildPhase(existing)) {\n existing.shellScript = encodePbxShellScript(buildDsymUploadShellScript(includeSource, skipOnConflict))\n existing.inputPaths = Array.from(\n new Set([...(Array.isArray(existing.inputPaths) ? existing.inputPaths : []), POSTHOG_DSYM_INPUT_PATH])\n )\n }\n } else {\n xcodeProject.addBuildPhase([], 'PBXShellScriptBuildPhase', POSTHOG_DSYM_BUILD_PHASE_NAME, null, {\n inputPaths: [POSTHOG_DSYM_INPUT_PATH],\n shellPath: '/bin/sh',\n shellScript: buildDsymUploadShellScript(includeSource, skipOnConflict),\n })\n }\n\n moveDsymUploadBuildPhaseToEnd(xcodeProject)\n}\n\nexport function disableUserScriptSandboxing(xcodeProject: any): void {\n // posthog-cli reads .git/ for release auto-detection, which the Xcode 14+ user script\n // sandbox blocks. Applies to all configs in the main app's .xcodeproj (Pods project is\n // separate and untouched).\n const configurations = xcodeProject.pbxXCBuildConfigurationSection()\n for (const key in configurations) {\n const configuration = configurations[key]\n if (configuration && configuration.buildSettings) {\n configuration.buildSettings.ENABLE_USER_SCRIPT_SANDBOXING = '\"NO\"'\n }\n }\n}\n\nconst POSTHOG_DOTENV_BUILD_SETTING = 'POSTHOG_CLI_DOTENV_FILE'\nconst POSTHOG_DOTENV_GRADLE_PROPERTY = 'posthog.dotenvFile'\n\n// Strips a leading ./ so relative props join cleanly onto their per-platform prefix.\nfunction normalizeDotenvFileProp(dotenvFile: string): string {\n return dotenvFile.replace(/^\\.\\//, '')\n}\n\n// Empty/whitespace-only values (easy to produce from templated app.config values)\n// count as unset — mirrors the trim guard in posthog.gradle.\nexport function resolveDotenvFileProp(dotenvFile?: string): string | undefined {\n const trimmed = dotenvFile?.trim()\n return trimmed ? trimmed : undefined\n}\n\n// Posix root or a Windows drive prefix — enough without pulling in `path`,\n// whose isAbsolute is platform-bound while prebuild can run anywhere.\nfunction isAbsoluteDotenvPath(dotenvFile: string): boolean {\n return dotenvFile.startsWith('/') || /^[A-Za-z]:[\\\\/]/.test(dotenvFile)\n}\n\n// pbxproj stores build-setting values quoted; escape so paths with quotes or\n// backslashes survive serialization. $(SRCROOT) is the generated ios/ dir, so\n// project-root-relative props live one level up.\nexport function buildIosDotenvFileBuildSetting(dotenvFile: string): string {\n const value = isAbsoluteDotenvPath(dotenvFile) ? dotenvFile : `$(SRCROOT)/../${normalizeDotenvFileProp(dotenvFile)}`\n return '\"' + value.replace(/([\"\\\\])/g, '\\\\$1') + '\"'\n}\n\n// Xcode exports build settings as env vars to every Run Script phase, so one\n// setting feeds both the bundle-phase hermes upload and the dSYM upload phase;\n// posthog-cli (>= 0.8.4) reads POSTHOG_CLI_DOTENV_FILE itself, no script\n// changes needed. Removing the prop removes the setting again so changes take\n// effect without a clean prebuild.\nexport function applyDotenvFileBuildSetting(xcodeProject: any, dotenvFile?: string): void {\n const configurations = xcodeProject.pbxXCBuildConfigurationSection()\n for (const key in configurations) {\n const configuration = configurations[key]\n if (configuration && configuration.buildSettings) {\n if (dotenvFile) {\n configuration.buildSettings[POSTHOG_DOTENV_BUILD_SETTING] = buildIosDotenvFileBuildSetting(dotenvFile)\n } else {\n delete configuration.buildSettings[POSTHOG_DOTENV_BUILD_SETTING]\n }\n }\n }\n}\n\ntype GradlePropertiesItem = { type: string; key?: string; value?: string }\n\n// gradle.properties lives in android/, so a project-root-relative prop becomes ../<path>.\nexport function buildAndroidDotenvFileGradleValue(dotenvFile: string): string {\n return isAbsoluteDotenvPath(dotenvFile) ? dotenvFile : `../${normalizeDotenvFileProp(dotenvFile)}`\n}\n\n// Managed posthog.dotenvFile entry in android/gradle.properties, consumed by\n// both gradle hooks (the SDK's posthog.gradle hermes upload and the\n// com.posthog.android mapping upload). Added when the prop is set, removed\n// when it isn't.\nexport function updateDotenvFileGradleProperties(\n properties: GradlePropertiesItem[],\n dotenvFile?: string\n): GradlePropertiesItem[] {\n const rest = properties.filter((item) => !(item.type === 'property' && item.key === POSTHOG_DOTENV_GRADLE_PROPERTY))\n if (!dotenvFile) {\n return rest\n }\n rest.push({\n type: 'property',\n key: POSTHOG_DOTENV_GRADLE_PROPERTY,\n value: buildAndroidDotenvFileGradleValue(dotenvFile),\n })\n return rest\n}\n\n// Managed posthog.hermesReleaseMode entry in android/gradle.properties, read by the SDK's\n// posthog.gradle hermes upload. The key is deliberately not posthog.releaseMode:\n// com.posthog.android below 1.6.0 reads that one for the R8 mapping upload, and the mode must not\n// reach it. A posthog.releaseMode entry is deprecated user-owned config, so the prebuild leaves it\n// alone. posthog.gradle reads it as a fallback with a warning, and com.posthog.android 1.6.0\n// warns about it and ignores it.\nexport function updateHermesReleaseModeGradleProperties(\n properties: GradlePropertiesItem[],\n releaseMode?: PostHogReleaseMode\n): GradlePropertiesItem[] {\n const rest = properties.filter(\n (item) => !(item.type === 'property' && item.key === POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY)\n )\n if (!releaseMode) {\n return rest\n }\n rest.push({ type: 'property', key: POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY, value: releaseMode })\n return rest\n}\n\nconst withPostHogGradleProperties = (config: any, dotenvFile?: string, releaseMode?: PostHogReleaseMode) => {\n return withGradleProperties(config, (config: any) => {\n config.modResults = updateDotenvFileGradleProperties(config.modResults, dotenvFile)\n config.modResults = updateHermesReleaseModeGradleProperties(config.modResults, releaseMode)\n return config\n })\n}\n\ntype PostHogPluginProps = {\n /**\n * Whether to disable Xcode's user script sandboxing (ENABLE_USER_SCRIPT_SANDBOXING=NO).\n *\n * posthog-cli reads .git/ during sourcemap uploads for release auto-detection;\n * sandboxing (on by default in Xcode 14+) blocks that, so uploads lose git info\n * or fail silently.\n *\n * Default: true (disable sandboxing so uploads \"just work\").\n * Set to false if your org requires sandboxing stays on —\n * you'll lose automatic git metadata on sourcemap uploads on iOS builds only.\n *\n * Note that this setting is recommended in the Expo docs:\n * https://docs.expo.dev/brownfield/integrated-approach/#configuring-your-xcode-project\n */\n disableSandboxing?: boolean\n\n /**\n * Whether to upload native debug symbols so native crashes can be symbolicated.\n *\n * When enabled, the plugin wires the native symbol-upload tooling that the\n * native PostHog SDKs already ship:\n * - iOS: a build phase that runs posthog-ios's `upload-symbols.sh`\n * (`posthog-cli dsym upload`).\n * - Android: the official `com.posthog.android` Gradle plugin, which uploads\n * ProGuard/R8 mapping files and injects the matching map-id into the app.\n *\n * Pass `{ includeSource: true }` to also upload native source files so PostHog\n * can show source-code context around native crashes. This is **iOS only** —\n * the Android proguard upload has no source-inclusion equivalent, so the flag\n * is ignored there. Note it uploads your source code to PostHog, hence opt-in.\n *\n * Default: false. Pair this with `errorTracking.autocapture.nativeCrashes` at\n * runtime — without uploaded symbols, native stack traces won't be symbolicated.\n * Requires `posthog-cli` to be available and authenticated during release builds.\n */\n uploadNativeSymbols?: boolean | { includeSource?: boolean }\n\n /**\n * Whether to skip uploads whose content already exists in PostHog instead of failing the build.\n *\n * Appends `--skip-on-conflict` to `posthog-cli hermes upload` on iOS and Android. When\n * `uploadNativeSymbols` is enabled, also sets `POSTHOG_SKIP_ON_CONFLICT=1` in the iOS dSYM\n * upload build phase; posthog-ios's `upload-symbols.sh` forwards it as `--skip-on-conflict`\n * to `posthog-cli dsym upload` on posthog-ios >= 3.64.7 (with posthog-cli >= 0.7.12) and\n * ignores it on older versions, where dSYM conflicts keep failing the build.\n *\n * Default: false.\n */\n skipOnConflict?: boolean\n\n /**\n * Path to a dotenv file with POSTHOG_CLI_* credentials (API key, project id,\n * optional host), relative to the project root — or absolute.\n *\n * The path reaches every upload hook as POSTHOG_CLI_DOTENV_FILE: on iOS as a\n * build setting (Xcode exports it to the bundle and dSYM script phases), on\n * Android as a `posthog.dotenvFile` entry in android/gradle.properties read\n * by the SDK's `posthog.gradle` hermes upload and, on gradle plugin >= 1.4.0,\n * by the `com.posthog.android` mapping upload. Process env always wins inside\n * the CLI; a missing file is a warning, not a build failure.\n *\n * Requires posthog-cli >= 0.8.4 — older CLIs ignore the variable and fall\n * back to their other credential sources. With `disableSandboxing: false`,\n * Xcode's script sandbox can block reading the file, which is a hard CLI\n * error (an unreadable-but-present file does not fall through).\n */\n dotenvFile?: string\n\n /**\n * How the release a build belongs to gets associated with the exceptions it reports.\n *\n * This steers the Hermes source map upload only. iOS dSYMs and Android R8 mappings always bind to\n * the release their build creates. The R8 half of that needs the `com.posthog.android` gradle\n * plugin 1.6.0, which ignores the deprecated `posthog.releaseMode` key. A fresh prebuild injects\n * that version, but a project whose android/build.gradle already carries an older classpath line\n * keeps it: bump the line by hand or prebuild with `--clean`.\n *\n * `event` (the default; still EXPERIMENTAL while the rollout settles) uploads the maps\n * release-independent, and each event resolves its own release from the `$app_namespace` /\n * `$app_version` / `$app_build` the SDK sends. Use it when two releases can ship identical\n * JavaScript: the map id comes from content, so in `symbol-set` mode both releases report\n * whichever one uploaded first.\n *\n * Event mode's release link depends on those coordinates reaching each exception. The SDK reads\n * them from the optional `expo-application` or `react-native-device-info` module, and a plain\n * `customAppProperties` object replaces the defaults rather than merging. An install with neither\n * module — or a `customAppProperties` that drops the keys — still symbolicates, but its JavaScript\n * exceptions carry no release. Keep a metadata module (or those keys) to attribute event-mode\n * exceptions to a release; `symbol-set` instead stamps the release onto the uploaded maps from the\n * build settings and does not need them.\n *\n * When this prop is absent, the prebuild reads `POSTHOG_RELEASE_MODE`; set the variable before\n * you run the prebuild. A configured mode is written into the build files and beats the variable\n * at build time. With neither configured, the prebuild writes nothing, the build scripts apply\n * the `event` default at build time, and `POSTHOG_RELEASE_MODE` also still works there.\n *\n * Event mode needs posthog-cli >= 0.16.0, which carries `--release-mode` on the `hermes`\n * commands. A configured `event` fails the build on an older one and names the upgrade. The\n * unconfigured default softens instead: the build warns and uploads the maps bound to the\n * release, as it did before the default changed. That floor lives in posthog-xcode.sh and\n * posthog.gradle: update them and this line together.\n */\n releaseMode?: PostHogReleaseMode\n\n /**\n * Whether to give Android's `MainActivity` an `onNewIntent` override that calls\n * `setIntent(intent)` before delegating to React Native.\n *\n * Works around a React Native defect. When Android reopens an app whose process it had killed\n * while the task stayed in recents, the tap arrives before the React context is ready and is then\n * invisible to the whole process — PostHog captures no `$push_notification_opened`, Firebase\n * Messaging's `getInitialNotification()` returns null, and deep links are lost. Recording the\n * intent first makes `getIntent()` correct for every library in the app.\n *\n * Default: true. The plugin leaves a `MainActivity` that already overrides `onNewIntent`\n * untouched and warns instead — add `setIntent(intent)` as the first statement of your own\n * override. Set to false to skip the injection entirely (and remove one a previous prebuild\n * wrote); bare React Native apps that do not run `expo prebuild` need the same override by hand.\n */\n patchMainActivityNewIntent?: boolean\n}\n\n// Normalizes the uploadNativeSymbols prop (boolean | { includeSource }) into a\n// flat shape. `includeSource` is iOS-only and ignored on Android.\nexport function resolveNativeSymbolUpload(prop: PostHogPluginProps['uploadNativeSymbols']): {\n enabled: boolean\n includeSource: boolean\n} {\n if (prop === true) {\n return { enabled: true, includeSource: false }\n }\n if (prop && typeof prop === 'object') {\n return { enabled: true, includeSource: prop.includeSource === true }\n }\n return { enabled: false, includeSource: false }\n}\n\n// Expo's standard mods run their action before the previously registered action. This wrapper\n// deliberately runs its action after the rest of the Xcode mod chain, so later config plugins\n// cannot leave a newly created extension-embedding phase after the PostHog upload phase.\nconst withFinalizedXcodeProject = (config: any, action: (config: any) => any) => {\n return withBaseMod(config, {\n platform: 'ios',\n mod: 'xcodeproj',\n async action(config: any) {\n const { nextMod, ...modRequest } = config.modRequest\n const results = await nextMod({ ...config, modRequest })\n return action(results)\n },\n })\n}\n\nconst withIosPlugin = (config: any, props: PostHogPluginProps = {}) => {\n const nativeSymbols = resolveNativeSymbolUpload(props.uploadNativeSymbols)\n\n config = withXcodeProject(config, (config: any) => {\n const xcodeProject = config.modResults\n\n const bundleReactNativePhase = xcodeProject.pbxItemByComment(\n 'Bundle React Native code and images',\n 'PBXShellScriptBuildPhase'\n )\n\n modifyExistingXcodeBuildScript(bundleReactNativePhase, props.skipOnConflict === true, props.releaseMode)\n\n if (nativeSymbols.enabled) {\n addDsymUploadBuildPhase(xcodeProject, nativeSymbols.includeSource, props.skipOnConflict === true)\n }\n\n applyDotenvFileBuildSetting(xcodeProject, props.dotenvFile)\n\n if (props.disableSandboxing !== false) {\n disableUserScriptSandboxing(xcodeProject)\n console.warn(\n '[posthog-react-native] Setting ENABLE_USER_SCRIPT_SANDBOXING=NO on all Xcode ' +\n 'build configurations so sourcemap uploads can resolve git metadata. ' +\n 'If your org requires sandboxing to stay enabled, set `{ disableSandboxing: false }` ' +\n 'on the plugin in app.json — note that stock Expo projects may fail to build under ' +\n 'sandboxing until every script build phase declares its input/output files.'\n )\n }\n\n return config\n })\n\n if (nativeSymbols.enabled) {\n config = withFinalizedXcodeProject(config, (config: any) => {\n moveDsymUploadBuildPhaseToEnd(config.modResults)\n return config\n })\n }\n\n return config\n}\n\nconst withPostHogPlugin = (config: any, rawProps: PostHogPluginProps = {}) => {\n const props = {\n ...rawProps,\n dotenvFile: resolveDotenvFileProp(rawProps.dotenvFile),\n releaseMode: resolveReleaseModeProp(rawProps.releaseMode, process.env.POSTHOG_RELEASE_MODE),\n }\n // includeSource is iOS-only, so on Android we only care whether upload is enabled.\n if (resolveNativeSymbolUpload(props.uploadNativeSymbols).enabled) {\n config = withAndroidNativeSymbolsPlugin(config)\n }\n config = withAndroidPlugin(config, props.skipOnConflict === true)\n // Runs unconditionally so removing the prop also removes the managed entry.\n config = withPostHogGradleProperties(config, props.dotenvFile, props.releaseMode)\n config = withMainActivityNewIntent(config, props.patchMainActivityNewIntent !== false)\n return withIosPlugin(config, props)\n}\n\nconst postHogPlugin = (config: any, props: PostHogPluginProps = {}): any => {\n return withPostHogPlugin(config, props)\n}\n\n// Re-export the plugin function as the default export while keeping the\n// named exports above callable from tests.\nmodule.exports = postHogPlugin\nmodule.exports.modifyExistingXcodeBuildScript = modifyExistingXcodeBuildScript\nmodule.exports.addPostHogWithBundledScriptsToBundleShellScript = addPostHogWithBundledScriptsToBundleShellScript\nmodule.exports.disableUserScriptSandboxing = disableUserScriptSandboxing\nmodule.exports.buildDsymUploadShellScript = buildDsymUploadShellScript\nmodule.exports.addDsymUploadBuildPhase = addDsymUploadBuildPhase\nmodule.exports.moveDsymUploadBuildPhaseToEnd = moveDsymUploadBuildPhaseToEnd\nmodule.exports.resolveNativeSymbolUpload = resolveNativeSymbolUpload\nmodule.exports.buildAndroidSkipOnConflictGradleLine = buildAndroidSkipOnConflictGradleLine\nmodule.exports.addPostHogAndroidGradlePluginClasspath = addPostHogAndroidGradlePluginClasspath\nmodule.exports.applyPostHogAndroidGradlePlugin = applyPostHogAndroidGradlePlugin\nmodule.exports.buildIosDotenvFileBuildSetting = buildIosDotenvFileBuildSetting\nmodule.exports.applyDotenvFileBuildSetting = applyDotenvFileBuildSetting\nmodule.exports.resolveDotenvFileProp = resolveDotenvFileProp\nmodule.exports.buildAndroidDotenvFileGradleValue = buildAndroidDotenvFileGradleValue\nmodule.exports.updateDotenvFileGradleProperties = updateDotenvFileGradleProperties\nmodule.exports.POSTHOG_RELEASE_MODES = POSTHOG_RELEASE_MODES\nmodule.exports.resolveReleaseModeProp = resolveReleaseModeProp\nmodule.exports.updateHermesReleaseModeGradleProperties = updateHermesReleaseModeGradleProperties\nmodule.exports.updateMainActivityNewIntentOverride = updateMainActivityNewIntentOverride\n"],"mappings":"szHAIA,GAAM,CAAAA,EAAE,CAAGC,OAAO,CAAC,IAAI,CAAC,CACxB,GAAM,CAAAC,IAAI,CAAGD,OAAO,CAAC,MAAM,CAAC,CAE5B,IAAAE,QAAA,CAOIF,OAAO,CAAC,sBAAsB,CAAC,CANjCG,aAAa,CAAAD,QAAA,CAAbC,aAAa,CACbC,kBAAkB,CAAAF,QAAA,CAAlBE,kBAAkB,CAClBC,WAAW,CAAAH,QAAA,CAAXG,WAAW,CACXC,gBAAgB,CAAAJ,QAAA,CAAhBI,gBAAgB,CAChBC,oBAAoB,CAAAL,QAAA,CAApBK,oBAAoB,CACpBC,gBAAgB,CAAAN,QAAA,CAAhBM,gBAAgB,CAQlB,GAAM,CAAAC,qCAAqC,CAAG,OAAO,CAErD,GAAM,CAAAC,wCAAwC,CAC5C,8KAA8K,CAEhL,GAAM,CAAAC,yCAAyC,CAAG,kCAAkC,CAEpF,GAAM,CAAAC,2CAA2C,CAAG,2BAA2B,CAgBxE,GAAM,CAAAC,qBAAqB,CAAAC,OAAA,CAAAD,qBAAA,CAAyB,CAAC,YAAY,CAAE,OAAO,CAAC,CAU5E,QAAU,CAAAE,sBAAsBA,CAACC,WAAoB,CAAEC,eAAwB,EACnF,GAAM,CAAAC,OAAO,CAAG,CAAAF,WAAW,SAAXA,WAAW,iBAAXA,WAAW,CAAEG,IAAI,EAAE,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CAACoC,sCAAsC,CAAGA,sCAAsC,CAC9FyO,MAAM,CAAC7Q,OAAO,CAACiD,+BAA+B,CAAGA,+BAA+B,CAChF4N,MAAM,CAAC7Q,OAAO,CAAC8O,8BAA8B,CAAGA,8BAA8B,CAC9E+B,MAAM,CAAC7Q,OAAO,CAAC+O,2BAA2B,CAAGA,2BAA2B,CACxE8B,MAAM,CAAC7Q,OAAO,CAAC4O,qBAAqB,CAAGA,qBAAqB,CAC5DiC,MAAM,CAAC7Q,OAAO,CAACgP,iCAAiC,CAAGA,iCAAiC,CACpF6B,MAAM,CAAC7Q,OAAO,CAACiP,gCAAgC,CAAGA,gCAAgC,CAClF4B,MAAM,CAAC7Q,OAAO,CAACD,qBAAqB,CAAGA,qBAAqB,CAC5D8Q,MAAM,CAAC7Q,OAAO,CAACC,sBAAsB,CAAGA,sBAAsB,CAC9D4Q,MAAM,CAAC7Q,OAAO,CAACsP,uCAAuC,CAAGA,uCAAuC,CAChGuB,MAAM,CAAC7Q,OAAO,CAAC6H,mCAAmC,CAAGA,mCAAmC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"expoconfig.js","names":["fs","require","path","_require","AndroidConfig","withAppBuildGradle","withBaseMod","withDangerousMod","withGradleProperties","withXcodeProject","POSTHOG_ANDROID_GRADLE_PLUGIN_VERSION","resolvePostHogReactNativePackageJsonPath","POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY","POSTHOG_ANDROID_FORCE_PROPERTY","POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY","POSTHOG_RELEASE_MODES","exports","resolveReleaseModeProp","releaseMode","environmentMode","trimmed","trim","undefined","includes","Error","concat","join","buildAndroidSkipOnConflictGradleLine","skipOnConflict","buildAndroidForceGradleLine","force","androidConflictPropertyPattern","property","RegExp","withAndroidPlugin","config","arguments","length","modResults","language","console","warn","buildGradle","contents","applyFrom","conflictLines","filter","line","applyBlock","conflictPatterns","reduce","gradle","pattern","replace","match","matchingBraceIndex","s","openBraceIndex","depth","i","addPostHogAndroidGradlePluginClasspath","projectBuildGradle","classpathPresent","classpathLine","buildscriptMatch","exec","buildscriptOpenBrace","index","buildscriptEnd","buildscriptBody","slice","dependenciesMatch","insertAt","applyPostHogAndroidGradlePlugin","appBuildGradle","test","applyLine","appPluginPattern","androidBlockPattern","withFinalizedProjectBuildGradle","action","platform","mod","skipEmptyMod","_asyncToGenerator2","_regenerator","mark","_callee","_config$modRequest","nextMod","modRequest","results","wrap","_context","prev","next","_objectWithoutProperties2","_excluded","_objectSpread","sent","abrupt","stop","withAndroidNativeSymbolsPlugin","_ref","_callee2","result","_context2","promises","writeFile","Paths","getAppBuildGradleAsync","projectRoot","_x","apply","POSTHOG_NEW_INTENT_MARKER","POSTHOG_NEW_INTENT_BEGIN","POSTHOG_NEW_INTENT_END","NEW_INTENT_DOC","NEW_INTENT_KOTLIN_BODY","NEW_INTENT_JAVA_BODY","newIntentOverrideBlock","body","escapeRegExp","value","POSTHOG_NEW_INTENT_BLOCK_PATTERN","literalEnd","start","quote","raw","startsWith","c","close","matchingBraceIndexInSource","end","indexOf","depthOfComment","maskCommentsAndLiterals","source","out","split","blank","from","to","j","mainActivityBody","code","declaration","searchFrom","open","updateMainActivityNewIntentOverride","enabled","withoutManagedBlock","codeOnly","MAIN_ACTIVITY_SOURCE_ROOTS","findMainActivityPath","walk","dir","existsSync","_iterator","_createForOfIteratorHelper","readdirSync","withFileTypes","_step","n","done","entry","candidate","name","isDirectory","hit","err","e","f","_i","_MAIN_ACTIVITY_SOURCE","sourceRoot","withMainActivityNewIntent","_ref2","_callee3","mainActivityPath","updated","_context3","readFile","endsWith","relative","_x2","modifyExistingXcodeBuildScript","script","shellScript","migrateLegacyPostHogWrapperInvocation","JSON","parse","stringify","updatePostHogBundlePhaseExports","addPostHogWithBundledScriptsToBundleShellScript","POSTHOG_REACT_NATIVE_XCODE_PATH","POSTHOG_SKIP_ON_CONFLICT_EXPORT","POSTHOG_FORCE_EXPORT","POSTHOG_RELEASE_MODE_EXPORT_PREFIX","buildBundlePhaseExports","push","REACT_NATIVE_XCODE_LINE","skipArg","lines","commandIndex","findIndex","indent","_b","_a","splice","_toConsumableArray2","map","_match","rnCommand","POSTHOG_DSYM_BUILD_PHASE_NAME","POSTHOG_DSYM_INPUT_PATH","buildDsymUploadShellScript","includeSource","composeDsymUploadShellScript","legacyDsymReleaseModeLines","buildLegacyReleaseModeDsymUploadShellScript","uploadIndex","encodePbxShellScript","decodePbxShellScript","stored","ch","isPluginGeneratedDsymUploadBuildPhase","phase","some","skip","mode","moveDsymUploadBuildPhaseToEnd","xcodeProject","existing","pbxItemByComment","buildPhases","getFirstTarget","call","firstTarget","Array","isArray","phaseIndex","comment","addDsymUploadBuildPhase","inputPaths","Set","addBuildPhase","shellPath","disableUserScriptSandboxing","configurations","pbxXCBuildConfigurationSection","key","configuration","buildSettings","ENABLE_USER_SCRIPT_SANDBOXING","POSTHOG_DOTENV_BUILD_SETTING","POSTHOG_DOTENV_GRADLE_PROPERTY","normalizeDotenvFileProp","dotenvFile","resolveDotenvFileProp","isAbsoluteDotenvPath","buildIosDotenvFileBuildSetting","applyDotenvFileBuildSetting","buildAndroidDotenvFileGradleValue","updateDotenvFileGradleProperties","properties","rest","item","type","updateHermesReleaseModeGradleProperties","withPostHogGradleProperties","resolveNativeSymbolUpload","prop","_typeof2","withFinalizedXcodeProject","_callee4","_config$modRequest2","_context4","_excluded2","withIosPlugin","props","nativeSymbols","uploadNativeSymbols","bundleReactNativePhase","disableSandboxing","withPostHogPlugin","rawProps","process","env","POSTHOG_RELEASE_MODE","patchMainActivityNewIntent","postHogPlugin","module"],"sources":["../../src/tooling/expoconfig.ts"],"sourcesContent":["// Portions of this file are derived from getsentry/sentry-react-native\n// Copyright (c) 2017 Sentry\n// Licensed under the MIT License: https://github.com/getsentry/sentry-react-native/blob/main/LICENSE.md\n\nconst fs = require('fs')\nconst path = require('path')\n\nconst {\n AndroidConfig,\n withAppBuildGradle,\n withBaseMod,\n withDangerousMod,\n withGradleProperties,\n withXcodeProject,\n} = require('@expo/config-plugins')\n\n// com.posthog.android uploads R8 mapping files and injects a matching map-id so native\n// crash stack traces can be deobfuscated. The injected version has to read every gradle\n// property the plugin writes, or that half of the build ignores the option: 1.4.0 is the first\n// version that reads posthog.dotenvFile. 1.6.0 is the first version that ignores\n// posthog.releaseMode with a deprecation warning, so the R8 mapping always binds to the release.\nconst POSTHOG_ANDROID_GRADLE_PLUGIN_VERSION = '1.6.0'\n\nconst resolvePostHogReactNativePackageJsonPath =\n \"[\\\"node\\\", \\\"--print\\\", \\\"require('path').join(require('path').dirname(require.resolve('posthog-react-native')), '..', 'tooling', 'posthog.gradle')\\\"].execute().text.trim()\"\n\nconst POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY = 'posthogReactNativeSkipOnConflict'\nconst POSTHOG_ANDROID_FORCE_PROPERTY = 'posthogReactNativeForce'\n\nconst POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY = 'posthog.hermesReleaseMode'\n\n/**\n * How the release a build belongs to gets associated with the exceptions it reports. This steers\n * the Hermes source map upload only. iOS dSYMs and Android R8 mappings always bind to the release\n * their build creates.\n *\n * `event`, the default, uploads the maps release-independent and lets each event resolve its own\n * release from the app version and namespace the SDK already sends. `symbol-set` stamps the release\n * onto the uploaded maps instead, and an exception inherits the release of the maps its frames\n * resolved against.\n */\nexport type PostHogReleaseMode = 'symbol-set' | 'event'\n\n// Exported so a test can hold the copies in posthog-xcode.sh, posthog.gradle and the generated\n// dSYM phase to this list, because nothing else fails when they drift.\nexport const POSTHOG_RELEASE_MODES: PostHogReleaseMode[] = ['symbol-set', 'event']\n\n// Empty/whitespace-only values (easy to produce from templated app.config values) count as unset\n// and fall through to the next source. A configured mode is written into the bundle phase, and that\n// beats POSTHOG_RELEASE_MODE at build time, so this reads the variable rather than leaving an Expo\n// build with no way to opt out. Undefined means nothing configured a mode: the prebuild then writes\n// nothing, and the build scripts apply the event default themselves, which they can soften to a\n// bound upload when the installed posthog-cli predates the flag. An unrecognized value stops the\n// prebuild rather than falling back, so a typo cannot silently leave a build binding its maps to a\n// release it meant to keep independent.\nexport function resolveReleaseModeProp(releaseMode?: string, environmentMode?: string): PostHogReleaseMode | undefined {\n const trimmed = releaseMode?.trim() || environmentMode?.trim()\n if (!trimmed) {\n return undefined\n }\n if (!POSTHOG_RELEASE_MODES.includes(trimmed as PostHogReleaseMode)) {\n throw new Error(\n `[posthog-react-native] releaseMode must be one of ${POSTHOG_RELEASE_MODES.join(', ')}, was '${trimmed}'`\n )\n }\n return trimmed as PostHogReleaseMode\n}\n\nexport function buildAndroidSkipOnConflictGradleLine(skipOnConflict: boolean): string | null {\n if (!skipOnConflict) {\n return null\n }\n return `project.ext.${POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY} = true`\n}\n\nexport function buildAndroidForceGradleLine(force: boolean): string | null {\n if (!force) {\n return null\n }\n return `project.ext.${POSTHOG_ANDROID_FORCE_PROPERTY} = true`\n}\n\nconst androidConflictPropertyPattern = (property: string): RegExp =>\n new RegExp(`^project\\\\.ext\\\\.${property}\\\\s*=\\\\s*(true|false)\\\\n?`, 'm')\n\nconst withAndroidPlugin = (config: any, skipOnConflict = false, force = false) => {\n return withAppBuildGradle(config, (config: any) => {\n if (config.modResults.language !== 'groovy') {\n console.warn('Cannot configure PostHog in the app gradle because the build.gradle is not groovy')\n }\n\n const buildGradle = config.modResults.contents\n const applyFrom = `apply from: new File(${resolvePostHogReactNativePackageJsonPath})`\n const conflictLines = [buildAndroidSkipOnConflictGradleLine(skipOnConflict), buildAndroidForceGradleLine(force)]\n .filter((line): line is string => line !== null)\n .join('\\n')\n const applyBlock = conflictLines ? `${conflictLines}\\n${applyFrom}` : applyFrom\n const conflictPatterns = [\n androidConflictPropertyPattern(POSTHOG_ANDROID_SKIP_ON_CONFLICT_PROPERTY),\n androidConflictPropertyPattern(POSTHOG_ANDROID_FORCE_PROPERTY),\n ]\n\n if (buildGradle.includes(applyFrom)) {\n let contents = conflictPatterns.reduce((gradle, pattern) => gradle.replace(pattern, ''), buildGradle)\n if (conflictLines) {\n contents = contents.replace(applyFrom, `${conflictLines}\\n${applyFrom}`)\n }\n config.modResults.contents = contents\n return config\n }\n\n // Find the 'android {' block and insert the line directly above it\n const pattern = /^android\\s*\\{/m\n\n if (buildGradle.match(pattern)) {\n config.modResults.contents = buildGradle.replace(pattern, `${applyBlock}\\n\\nandroid {`)\n } else {\n console.warn('PostHog: Could not find \"android {\" block in build.gradle')\n }\n\n return config\n })\n}\n\n// Index of the `}` matching the `{` at openBraceIndex, or -1 if unbalanced. Manual scan\n// (not regex) to avoid ReDoS; counts all braces, fine for the generated gradle we target.\nfunction matchingBraceIndex(s: string, openBraceIndex: number): number {\n let depth = 0\n for (let i = openBraceIndex; i < s.length; i++) {\n if (s[i] === '{') {\n depth++\n } else if (s[i] === '}') {\n depth--\n if (depth === 0) {\n return i\n }\n }\n }\n return -1\n}\n\n// Published to Maven Central (not the Gradle Plugin Portal), so we use the legacy buildscript\n// classpath + apply route. Idempotent. `classpathPresent` tells the caller to only `apply\n// plugin` when the classpath is in the file, else the build can't resolve it.\nexport function addPostHogAndroidGradlePluginClasspath(projectBuildGradle: string): {\n contents: string\n classpathPresent: boolean\n} {\n if (projectBuildGradle.includes('posthog-android-gradle-plugin')) {\n return { contents: projectBuildGradle, classpathPresent: true }\n }\n\n const classpathLine = ` classpath(\"com.posthog:posthog-android-gradle-plugin:${POSTHOG_ANDROID_GRADLE_PLUGIN_VERSION}\")`\n\n // First `dependencies {` inside the `buildscript {}` block. Bounding to the buildscript body\n // avoids a backtracking regex (ReDoS) and mis-placing into a later block (e.g. allprojects).\n const buildscriptMatch = /buildscript\\s*\\{/.exec(projectBuildGradle)\n const buildscriptOpenBrace = buildscriptMatch ? buildscriptMatch.index + buildscriptMatch[0].length - 1 : -1\n const buildscriptEnd = buildscriptOpenBrace === -1 ? -1 : matchingBraceIndex(projectBuildGradle, buildscriptOpenBrace)\n const buildscriptBody = buildscriptEnd === -1 ? '' : projectBuildGradle.slice(buildscriptOpenBrace, buildscriptEnd)\n const dependenciesMatch = buildscriptBody ? /dependencies\\s*\\{/.exec(buildscriptBody) : null\n\n if (!dependenciesMatch) {\n console.warn(\n 'PostHog: Could not find a buildscript dependencies block in the project build.gradle; ' +\n 'skipping the com.posthog.android classpath. Native symbols will not be uploaded.'\n )\n return { contents: projectBuildGradle, classpathPresent: false }\n }\n\n const insertAt = buildscriptOpenBrace + dependenciesMatch.index + dependenciesMatch[0].length\n return {\n contents: `${projectBuildGradle.slice(0, insertAt)}\\n${classpathLine}${projectBuildGradle.slice(insertAt)}`,\n classpathPresent: true,\n }\n}\n\n// Applies the com.posthog.android plugin in the app module. Idempotent.\nexport function applyPostHogAndroidGradlePlugin(appBuildGradle: string): string {\n if (/apply plugin: [\"']com\\.posthog\\.android[\"']/.test(appBuildGradle)) {\n return appBuildGradle\n }\n\n const applyLine = 'apply plugin: \"com.posthog.android\"'\n\n // Apply right after com.android.application so the plugin can hook AGP variants.\n const appPluginPattern = /^([ \\t]*apply plugin: [\"']com\\.android\\.application[\"'].*)$/m\n if (appPluginPattern.test(appBuildGradle)) {\n return appBuildGradle.replace(appPluginPattern, `$1\\n${applyLine}`)\n }\n\n // Fallback: insert directly above the android { } block.\n const androidBlockPattern = /^android\\s*\\{/m\n if (androidBlockPattern.test(appBuildGradle)) {\n return appBuildGradle.replace(androidBlockPattern, `${applyLine}\\n\\nandroid {`)\n }\n\n console.warn('PostHog: Could not find where to apply com.posthog.android in the app build.gradle')\n return appBuildGradle\n}\n\n// Expo's standard mods run their action before the previously registered action. This wrapper\n// deliberately runs its action after the rest of the project Gradle mod chain, so it can safely\n// coordinate the project classpath and app plugin edits without relying on mod-key order.\nconst withFinalizedProjectBuildGradle = (config: any, action: (config: any) => any) => {\n return withBaseMod(config, {\n platform: 'android',\n mod: 'projectBuildGradle',\n skipEmptyMod: false,\n async action(config: any) {\n const { nextMod, ...modRequest } = config.modRequest\n const results = await nextMod({ ...config, modRequest })\n return action(results)\n },\n })\n}\n\nconst withAndroidNativeSymbolsPlugin = (config: any) => {\n return withFinalizedProjectBuildGradle(config, async (config: any) => {\n if (config.modResults.language !== 'groovy') {\n console.warn('Cannot configure the PostHog Android Gradle plugin because the project build.gradle is not groovy')\n return config\n }\n\n const result = addPostHogAndroidGradlePluginClasspath(config.modResults.contents)\n if (result.contents !== config.modResults.contents) {\n // Persist the classpath before applying the app plugin so a failed second write cannot\n // leave an apply line without its matching classpath.\n await fs.promises.writeFile(config.modResults.path, result.contents)\n config.modResults.contents = result.contents\n }\n if (!result.classpathPresent) {\n // No classpath (or no buildscript dependencies block) → applying would break the build.\n return config\n }\n\n const appBuildGradle = await AndroidConfig.Paths.getAppBuildGradleAsync(config.modRequest.projectRoot)\n if (appBuildGradle.language !== 'groovy') {\n console.warn('Cannot configure the PostHog Android Gradle plugin because the app build.gradle is not groovy')\n return config\n }\n\n const contents = applyPostHogAndroidGradlePlugin(appBuildGradle.contents)\n if (contents !== appBuildGradle.contents) {\n await fs.promises.writeFile(appBuildGradle.path, contents)\n }\n return config\n })\n}\n\nconst POSTHOG_NEW_INTENT_MARKER = 'posthog-new-intent'\nconst POSTHOG_NEW_INTENT_BEGIN = `// @generated begin ${POSTHOG_NEW_INTENT_MARKER} - posthog-react-native (DO NOT MODIFY)`\nconst POSTHOG_NEW_INTENT_END = `// @generated end ${POSTHOG_NEW_INTENT_MARKER}`\n\n// `android.content.Intent` is spelled out to keep the block self-contained: adding an import is a\n// second, riskier edit, and the templates we patch do not already import Intent.\nconst NEW_INTENT_DOC = ` /**\n * Records the intent that reopened the app so getIntent() stays correct.\n *\n * Works around a React Native defect that drops notification taps and deep links arriving while\n * the React context is still starting. Managed by the posthog-react-native Expo config plugin;\n * remove it with { patchMainActivityNewIntent: false } in app.json.\n * https://posthog.com/docs/workflows/push-notifications/react-native\n */`\n\nconst NEW_INTENT_KOTLIN_BODY = ` override fun onNewIntent(intent: android.content.Intent) {\n setIntent(intent)\n super.onNewIntent(intent)\n }`\n\nconst NEW_INTENT_JAVA_BODY = ` @Override\n public void onNewIntent(android.content.Intent intent) {\n setIntent(intent);\n super.onNewIntent(intent);\n }`\n\nfunction newIntentOverrideBlock(language: string): string {\n const body = language === 'java' ? NEW_INTENT_JAVA_BODY : NEW_INTENT_KOTLIN_BODY\n return `\\n ${POSTHOG_NEW_INTENT_BEGIN}\\n${NEW_INTENT_DOC}\\n${body}\\n ${POSTHOG_NEW_INTENT_END}\\n`\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n// Lazy body match so two blocks (only reachable from a hand-edited file) are removed separately\n// rather than swallowing everything between them. The `\\r?` on both ends keeps the block removable\n// after an editor or a Windows checkout has normalized the file to CRLF.\nconst POSTHOG_NEW_INTENT_BLOCK_PATTERN = new RegExp(\n `\\\\r?\\\\n?[ \\\\t]*${escapeRegExp(POSTHOG_NEW_INTENT_BEGIN)}[\\\\s\\\\S]*?${escapeRegExp(\n POSTHOG_NEW_INTENT_END\n )}[ \\\\t]*\\\\r?\\\\n`,\n 'g'\n)\n\n// Index just past the string or character literal opening at `start`, or -1 when it never closes.\n// Covers `\"...\"` and `'...'` with backslash escapes (which end at a newline in both languages),\n// `\"\"\"...\"\"\"` raw strings and text blocks, and Kotlin `${...}` templates, whose contents are code\n// that may nest further literals.\nfunction literalEnd(s: string, start: number, language: string): number {\n const quote = s[start]\n const raw = quote === '\"' && s.startsWith('\"\"\"', start)\n let i = start + (raw ? 3 : 1)\n while (i < s.length) {\n const c = s[i]\n if (raw) {\n if (s.startsWith('\"\"\"', i)) {\n // Kotlin closes on the last three of a longer run of quotes.\n while (s[i] === '\"') {\n i++\n }\n return i\n }\n } else if (c === '\\n') {\n return -1\n } else if (c === quote) {\n return i + 1\n }\n if (c === '\\\\' && (!raw || language === 'java')) {\n i += 2\n continue\n }\n if (language === 'kt' && quote === '\"' && c === '$' && s[i + 1] === '{') {\n const close = matchingBraceIndexInSource(s, i + 1, language)\n if (close === -1) {\n return -1\n }\n i = close + 1\n continue\n }\n i++\n }\n return -1\n}\n\n// Index of the `}` matching the `{` at openBraceIndex in Kotlin or Java source, or -1 if\n// unbalanced. Braces inside literals and comments are not structural: a `\"}\"` field before an\n// existing onNewIntent must not end the class early, which would hide that override from the\n// scoped check below and make us insert a duplicate the file no longer compiles with.\nfunction matchingBraceIndexInSource(s: string, openBraceIndex: number, language: string): number {\n let depth = 0\n let i = openBraceIndex\n while (i < s.length) {\n const c = s[i]\n if (c === '/' && s[i + 1] === '/') {\n const end = s.indexOf('\\n', i)\n i = end === -1 ? s.length : end\n continue\n }\n if (c === '/' && s[i + 1] === '*') {\n // Kotlin nests block comments, Java does not: taking the first `*/` in Kotlin would end the\n // comment early and let a commented-out `}` close the class, hiding a real override below it.\n let depthOfComment = 1\n i += 2\n while (i < s.length && depthOfComment > 0) {\n if (language === 'kt' && s[i] === '/' && s[i + 1] === '*') {\n depthOfComment++\n i += 2\n continue\n }\n if (s[i] === '*' && s[i + 1] === '/') {\n depthOfComment--\n i += 2\n continue\n }\n i++\n }\n if (depthOfComment > 0) {\n return -1\n }\n continue\n }\n if (c === '\"' || c === \"'\") {\n const end = literalEnd(s, i, language)\n if (end === -1) {\n return -1\n }\n i = end\n continue\n }\n if (c === '{') {\n depth++\n } else if (c === '}') {\n depth--\n if (depth === 0) {\n return i\n }\n }\n i++\n }\n return -1\n}\n\n// A copy of `source` with the inside of every comment and string/char literal replaced by spaces,\n// keeping length and line breaks so indexes still line up with the original. One pass, so the class\n// declaration, the brace scan and the existing-override check all agree on what is code: a\n// commented-out `class MainActivity`, a `\"}\"` field, or an `onNewIntent` inside a comment are all\n// invisible to every one of them. Kotlin nests block comments and Java does not.\nfunction maskCommentsAndLiterals(source: string, language: string): string {\n const out = source.split('')\n const blank = (from: number, to: number) => {\n for (let j = from; j < to && j < out.length; j++) {\n if (out[j] !== '\\n') {\n out[j] = ' '\n }\n }\n }\n\n let i = 0\n while (i < source.length) {\n const c = source[i]\n if (c === '/' && source[i + 1] === '/') {\n const end = source.indexOf('\\n', i)\n const stop = end === -1 ? source.length : end\n blank(i, stop)\n i = stop\n continue\n }\n if (c === '/' && source[i + 1] === '*') {\n let depth = 1\n let j = i + 2\n while (j < source.length && depth > 0) {\n if (language === 'kt' && source[j] === '/' && source[j + 1] === '*') {\n depth++\n j += 2\n continue\n }\n if (source[j] === '*' && source[j + 1] === '/') {\n depth--\n j += 2\n continue\n }\n j++\n }\n blank(i, j)\n i = j\n continue\n }\n if (c === '\"' || c === \"'\") {\n const end = literalEnd(source, i, language)\n if (end === -1) {\n // Unterminated literal: blank the rest so nothing after it reads as code.\n blank(i, source.length)\n return out.join('')\n }\n blank(i, end)\n i = end\n continue\n }\n i++\n }\n return out.join('')\n}\n\n// The span of MainActivity's body, or undefined when the file does not look like the templates we\n// patch: a supertype list is all we expect between the class name and the opening brace.\nfunction mainActivityBody(contents: string, language: string): { open: number; close: number } | undefined {\n const code = maskCommentsAndLiterals(contents, language)\n const declaration = /\\bclass\\s+MainActivity\\b/.exec(code)\n if (!declaration) {\n return undefined\n }\n const searchFrom = declaration.index + declaration[0].length\n const open = code.indexOf('{', searchFrom)\n if (open === -1 || !/^[^;{}]*$/.test(code.slice(searchFrom, open))) {\n return undefined\n }\n // Unbalanced braces mean we cannot tell where the body ends, so the file is not ours to edit.\n let depth = 0\n let close = -1\n for (let i = open; i < code.length; i++) {\n if (code[i] === '{') {\n depth++\n } else if (code[i] === '}') {\n depth--\n if (depth === 0) {\n close = i\n break\n }\n }\n }\n return close === -1 ? undefined : { open, close }\n}\n\n/**\n * Adds (or, when disabled, removes) the managed `onNewIntent` override in MainActivity.\n *\n * Idempotent: the block is delimited by generated markers and rewritten in place, so repeated\n * prebuilds never stack copies. An app that already overrides `onNewIntent` keeps its own — a\n * second override would not compile, and the one-line `setIntent(intent)` belongs at the top of\n * theirs instead.\n */\nexport function updateMainActivityNewIntentOverride(contents: string, language: string, enabled: boolean): string {\n const withoutManagedBlock = contents.replace(POSTHOG_NEW_INTENT_BLOCK_PATTERN, '')\n if (!enabled) {\n return withoutManagedBlock\n }\n\n const body = mainActivityBody(withoutManagedBlock, language)\n if (!body) {\n console.warn(\n '[posthog-react-native] Could not find the MainActivity class body; skipping the onNewIntent ' +\n 'override. Notification taps delivered while the React context is starting will be lost.'\n )\n return withoutManagedBlock\n }\n\n // Scoped to MainActivity's own body, and matching a declaration rather than the bare token: an\n // onNewIntent on a helper class in the same file, or named in a comment or a string, must not\n // turn the fix off — but every real override of it in either language matches.\n const codeOnly = maskCommentsAndLiterals(withoutManagedBlock, language)\n if (/\\b(fun|void)\\s+onNewIntent\\s*\\(/.test(codeOnly.slice(body.open, body.close))) {\n console.warn(\n '[posthog-react-native] MainActivity already overrides onNewIntent; leaving it alone. ' +\n 'Add `setIntent(intent)` as its first statement so a notification tap that arrives before ' +\n 'the React context is ready is not lost, or set `{ patchMainActivityNewIntent: false }` ' +\n 'on the plugin to silence this.'\n )\n return withoutManagedBlock\n }\n\n return (\n withoutManagedBlock.slice(0, body.open + 1) +\n newIntentOverrideBlock(language) +\n withoutManagedBlock.slice(body.open + 1)\n )\n}\n\n// Expo's own `mainActivity` mod resolves the file with a glob over android/app/src/main/java only,\n// and asserts, so registering it turns sources under src/main/kotlin — or no MainActivity at all —\n// into a hard prebuild failure whose message never mentions PostHog. Look the file up ourselves\n// instead. Dangerous mods run before the standard android chain, so another plugin's\n// withMainActivity still reads (and re-writes) our edit.\nconst MAIN_ACTIVITY_SOURCE_ROOTS = ['android/app/src/main/java', 'android/app/src/main/kotlin']\n\nfunction findMainActivityPath(projectRoot: string): string | undefined {\n const walk = (dir: string): string | undefined => {\n if (!fs.existsSync(dir)) {\n return undefined\n }\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const candidate = path.join(dir, entry.name)\n if (!entry.isDirectory()) {\n if (/^MainActivity\\.(kt|java)$/.test(entry.name)) {\n return candidate\n }\n continue\n }\n const hit = walk(candidate)\n if (hit) {\n return hit\n }\n }\n return undefined\n }\n\n for (const sourceRoot of MAIN_ACTIVITY_SOURCE_ROOTS) {\n const hit = walk(path.join(projectRoot, sourceRoot))\n if (hit) {\n return hit\n }\n }\n return undefined\n}\n\nconst withMainActivityNewIntent = (config: any, enabled: boolean) => {\n return withDangerousMod(config, [\n 'android',\n async (config: any) => {\n const mainActivityPath = findMainActivityPath(config.modRequest.projectRoot)\n if (!mainActivityPath) {\n console.warn(\n '[posthog-react-native] Could not find MainActivity under android/app/src/main/{java,kotlin}; ' +\n 'skipping the onNewIntent override. Notification taps delivered while the React context is ' +\n 'starting will be lost.'\n )\n return config\n }\n\n const contents = await fs.promises.readFile(mainActivityPath, 'utf8')\n const updated = updateMainActivityNewIntentOverride(\n contents,\n mainActivityPath.endsWith('.java') ? 'java' : 'kt',\n enabled\n )\n if (updated !== contents) {\n await fs.promises.writeFile(mainActivityPath, updated)\n }\n // Only when the block is new, so a re-run of an already-patched project stays quiet.\n if (!contents.includes(POSTHOG_NEW_INTENT_BEGIN) && updated.includes(POSTHOG_NEW_INTENT_BEGIN)) {\n console.warn(\n `[posthog-react-native] Added an onNewIntent override to ${path.relative(\n config.modRequest.projectRoot,\n mainActivityPath\n )} so a notification tap that arrives before the React context is ready is not lost. ` +\n 'Set `{ patchMainActivityNewIntent: false }` on the plugin in app.json to opt out.'\n )\n }\n return config\n },\n ])\n}\n\ntype BuildPhase = { shellScript: string }\n\nexport function modifyExistingXcodeBuildScript(\n script: BuildPhase | undefined,\n skipOnConflict = false,\n releaseMode?: PostHogReleaseMode,\n force = false\n): void {\n if (!script?.shellScript) {\n console.warn(\n \"[posthog-react-native] Could not find the 'Bundle React Native code and images' build phase; \" +\n 'skipping sourcemap upload setup.'\n )\n return\n }\n\n if (!script.shellScript.match(/(packager|scripts)\\/react-native-xcode\\.sh\\b/)) {\n return\n }\n\n if (script.shellScript.includes('posthog-xcode.sh')) {\n const code = migrateLegacyPostHogWrapperInvocation(JSON.parse(script.shellScript))\n script.shellScript = JSON.stringify(updatePostHogBundlePhaseExports(code, skipOnConflict, releaseMode, force))\n return\n }\n\n if (script.shellScript.includes('posthog-react-native')) {\n return\n }\n\n const code = JSON.parse(script.shellScript)\n script.shellScript = JSON.stringify(\n addPostHogWithBundledScriptsToBundleShellScript(code, skipOnConflict, releaseMode, force)\n )\n}\n\n// Invoked directly so another wrapper receives this script—not /bin/sh—as $1.\n// package.json declares it as a bin target so package managers preserve its executable bit.\nconst POSTHOG_REACT_NATIVE_XCODE_PATH =\n \"`\\\"$NODE_BINARY\\\" --print \\\"require('path').join(require('path').dirname(require.resolve('posthog-react-native')), '..', 'tooling', 'posthog-xcode.sh')\\\"`\"\n\nconst POSTHOG_SKIP_ON_CONFLICT_EXPORT = 'export POSTHOG_SKIP_ON_CONFLICT=1'\nconst POSTHOG_FORCE_EXPORT = 'export POSTHOG_FORCE=1'\nconst POSTHOG_RELEASE_MODE_EXPORT_PREFIX = 'export POSTHOG_RELEASE_MODE='\n\n// Exported before the wrapped command so posthog-xcode.sh — and any outer wrapper that re-invokes\n// it — sees them. posthog-cli reads POSTHOG_RELEASE_MODE itself, so one export covers the hermes\n// clone and upload alike.\nfunction buildBundlePhaseExports(skipOnConflict: boolean, releaseMode?: PostHogReleaseMode, force = false): string[] {\n const exports: string[] = []\n if (skipOnConflict) {\n exports.push(POSTHOG_SKIP_ON_CONFLICT_EXPORT)\n }\n if (force) {\n exports.push(POSTHOG_FORCE_EXPORT)\n }\n if (releaseMode) {\n exports.push(`${POSTHOG_RELEASE_MODE_EXPORT_PREFIX}${releaseMode}`)\n }\n return exports\n}\n\nconst REACT_NATIVE_XCODE_LINE =\n /^([ \\t]*)(?![A-Za-z_][A-Za-z0-9_]*=)([^\\n]*(?:packager|scripts)\\/react-native-xcode\\.sh\\b[^\\n]*)$/m\n\nfunction migrateLegacyPostHogWrapperInvocation(script: string): string {\n return script.replace(`/bin/sh ${POSTHOG_REACT_NATIVE_XCODE_PATH}`, POSTHOG_REACT_NATIVE_XCODE_PATH)\n}\n\n// Rewrites the managed exports on an already-wrapped bundle phase, so changing an option in\n// app.json takes effect without a clean prebuild.\nfunction updatePostHogBundlePhaseExports(\n script: string,\n skipOnConflict: boolean,\n releaseMode?: PostHogReleaseMode,\n force = false\n): string {\n const skipArg = '--posthog-skip-on-conflict --'\n const lines = script\n .replace(new RegExp(`\\\\s*${skipArg}\\\\s*`, 'g'), ' ')\n .split('\\n')\n .filter((line) => line.trim() !== POSTHOG_SKIP_ON_CONFLICT_EXPORT)\n .filter((line) => line.trim() !== POSTHOG_FORCE_EXPORT)\n .filter((line) => !line.trim().startsWith(POSTHOG_RELEASE_MODE_EXPORT_PREFIX))\n\n const exports = buildBundlePhaseExports(skipOnConflict, releaseMode, force)\n if (exports.length > 0) {\n const commandIndex = lines.findIndex((line) => line.includes(POSTHOG_REACT_NATIVE_XCODE_PATH))\n if (commandIndex !== -1) {\n const indent = lines[commandIndex].match(/^[ \\t]*/)?.[0] ?? ''\n lines.splice(commandIndex, 0, ...exports.map((line) => `${indent}${line}`))\n }\n }\n\n return lines.join('\\n')\n}\n\nexport function addPostHogWithBundledScriptsToBundleShellScript(\n script: string,\n skipOnConflict = false,\n releaseMode?: PostHogReleaseMode,\n force = false\n): string {\n // Capture the full RN script invocation. Expo uses a backtick-wrapped\n // node --print command, so matching only up to react-native-xcode.sh cuts the\n // command substitution in half and leaves the generated shell invalid.\n return script.replace(REACT_NATIVE_XCODE_LINE, (_match: string, indent: string, rnCommand: string) => {\n const exports = buildBundlePhaseExports(skipOnConflict, releaseMode, force)\n .map((line) => `${indent}${line}\\n`)\n .join('')\n return `${exports}${indent}${POSTHOG_REACT_NATIVE_XCODE_PATH} ${rnCommand}`\n })\n}\n\nconst POSTHOG_DSYM_BUILD_PHASE_NAME = 'Upload PostHog Debug Symbols'\nconst POSTHOG_DSYM_INPUT_PATH =\n '\"$(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)/Contents/Resources/DWARF/$(EXECUTABLE_NAME)\"'\n\n// Shell script for the dSYM upload build phase. It locates and runs posthog-ios's\n// upload-symbols.sh (CocoaPods or SwiftPM) rather than re-implementing dSYM upload.\n// `includeSource` (iOS only) opts into POSTHOG_INCLUDE_SOURCE to also upload native source.\nexport function buildDsymUploadShellScript(includeSource = false, skipOnConflict = false, force = false): string {\n return composeDsymUploadShellScript(includeSource, skipOnConflict, force)\n}\n\n// The phase as SDKs without release-mode support wrote it: the same script with no release-mode\n// block. isPluginGeneratedDsymUploadBuildPhase compares against this exact text, so a change here\n// makes the plugin stop recognizing the phases it wrote before, and stop refreshing them.\nfunction composeDsymUploadShellScript(includeSource: boolean, skipOnConflict: boolean, force: boolean): string {\n const lines = [\n '# Upload iOS dSYMs to PostHog so native crashes can be symbolicated.',\n '# upload-symbols.sh ships inside the posthog-ios dependency.',\n ]\n\n if (includeSource) {\n lines.push(\n '# Also upload native source files for source-code context around crashes.',\n 'export POSTHOG_INCLUDE_SOURCE=1'\n )\n }\n\n if (skipOnConflict) {\n lines.push(\n '# Skip dSYMs that already exist in PostHog with different content instead of failing the build.',\n 'export POSTHOG_SKIP_ON_CONFLICT=1'\n )\n }\n\n if (force) {\n lines.push(\n '# Overwrite dSYMs that already exist in PostHog with different content instead of failing the build.',\n 'export POSTHOG_FORCE=1'\n )\n }\n\n lines.push(\n 'PODS_SCRIPT=\"${PODS_ROOT}/PostHog/build-tools/upload-symbols.sh\"',\n 'SPM_SCRIPT=\"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/posthog-ios/build-tools/upload-symbols.sh\"',\n 'if [ -f \"$PODS_SCRIPT\" ]; then',\n ' /bin/sh \"$PODS_SCRIPT\"',\n 'elif [ -f \"$SPM_SCRIPT\" ]; then',\n ' /bin/sh \"$SPM_SCRIPT\"',\n 'else',\n ' echo \"warning: PostHog upload-symbols.sh not found in Pods or SwiftPM checkouts; skipping dSYM upload.\"',\n 'fi'\n )\n\n return lines.join('\\n')\n}\n\n// The release-mode block exactly as 4.64.0 through 4.66.x wrote it into the dSYM phase. Its\n// POSTHOG_NO_RELEASE_BIND export still steers the posthog-ios this plugin pins, so a phase carrying\n// the block must stay recognized and get rewritten to the block-free script. Verbatim on purpose.\nfunction legacyDsymReleaseModeLines(releaseMode?: PostHogReleaseMode): string[] {\n return [\n releaseMode\n ? `POSTHOG_RESOLVED_RELEASE_MODE=\"${releaseMode}\"`\n : 'POSTHOG_RESOLVED_RELEASE_MODE=\"${POSTHOG_RELEASE_MODE:-}\"',\n 'case \"$POSTHOG_RESOLVED_RELEASE_MODE\" in',\n ' \"\"|symbol-set) ;;',\n ' event)',\n ' # Upload dSYMs without binding them to a release, so each crash resolves its own from the',\n ' # app version and namespace the SDK sends. posthog-ios versions whose upload-symbols.sh',\n ' # does not read this variable ignore it and keep binding the dSYMs.',\n ' export POSTHOG_NO_RELEASE_BIND=1',\n ' ;;',\n ' *)',\n \" echo \\\"error: posthog release mode must be 'symbol-set' or 'event', was '$POSTHOG_RESOLVED_RELEASE_MODE'\\\"\",\n ' exit 1',\n ' ;;',\n 'esac',\n ]\n}\n\n// The phase as the release-mode era wrote it: the current script with the mode block ahead of the\n// upload lines. Derived from composeDsymUploadShellScript, so the shared lines stay a compatibility\n// contract: a change to them needs the old text kept as a variant, or these phases go unrecognized.\n// The verbatim fixtures in expoconfig.spec.ts hold this derivation to the published 4.66.3 text.\nfunction buildLegacyReleaseModeDsymUploadShellScript(\n includeSource: boolean,\n skipOnConflict: boolean,\n releaseMode?: PostHogReleaseMode\n): string {\n // 4.64.0 through 4.66.x predate the force option, so no phase of this era carries POSTHOG_FORCE.\n const lines = composeDsymUploadShellScript(includeSource, skipOnConflict, false).split('\\n')\n const uploadIndex = lines.findIndex((line) => line.startsWith('PODS_SCRIPT='))\n lines.splice(uploadIndex, 0, ...legacyDsymReleaseModeLines(releaseMode))\n return lines.join('\\n')\n}\n\n// xcode's addBuildPhase stores shellScript quote-escaped with literal newlines; in-place\n// refreshes must match or the stored pbxproj representation churns.\nfunction encodePbxShellScript(script: string): string {\n return '\"' + script.replace(/\"/g, '\\\\\"') + '\"'\n}\n\n// Undoes any quoted pbxproj encoding of shellScript. Handles both the literal-newline\n// form xcode's addBuildPhase writes and the \\n-escaped form Xcode itself writes, so a\n// pristine phase is recognized regardless of which tool last serialized the project.\nfunction decodePbxShellScript(stored: string): string {\n if (!stored.startsWith('\"') || !stored.endsWith('\"')) {\n return stored\n }\n return stored.slice(1, -1).replace(/\\\\(.)/g, (_match, ch) => (ch === 'n' ? '\\n' : ch === 't' ? '\\t' : ch))\n}\n\nfunction isPluginGeneratedDsymUploadBuildPhase(phase: any): boolean {\n if (typeof phase?.shellScript !== 'string') {\n return false\n }\n const stored = decodePbxShellScript(phase.shellScript)\n return [false, true].some((source) =>\n [false, true].some(\n (skip) =>\n [false, true].some((force) => stored === buildDsymUploadShellScript(source, skip, force)) ||\n [undefined, ...POSTHOG_RELEASE_MODES].some(\n (mode) => stored === buildLegacyReleaseModeDsymUploadShellScript(source, skip, mode)\n )\n )\n )\n}\n\nexport function moveDsymUploadBuildPhaseToEnd(xcodeProject: any): void {\n const existing = xcodeProject.pbxItemByComment(POSTHOG_DSYM_BUILD_PHASE_NAME, 'PBXShellScriptBuildPhase')\n if (!isPluginGeneratedDsymUploadBuildPhase(existing)) {\n return\n }\n\n const buildPhases = xcodeProject.getFirstTarget?.().firstTarget?.buildPhases\n if (Array.isArray(buildPhases)) {\n const phaseIndex = buildPhases.findIndex((phase: any) => phase.comment === POSTHOG_DSYM_BUILD_PHASE_NAME)\n if (phaseIndex !== -1 && phaseIndex !== buildPhases.length - 1) {\n buildPhases.push(...buildPhases.splice(phaseIndex, 1))\n }\n }\n}\n\n// Keeps the upload phase last and declares the main DWARF as an input, matching the native iOS\n// setup guide. Both are required: the input makes Xcode wait for dSYM generation, while placing\n// the phase after extension embedding avoids dependency cycles in apps with app extensions.\n// Re-runs refresh only a still-plugin-generated phase, also one an older SDK wrote, so user\n// customizations remain untouched.\nexport function addDsymUploadBuildPhase(\n xcodeProject: any,\n includeSource = false,\n skipOnConflict = false,\n force = false\n): void {\n const existing = xcodeProject.pbxItemByComment(POSTHOG_DSYM_BUILD_PHASE_NAME, 'PBXShellScriptBuildPhase')\n if (existing) {\n if (isPluginGeneratedDsymUploadBuildPhase(existing)) {\n existing.shellScript = encodePbxShellScript(buildDsymUploadShellScript(includeSource, skipOnConflict, force))\n existing.inputPaths = Array.from(\n new Set([...(Array.isArray(existing.inputPaths) ? existing.inputPaths : []), POSTHOG_DSYM_INPUT_PATH])\n )\n }\n } else {\n xcodeProject.addBuildPhase([], 'PBXShellScriptBuildPhase', POSTHOG_DSYM_BUILD_PHASE_NAME, null, {\n inputPaths: [POSTHOG_DSYM_INPUT_PATH],\n shellPath: '/bin/sh',\n shellScript: buildDsymUploadShellScript(includeSource, skipOnConflict, force),\n })\n }\n\n moveDsymUploadBuildPhaseToEnd(xcodeProject)\n}\n\nexport function disableUserScriptSandboxing(xcodeProject: any): void {\n // posthog-cli reads .git/ for release auto-detection, which the Xcode 14+ user script\n // sandbox blocks. Applies to all configs in the main app's .xcodeproj (Pods project is\n // separate and untouched).\n const configurations = xcodeProject.pbxXCBuildConfigurationSection()\n for (const key in configurations) {\n const configuration = configurations[key]\n if (configuration && configuration.buildSettings) {\n configuration.buildSettings.ENABLE_USER_SCRIPT_SANDBOXING = '\"NO\"'\n }\n }\n}\n\nconst POSTHOG_DOTENV_BUILD_SETTING = 'POSTHOG_CLI_DOTENV_FILE'\nconst POSTHOG_DOTENV_GRADLE_PROPERTY = 'posthog.dotenvFile'\n\n// Strips a leading ./ so relative props join cleanly onto their per-platform prefix.\nfunction normalizeDotenvFileProp(dotenvFile: string): string {\n return dotenvFile.replace(/^\\.\\//, '')\n}\n\n// Empty/whitespace-only values (easy to produce from templated app.config values)\n// count as unset — mirrors the trim guard in posthog.gradle.\nexport function resolveDotenvFileProp(dotenvFile?: string): string | undefined {\n const trimmed = dotenvFile?.trim()\n return trimmed ? trimmed : undefined\n}\n\n// Posix root or a Windows drive prefix — enough without pulling in `path`,\n// whose isAbsolute is platform-bound while prebuild can run anywhere.\nfunction isAbsoluteDotenvPath(dotenvFile: string): boolean {\n return dotenvFile.startsWith('/') || /^[A-Za-z]:[\\\\/]/.test(dotenvFile)\n}\n\n// pbxproj stores build-setting values quoted; escape so paths with quotes or\n// backslashes survive serialization. $(SRCROOT) is the generated ios/ dir, so\n// project-root-relative props live one level up.\nexport function buildIosDotenvFileBuildSetting(dotenvFile: string): string {\n const value = isAbsoluteDotenvPath(dotenvFile) ? dotenvFile : `$(SRCROOT)/../${normalizeDotenvFileProp(dotenvFile)}`\n return '\"' + value.replace(/([\"\\\\])/g, '\\\\$1') + '\"'\n}\n\n// Xcode exports build settings as env vars to every Run Script phase, so one\n// setting feeds both the bundle-phase hermes upload and the dSYM upload phase;\n// posthog-cli (>= 0.8.4) reads POSTHOG_CLI_DOTENV_FILE itself, no script\n// changes needed. Removing the prop removes the setting again so changes take\n// effect without a clean prebuild.\nexport function applyDotenvFileBuildSetting(xcodeProject: any, dotenvFile?: string): void {\n const configurations = xcodeProject.pbxXCBuildConfigurationSection()\n for (const key in configurations) {\n const configuration = configurations[key]\n if (configuration && configuration.buildSettings) {\n if (dotenvFile) {\n configuration.buildSettings[POSTHOG_DOTENV_BUILD_SETTING] = buildIosDotenvFileBuildSetting(dotenvFile)\n } else {\n delete configuration.buildSettings[POSTHOG_DOTENV_BUILD_SETTING]\n }\n }\n }\n}\n\ntype GradlePropertiesItem = { type: string; key?: string; value?: string }\n\n// gradle.properties lives in android/, so a project-root-relative prop becomes ../<path>.\nexport function buildAndroidDotenvFileGradleValue(dotenvFile: string): string {\n return isAbsoluteDotenvPath(dotenvFile) ? dotenvFile : `../${normalizeDotenvFileProp(dotenvFile)}`\n}\n\n// Managed posthog.dotenvFile entry in android/gradle.properties, consumed by\n// both gradle hooks (the SDK's posthog.gradle hermes upload and the\n// com.posthog.android mapping upload). Added when the prop is set, removed\n// when it isn't.\nexport function updateDotenvFileGradleProperties(\n properties: GradlePropertiesItem[],\n dotenvFile?: string\n): GradlePropertiesItem[] {\n const rest = properties.filter((item) => !(item.type === 'property' && item.key === POSTHOG_DOTENV_GRADLE_PROPERTY))\n if (!dotenvFile) {\n return rest\n }\n rest.push({\n type: 'property',\n key: POSTHOG_DOTENV_GRADLE_PROPERTY,\n value: buildAndroidDotenvFileGradleValue(dotenvFile),\n })\n return rest\n}\n\n// Managed posthog.hermesReleaseMode entry in android/gradle.properties, read by the SDK's\n// posthog.gradle hermes upload. The key is deliberately not posthog.releaseMode:\n// com.posthog.android below 1.6.0 reads that one for the R8 mapping upload, and the mode must not\n// reach it. A posthog.releaseMode entry is deprecated user-owned config, so the prebuild leaves it\n// alone. posthog.gradle reads it as a fallback with a warning, and com.posthog.android 1.6.0\n// warns about it and ignores it.\nexport function updateHermesReleaseModeGradleProperties(\n properties: GradlePropertiesItem[],\n releaseMode?: PostHogReleaseMode\n): GradlePropertiesItem[] {\n const rest = properties.filter(\n (item) => !(item.type === 'property' && item.key === POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY)\n )\n if (!releaseMode) {\n return rest\n }\n rest.push({ type: 'property', key: POSTHOG_HERMES_RELEASE_MODE_GRADLE_PROPERTY, value: releaseMode })\n return rest\n}\n\nconst withPostHogGradleProperties = (config: any, dotenvFile?: string, releaseMode?: PostHogReleaseMode) => {\n return withGradleProperties(config, (config: any) => {\n config.modResults = updateDotenvFileGradleProperties(config.modResults, dotenvFile)\n config.modResults = updateHermesReleaseModeGradleProperties(config.modResults, releaseMode)\n return config\n })\n}\n\ntype PostHogPluginProps = {\n /**\n * Whether to disable Xcode's user script sandboxing (ENABLE_USER_SCRIPT_SANDBOXING=NO).\n *\n * posthog-cli reads .git/ during sourcemap uploads for release auto-detection;\n * sandboxing (on by default in Xcode 14+) blocks that, so uploads lose git info\n * or fail silently.\n *\n * Default: true (disable sandboxing so uploads \"just work\").\n * Set to false if your org requires sandboxing stays on —\n * you'll lose automatic git metadata on sourcemap uploads on iOS builds only.\n *\n * Note that this setting is recommended in the Expo docs:\n * https://docs.expo.dev/brownfield/integrated-approach/#configuring-your-xcode-project\n */\n disableSandboxing?: boolean\n\n /**\n * Whether to upload native debug symbols so native crashes can be symbolicated.\n *\n * When enabled, the plugin wires the native symbol-upload tooling that the\n * native PostHog SDKs already ship:\n * - iOS: a build phase that runs posthog-ios's `upload-symbols.sh`\n * (`posthog-cli dsym upload`).\n * - Android: the official `com.posthog.android` Gradle plugin, which uploads\n * ProGuard/R8 mapping files and injects the matching map-id into the app.\n *\n * Pass `{ includeSource: true }` to also upload native source files so PostHog\n * can show source-code context around native crashes. This is **iOS only** —\n * the Android proguard upload has no source-inclusion equivalent, so the flag\n * is ignored there. Note it uploads your source code to PostHog, hence opt-in.\n *\n * Default: false. Pair this with `errorTracking.autocapture.nativeCrashes` at\n * runtime — without uploaded symbols, native stack traces won't be symbolicated.\n * Requires `posthog-cli` to be available and authenticated during release builds.\n */\n uploadNativeSymbols?: boolean | { includeSource?: boolean }\n\n /**\n * Whether to skip uploads whose content already exists in PostHog instead of failing the build.\n *\n * Appends `--skip-on-conflict` to `posthog-cli hermes upload` on iOS and Android. When\n * `uploadNativeSymbols` is enabled, also sets `POSTHOG_SKIP_ON_CONFLICT=1` in the iOS dSYM\n * upload build phase; posthog-ios's `upload-symbols.sh` forwards it as `--skip-on-conflict`\n * to `posthog-cli dsym upload` on posthog-ios >= 3.64.7 (with posthog-cli >= 0.7.12) and\n * ignores it on older versions, where dSYM conflicts keep failing the build.\n *\n * Mutually exclusive with `force`: posthog-cli rejects the two flags together, so enabling\n * both stops the prebuild.\n *\n * Default: false.\n */\n skipOnConflict?: boolean\n\n /**\n * Whether to overwrite uploads whose content already exists in PostHog instead of failing the\n * build.\n *\n * Appends `--force` to `posthog-cli hermes upload` on iOS and Android. When\n * `uploadNativeSymbols` is enabled, also sets `POSTHOG_FORCE=1` in the iOS dSYM upload build\n * phase; posthog-ios's `upload-symbols.sh` forwards it as `--force` to `posthog-cli dsym upload`\n * on versions that read the variable and ignores it on older ones, where dSYM conflicts keep\n * failing the build. `uploadNativeSymbols: { includeSource: true }` already overwrites dSYMs.\n *\n * Mutually exclusive with `skipOnConflict`: posthog-cli rejects the two flags together, so\n * enabling both stops the prebuild.\n *\n * Default: false.\n */\n force?: boolean\n\n /**\n * Path to a dotenv file with POSTHOG_CLI_* credentials (API key, project id,\n * optional host), relative to the project root — or absolute.\n *\n * The path reaches every upload hook as POSTHOG_CLI_DOTENV_FILE: on iOS as a\n * build setting (Xcode exports it to the bundle and dSYM script phases), on\n * Android as a `posthog.dotenvFile` entry in android/gradle.properties read\n * by the SDK's `posthog.gradle` hermes upload and, on gradle plugin >= 1.4.0,\n * by the `com.posthog.android` mapping upload. Process env always wins inside\n * the CLI; a missing file is a warning, not a build failure.\n *\n * Requires posthog-cli >= 0.8.4 — older CLIs ignore the variable and fall\n * back to their other credential sources. With `disableSandboxing: false`,\n * Xcode's script sandbox can block reading the file, which is a hard CLI\n * error (an unreadable-but-present file does not fall through).\n */\n dotenvFile?: string\n\n /**\n * How the release a build belongs to gets associated with the exceptions it reports.\n *\n * This steers the Hermes source map upload only. iOS dSYMs and Android R8 mappings always bind to\n * the release their build creates. The R8 half of that needs the `com.posthog.android` gradle\n * plugin 1.6.0, which ignores the deprecated `posthog.releaseMode` key. A fresh prebuild injects\n * that version, but a project whose android/build.gradle already carries an older classpath line\n * keeps it: bump the line by hand or prebuild with `--clean`.\n *\n * `event` (the default; still EXPERIMENTAL while the rollout settles) uploads the maps\n * release-independent, and each event resolves its own release from the `$app_namespace` /\n * `$app_version` / `$app_build` the SDK sends. Use it when two releases can ship identical\n * JavaScript: the map id comes from content, so in `symbol-set` mode both releases report\n * whichever one uploaded first.\n *\n * Event mode's release link depends on those coordinates reaching each exception. The SDK reads\n * them from the optional `expo-application` or `react-native-device-info` module, and a plain\n * `customAppProperties` object replaces the defaults rather than merging. An install with neither\n * module — or a `customAppProperties` that drops the keys — still symbolicates, but its JavaScript\n * exceptions carry no release. Keep a metadata module (or those keys) to attribute event-mode\n * exceptions to a release; `symbol-set` instead stamps the release onto the uploaded maps from the\n * build settings and does not need them.\n *\n * When this prop is absent, the prebuild reads `POSTHOG_RELEASE_MODE`; set the variable before\n * you run the prebuild. A configured mode is written into the build files and beats the variable\n * at build time. With neither configured, the prebuild writes nothing, the build scripts apply\n * the `event` default at build time, and `POSTHOG_RELEASE_MODE` also still works there.\n *\n * Event mode needs posthog-cli >= 0.16.0, which carries `--release-mode` on the `hermes`\n * commands. A configured `event` fails the build on an older one and names the upgrade. The\n * unconfigured default softens instead: the build warns and uploads the maps bound to the\n * release, as it did before the default changed. That floor lives in posthog-xcode.sh and\n * posthog.gradle: update them and this line together.\n */\n releaseMode?: PostHogReleaseMode\n\n /**\n * Whether to give Android's `MainActivity` an `onNewIntent` override that calls\n * `setIntent(intent)` before delegating to React Native.\n *\n * Works around a React Native defect. When Android reopens an app whose process it had killed\n * while the task stayed in recents, the tap arrives before the React context is ready and is then\n * invisible to the whole process — PostHog captures no `$push_notification_opened`, Firebase\n * Messaging's `getInitialNotification()` returns null, and deep links are lost. Recording the\n * intent first makes `getIntent()` correct for every library in the app.\n *\n * Default: true. The plugin leaves a `MainActivity` that already overrides `onNewIntent`\n * untouched and warns instead — add `setIntent(intent)` as the first statement of your own\n * override. Set to false to skip the injection entirely (and remove one a previous prebuild\n * wrote); bare React Native apps that do not run `expo prebuild` need the same override by hand.\n */\n patchMainActivityNewIntent?: boolean\n}\n\n// Normalizes the uploadNativeSymbols prop (boolean | { includeSource }) into a\n// flat shape. `includeSource` is iOS-only and ignored on Android.\nexport function resolveNativeSymbolUpload(prop: PostHogPluginProps['uploadNativeSymbols']): {\n enabled: boolean\n includeSource: boolean\n} {\n if (prop === true) {\n return { enabled: true, includeSource: false }\n }\n if (prop && typeof prop === 'object') {\n return { enabled: true, includeSource: prop.includeSource === true }\n }\n return { enabled: false, includeSource: false }\n}\n\n// Expo's standard mods run their action before the previously registered action. This wrapper\n// deliberately runs its action after the rest of the Xcode mod chain, so later config plugins\n// cannot leave a newly created extension-embedding phase after the PostHog upload phase.\nconst withFinalizedXcodeProject = (config: any, action: (config: any) => any) => {\n return withBaseMod(config, {\n platform: 'ios',\n mod: 'xcodeproj',\n async action(config: any) {\n const { nextMod, ...modRequest } = config.modRequest\n const results = await nextMod({ ...config, modRequest })\n return action(results)\n },\n })\n}\n\nconst withIosPlugin = (config: any, props: PostHogPluginProps = {}) => {\n const nativeSymbols = resolveNativeSymbolUpload(props.uploadNativeSymbols)\n\n config = withXcodeProject(config, (config: any) => {\n const xcodeProject = config.modResults\n\n const bundleReactNativePhase = xcodeProject.pbxItemByComment(\n 'Bundle React Native code and images',\n 'PBXShellScriptBuildPhase'\n )\n\n modifyExistingXcodeBuildScript(\n bundleReactNativePhase,\n props.skipOnConflict === true,\n props.releaseMode,\n props.force === true\n )\n\n if (nativeSymbols.enabled) {\n addDsymUploadBuildPhase(\n xcodeProject,\n nativeSymbols.includeSource,\n props.skipOnConflict === true,\n props.force === true\n )\n }\n\n applyDotenvFileBuildSetting(xcodeProject, props.dotenvFile)\n\n if (props.disableSandboxing !== false) {\n disableUserScriptSandboxing(xcodeProject)\n console.warn(\n '[posthog-react-native] Setting ENABLE_USER_SCRIPT_SANDBOXING=NO on all Xcode ' +\n 'build configurations so sourcemap uploads can resolve git metadata. ' +\n 'If your org requires sandboxing to stay enabled, set `{ disableSandboxing: false }` ' +\n 'on the plugin in app.json — note that stock Expo projects may fail to build under ' +\n 'sandboxing until every script build phase declares its input/output files.'\n )\n }\n\n return config\n })\n\n if (nativeSymbols.enabled) {\n config = withFinalizedXcodeProject(config, (config: any) => {\n moveDsymUploadBuildPhaseToEnd(config.modResults)\n return config\n })\n }\n\n return config\n}\n\nconst withPostHogPlugin = (config: any, rawProps: PostHogPluginProps = {}) => {\n // posthog-cli declares --skip-on-conflict and --force mutually exclusive. Stop the prebuild\n // rather than writing build files the build then fails on.\n if (rawProps.skipOnConflict === true && rawProps.force === true) {\n throw new Error(\n '[posthog-react-native] skipOnConflict and force cannot both be enabled: posthog-cli accepts only one of --skip-on-conflict and --force'\n )\n }\n const props = {\n ...rawProps,\n dotenvFile: resolveDotenvFileProp(rawProps.dotenvFile),\n releaseMode: resolveReleaseModeProp(rawProps.releaseMode, process.env.POSTHOG_RELEASE_MODE),\n }\n // includeSource is iOS-only, so on Android we only care whether upload is enabled.\n if (resolveNativeSymbolUpload(props.uploadNativeSymbols).enabled) {\n config = withAndroidNativeSymbolsPlugin(config)\n }\n config = withAndroidPlugin(config, props.skipOnConflict === true, props.force === true)\n // Runs unconditionally so removing the prop also removes the managed entry.\n config = withPostHogGradleProperties(config, props.dotenvFile, props.releaseMode)\n config = withMainActivityNewIntent(config, props.patchMainActivityNewIntent !== false)\n return withIosPlugin(config, props)\n}\n\nconst postHogPlugin = (config: any, props: PostHogPluginProps = {}): any => {\n return withPostHogPlugin(config, props)\n}\n\n// Re-export the plugin function as the default export while keeping the\n// named exports above callable from tests.\nmodule.exports = postHogPlugin\nmodule.exports.modifyExistingXcodeBuildScript = modifyExistingXcodeBuildScript\nmodule.exports.addPostHogWithBundledScriptsToBundleShellScript = addPostHogWithBundledScriptsToBundleShellScript\nmodule.exports.disableUserScriptSandboxing = disableUserScriptSandboxing\nmodule.exports.buildDsymUploadShellScript = buildDsymUploadShellScript\nmodule.exports.addDsymUploadBuildPhase = addDsymUploadBuildPhase\nmodule.exports.moveDsymUploadBuildPhaseToEnd = moveDsymUploadBuildPhaseToEnd\nmodule.exports.resolveNativeSymbolUpload = resolveNativeSymbolUpload\nmodule.exports.buildAndroidSkipOnConflictGradleLine = buildAndroidSkipOnConflictGradleLine\nmodule.exports.buildAndroidForceGradleLine = buildAndroidForceGradleLine\nmodule.exports.addPostHogAndroidGradlePluginClasspath = addPostHogAndroidGradlePluginClasspath\nmodule.exports.applyPostHogAndroidGradlePlugin = applyPostHogAndroidGradlePlugin\nmodule.exports.buildIosDotenvFileBuildSetting = buildIosDotenvFileBuildSetting\nmodule.exports.applyDotenvFileBuildSetting = applyDotenvFileBuildSetting\nmodule.exports.resolveDotenvFileProp = resolveDotenvFileProp\nmodule.exports.buildAndroidDotenvFileGradleValue = buildAndroidDotenvFileGradleValue\nmodule.exports.updateDotenvFileGradleProperties = updateDotenvFileGradleProperties\nmodule.exports.POSTHOG_RELEASE_MODES = POSTHOG_RELEASE_MODES\nmodule.exports.resolveReleaseModeProp = resolveReleaseModeProp\nmodule.exports.updateHermesReleaseModeGradleProperties = updateHermesReleaseModeGradleProperties\nmodule.exports.updateMainActivityNewIntentOverride = updateMainActivityNewIntentOverride\n"],"mappings":"s3HAIA,GAAM,CAAAA,EAAE,CAAGC,OAAO,CAAC,IAAI,CAAC,CACxB,GAAM,CAAAC,IAAI,CAAGD,OAAO,CAAC,MAAM,CAAC,CAE5B,IAAAE,QAAA,CAOIF,OAAO,CAAC,sBAAsB,CAAC,CANjCG,aAAa,CAAAD,QAAA,CAAbC,aAAa,CACbC,kBAAkB,CAAAF,QAAA,CAAlBE,kBAAkB,CAClBC,WAAW,CAAAH,QAAA,CAAXG,WAAW,CACXC,gBAAgB,CAAAJ,QAAA,CAAhBI,gBAAgB,CAChBC,oBAAoB,CAAAL,QAAA,CAApBK,oBAAoB,CACpBC,gBAAgB,CAAAN,QAAA,CAAhBM,gBAAgB,CAQlB,GAAM,CAAAC,qCAAqC,CAAG,OAAO,CAErD,GAAM,CAAAC,wCAAwC,CAC5C,8KAA8K,CAEhL,GAAM,CAAAC,yCAAyC,CAAG,kCAAkC,CACpF,GAAM,CAAAC,8BAA8B,CAAG,yBAAyB,CAEhE,GAAM,CAAAC,2CAA2C,CAAG,2BAA2B,CAgBxE,GAAM,CAAAC,qBAAqB,CAAAC,OAAA,CAAAD,qBAAA,CAAyB,CAAC,YAAY,CAAE,OAAO,CAAC,CAU5E,QAAU,CAAAE,sBAAsBA,CAACC,WAAoB,CAAEC,eAAwB,EACnF,GAAM,CAAAC,OAAO,CAAG,CAAAF,WAAW,SAAXA,WAAW,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F6B,MAAM,CAACpR,OAAO,CAACwP,gCAAgC,CAAGA,gCAAgC,CAClF4B,MAAM,CAACpR,OAAO,CAACD,qBAAqB,CAAGA,qBAAqB,CAC5DqR,MAAM,CAACpR,OAAO,CAACC,sBAAsB,CAAGA,sBAAsB,CAC9DmR,MAAM,CAACpR,OAAO,CAAC6P,uCAAuC,CAAGA,uCAAuC,CAChGuB,MAAM,CAACpR,OAAO,CAACqI,mCAAmC,CAAGA,mCAAmC","ignoreList":[]}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.
|
|
1
|
+
export declare const version = "4.76.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.version=void 0;var version=exports.version="4.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.version=void 0;var version=exports.version="4.76.0";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":["version","exports"],"sources":["../src/version.ts"],"sourcesContent":["export const version = \"4.
|
|
1
|
+
{"version":3,"file":"version.js","names":["version","exports"],"sources":["../src/version.ts"],"sourcesContent":["export const version = \"4.76.0\"\n"],"mappings":"6FAAO,GAAM,CAAAA,OAAO,CAAAC,OAAA,CAAAD,OAAA,CAAG,QAAQ","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthog-react-native",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.76.0",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"directory": "packages/react-native"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@posthog/core": "^1.55.
|
|
38
|
-
"@posthog/types": "^1.412.
|
|
37
|
+
"@posthog/core": "^1.55.1",
|
|
38
|
+
"@posthog/types": "^1.412.4"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@babel/cli": "^7.19.3",
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"typescript": "7.0.2",
|
|
74
74
|
"@vitest/coverage-v8": "^1.6.1",
|
|
75
75
|
"vitest": "^1.6.1",
|
|
76
|
+
"@posthog/react-native-plugin": "2.9.4",
|
|
76
77
|
"@posthog-tooling/rollup-utils": "1.1.1",
|
|
77
|
-
"@posthog-tooling/tsconfig-base": "1.1.1"
|
|
78
|
-
"@posthog/react-native-plugin": "2.9.4"
|
|
78
|
+
"@posthog-tooling/tsconfig-base": "1.1.1"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"@react-native-async-storage/async-storage": ">=1.0.0",
|
package/tooling/posthog-xcode.sh
CHANGED
|
@@ -33,6 +33,7 @@ print_command_error() {
|
|
|
33
33
|
# WITH_ENVIRONMENT is executed by React Native
|
|
34
34
|
|
|
35
35
|
POSTHOG_SKIP_ON_CONFLICT_ENABLED="${POSTHOG_SKIP_ON_CONFLICT:-}"
|
|
36
|
+
POSTHOG_FORCE_ENABLED="${POSTHOG_FORCE:-}"
|
|
36
37
|
# The mode is explicit when the environment or a --posthog-release-mode argument supplies it, and
|
|
37
38
|
# implicit when only the event default applies. The difference decides how an old posthog-cli is
|
|
38
39
|
# handled below: an explicit mode fails the build, the implicit default softens to a bound upload.
|
|
@@ -47,6 +48,10 @@ while [ "$#" -gt 0 ]; do
|
|
|
47
48
|
POSTHOG_SKIP_ON_CONFLICT_ENABLED=1
|
|
48
49
|
shift
|
|
49
50
|
;;
|
|
51
|
+
--posthog-force)
|
|
52
|
+
POSTHOG_FORCE_ENABLED=1
|
|
53
|
+
shift
|
|
54
|
+
;;
|
|
50
55
|
--posthog-release-mode)
|
|
51
56
|
# `shift 2` past the end of the argument list makes `set -e` abort the wrapper silently.
|
|
52
57
|
if [ "$#" -lt 2 ]; then
|
|
@@ -72,10 +77,26 @@ while [ "$#" -gt 0 ]; do
|
|
|
72
77
|
esac
|
|
73
78
|
done
|
|
74
79
|
|
|
80
|
+
posthog_flag_is_enabled() {
|
|
81
|
+
[ "$1" = "1" ] || [ "$1" = "true" ]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# How an upload treats a symbol set that already exists with different content: skip-on-conflict
|
|
85
|
+
# keeps the stored one, force overwrites it, and the default fails the build. posthog-cli declares
|
|
86
|
+
# the two flags mutually exclusive, so reject the pair here rather than letting the upload fail on
|
|
87
|
+
# an argument-parser error after the bundle is built.
|
|
88
|
+
if posthog_flag_is_enabled "$POSTHOG_SKIP_ON_CONFLICT_ENABLED" && posthog_flag_is_enabled "$POSTHOG_FORCE_ENABLED"; then
|
|
89
|
+
echo "error: posthog skip-on-conflict and force cannot both be set. posthog-cli accepts only one of --skip-on-conflict and --force."
|
|
90
|
+
exit 1
|
|
91
|
+
fi
|
|
92
|
+
|
|
75
93
|
POSTHOG_UPLOAD_ARGS=()
|
|
76
|
-
if
|
|
94
|
+
if posthog_flag_is_enabled "$POSTHOG_SKIP_ON_CONFLICT_ENABLED"; then
|
|
77
95
|
POSTHOG_UPLOAD_ARGS+=(--skip-on-conflict)
|
|
78
96
|
fi
|
|
97
|
+
if posthog_flag_is_enabled "$POSTHOG_FORCE_ENABLED"; then
|
|
98
|
+
POSTHOG_UPLOAD_ARGS+=(--force)
|
|
99
|
+
fi
|
|
79
100
|
|
|
80
101
|
# How the release a build belongs to gets associated with the exceptions it reports. This covers
|
|
81
102
|
# the Hermes source maps only. The dSYM upload always binds to the release its build creates.
|
package/tooling/posthog.gradle
CHANGED
|
@@ -92,10 +92,22 @@ plugins.withId('com.android.application') {
|
|
|
92
92
|
extraArgs.addAll(["--build", versionCode.toString()])
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
// How an upload treats a symbol set that already exists with different
|
|
96
|
+
// content: skip-on-conflict keeps the stored one, force overwrites it, and
|
|
97
|
+
// the default fails the build. posthog-cli declares the two flags mutually
|
|
98
|
+
// exclusive, so reject the pair rather than failing on a parser error.
|
|
95
99
|
def posthogUploadArgs = []
|
|
96
|
-
|
|
100
|
+
def posthogSkipOnConflict = project.ext.has("posthogReactNativeSkipOnConflict") && project.ext.get("posthogReactNativeSkipOnConflict") == true
|
|
101
|
+
def posthogForce = project.ext.has("posthogReactNativeForce") && project.ext.get("posthogReactNativeForce") == true
|
|
102
|
+
if (posthogSkipOnConflict && posthogForce) {
|
|
103
|
+
throw new GradleException("posthogReactNativeSkipOnConflict and posthogReactNativeForce cannot both be true. posthog-cli accepts only one of --skip-on-conflict and --force.")
|
|
104
|
+
}
|
|
105
|
+
if (posthogSkipOnConflict) {
|
|
97
106
|
posthogUploadArgs.add("--skip-on-conflict")
|
|
98
107
|
}
|
|
108
|
+
if (posthogForce) {
|
|
109
|
+
posthogUploadArgs.add("--force")
|
|
110
|
+
}
|
|
99
111
|
|
|
100
112
|
// How the release a build belongs to gets associated with the exceptions
|
|
101
113
|
// it reports. `event` (the default) uploads the source maps
|