@quenty/funnels 1.0.1-canary.522.b5d379b.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/CHANGELOG.md +11 -0
- package/LICENSE.md +21 -0
- package/README.md +23 -0
- package/default.project.json +7 -0
- package/package.json +39 -0
- package/src/Server/Steps/FunnelStepLogger.lua +66 -0
- package/src/Shared/Steps/FunnelStepTracker.lua +49 -0
- package/src/node_modules.project.json +7 -0
- package/test/default.project.json +12 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 1.0.1-canary.522.b5d379b.0 (2024-11-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add funnels helper package ([4dffc3c](https://github.com/Quenty/NevermoreEngine/commit/4dffc3ce700ff6f750cf5483d4a6fb95ebc1c80a))
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-2024 James Onnen (Quenty)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## Funnels
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<a href="http://quenty.github.io/NevermoreEngine/">
|
|
5
|
+
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
|
|
6
|
+
</a>
|
|
7
|
+
<a href="https://discord.gg/mhtGUS8">
|
|
8
|
+
<img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://github.com/Quenty/NevermoreEngine/actions">
|
|
11
|
+
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
|
|
12
|
+
</a>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
Funnel utility class
|
|
16
|
+
|
|
17
|
+
<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/RecurringFunnel">View docs →</a></div>
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
npm install @quenty/funnels --save
|
|
23
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quenty/funnels",
|
|
3
|
+
"version": "1.0.1-canary.522.b5d379b.0",
|
|
4
|
+
"description": "Funnel utility class",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Roblox",
|
|
7
|
+
"Nevermore",
|
|
8
|
+
"Lua",
|
|
9
|
+
"funnels"
|
|
10
|
+
],
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/Quenty/NevermoreEngine/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/Quenty/NevermoreEngine.git",
|
|
17
|
+
"directory": "src/funnels/"
|
|
18
|
+
},
|
|
19
|
+
"funding": {
|
|
20
|
+
"type": "patreon",
|
|
21
|
+
"url": "https://www.patreon.com/quenty"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"contributors": [
|
|
25
|
+
"Quenty"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@quenty/adorneedata": "7.14.1-canary.522.b5d379b.0",
|
|
29
|
+
"@quenty/baseobject": "10.7.1",
|
|
30
|
+
"@quenty/binder": "14.15.1-canary.522.b5d379b.0",
|
|
31
|
+
"@quenty/loader": "10.7.1",
|
|
32
|
+
"@quenty/propertyvalue": "7.13.1-canary.522.b5d379b.0",
|
|
33
|
+
"@quenty/servicebag": "11.10.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "b5d379b3553fb94b954870562e1bd2a57e9a1c10"
|
|
39
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
Server-side funnel logger
|
|
3
|
+
|
|
4
|
+
@class FunnelStepLogger
|
|
5
|
+
]=]
|
|
6
|
+
|
|
7
|
+
local require = require(script.Parent.loader).load(script)
|
|
8
|
+
|
|
9
|
+
local AnalyticsService = game:GetService("AnalyticsService")
|
|
10
|
+
local HttpService = game:GetService("HttpService")
|
|
11
|
+
|
|
12
|
+
local BaseObject = require("BaseObject")
|
|
13
|
+
local FunnelStepTracker = require("FunnelStepTracker")
|
|
14
|
+
|
|
15
|
+
local FunnelStepLogger = setmetatable({}, BaseObject)
|
|
16
|
+
FunnelStepLogger.ClassName = "FunnelStepLogger"
|
|
17
|
+
FunnelStepLogger.__index = FunnelStepLogger
|
|
18
|
+
|
|
19
|
+
function FunnelStepLogger.new(player, funnelName)
|
|
20
|
+
local self = setmetatable(BaseObject.new(), FunnelStepLogger)
|
|
21
|
+
|
|
22
|
+
self._player = assert(player, "No player")
|
|
23
|
+
self._stepTracker = self._maid:Add(FunnelStepTracker.new())
|
|
24
|
+
self._funnelName = assert(funnelName, "Bad funnelName")
|
|
25
|
+
self._funnelSessionId = HttpService:GenerateGUID(false)
|
|
26
|
+
self._printDebugEnabled = false
|
|
27
|
+
|
|
28
|
+
local steps = self._stepTracker:GetLoggedSteps()
|
|
29
|
+
if next(steps) then
|
|
30
|
+
-- Give us time to print if we need
|
|
31
|
+
self._maid:GiveTask(task.defer(function()
|
|
32
|
+
for stepNumber, stepName in pairs(steps) do
|
|
33
|
+
self:_sendStep(stepNumber, stepName)
|
|
34
|
+
end
|
|
35
|
+
end))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
self._maid:GiveTask(self._stepTracker.StepLogged:Connect(function(stepNumber, stepName)
|
|
39
|
+
self:_sendStep(stepNumber, stepName)
|
|
40
|
+
end))
|
|
41
|
+
|
|
42
|
+
return self
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
function FunnelStepLogger:SetPrintDebugEnabled(debugEnabled)
|
|
46
|
+
assert(type(debugEnabled) == "boolean", "Bad debugEnabled")
|
|
47
|
+
|
|
48
|
+
self._printDebugEnabled = debugEnabled
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
function FunnelStepLogger:LogStep(stepNumber, stepName)
|
|
52
|
+
assert(type(stepNumber) == "number", "Bad stepNumber")
|
|
53
|
+
assert(type(stepName) == "string", "Bad stepName")
|
|
54
|
+
|
|
55
|
+
self._stepTracker:LogStep(stepNumber, stepName)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
function FunnelStepLogger:_sendStep(stepNumber, stepName)
|
|
59
|
+
AnalyticsService:LogFunnelStepEvent(self._player, self._funnelName, self._funnelSessionId, stepNumber, stepName)
|
|
60
|
+
|
|
61
|
+
if self._printDebugEnabled then
|
|
62
|
+
print(string.format("%s - %d - %s", self._funnelName, stepNumber, stepName))
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
return FunnelStepLogger
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
@class FunnelStepTracker
|
|
3
|
+
]=]
|
|
4
|
+
|
|
5
|
+
local require = require(script.Parent.loader).load(script)
|
|
6
|
+
|
|
7
|
+
local Signal = require("Signal")
|
|
8
|
+
local BaseObject = require("BaseObject")
|
|
9
|
+
|
|
10
|
+
local FunnelStepTracker = setmetatable({}, BaseObject)
|
|
11
|
+
FunnelStepTracker.ClassName = "FunnelStepTracker"
|
|
12
|
+
FunnelStepTracker.__index = FunnelStepTracker
|
|
13
|
+
|
|
14
|
+
function FunnelStepTracker.new()
|
|
15
|
+
local self = setmetatable(BaseObject.new(), FunnelStepTracker)
|
|
16
|
+
|
|
17
|
+
self._stepsLogged = {}
|
|
18
|
+
|
|
19
|
+
self.StepLogged = self._maid:Add(Signal.new())
|
|
20
|
+
|
|
21
|
+
return self
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
function FunnelStepTracker:LogStep(stepNumber, stepName)
|
|
25
|
+
assert(type(stepNumber) == "number", "Bad stepNumber")
|
|
26
|
+
assert(type(stepName) == "string", "Bad stepName")
|
|
27
|
+
|
|
28
|
+
if self._stepsLogged[stepNumber] then
|
|
29
|
+
if self._stepsLogged[stepNumber] ~= stepName then
|
|
30
|
+
error(string.format("[FunnelStepTracker.LogStep] - Trying to log step with 2 separate names, %q and %q", self._stepsLogged[stepNumber], stepNumber))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
return
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
self._stepsLogged[stepNumber] = stepName
|
|
37
|
+
|
|
38
|
+
self.StepLogged:Fire(stepNumber, stepName)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
function FunnelStepTracker:GetLoggedSteps()
|
|
42
|
+
return table.clone(self._stepsLogged)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
function FunnelStepTracker:ClearLoggedSteps()
|
|
46
|
+
table.clear(self._stepsLogged)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
return FunnelStepTracker
|