mparticle-roku-sdk 2.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/.github/workflows/build.yml +26 -0
  2. package/.gitmodules +3 -0
  3. package/LICENSE +191 -0
  4. package/README.md +24 -0
  5. package/example-legacy-sdk/images/MainMenu_Icon_Center_HD.png +0 -0
  6. package/example-legacy-sdk/images/MainMenu_Icon_Center_SD43.png +0 -0
  7. package/example-legacy-sdk/images/MainMenu_Icon_Side_HD.png +0 -0
  8. package/example-legacy-sdk/images/MainMenu_Icon_Side_SD43.png +0 -0
  9. package/example-legacy-sdk/images/splash_fhd.jpg +0 -0
  10. package/example-legacy-sdk/images/splash_hd.jpg +0 -0
  11. package/example-legacy-sdk/images/splash_sd.jpg +0 -0
  12. package/example-legacy-sdk/manifest +26 -0
  13. package/example-legacy-sdk/source/main.brs +45 -0
  14. package/example-scenegraph-sdk/LICENSE +1 -0
  15. package/example-scenegraph-sdk/README.md +2 -0
  16. package/example-scenegraph-sdk/source/Makefile +6 -0
  17. package/example-scenegraph-sdk/source/app.mk +675 -0
  18. package/example-scenegraph-sdk/source/components/helloworld.brs +300 -0
  19. package/example-scenegraph-sdk/source/components/helloworld.xml +66 -0
  20. package/example-scenegraph-sdk/source/images/channel-poster_fhd.png +0 -0
  21. package/example-scenegraph-sdk/source/images/channel-poster_hd.png +0 -0
  22. package/example-scenegraph-sdk/source/images/channel-poster_sd.png +0 -0
  23. package/example-scenegraph-sdk/source/images/splash-screen_fhd.jpg +0 -0
  24. package/example-scenegraph-sdk/source/images/splash-screen_hd.jpg +0 -0
  25. package/example-scenegraph-sdk/source/images/splash-screen_sd.jpg +0 -0
  26. package/example-scenegraph-sdk/source/manifest +12 -0
  27. package/example-scenegraph-sdk/source/source/Main.brs +46 -0
  28. package/example-scenegraph-sdk/source/testFramework/UnitTestFramework.brs +2867 -0
  29. package/example-scenegraph-sdk/source/tests/TestBasics.brs +266 -0
  30. package/mParticleBundle.crt +68 -0
  31. package/mParticleCore.brs +2301 -0
  32. package/mParticleTask.brs +78 -0
  33. package/mParticleTask.xml +12 -0
  34. package/package.json +5 -0
  35. package/testing/tests/Test__mParticle.brs +88 -0
@@ -0,0 +1,78 @@
1
+ '*************************************************************
2
+ ' mParticle Roku SDK - mParticle Task Node for Scene Graph
3
+ ' Copyright 2019 mParticle, Inc.
4
+ '*************************************************************
5
+
6
+ sub init()
7
+ m.port = createObject("roMessagePort")
8
+ m.top.observeField("mParticleApiCall", m.port)
9
+ m.top.functionName = "setupRunLoop"
10
+ m.top.control = "RUN"
11
+ end sub
12
+
13
+ sub setupRunLoop()
14
+ options = m.global.mparticleOptions
15
+ options.addReplace("batchUploads", true)
16
+ mParticleStart(options, m.port)
17
+ m.mparticle = mparticle()
18
+ m.top[mParticleConstants().SCENEGRAPH_NODES.CURRENT_USER_NODE] = m.mparticle.identity.getCurrentUser()
19
+ while true
20
+ msg = wait(15 * 1000, m.port)
21
+ if (msg = invalid) then
22
+ m.mparticle._internal.sessionManager.updateLastEventTime(m.mparticle._internal.utils.unixTimeMillis())
23
+ m.mparticle._internal.networking.queueUpload()
24
+ m.mparticle._internal.networking.processUploads()
25
+ else
26
+ mt = type(msg)
27
+
28
+ if mt = "roSGNodeEvent"
29
+ if msg.getField() = mParticleConstants().SCENEGRAPH_NODES.API_CALL_NODE
30
+ executeApiCall(msg.getData())
31
+ end if
32
+ else if (mt = "roUrlEvent")
33
+ if m.mparticle.isMparticleEvent(msg.getSourceIdentity())
34
+ identityResult = m.mparticle.onUrlEvent(msg)
35
+ if (identityResult <> invalid) then
36
+ m.top[mParticleConstants().SCENEGRAPH_NODES.IDENTITY_RESULT_NODE] = identityResult
37
+ if (identityResult.httpcode = 200) then
38
+ m.top[mParticleConstants().SCENEGRAPH_NODES.CURRENT_USER_NODE] = m.mparticle.identity.getCurrentUser()
39
+ end if
40
+ end if
41
+ end if
42
+ else
43
+ print "Error: unrecognized event type '"; mt ; "'"
44
+ end if
45
+ end if
46
+ end while
47
+ end sub
48
+
49
+ function executeApiCall(apiCall as object)
50
+ args = apiCall.args
51
+ length = args.count()
52
+ if (apiCall.methodName.Instr("identity/") = 0) then
53
+ target = m.mparticle.identity
54
+ methodName = apiCall.methodName.Replace("identity/", "")
55
+ else if (apiCall.methodName.Instr("media/") = 0) then
56
+ target = m.mparticle.media
57
+ methodName = apiCall.methodName.Replace("media/", "")
58
+ else
59
+ target = m.mparticle
60
+ methodName = apiCall.methodName
61
+ end if
62
+
63
+ if (length = 0) then
64
+ target[methodName]()
65
+ else if (length = 1) then
66
+ target[methodName](args[0])
67
+ else if (length = 2) then
68
+ target[methodName](args[0], args[1])
69
+ else if (length = 3) then
70
+ target[methodName](args[0], args[1], args[2])
71
+ else if (length = 4) then
72
+ target[methodName](args[0], args[1], args[2], args[3])
73
+ else if (length = 5) then
74
+ target[methodName](args[0], args[1], args[2], args[3], args[4])
75
+ else if (length = 6) then
76
+ target[methodName](args[0], args[1], args[2], args[3], args[4], args[5])
77
+ end if
78
+ end function
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <component name="mParticleTask" extends="Task">
3
+ <interface>
4
+ <field id="mParticleApiCall" type="assocarray"/>
5
+ <field id="mParticleIdentityResult" type="assocarray"/>
6
+ <field id="mParticleCurrentUser" type="assocarray"/>
7
+ </interface>
8
+ <!-- Replace with correct path if necessary -->
9
+ <script type="text/brightscript" uri="pkg:/components/mParticleTask.brs"/>
10
+ <!-- Replace with correct path if necessary -->
11
+ <script type="text/brightscript" uri="pkg:/source/mparticle/mParticleCore.brs"/>
12
+ </component>
package/package.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "mparticle-roku-sdk",
3
+ "description": "mParticle SDK for Roku Streaming devices",
4
+ "version": "2.1.16"
5
+ }
@@ -0,0 +1,88 @@
1
+ function TestSuite__mParticle() as object
2
+ this = BaseTestSuite()
3
+ this.Name = "mParticleTestSuite"
4
+ this.addTest("TestCase__mParticle_CheckConfiguration", TestCase__mParticle_CheckConfiguration)
5
+ this.addTest("TestCase__mParticle_CheckDefaultEnvironment", TestCase__mParticle_CheckDefaultEnvironment)
6
+ this.addTest("TestCase__mParticle_CheckSetEnvironment", TestCase__mParticle_CheckSetEnvironment)
7
+ this.addTest("TestCase__mParticle_TestSetUserIdentity", TestCase__mParticle_TestSetUserIdentity)
8
+
9
+ this.SetUp = mParticleTestSuite__SetUp
10
+ this.TearDown = mParticleTestSuite__TearDown
11
+ return this
12
+ end function
13
+
14
+ sub mParticleTestSuite__SetUp()
15
+ end sub
16
+
17
+ sub mParticleTestSuite__TearDown()
18
+ end sub
19
+
20
+ function reset()
21
+ getGlobalAA().mparticleInstance = invalid
22
+ end function
23
+
24
+ function TestCase__mParticle_CheckConfiguration() as string
25
+ reset()
26
+ options = {}
27
+ options.logLevel = mparticleConstants().LOG_LEVEL.DEBUG
28
+ options.apiKey = "fookey"
29
+ options.apiSecret = "foosecret"
30
+ option.dataPlanId = "fooId"
31
+ options.dataPlanVersion = 1
32
+ options.isscenegraph = true
33
+ mparticlestart(options)
34
+ msgs = []
35
+ msgs.push(m.assertEqual(mparticle()._internal.configuration.apiKey, "fookey"))
36
+ msgs.push(m.assertEqual(mparticle()._internal.configuration.apiSecret, "foosecret"))
37
+ msgs.push(m.assertEqual(mparticle()._internal.configuration.dataPlanId, "fooId"))
38
+ msgs.push(m.assertEqual(mparticle()._internal.configuration.dataPlanVersion, 1))
39
+ msgs.push(m.assertEqual(mparticle()._internal.configuration.logLevel, mparticleConstants().LOG_LEVEL.DEBUG))
40
+ msgs.push(m.assertTrue(mparticle()._internal.configuration.isscenegraph))
41
+ return testResult(msgs)
42
+ end function
43
+
44
+ function TestCase__mParticle_CheckDefaultEnvironment() as string
45
+ reset()
46
+ options = {}
47
+ mparticlestart(options)
48
+ msgs = []
49
+ msgs.push(m.assertTrue(mparticle()._internal.configuration.development))
50
+ return testResult(msgs)
51
+ end function
52
+
53
+ function TestCase__mParticle_CheckSetEnvironment() as string
54
+ reset()
55
+ options = {}
56
+ options.environment = mParticleConstants().ENVIRONMENT.FORCE_DEVELOPMENT
57
+ mparticlestart(options)
58
+ msgs = []
59
+ msgs.push(m.assertTrue(mparticle()._internal.configuration.development))
60
+ return testResult(msgs)
61
+ end function
62
+
63
+ function TestCase__mParticle_TestSetUserIdentity() as string
64
+ reset()
65
+ options = {}
66
+ mparticlestart({})
67
+ mp = mparticle()
68
+ mp._internal.storage.clear()
69
+ mp.setuseridentity(mparticleConstants().IDENTITY_TYPE.CUSTOMER_ID, "foo-customer-id")
70
+ identity = mparticle()._internal.storage.getUserIdentities().lookup(mparticleConstants().IDENTITY_TYPE.CUSTOMER_ID)
71
+ msgs = []
72
+ msgs.push(m.assertEqual(identity.n, mparticleConstants().IDENTITY_TYPE.CUSTOMER_ID))
73
+ msgs.push(m.assertEqual(identity.i, "foo-customer-id"))
74
+ return testResult(msgs)
75
+ end function
76
+
77
+ function testResult(msgs as object) as string
78
+ endMessage = []
79
+ for each msg in msgs
80
+ if (len(msg) > 0)
81
+ endMessage.push(msg)
82
+ end if
83
+ end for
84
+ if (endMessage.count() > 0)
85
+ return formatjson(endmessage)
86
+ end if
87
+ return ""
88
+ end function