You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

FlurrySDK中UserProperties.Add与UserProperties.Set的功能差异及正确使用方式咨询

Flurry UserProperties: Add vs Set - Usage Logic in Unity

Hey there! Let's break down the differences between Flurry.UserProperties.Add and Flurry.UserProperties.Set in Unity, and clarify the right way to use them based on your question.

Core Differences Between Add and Set

First, let's ground this in the official docs you shared, then translate that into practical use cases:

  • Flurry.UserProperties.Set:

    官方文档描述:Set方法用于设置并替换(若已存在)属性的值
    Think of this as an "upsert" operation. If the property doesn't exist yet, it creates the property and assigns the value. If the property already exists, it completely overwrites the old value with the new one. This is made for single-value properties—things like a user's currentLevel, subscriptionStatus, or selectedLanguage where there should only be one definitive value at any time.

  • Flurry.UserProperties.Add:

    官方文档描述:Add方法用于添加用户属性值,添加已存在于当前状态中的值不会产生效果且不会报错。
    This is exclusively for multi-value properties—attributes where a user can have multiple unique values, like favoriteGameGenres or unlockedFeatures. Each call adds a new value to the property's collection, and duplicates are silently ignored (no errors, no changes). It never overwrites existing values, only appends new unique ones.

Can I Just Use Add and Ignore Set?

Short answer: No, that's a bad idea. They solve entirely different problems:

  • If you use Add for a single-value property (like currentLevel), you'll end up with a list of every level the user has ever reached, instead of their active current level. That's useless for tracking their current state.
  • Add only makes sense for properties where multiple values are meaningful. For any attribute that needs one clear, up-to-date value, Set is the correct tool.

Do I Need to "Define" Properties via Add First, Then Use Set?

Nope, that's a common misunderstanding. You don't need to pre-define properties in Flurry through SDK calls. Both Add and Set will automatically create the property in your Flurry dashboard if it doesn't exist already.

The only time you'd chain Add calls is when building out a multi-value property (like adding multiple favorite genres). For single-value properties, you can call Set directly from the start—no pre-definition required.

Quick Practical Examples

Using Set for Single-Value Properties

// Set initial user level (creates the property if it doesn't exist)
Flurry.UserProperties.Set("currentLevel", 5);

// Later, when the user levels up, overwrite the old value
Flurry.UserProperties.Set("currentLevel", 6);

Using Add for Multi-Value Properties

// Add multiple unique favorite genres (duplicates are ignored)
Flurry.UserProperties.Add("favoriteGenres", "RPG");
Flurry.UserProperties.Add("favoriteGenres", "Strategy");
Flurry.UserProperties.Add("favoriteGenres", "RPG"); // This call does nothing

内容的提问来源于stack exchange,提问作者user1579019

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 09:23:16