-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #570 from OneSignal/release/3.0.8
Release 3.0.8
- Loading branch information
Showing
20 changed files
with
170 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
OneSignalExample/Assets/OneSignal/Attribution/OneSignalVSAttribution.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Modified MIT License | ||
* | ||
* Copyright 2022 OneSignal | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* 1. The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* 2. All copies of substantial portions of the Software may only be used in connection | ||
* with services provided by OneSignal. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
using UnityEngine; | ||
using UnityEditor.VSAttribution.OneSignalSDK; | ||
|
||
namespace OneSignalSDK | ||
{ | ||
internal static class AttachToInit { | ||
#if ONE_SIGNAL_INSTALLED | ||
[RuntimeInitializeOnLoadMethod] public static void Init() { | ||
if (string.IsNullOrEmpty(OneSignal.AppId)) | ||
OneSignal.OnInitialize += appId => VSAttribution.SendAttributionEvent("Login", "OneSignal", appId); | ||
else | ||
VSAttribution.SendAttributionEvent("Login", "OneSignal", OneSignal.AppId); | ||
} | ||
#endif | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
OneSignalExample/Assets/OneSignal/Attribution/OneSignalVSAttribution.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
OneSignalExample/Assets/OneSignal/Attribution/VSAttribution.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using UnityEngine.Analytics; | ||
|
||
namespace UnityEditor.VSAttribution.OneSignalSDK | ||
{ | ||
public static class VSAttribution | ||
{ | ||
const int k_VersionId = 4; | ||
const int k_MaxEventsPerHour = 10; | ||
const int k_MaxNumberOfElements = 1000; | ||
|
||
const string k_VendorKey = "unity.vsp-attribution"; | ||
const string k_EventName = "vspAttribution"; | ||
|
||
static bool RegisterEvent() | ||
{ | ||
AnalyticsResult result = EditorAnalytics.RegisterEventWithLimit(k_EventName, k_MaxEventsPerHour, | ||
k_MaxNumberOfElements, k_VendorKey, k_VersionId); | ||
|
||
var isResultOk = result == AnalyticsResult.Ok; | ||
return isResultOk; | ||
} | ||
|
||
[Serializable] | ||
struct VSAttributionData | ||
{ | ||
public string actionName; | ||
public string partnerName; | ||
public string customerUid; | ||
public string extra; | ||
} | ||
|
||
/// <summary> | ||
/// Registers and attempts to send a Verified Solutions Attribution event. | ||
/// </summary> | ||
/// <param name="actionName">Name of the action, identifying a place this event was called from.</param> | ||
/// <param name="partnerName">Identifiable Verified Solutions Partner's name.</param> | ||
/// <param name="customerUid">Unique identifier of the customer using Partner's Verified Solution.</param> | ||
public static AnalyticsResult SendAttributionEvent(string actionName, string partnerName, string customerUid) | ||
{ | ||
try | ||
{ | ||
// Are Editor Analytics enabled ? (Preferences) | ||
if (!EditorAnalytics.enabled) | ||
return AnalyticsResult.AnalyticsDisabled; | ||
|
||
if (!RegisterEvent()) | ||
return AnalyticsResult.InvalidData; | ||
|
||
// Create an expected data object | ||
var eventData = new VSAttributionData | ||
{ | ||
actionName = actionName, | ||
partnerName = partnerName, | ||
customerUid = customerUid, | ||
extra = "{}" | ||
}; | ||
|
||
return EditorAnalytics.SendEventWithLimit(k_EventName, eventData, k_VersionId); | ||
} | ||
catch | ||
{ | ||
// Fail silently | ||
return AnalyticsResult.AnalyticsDisabled; | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
108 changes: 0 additions & 108 deletions
108
OneSignalExample/Assets/OneSignal/Attribution/VspAttribution.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.0.7 | ||
3.0.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.