com.usercentrics.sdk.static 0.0.0-stage → 2.36.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.
Files changed (108) hide show
  1. package/Documentation/LICENSE +2 -0
  2. package/Documentation/LICENSE.meta +7 -0
  3. package/Documentation/README +169 -0
  4. package/Documentation/README.meta +7 -0
  5. package/Documentation.meta +8 -0
  6. package/Editor/ATTLocalizationMessageDrawer.cs +92 -0
  7. package/Editor/ATTLocalizationMessageDrawer.cs.meta +11 -0
  8. package/Editor/AssemblyInfo.cs +4 -0
  9. package/Editor/AssemblyInfo.cs.meta +11 -0
  10. package/Editor/Unity.UsercentricsEditor.asmdef +18 -0
  11. package/Editor/Unity.UsercentricsEditor.asmdef.meta +7 -0
  12. package/Editor/UsercentricsATTPostProcessor.cs +125 -0
  13. package/Editor/UsercentricsATTPostProcessor.cs.meta +11 -0
  14. package/Editor/UsercentricsAndroidPostBuild.cs +45 -0
  15. package/Editor/UsercentricsAndroidPostBuild.cs.meta +11 -0
  16. package/Editor/UsercentricsAndroidSdkCheck.cs +29 -0
  17. package/Editor/UsercentricsAndroidSdkCheck.cs.meta +11 -0
  18. package/Editor/UsercentricsDependencies.xml +18 -0
  19. package/Editor/UsercentricsDependencies.xml.meta +7 -0
  20. package/Editor/UsercentricsExternalDependencyManagerBuildCheck.cs +56 -0
  21. package/Editor/UsercentricsExternalDependencyManagerBuildCheck.cs.meta +11 -0
  22. package/Editor/UsercentricsExternalDependencyManagerCheck.cs +34 -0
  23. package/Editor/UsercentricsExternalDependencyManagerCheck.cs.meta +11 -0
  24. package/Editor/UsercentricsIOSBuildFixes.cs +171 -0
  25. package/Editor/UsercentricsIOSBuildFixes.cs.meta +11 -0
  26. package/Editor/UsercentricsPBXProjectExtensions.cs +281 -0
  27. package/Editor/UsercentricsPBXProjectExtensions.cs.meta +11 -0
  28. package/Editor/UsercentricsPodfilePatches.cs +116 -0
  29. package/Editor/UsercentricsPodfilePatches.cs.meta +11 -0
  30. package/Editor/UsercentricsSentryExcludePostBuild.cs +77 -0
  31. package/Editor/UsercentricsSentryExcludePostBuild.cs.meta +11 -0
  32. package/Editor/UsercentricsSentryGradleExclude.cs +189 -0
  33. package/Editor/UsercentricsSentryGradleExclude.cs.meta +11 -0
  34. package/Editor/UsercentricsWelcomeDialog.cs +76 -0
  35. package/Editor/UsercentricsWelcomeDialog.cs.meta +11 -0
  36. package/Editor.meta +8 -0
  37. package/Prefabs/ATTManager.prefab +47 -0
  38. package/Prefabs/ATTManager.prefab.meta +7 -0
  39. package/Prefabs/Usercentrics.prefab +74 -0
  40. package/Prefabs/Usercentrics.prefab.meta +7 -0
  41. package/Prefabs.meta +8 -0
  42. package/Scripts/AppTrackingTransparency/AppTrackingTransparencyManager.cs +59 -0
  43. package/Scripts/AppTrackingTransparency/AppTrackingTransparencyManager.cs.meta +11 -0
  44. package/Scripts/AppTrackingTransparency/Model/ATTLocalizationMessage.cs +15 -0
  45. package/Scripts/AppTrackingTransparency/Model/ATTLocalizationMessage.cs.meta +11 -0
  46. package/Scripts/AppTrackingTransparency/Model/AuthorizationStatus.cs +10 -0
  47. package/Scripts/AppTrackingTransparency/Model/AuthorizationStatus.cs.meta +11 -0
  48. package/Scripts/AppTrackingTransparency/Model/Language.cs +136 -0
  49. package/Scripts/AppTrackingTransparency/Model/Language.cs.meta +11 -0
  50. package/Scripts/AppTrackingTransparency/Model.meta +8 -0
  51. package/Scripts/AppTrackingTransparency.cs +60 -0
  52. package/Scripts/AppTrackingTransparency.cs.meta +11 -0
  53. package/Scripts/AppTrackingTransparency.meta +8 -0
  54. package/Scripts/Internal/AssemblyInfo.cs +3 -0
  55. package/Scripts/Internal/AssemblyInfo.cs.meta +11 -0
  56. package/Scripts/Internal/AutoInitialize.cs +42 -0
  57. package/Scripts/Internal/AutoInitialize.cs.meta +11 -0
  58. package/Scripts/Internal/BannerSettings.cs +165 -0
  59. package/Scripts/Internal/BannerSettings.cs.meta +11 -0
  60. package/Scripts/Internal/ConsentUpdateSubscriptionCoordinator.cs +42 -0
  61. package/Scripts/Internal/ConsentUpdateSubscriptionCoordinator.cs.meta +11 -0
  62. package/Scripts/Internal/Data.cs +960 -0
  63. package/Scripts/Internal/Data.cs.meta +11 -0
  64. package/Scripts/Internal/Errors.cs +22 -0
  65. package/Scripts/Internal/Errors.cs.meta +11 -0
  66. package/Scripts/Internal/FirstLayerStyleSettings.cs +248 -0
  67. package/Scripts/Internal/FirstLayerStyleSettings.cs.meta +11 -0
  68. package/Scripts/Internal/IUsercentrics.cs +45 -0
  69. package/Scripts/Internal/IUsercentrics.cs.meta +11 -0
  70. package/Scripts/Internal/InspectorLink.cs +27 -0
  71. package/Scripts/Internal/InspectorLink.cs.meta +11 -0
  72. package/Scripts/Internal/Singleton.cs +68 -0
  73. package/Scripts/Internal/Singleton.cs.meta +11 -0
  74. package/Scripts/Internal/StringParser.cs +41 -0
  75. package/Scripts/Internal/StringParser.cs.meta +11 -0
  76. package/Scripts/Internal/UCConstants.cs +13 -0
  77. package/Scripts/Internal/UCConstants.cs.meta +11 -0
  78. package/Scripts/Internal/UnityConsentModeAdapter.cs +78 -0
  79. package/Scripts/Internal/UnityConsentModeAdapter.cs.meta +11 -0
  80. package/Scripts/Internal/UsercentricsAndroid.cs +210 -0
  81. package/Scripts/Internal/UsercentricsAndroid.cs.meta +11 -0
  82. package/Scripts/Internal/UsercentricsIOS.cs +307 -0
  83. package/Scripts/Internal/UsercentricsIOS.cs.meta +11 -0
  84. package/Scripts/Internal.meta +8 -0
  85. package/Scripts/Unity.Usercentrics.asmdef +14 -0
  86. package/Scripts/Unity.Usercentrics.asmdef.meta +7 -0
  87. package/Scripts/Usercentrics.cs +1160 -0
  88. package/Scripts/Usercentrics.cs.meta +11 -0
  89. package/Scripts.meta +8 -0
  90. package/UsercentricsInstallGuard/Usercentrics.InstallGuard.Static.asmdef +16 -0
  91. package/UsercentricsInstallGuard/Usercentrics.InstallGuard.Static.asmdef.meta +7 -0
  92. package/UsercentricsInstallGuard/UsercentricsInstallGuard.cs +82 -0
  93. package/UsercentricsInstallGuard/UsercentricsInstallGuard.cs.meta +11 -0
  94. package/UsercentricsInstallGuard.meta +8 -0
  95. package/iOS/TrackingTransparencyManager.h +13 -0
  96. package/iOS/TrackingTransparencyManager.h.meta +27 -0
  97. package/iOS/TrackingTransparencyManager.mm +99 -0
  98. package/iOS/TrackingTransparencyManager.mm.meta +37 -0
  99. package/iOS/Usercentrics.mm +228 -0
  100. package/iOS/Usercentrics.mm.meta +37 -0
  101. package/iOS/UsercentricsATTManager.mm +21 -0
  102. package/iOS/UsercentricsATTManager.mm.meta +37 -0
  103. package/iOS.meta +8 -0
  104. package/link.xml +24 -0
  105. package/link.xml.meta +7 -0
  106. package/package.json +10 -4
  107. package/package.json.meta +7 -0
  108. package/README.md +0 -3
@@ -0,0 +1,116 @@
1
+ using System.IO;
2
+
3
+ namespace Unity.Usercentrics.Editor
4
+ {
5
+ /// <summary>
6
+ /// Pure logic (no Unity API) used by <see cref="UsercentricsIOSBuildFixes"/>: the two patches it makes to the
7
+ /// exported Podfile and to the Pods xcconfigs. Kept separate so it can be unit-tested with plain dotnet —
8
+ /// <see cref="UsercentricsIOSBuildFixes"/> itself needs the iOS editor APIs and cannot be.
9
+ /// </summary>
10
+ public static class UsercentricsPodfilePatches
11
+ {
12
+ /// <summary>
13
+ /// EDM4U's iOS resolver does its work in ordered [PostProcessBuild] callbacks: it writes the Podfile at
14
+ /// order 40 (IOSResolver.OnPostProcessGenPodfile) and runs `pod install` at order 50
15
+ /// (IOSResolver.OnPostProcessInstallPods). <see cref="FixDynamicLinkage"/> has to run between the two —
16
+ /// after the Podfile exists, before the workspace is generated from it.
17
+ ///
18
+ /// Running it later only rewrites a file nothing reads again (MSDK-5360): the Podfile on disk ends up
19
+ /// correct while the workspace keeps the static layout, so the app target never gets an
20
+ /// "Embed Pods Frameworks" phase, the SDK frameworks are not copied into the .app, and dyld kills the
21
+ /// process at launch. The Podfile looking right is what makes that failure so hard to read.
22
+ /// </summary>
23
+ public const int Edm4uGenPodfileBuildOrder = 40;
24
+
25
+ /// <inheritdoc cref="Edm4uGenPodfileBuildOrder"/>
26
+ public const int Edm4uInstallPodsBuildOrder = 50;
27
+
28
+ /// <inheritdoc cref="Edm4uGenPodfileBuildOrder"/>
29
+ public const int PodfileLinkageBuildOrder = 45;
30
+
31
+ public const string StaticSdkLinkFlagsHookMarker = "# Usercentrics: keep the static SDK off the app target link line";
32
+
33
+ public const string ExistingPostInstallWarning =
34
+ "[Usercentrics] The Podfile already has a post_install hook, so the static SDK link-line fix only patched the current Pods xcconfigs. A later `pod install` brings back -framework \"Usercentrics\" -framework \"UsercentricsUI\" on the app target link line (duplicate Kotlin runtime, crash at the first SDK call): remove them again or add that step to your hook.";
35
+
36
+ /// <summary>
37
+ /// Usercentrics.xcframework is a pre-built dynamic library. EDM4U generates the Podfile with
38
+ /// :linkage => :static, which prevents CocoaPods from creating the "Embed Pods Frameworks" build phase.
39
+ /// Without that phase Usercentrics.framework is never copied into the app bundle and dyld fails at launch
40
+ /// with "Library not loaded". Switching to dynamic linkage makes CocoaPods generate the embed phase.
41
+ ///
42
+ /// The -unity-static package variant is built and packaged for static linkage (its resource bundle is only
43
+ /// resolvable when CocoaPods nests it inside UnityFramework.framework under static linkage). Forcing it to
44
+ /// dynamic would break that resolution and reintroduce the very failure this fix prevents for the dynamic
45
+ /// variant, so the flip applies to the dynamic package only.
46
+ /// </summary>
47
+ /// <returns>true when the Podfile was rewritten.</returns>
48
+ public static bool FixDynamicLinkage(string buildPath)
49
+ {
50
+ var podfilePath = Path.Combine(buildPath, "Podfile");
51
+ if (!File.Exists(podfilePath)) return false;
52
+
53
+ var content = File.ReadAllText(podfilePath);
54
+ if (!content.Contains(":linkage => :static")) return false;
55
+ if (content.Contains("-unity-static")) return false;
56
+
57
+ File.WriteAllText(podfilePath, content.Replace("use_frameworks! :linkage => :static", "use_frameworks!"));
58
+ return true;
59
+ }
60
+
61
+ /// <summary>
62
+ /// The pod is declared for the UnityFramework target only, but CocoaPods also writes
63
+ /// -framework "Usercentrics" -framework "UsercentricsUI" into the Pods-Unity-iPhone xcconfigs. With the
64
+ /// static frameworks of the -unity-static package that links the whole SDK into the app executable as well
65
+ /// as into UnityFramework, so the app holds two copies of the Kotlin runtime and the first SDK call crashes
66
+ /// at launch (EXC_BAD_ACCESS in +[KotlinBase createRetainedWrapper:], CTS-5050 / MSDK-4946). The app never
67
+ /// calls the SDK itself, so the two frameworks come off the app target's link line. Only for the static
68
+ /// variant: the dynamic frameworks are embedded and loaded once.
69
+ ///
70
+ /// Not knowing whether `pod install` has already run when the post-processor does, this patches the
71
+ /// xcconfigs if they exist and also adds a Podfile hook so a later `pod install` writes them patched.
72
+ /// CocoaPods supports a single post_install hook per Podfile, so an existing one is left alone and reported.
73
+ /// </summary>
74
+ /// <returns>A warning to log, or null when there is nothing to report.</returns>
75
+ public static string RemoveStaticSdkFromAppTargetLinkLine(string buildPath)
76
+ {
77
+ var podfilePath = Path.Combine(buildPath, "Podfile");
78
+ if (!File.Exists(podfilePath)) return null;
79
+
80
+ var podfile = File.ReadAllText(podfilePath);
81
+ if (!podfile.Contains("-unity-static")) return null;
82
+ // Only 2019.3+ puts the pods on a separate UnityFramework target; on a single-target
83
+ // project the app target is the one that has to link the SDK
84
+ if (!podfile.Contains("target 'UnityFramework'")) return null;
85
+
86
+ var appTargetSupportFiles = Path.Combine(buildPath, "Pods", "Target Support Files", "Pods-Unity-iPhone");
87
+ if (Directory.Exists(appTargetSupportFiles))
88
+ {
89
+ foreach (var xcconfigPath in Directory.GetFiles(appTargetSupportFiles, "*.xcconfig"))
90
+ {
91
+ var xcconfig = File.ReadAllText(xcconfigPath);
92
+ var patched = xcconfig
93
+ .Replace(" -framework \"Usercentrics\"", "")
94
+ .Replace(" -framework \"UsercentricsUI\"", "");
95
+ if (patched != xcconfig) File.WriteAllText(xcconfigPath, patched);
96
+ }
97
+ }
98
+
99
+ if (podfile.Contains(StaticSdkLinkFlagsHookMarker)) return null;
100
+ if (podfile.Contains("post_install")) return ExistingPostInstallWarning;
101
+
102
+ const string hook =
103
+ "\n" + StaticSdkLinkFlagsHookMarker + "\n" +
104
+ "post_install do |installer|\n" +
105
+ " support_files = File.join(installer.sandbox.root.to_s, 'Target Support Files', 'Pods-Unity-iPhone')\n" +
106
+ " Dir.glob(File.join(support_files, '*.xcconfig')).each do |path|\n" +
107
+ " content = File.read(path)\n" +
108
+ " patched = content.gsub(/ -framework \"(Usercentrics|UsercentricsUI)\"/, '')\n" +
109
+ " File.write(path, patched) unless patched == content\n" +
110
+ " end\n" +
111
+ "end\n";
112
+ File.AppendAllText(podfilePath, hook);
113
+ return null;
114
+ }
115
+ }
116
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: a2875f5548344caaa191169f44aed6d7
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,77 @@
1
+ using System;
2
+ using System.IO;
3
+ using System.Text;
4
+ using UnityEditor.Android;
5
+ using UnityEngine;
6
+
7
+ namespace Unity.Usercentrics.Editor
8
+ {
9
+ /// <summary>
10
+ /// Keeps the Usercentrics crash-reporting dependency io.sentry:sentry out of every Unity Android build.
11
+ /// It also removes the duplicate-class clash with Sentry for Unity (which ships its own sentry.jar).
12
+ /// EDM4U's androidPackage XML cannot express Gradle excludes, so this adds the exclude to the Usercentrics
13
+ /// dependency line(s) of the generated unityLibrary/build.gradle (a module-wide exclude block is the fallback when
14
+ /// no such line exists), and deletes EDM4U's own io.sentry.sentry-&lt;version&gt;.jar copy from the export.
15
+ /// </summary>
16
+ public class UsercentricsSentryExcludePostBuild : IPostGenerateGradleAndroidProject
17
+ {
18
+ const string Tag = "[Usercentrics] ";
19
+
20
+ // 1:1 byte <-> char mapping. Patch only adds ASCII, so every original byte (BOM, non-UTF-8 text) is kept.
21
+ static readonly Encoding Latin1 = Encoding.GetEncoding(28591);
22
+
23
+ // Run last, after any callback that edits build.gradle.
24
+ public int callbackOrder => int.MaxValue;
25
+
26
+ public void OnPostGenerateGradleAndroidProject(string path)
27
+ {
28
+ // Independent of the build.gradle step below: neither may stop the other.
29
+ UsercentricsSentryGradleExclude.RemoveEdm4uSentryJars(
30
+ Path.Combine(path, "libs"),
31
+ message => Debug.Log(Tag + message),
32
+ message => Debug.LogWarning(Tag + message));
33
+
34
+ string gradleFile = Path.Combine(path, "build.gradle");
35
+ if (!File.Exists(gradleFile))
36
+ {
37
+ Debug.LogWarning(Tag + gradleFile + " not found; not adding the Sentry exclude.");
38
+ return;
39
+ }
40
+
41
+ string patched;
42
+ UsercentricsSentryGradleExclude.Result result;
43
+ try
44
+ {
45
+ patched = UsercentricsSentryGradleExclude.Patch(Latin1.GetString(File.ReadAllBytes(gradleFile)), out result);
46
+ }
47
+ catch (Exception e) when (e is IOException || e is UnauthorizedAccessException)
48
+ {
49
+ Debug.LogWarning(Tag + "Could not read " + gradleFile + " (" + e.Message + "); not adding the Sentry exclude. Add it manually if checkReleaseDuplicateClasses fails.");
50
+ return;
51
+ }
52
+ switch (result)
53
+ {
54
+ case UsercentricsSentryGradleExclude.Result.Patched:
55
+ case UsercentricsSentryGradleExclude.Result.PatchedModuleWide:
56
+ try
57
+ {
58
+ File.WriteAllBytes(gradleFile, Latin1.GetBytes(patched));
59
+ Debug.Log(Tag + (result == UsercentricsSentryGradleExclude.Result.Patched
60
+ ? "Added the io.sentry:sentry exclude to the Usercentrics dependency in " + gradleFile + " ."
61
+ : "No Usercentrics dependency line found; added a module-wide io.sentry:sentry exclude block to " + gradleFile + " ."));
62
+ }
63
+ catch (Exception e) when (e is IOException || e is UnauthorizedAccessException)
64
+ {
65
+ Debug.LogWarning(Tag + "Could not write " + gradleFile + " (" + e.Message + "); the Sentry exclude was not added. Add it manually if checkReleaseDuplicateClasses fails.");
66
+ }
67
+ break;
68
+ case UsercentricsSentryGradleExclude.Result.AlreadyPatched:
69
+ Debug.Log(Tag + "Sentry exclude already present in " + gradleFile + "; skipping.");
70
+ break;
71
+ default:
72
+ Debug.LogWarning(Tag + "Unexpected layout in " + gradleFile + "; not adding the Sentry exclude. Add it manually if checkReleaseDuplicateClasses fails.");
73
+ break;
74
+ }
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 7d2e8f1b04c5470f9b32d1e8f4a05b22
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,189 @@
1
+ using System;
2
+ using System.IO;
3
+ using System.Text;
4
+ using System.Text.RegularExpressions;
5
+
6
+ namespace Unity.Usercentrics.Editor
7
+ {
8
+ /// <summary>
9
+ /// Pure logic (no Unity API) used by <see cref="UsercentricsSentryExcludePostBuild"/>.
10
+ /// Kept separate so it can be unit-tested with plain dotnet.
11
+ /// </summary>
12
+ public static class UsercentricsSentryGradleExclude
13
+ {
14
+ public const string BeginMarker = "// >>> Usercentrics: Sentry exclude";
15
+ public const string EndMarker = "// <<< Usercentrics";
16
+
17
+ // The exclude that is put on every Usercentrics dependency line, e.g.
18
+ // implementation('com.usercentrics.sdk:usercentrics-ui:[2.34.0]') { exclude group: 'io.sentry', module: 'sentry' }
19
+ // It only applies to what is reached through that dependency, so an io.sentry:sentry that comes from another
20
+ // dependency (for example io.sentry:sentry-android-core added by the host) is kept.
21
+ const string EdgeExclude = " { exclude group: 'io.sentry', module: 'sentry' }";
22
+
23
+ static readonly string[] BlockMarkers =
24
+ {
25
+ "// Android Resolver Dependencies",
26
+ "// Android Resolver Exclusions",
27
+ "// Android Resolver Repos",
28
+ };
29
+
30
+ // A whole line declaring a Usercentrics dependency, with an optional trailing comment, as EDM4U writes it:
31
+ // implementation 'com.usercentrics.sdk:usercentrics-ui:[2.34.0]' // Assets/.../UsercentricsDependencies.xml:4
32
+ // Lines with anything else after the dependency (a closure, other arguments) are deliberately not matched.
33
+ const string DependencyPrefix = @"^(?<indent>[ \t]*)(?<conf>implementation|api)[ \t]*\(?[ \t]*(?<q>['""])(?<coord>com\.usercentrics\.sdk:[^'""\r\n]+)\k<q>(?:[ \t]*\))?";
34
+
35
+ static readonly Regex UnscopedDependency = new Regex(
36
+ DependencyPrefix + @"(?<tail>[ \t]*(?://[^\r\n]*)?)(?=\r?$)",
37
+ RegexOptions.Compiled | RegexOptions.Multiline);
38
+
39
+ static readonly Regex ScopedDependency = new Regex(
40
+ DependencyPrefix + Regex.Escape(EdgeExclude).Replace(@"\ ", " ") + @"(?=[ \t]*(?://[^\r\n]*)?\r?$)",
41
+ RegexOptions.Compiled | RegexOptions.Multiline);
42
+
43
+ public enum Result
44
+ {
45
+ /// <summary>The exclude was added to the Usercentrics dependency line(s).</summary>
46
+ Patched,
47
+ /// <summary>No Usercentrics dependency line was found: the module-wide exclude block was appended.</summary>
48
+ PatchedModuleWide,
49
+ AlreadyPatched,
50
+ UnsafeLayout
51
+ }
52
+
53
+ public static string BuildBlock(string newline)
54
+ {
55
+ // Fallback only. It applies to every dependency of the module, so it is used just when the Usercentrics
56
+ // dependency line cannot be found (which is the only place the scoped exclude can be put).
57
+ return BeginMarker + newline
58
+ + "configurations.all {" + newline
59
+ + " exclude group: 'io.sentry', module: 'sentry'" + newline
60
+ + "}" + newline
61
+ + EndMarker + newline;
62
+ }
63
+
64
+ /// <summary>
65
+ /// Keeps the Usercentrics io.sentry:sentry dependency out of the module. Idempotent.
66
+ /// Preferred: rewrites the Usercentrics dependency line(s) EDM4U generated to carry the exclude.
67
+ /// Fallback (no such line): appends a module-wide exclude block to the end of the file.
68
+ /// Only ASCII is ever added, so the caller can round-trip the file through a 1:1 encoding (Latin-1)
69
+ /// and keep every original byte, including a BOM.
70
+ /// </summary>
71
+ public static string Patch(string gradle, out Result result)
72
+ {
73
+ if (gradle == null) gradle = string.Empty;
74
+
75
+ // Only the exact current block counts: a stale, emptied or commented-out block under the same marker
76
+ // text must not stop the exclude from being added.
77
+ if (gradle.Contains(BuildBlock("\n")) || gradle.Contains(BuildBlock("\r\n")))
78
+ {
79
+ result = Result.AlreadyPatched;
80
+ return gradle;
81
+ }
82
+
83
+ int scoped = ScopedDependency.Matches(gradle).Count;
84
+ int rewritten = 0;
85
+ string patched = UnscopedDependency.Replace(gradle, m =>
86
+ {
87
+ rewritten++;
88
+ return m.Groups["indent"].Value + m.Groups["conf"].Value + "(" + m.Groups["q"].Value + m.Groups["coord"].Value
89
+ + m.Groups["q"].Value + ")" + EdgeExclude + m.Groups["tail"].Value;
90
+ });
91
+ if (rewritten > 0)
92
+ {
93
+ result = Result.Patched;
94
+ return patched;
95
+ }
96
+ if (scoped > 0)
97
+ {
98
+ result = Result.AlreadyPatched;
99
+ return gradle;
100
+ }
101
+
102
+ // The end of the file must not be inside an EDM4U block (appending there would corrupt it).
103
+ if (EndsInsideBlock(gradle))
104
+ {
105
+ result = Result.UnsafeLayout;
106
+ return gradle;
107
+ }
108
+
109
+ string nl = gradle.Contains("\r\n") ? "\r\n" : "\n";
110
+ var sb = new StringBuilder(gradle);
111
+ if (gradle.Length > 0 && !gradle.EndsWith("\n")) sb.Append(nl);
112
+ sb.Append(nl).Append(BuildBlock(nl));
113
+ result = Result.PatchedModuleWide;
114
+ return sb.ToString();
115
+ }
116
+
117
+ // EDM4U (without mainTemplate patching) copies the Maven jar as io.sentry.sentry-<version>.jar.
118
+ // Sentry for Unity's own files (sentry.jar, sentry-android-*.aar, sentry-native-*.aar) must NOT match.
119
+ static readonly Regex Edm4uSentryJar = new Regex(@"^io\.sentry\.sentry-[0-9][^/\\\r\n]*\.jar\z", RegexOptions.Compiled);
120
+
121
+ public static bool IsEdm4uSentryJar(string fileName)
122
+ {
123
+ return fileName != null && Edm4uSentryJar.IsMatch(fileName);
124
+ }
125
+
126
+ /// <summary>
127
+ /// Deletes EDM4U's io.sentry.sentry-&lt;version&gt;.jar copies from an exported module's libs folder.
128
+ /// Never throws: a problem is reported through <paramref name="warn"/> and the caller carries on.
129
+ /// </summary>
130
+ /// <returns>The number of jars removed.</returns>
131
+ public static int RemoveEdm4uSentryJars(string libs, Action<string> log, Action<string> warn)
132
+ {
133
+ if (!Directory.Exists(libs))
134
+ {
135
+ log(libs + " does not exist; no EDM4U io.sentry.sentry-<version>.jar to remove.");
136
+ return 0;
137
+ }
138
+ int found = 0, removed = 0;
139
+ try
140
+ {
141
+ foreach (string jar in Directory.GetFiles(libs, "io.sentry.sentry-*.jar"))
142
+ {
143
+ string name = Path.GetFileName(jar);
144
+ if (!IsEdm4uSentryJar(name))
145
+ continue;
146
+ found++;
147
+ try
148
+ {
149
+ File.Delete(jar);
150
+ removed++;
151
+ log("Removed " + name + " from the export (Usercentrics crash-reporting dependency).");
152
+ }
153
+ catch (Exception e) when (e is IOException || e is UnauthorizedAccessException)
154
+ {
155
+ warn("Could not remove " + jar + " (" + e.Message + "); delete it manually if checkReleaseDuplicateClasses fails.");
156
+ }
157
+ }
158
+ }
159
+ catch (Exception e)
160
+ {
161
+ // For example UnauthorizedAccessException on an unreadable libs folder. The caller still has to add the
162
+ // exclude to build.gradle, so this must never escape.
163
+ warn("Could not scan " + libs + " for the EDM4U Sentry jar (" + e.Message + "); delete io.sentry.sentry-<version>.jar from the export manually if checkReleaseDuplicateClasses fails.");
164
+ return removed;
165
+ }
166
+ if (found == 0)
167
+ log("No EDM4U io.sentry.sentry-<version>.jar found in " + libs + "; nothing to remove.");
168
+ return removed;
169
+ }
170
+
171
+ // True when the last EDM4U marker line of some block is its Start line (the file ends inside that block).
172
+ // Whole trimmed lines only: prose that merely mentions a marker does not count.
173
+ static bool EndsInsideBlock(string text)
174
+ {
175
+ var open = new bool[BlockMarkers.Length];
176
+ foreach (string raw in text.Split('\n'))
177
+ {
178
+ string line = raw.Trim();
179
+ for (int i = 0; i < BlockMarkers.Length; i++)
180
+ {
181
+ if (line == BlockMarkers[i] + " Start") open[i] = true;
182
+ else if (line == BlockMarkers[i] + " End") open[i] = false;
183
+ }
184
+ }
185
+ foreach (bool o in open) if (o) return true;
186
+ return false;
187
+ }
188
+ }
189
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 5b1c7e0a93d44f6e8a21c0d7e3f94a11
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,76 @@
1
+ using System.Diagnostics;
2
+ using Unity.Usercentrics;
3
+ using UnityEditor;
4
+ using UnityEngine;
5
+
6
+ namespace Unity.Usercentrics
7
+ {
8
+ public class UsercentricsWelcomeDialog : AssetPostprocessor
9
+ {
10
+ // Root folder Unity imports for each install method. Matched exactly, so the dialog shows once per SDK import.
11
+ private static readonly string[] SDK_ROOT_PATHS =
12
+ {
13
+ "Assets/Usercentrics", // .unitypackage (normal and static)
14
+ "Packages/com.usercentrics.sdk", // UPM normal
15
+ "Packages/com.usercentrics.sdk.static", // UPM static
16
+ };
17
+
18
+ public static bool IsSdkRoot(string assetPath)
19
+ {
20
+ return System.Array.IndexOf(SDK_ROOT_PATHS, assetPath) >= 0;
21
+ }
22
+
23
+ private static readonly int UNITY_MIN_MAJOR_VERSION = 2018;
24
+ private static readonly int UNITY_MIN_MINOR_VERSION = 4;
25
+ private static readonly string UNITY_MIN_VERSION = UNITY_MIN_MAJOR_VERSION + "." + UNITY_MIN_MINOR_VERSION;
26
+
27
+ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
28
+ {
29
+ foreach (string importedAsset in importedAssets)
30
+ {
31
+ if (IsSdkRoot(importedAsset))
32
+ {
33
+ string unityVersion = Application.unityVersion;
34
+ if (!ValidateUnityVersion(unityVersion))
35
+ {
36
+ DisplayInvalidUnityVersionDialog(unityVersion);
37
+ }
38
+
39
+ return;
40
+ }
41
+ }
42
+ }
43
+
44
+ private static void DisplayInvalidUnityVersionDialog(string unityVersion)
45
+ {
46
+ string message = "The Unity version is not supported.\n - Current: " + unityVersion + "\n - Minimum: " + UNITY_MIN_VERSION;
47
+ bool openRequirements = EditorUtility.DisplayDialog("Usercentrics - Unity", message, "Requirements", "Close");
48
+ if (openRequirements)
49
+ {
50
+ Help.BrowseURL(UCConstants.REQUIREMENTS_URL);
51
+ }
52
+ }
53
+
54
+ private static bool ValidateUnityVersion(string unityVersion)
55
+ {
56
+ string[] splitUnityVersion = unityVersion.Split('.');
57
+ return splitUnityVersion.Length >= 2 && ValidateUnityVersion(int.Parse(splitUnityVersion[0]), int.Parse(splitUnityVersion[1]));
58
+ }
59
+
60
+ private static bool ValidateUnityVersion(int majorVersion, int minorVersion)
61
+ {
62
+ if (majorVersion > UNITY_MIN_MAJOR_VERSION)
63
+ {
64
+ return true;
65
+ }
66
+ else if (majorVersion == UNITY_MIN_MAJOR_VERSION)
67
+ {
68
+ return minorVersion >= UNITY_MIN_MINOR_VERSION;
69
+ }
70
+ else
71
+ {
72
+ return false;
73
+ }
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 5a98d39354da940dda25841a2cc99fdf
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
package/Editor.meta ADDED
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 775814872f1364fc6bc8141e488666c2
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,47 @@
1
+ %YAML 1.1
2
+ %TAG !u! tag:unity3d.com,2011:
3
+ --- !u!1 &8164193669218763508
4
+ GameObject:
5
+ m_ObjectHideFlags: 0
6
+ m_CorrespondingSourceObject: {fileID: 0}
7
+ m_PrefabInstance: {fileID: 0}
8
+ m_PrefabAsset: {fileID: 0}
9
+ serializedVersion: 6
10
+ m_Component:
11
+ - component: {fileID: 8164193669218763506}
12
+ - component: {fileID: 8333650896526633395}
13
+ m_Layer: 0
14
+ m_Name: ATTManager
15
+ m_TagString: Untagged
16
+ m_Icon: {fileID: 0}
17
+ m_NavMeshLayer: 0
18
+ m_StaticEditorFlags: 0
19
+ m_IsActive: 1
20
+ --- !u!4 &8164193669218763506
21
+ Transform:
22
+ m_ObjectHideFlags: 0
23
+ m_CorrespondingSourceObject: {fileID: 0}
24
+ m_PrefabInstance: {fileID: 0}
25
+ m_PrefabAsset: {fileID: 0}
26
+ m_GameObject: {fileID: 8164193669218763508}
27
+ m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
28
+ m_LocalPosition: {x: 605.6006, y: 872.2115, z: -90.387695}
29
+ m_LocalScale: {x: 1, y: 1, z: 1}
30
+ m_Children: []
31
+ m_Father: {fileID: 0}
32
+ m_RootOrder: 0
33
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
34
+ --- !u!114 &8333650896526633395
35
+ MonoBehaviour:
36
+ m_ObjectHideFlags: 0
37
+ m_CorrespondingSourceObject: {fileID: 0}
38
+ m_PrefabInstance: {fileID: 0}
39
+ m_PrefabAsset: {fileID: 0}
40
+ m_GameObject: {fileID: 8164193669218763508}
41
+ m_Enabled: 1
42
+ m_EditorHideFlags: 0
43
+ m_Script: {fileID: 11500000, guid: c858a4e8cf41f4b37a4fc8137ec2cb61, type: 3}
44
+ m_Name:
45
+ m_EditorClassIdentifier:
46
+ PopupMessage:
47
+ IsATTEnabled: 1
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 9be3c5746e037411c8f7559bd7c54677
3
+ PrefabImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,74 @@
1
+ %YAML 1.1
2
+ %TAG !u! tag:unity3d.com,2011:
3
+ --- !u!1 &2299541421496455896
4
+ GameObject:
5
+ m_ObjectHideFlags: 0
6
+ m_CorrespondingSourceObject: {fileID: 0}
7
+ m_PrefabInstance: {fileID: 0}
8
+ m_PrefabAsset: {fileID: 0}
9
+ serializedVersion: 6
10
+ m_Component:
11
+ - component: {fileID: 2299541421496455903}
12
+ - component: {fileID: 5543985822248930565}
13
+ - component: {fileID: 8233563021425905443}
14
+ m_Layer: 0
15
+ m_Name: Usercentrics
16
+ m_TagString: Untagged
17
+ m_Icon: {fileID: 2800000, guid: 94ce25536c5044da09096a633bf35771, type: 3}
18
+ m_NavMeshLayer: 0
19
+ m_StaticEditorFlags: 0
20
+ m_IsActive: 1
21
+ --- !u!4 &2299541421496455903
22
+ Transform:
23
+ m_ObjectHideFlags: 0
24
+ m_CorrespondingSourceObject: {fileID: 0}
25
+ m_PrefabInstance: {fileID: 0}
26
+ m_PrefabAsset: {fileID: 0}
27
+ m_GameObject: {fileID: 2299541421496455896}
28
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
29
+ m_LocalPosition: {x: 0, y: 0, z: 0}
30
+ m_LocalScale: {x: 1, y: 1, z: 1}
31
+ m_Children: []
32
+ m_Father: {fileID: 0}
33
+ m_RootOrder: 0
34
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35
+ --- !u!114 &5543985822248930565
36
+ MonoBehaviour:
37
+ m_ObjectHideFlags: 0
38
+ m_CorrespondingSourceObject: {fileID: 0}
39
+ m_PrefabInstance: {fileID: 0}
40
+ m_PrefabAsset: {fileID: 0}
41
+ m_GameObject: {fileID: 2299541421496455896}
42
+ m_Enabled: 1
43
+ m_EditorHideFlags: 0
44
+ m_Script: {fileID: 11500000, guid: 3744782c8b4014366882ac904e51588d, type: 3}
45
+ m_Name:
46
+ m_EditorClassIdentifier:
47
+ SettingsID: EA4jnNPb9
48
+ RulesetID:
49
+ Options:
50
+ DefaultLanguage:
51
+ Version: latest
52
+ DebugMode: 1
53
+ TimeoutMillis: 10000
54
+ NetworkMode: 0
55
+ ConsentMediation: 0
56
+ Android:
57
+ DisableSystemBackButton: 1
58
+ StatusBarColor:
59
+ ShowBannerInFullscreen: 1
60
+ ConfigurationDashboard: https://account.usercentrics.eu
61
+ Documentation: https://usercentrics.com/docs/games/intro/
62
+ --- !u!114 &8233563021425905443
63
+ MonoBehaviour:
64
+ m_ObjectHideFlags: 0
65
+ m_CorrespondingSourceObject: {fileID: 0}
66
+ m_PrefabInstance: {fileID: 0}
67
+ m_PrefabAsset: {fileID: 0}
68
+ m_GameObject: {fileID: 2299541421496455896}
69
+ m_Enabled: 1
70
+ m_EditorHideFlags: 0
71
+ m_Script: {fileID: 11500000, guid: 8cf8fd1d44a31436596d50528c9357a5, type: 3}
72
+ m_Name:
73
+ m_EditorClassIdentifier:
74
+ Enabled: 1
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: cf74ce6dd372d499f9cd1c0a2ed26f72
3
+ PrefabImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
package/Prefabs.meta ADDED
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: fe86af9d782a142df9264b7e76f14c28
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant: