posthog-react-native 4.41.2 → 4.42.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.
@@ -3,4 +3,5 @@ type BuildPhase = {
3
3
  };
4
4
  export declare function modifyExistingXcodeBuildScript(script: BuildPhase): void;
5
5
  export declare function addPostHogWithBundledScriptsToBundleShellScript(script: string): string;
6
+ export declare function disableUserScriptSandboxing(xcodeProject: any): void;
6
7
  export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.addPostHogWithBundledScriptsToBundleShellScript=addPostHogWithBundledScriptsToBundleShellScript;exports.modifyExistingXcodeBuildScript=modifyExistingXcodeBuildScript;var _require=require('@expo/config-plugins'),withAppBuildGradle=_require.withAppBuildGradle,withXcodeProject=_require.withXcodeProject;var resolvePostHogReactNativePackageJsonPath="[\"node\", \"--print\", \"require('path').join(require('path').dirname(require.resolve('posthog-react-native')), '..', 'tooling', 'posthog.gradle')\"].execute().text.trim()";var withAndroidPlugin=function withAndroidPlugin(config){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,")");if(buildGradle.includes(applyFrom)){return config;}var pattern=/^android\s*\{/m;if(buildGradle.match(pattern)){config.modResults.contents=buildGradle.replace(pattern,"".concat(applyFrom,"\n\nandroid {"));}else{console.warn('PostHog: Could not find "android {" block in build.gradle');}return config;});};function modifyExistingXcodeBuildScript(script){if(!script.shellScript.match(/(packager|scripts)\/react-native-xcode\.sh\b/)){return;}if(script.shellScript.includes('posthog-xcode.sh')){return;}if(script.shellScript.includes('posthog-react-native')){return;}var code=JSON.parse(script.shellScript);script.shellScript=JSON.stringify(addPostHogWithBundledScriptsToBundleShellScript(code));}var POSTHOG_REACT_NATIVE_XCODE_PATH="`\"$NODE_BINARY\" --print \"require('path').join(require('path').dirname(require.resolve('posthog-react-native')), '..', 'tooling', 'posthog-xcode.sh')\"`";function addPostHogWithBundledScriptsToBundleShellScript(script){return script.replace(/^.*?(packager|scripts)\/react-native-xcode\.sh\s*(\\'\\\\")?/m,function(match){return"/bin/sh ".concat(POSTHOG_REACT_NATIVE_XCODE_PATH," ").concat(match);});}var withIosPlugin=function withIosPlugin(config){return withXcodeProject(config,function(config){var xcodeProject=config.modResults;var bundleReactNativePhase=xcodeProject.pbxItemByComment('Bundle React Native code and images','PBXShellScriptBuildPhase');modifyExistingXcodeBuildScript(bundleReactNativePhase);return config;});};var withPostHogPlugin=function withPostHogPlugin(config){config=withAndroidPlugin(config);return withIosPlugin(config);};module.exports=function(config){return withPostHogPlugin(config);};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.addPostHogWithBundledScriptsToBundleShellScript=addPostHogWithBundledScriptsToBundleShellScript;exports.disableUserScriptSandboxing=disableUserScriptSandboxing;exports.modifyExistingXcodeBuildScript=modifyExistingXcodeBuildScript;var _require=require('@expo/config-plugins'),withAppBuildGradle=_require.withAppBuildGradle,withXcodeProject=_require.withXcodeProject;var resolvePostHogReactNativePackageJsonPath="[\"node\", \"--print\", \"require('path').join(require('path').dirname(require.resolve('posthog-react-native')), '..', 'tooling', 'posthog.gradle')\"].execute().text.trim()";var withAndroidPlugin=function withAndroidPlugin(config){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,")");if(buildGradle.includes(applyFrom)){return config;}var pattern=/^android\s*\{/m;if(buildGradle.match(pattern)){config.modResults.contents=buildGradle.replace(pattern,"".concat(applyFrom,"\n\nandroid {"));}else{console.warn('PostHog: Could not find "android {" block in build.gradle');}return config;});};function modifyExistingXcodeBuildScript(script){if(!script.shellScript.match(/(packager|scripts)\/react-native-xcode\.sh\b/)){return;}if(script.shellScript.includes('posthog-xcode.sh')){return;}if(script.shellScript.includes('posthog-react-native')){return;}var code=JSON.parse(script.shellScript);script.shellScript=JSON.stringify(addPostHogWithBundledScriptsToBundleShellScript(code));}var POSTHOG_REACT_NATIVE_XCODE_PATH="`\"$NODE_BINARY\" --print \"require('path').join(require('path').dirname(require.resolve('posthog-react-native')), '..', 'tooling', 'posthog-xcode.sh')\"`";function addPostHogWithBundledScriptsToBundleShellScript(script){return script.replace(/^.*?(packager|scripts)\/react-native-xcode\.sh\s*(\\'\\\\")?/m,function(match){return"/bin/sh ".concat(POSTHOG_REACT_NATIVE_XCODE_PATH," ").concat(match);});}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 withIosPlugin=function withIosPlugin(config){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return withXcodeProject(config,function(config){var xcodeProject=config.modResults;var bundleReactNativePhase=xcodeProject.pbxItemByComment('Bundle React Native code and images','PBXShellScriptBuildPhase');modifyExistingXcodeBuildScript(bundleReactNativePhase);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;});};var withPostHogPlugin=function withPostHogPlugin(config){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};config=withAndroidPlugin(config);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;
@@ -1 +1 @@
1
- {"version":3,"file":"expoconfig.js","sourceRoot":"","sources":["../../src/tooling/expoconfig.ts"],"names":[],"mappings":"AAAA,6JAA6J;AAE7J,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;AAEhF,MAAM,wCAAwC,GAC5C,8KAA8K,CAAA;AAEhL,MAAM,iBAAiB,GAAG,CAAC,MAAW,EAAE,EAAE;IACxC,OAAO,kBAAkB,CAAC,MAAM,EAAE,CAAC,MAAW,EAAE,EAAE;QAChD,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,mFAAmF,CAAC,CAAA;QACnG,CAAC;QAED,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAA;QAC9C,MAAM,SAAS,GAAG,wBAAwB,wCAAwC,GAAG,CAAA;QAErF,IAAI,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACpC,OAAO,MAAM,CAAA;QACf,CAAC;QAED,mEAAmE;QACnE,MAAM,OAAO,GAAG,gBAAgB,CAAA;QAEhC,IAAI,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,UAAU,CAAC,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,SAAS,eAAe,CAAC,CAAA;QACxF,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAA;QAC3E,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAID,MAAM,UAAU,8BAA8B,CAAC,MAAkB;IAC/D,IAAI,CAA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,CAAC,MAAM,EAAE,CAAC,MAAW,EAAE,EAAE;QAC9C,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAA;QAEtC,MAAM,sBAAsB,GAAG,YAAY,CAAC,gBAAgB,CAC1D,qCAAqC,EACrC,0BAA0B,CAC3B,CAAA;QAED,8BAA8B,CAAC,sBAAsB,CAAC,CAAA;QAEtD,IAAI,KAAK,CAAC,iBAAiB,KAAK,KAAK,EAAE,CAAC;YACtC,2BAA2B,CAAC,YAAY,CAAC,CAAA;YACzC,OAAO,CAAC,IAAI,CACV,+EAA+E;gBAC7E,sEAAsE;gBACtE,sFAAsF;gBACtF,oFAAoF;gBACpF,4EAA4E,CAC/E,CAAA;QACH,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,CAAC,MAAW,EAAE,QAA4B,EAAE,EAAE,EAAE;IACxE,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAA;IAClC,OAAO,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AACrC,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,CAAC,MAAW,EAAE,QAA4B,EAAE,EAAO,EAAE;IACzE,OAAO,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AACzC,CAAC,CAAA;AAED,wEAAwE;AACxE,2CAA2C;AAC3C,MAAM,CAAC,OAAO,GAAG,aAAa,CAAA;AAC9B,MAAM,CAAC,OAAO,CAAC,8BAA8B,GAAG,8BAA8B,CAAA;AAC9E,MAAM,CAAC,OAAO,CAAC,+CAA+C,GAAG,+CAA+C,CAAA;AAChH,MAAM,CAAC,OAAO,CAAC,2BAA2B,GAAG,2BAA2B,CAAA"}
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "4.41.2";
1
+ export declare const version = "4.42.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.version=void 0;var version=exports.version="4.41.2";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.version=void 0;var version=exports.version="4.42.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-react-native",
3
- "version": "4.41.2",
3
+ "version": "4.42.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -67,8 +67,8 @@
67
67
  "react-native-svg": "^15.0.0",
68
68
  "ts-jest": "29.4.0",
69
69
  "typescript": "5.8.2",
70
- "@posthog-tooling/tsconfig-base": "1.1.1",
71
- "@posthog-tooling/rollup-utils": "1.1.1"
70
+ "@posthog-tooling/rollup-utils": "1.1.1",
71
+ "@posthog-tooling/tsconfig-base": "1.1.1"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "@react-native-async-storage/async-storage": ">=1.0.0",
@@ -1,12 +1,15 @@
1
- # adapted from https://github.com/getsentry/sentry-react-native/blob/e76d0d388228437e82f235546de00f4e748fcbda/packages/core/scripts/sentry-xcode.sh
2
-
3
1
  #!/bin/bash
2
+ # adapted from https://github.com/getsentry/sentry-react-native/blob/e76d0d388228437e82f235546de00f4e748fcbda/packages/core/scripts/sentry-xcode.sh
4
3
  # Bundle React Native code and images
5
4
  # PWD=ios
6
5
 
7
6
  # print commands before executing them and stop on first error
8
7
  set -x -e
9
8
 
9
+ # Ensure common tool paths are available so posthog-cli can auto-detect git
10
+ # (Xcode runs build phases with a minimal PATH)
11
+ export PATH="/usr/bin:/usr/local/bin:/opt/homebrew/bin:$HOME/.cargo/bin:$HOME/.local/bin:$HOME/.posthog:$PATH"
12
+
10
13
  # WITH_ENVIRONMENT is executed by React Native
11
14
 
12
15
  REACT_NATIVE_XCODE_DEFAULT="../node_modules/react-native/scripts/react-native-xcode.sh"
@@ -45,8 +48,7 @@ else
45
48
  if [ -n "$NPM_LOCAL_ROOT" ] && [ -f "$NPM_LOCAL_ROOT/.bin/posthog-cli" ]; then
46
49
  PH_CLI_PATH="$NPM_LOCAL_ROOT/.bin/posthog-cli"
47
50
  else
48
- # Fallback to searching common locations
49
- export PATH="/usr/local/bin:/opt/homebrew/bin:$HOME/.cargo/bin:$HOME/.local/bin:$HOME/.posthog:$PATH"
51
+ # Fallback to searching common locations (PATH was already extended above)
50
52
  PH_CLI_PATH=$(command -v posthog-cli 2>/dev/null || true)
51
53
  fi
52
54
  fi
@@ -57,9 +59,31 @@ if [ -z "$PH_CLI_PATH" ] || [ ! -x "$PH_CLI_PATH" ]; then
57
59
  exit 1
58
60
  fi
59
61
 
62
+ MIN_POSTHOG_CLI_VERSION="0.7.8"
63
+ PH_CLI_VERSION=$("$PH_CLI_PATH" --version 2>/dev/null | awk '{print $NF}' | tr -d 'v')
64
+ if [ -n "$PH_CLI_VERSION" ]; then
65
+ LOWEST=$(printf '%s\n%s\n' "$MIN_POSTHOG_CLI_VERSION" "$PH_CLI_VERSION" | sort -t. -k1,1n -k2,2n -k3,3n | head -n1)
66
+ if [ "$LOWEST" != "$MIN_POSTHOG_CLI_VERSION" ]; then
67
+ echo "error: posthog-cli >= ${MIN_POSTHOG_CLI_VERSION} required (found ${PH_CLI_VERSION}). Upgrade: npm install -g @posthog/cli@latest"
68
+ exit 1
69
+ fi
70
+ fi
71
+
60
72
  # mimics how the file is defined in node_modules/react-native/scripts/react-native-xcode.sh (PACKAGER_SOURCEMAP_FILE)
61
73
  SOURCEMAP_PACKAGER_FILE="$CONFIGURATION_BUILD_DIR/$SOURCEMAP_NAME"
62
74
 
75
+ # Pass release info from Xcode build settings when available
76
+ CLI_RELEASE_ARGS=""
77
+ if [ -n "${PRODUCT_BUNDLE_IDENTIFIER}" ]; then
78
+ CLI_RELEASE_ARGS="$CLI_RELEASE_ARGS --release-name $PRODUCT_BUNDLE_IDENTIFIER"
79
+ fi
80
+ if [ -n "${MARKETING_VERSION}" ]; then
81
+ CLI_RELEASE_ARGS="$CLI_RELEASE_ARGS --release-version $MARKETING_VERSION"
82
+ fi
83
+ if [ -n "${CURRENT_PROJECT_VERSION}" ]; then
84
+ CLI_RELEASE_ARGS="$CLI_RELEASE_ARGS --build $CURRENT_PROJECT_VERSION"
85
+ fi
86
+
63
87
  # RN deletes the PACKAGER_SOURCEMAP_FILE file after execution but we need it
64
88
  # lets patch the script to comment out this part if not yet
65
89
  if grep -q '^[[:space:]]*rm.*PACKAGER_SOURCEMAP_FILE' "$REACT_NATIVE_XCODE"; then
@@ -88,9 +112,56 @@ if [[ "$SKIP_BUNDLING" ]]; then
88
112
  fi
89
113
  set -x -e
90
114
 
115
+ # posthog-cli auto-detects git by walking UP from the --directory arg
116
+ # (the sourcemap location). For Xcode, that's ~/Library/Developer/Xcode/DerivedData/
117
+ # which is outside the project tree, so .git is never found.
118
+ #
119
+ # Workaround for local builds: populate GITHUB_* env vars from the local git
120
+ # remote so the CLI's GitHub Actions detection path picks them up. The CLI
121
+ # doesn't validate the host — it builds the remote URL as
122
+ # "{GITHUB_SERVER_URL}/{GITHUB_REPOSITORY}.git", so this works regardless of
123
+ # the user's actual git provider (GitHub, GitLab, Bitbucket, self-hosted, ...).
124
+ #
125
+ # We only do this when not already inside a CI environment the CLI recognizes
126
+ # natively (GitHub Actions, Vercel). Those runners inject the real variables
127
+ # themselves, and we don't want to overwrite them with locally-derived ones.
128
+ #
129
+ if [ -z "$GITHUB_SHA" ] && [ -z "$VERCEL" ]; then
130
+ GIT_TOPLEVEL=$(git -C "${SRCROOT:-$(pwd)}" rev-parse --show-toplevel 2>/dev/null)
131
+ if [ -n "$GIT_TOPLEVEL" ]; then
132
+ GIT_REMOTE_URL=$(git -C "$GIT_TOPLEVEL" config --get remote.origin.url 2>/dev/null)
133
+ if [ -n "$GIT_REMOTE_URL" ]; then
134
+ # Parse host and "owner/repo" from either:
135
+ # git@host:owner/repo.git → host=host, repo=owner/repo
136
+ # https://host/owner/repo.git → host=host, repo=owner/repo
137
+ # ssh://git@host:port/owner/repo → host=host, repo=owner/repo
138
+ # git@gitlab.com:org/subgroup/repo.git → host=gitlab.com, repo=org/subgroup/repo
139
+ # Strip leading scheme + optional user@, then take everything up to the first : or /
140
+ GIT_HOST=$(echo "$GIT_REMOTE_URL" | sed -E 's#^[a-z]+://##; s#^[^@]*@##; s#[:/].*$##')
141
+ # Strip scheme + user@host + separator, optional port, and .git suffix
142
+ GIT_REPO_PATH=$(echo "$GIT_REMOTE_URL" | sed -E 's#^([a-z]+://)?[^:/]*[:/]##; s#^[0-9]+/##; s#\.git$##')
143
+ if [ -n "$GIT_HOST" ] && [ -n "$GIT_REPO_PATH" ]; then
144
+ GIT_BRANCH_NAME=$(git -C "$GIT_TOPLEVEL" rev-parse --abbrev-ref HEAD 2>/dev/null)
145
+ # --abbrev-ref returns the literal string "HEAD" when the working copy
146
+ # is in a detached-HEAD state (bisect, checking out a tag, CI checkouts
147
+ # that resolved to a SHA). Fall back to the short SHA so the branch
148
+ # field is meaningful rather than just "HEAD".
149
+ if [ "$GIT_BRANCH_NAME" = "HEAD" ]; then
150
+ GIT_BRANCH_NAME=$(git -C "$GIT_TOPLEVEL" rev-parse --short HEAD 2>/dev/null)
151
+ fi
152
+ export GITHUB_ACTIONS="true"
153
+ export GITHUB_SHA=$(git -C "$GIT_TOPLEVEL" rev-parse HEAD 2>/dev/null)
154
+ export GITHUB_REF_NAME="$GIT_BRANCH_NAME"
155
+ export GITHUB_REPOSITORY="$GIT_REPO_PATH"
156
+ export GITHUB_SERVER_URL="https://${GIT_HOST}"
157
+ fi
158
+ fi
159
+ fi
160
+ fi
161
+
91
162
  # Execute posthog cli clone
92
163
  set +x +e
93
- CLI_CLONE_OUTPUT=$(/bin/sh -c "$PH_CLI_PATH hermes clone --minified-map-path $SOURCEMAP_PACKAGER_FILE --composed-map-path $SOURCEMAP_FILE" 2>&1)
164
+ CLI_CLONE_OUTPUT=$(/bin/sh -c "$PH_CLI_PATH hermes clone --minified-map-path $SOURCEMAP_PACKAGER_FILE --composed-map-path $SOURCEMAP_FILE $CLI_RELEASE_ARGS" 2>&1)
94
165
  CLONE_EXIT_CODE=$?
95
166
  if [ $CLONE_EXIT_CODE -eq 0 ]; then
96
167
  echo "$CLI_CLONE_OUTPUT" | awk '{print "output: posthog-cli - " $0}'
@@ -102,7 +173,7 @@ set -x -e
102
173
 
103
174
  # Execute posthog cli upload
104
175
  set +x +e
105
- CLI_UPLOAD_OUTPUT=$(/bin/sh -c "$PH_CLI_PATH hermes upload --directory $DERIVED_FILE_DIR" 2>&1)
176
+ CLI_UPLOAD_OUTPUT=$(/bin/sh -c "$PH_CLI_PATH hermes upload --directory $DERIVED_FILE_DIR $CLI_RELEASE_ARGS" 2>&1)
106
177
  UPLOAD_EXIT_CODE=$?
107
178
  if [ $UPLOAD_EXIT_CODE -eq 0 ]; then
108
179
  echo "$CLI_UPLOAD_OUTPUT" | awk '{print "output: posthog-cli - " $0}'
@@ -54,6 +54,8 @@ plugins.withId('com.android.application') {
54
54
  def releaseName = currentVariant[1]
55
55
  def versionCode = currentVariant[2]
56
56
  applicationVariant = currentVariant[3]
57
+ def appId = currentVariant[4]
58
+ def versionName = currentVariant[5]
57
59
 
58
60
  try {
59
61
  if (versionCode instanceof String) {
@@ -76,6 +78,15 @@ plugins.withId('com.android.application') {
76
78
  group = 'posthog.com'
77
79
 
78
80
  def extraArgs = []
81
+ if (appId != null && !appId.isEmpty()) {
82
+ extraArgs.addAll(["--release-name", appId.toString()])
83
+ }
84
+ if (versionName != null && !versionName.toString().isEmpty()) {
85
+ extraArgs.addAll(["--release-version", versionName.toString()])
86
+ }
87
+ if (versionCode != null) {
88
+ extraArgs.addAll(["--build", versionCode.toString()])
89
+ }
79
90
 
80
91
  def injected = project.objects.newInstance(InjectedExecOps)
81
92
  doFirst {
@@ -365,7 +376,7 @@ static extractCurrentVariants(bundleTask, variant) {
365
376
  def outputName = output.baseName
366
377
 
367
378
  if (currentVariants[outputName] == null) currentVariants[outputName] = []
368
- currentVariants[outputName] = [outputName, releaseName, versionCode, variantName]
379
+ currentVariants[outputName] = [outputName, releaseName, versionCode, variantName, appId, versionName]
369
380
  }
370
381
  }
371
382