Game Analytics Multi place game problem

I have more than one place in my game and i want to keep the session when teleporting.

After you teleport to the second place it does not send any events, I call the isPlayerReady and gives me a false result.
image
Am I missing something? What do I need to do to send events?

The only thing I have found is this code on the Game Analytics page: Knowledge Base

This is the teleport script in my first place and at this point everything seems fine, it sends the events correctly.

local TeleportService = game:GetService("TeleportService")

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local teleportPlayer = RemoteEvents:WaitForChild("teleportPlayer")
local ServerStorage = game:GetService("ServerStorage")
local GameAnalytics = require(ServerStorage.KPIs.GameAnalytics)

local teleporter = game.Workspace.teleportStart1
local placeId = game.Workspace.GlobalSetting.WAITING_ROOM_ID.Value

local function CompleteProgressionEvent(playersInGame)
	print("complete progression event")
	GameAnalytics:addProgressionEvent(playersInGame.UserId, {
		progressionStatus = GameAnalytics.EGAProgressionStatus.Complete,
		progression01 = "Lobby",
	})
end

local function teleport(player)
	-- Teleport the player
	
	-- Teleport the player
	--local teleportResult = TeleportModule.teleportWithRetry(targetPlaceID, {player})

	local success, result = pcall(function()
		print(player)
		local playerIds = { player.UserId }
		--print("playerIds ", playerIds)
		local teleportData = {}

		-- Add other teleport data...

		teleportData = GameAnalytics:addGameAnalyticsTeleportData(playerIds, teleportData)
		print("teleportData ", teleportData)
		
		-- Call teleport function with the updated teleport data
		
		return TeleportService:TeleportAsync(placeId, {player})
	end)
	
	if success then
		local jobId = result
		
		CompleteProgressionEvent(player)
		
		print("Players teleported to ",jobId)
	else
		warn(result)
	end
end

teleportPlayer.OnServerEvent:Connect(teleport)

This is the code in my second place that does not send any events.

local players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local GameAnalytics = require(ServerStorage.KPIs.GameAnalytics)

local OnPlayerReadyEvent
OnPlayerReadyEvent = OnPlayerReadyEvent or game:GetService("ReplicatedStorage"):WaitForChild("OnPlayerReadyEvent")
local function onPlayerReady(Player)
	
	
	
	
	local isPlayerReady = GameAnalytics:isPlayerReady(Player.UserId)
	print("isPlayerReady", isPlayerReady)
	--if isPlayerReady then
		--print("is player ready ", isPlayerReady)
		GameAnalytics:addProgressionEvent(Player.UserId, {
			progressionStatus = GameAnalytics.EGAProgressionStatus.Start,
			progression01 = "Lobby",
			progression02 = "Waiting_Room"
		})

		GameAnalytics:addDesignEvent(Player.UserId, {
			eventId = "Waiting_Room",
			123
		})
	--end
	print("termino")
	
end

players.PlayerAdded:Connect(onPlayerReady)
2 Likes

Hi. I will try to do some testing to see if I can reproduce the issue and I will get back to you.

Have you remembered to add the GameAnalytics SDK to the second place as well? It works for me when testing in a small test game I have made with two places.

On my second place i have all the files except for the server init file

image

image

image

1 Like

Ok thanks. Would it be possible for you to create a small test project with the code needed for teleporting to a new place etc so I can test in my end as I am not able to reproduce it with the test project I have created? You can send it to sdk@gameanalytics.com.

Already sent it. Thank you :slight_smile:

1 Like

It looks like you are missing to add the teleportData (or teleportOptions for the async call) call.

return TeleportService:TeleportAsync(placeId, {player})

should instead be

local teleportOptions = Instance.new("TeleportOptions") local teleportData = {} teleportData = GameAnalytics:addGameAnalyticsTeleportData(playerIds, teleportData) teleportOptions:SetTeleportData(teleportData) return TeleportService:TeleportAsync(placeId, {player}, teleportOptions)

Hope this helps

1 Like

It helped me, thanks.
But on my second place what code do I need to run?

this line returns false:
local isPlayerReady = GameAnalytics:isPlayerReady(Player.UserId)

I still can’t send events.

1 Like

I think you might have to call GameAnalytics:initialize in the new place. Let me know if that works. I think I will have to specify that in SDK docs as that part is missing.

Thanks a lot for the help! It worked, i’ll mark the solution :grin:

1 Like