gamepulse-core 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,51 @@
1
+ from gamepulse_core.enums import EventCategory, Platform, SessionEndReason, Severity
2
+ from gamepulse_core.events import (
3
+ BaseEvent,
4
+ CrashEvent,
5
+ CurrencyEarnEvent,
6
+ CurrencySpendEvent,
7
+ CustomEvent,
8
+ GameplayEvent,
9
+ LevelCompleteEvent,
10
+ LevelFailEvent,
11
+ LevelStartEvent,
12
+ SessionEndEvent,
13
+ SessionStartEvent,
14
+ )
15
+ from gamepulse_core.schemas import (
16
+ BatchEventsRequest,
17
+ BatchEventsResponse,
18
+ CrashIngestRequest,
19
+ IdentifyPlayerRequest,
20
+ SessionEndRequest,
21
+ SessionStartRequest,
22
+ SessionStartResponse,
23
+ )
24
+ from gamepulse_core.version import SCHEMA_VERSION, __version__
25
+
26
+ __all__ = [
27
+ "BaseEvent",
28
+ "BatchEventsRequest",
29
+ "BatchEventsResponse",
30
+ "CrashEvent",
31
+ "CrashIngestRequest",
32
+ "CurrencyEarnEvent",
33
+ "CurrencySpendEvent",
34
+ "CustomEvent",
35
+ "EventCategory",
36
+ "GameplayEvent",
37
+ "IdentifyPlayerRequest",
38
+ "LevelCompleteEvent",
39
+ "LevelFailEvent",
40
+ "LevelStartEvent",
41
+ "Platform",
42
+ "SCHEMA_VERSION",
43
+ "SessionEndEvent",
44
+ "SessionEndReason",
45
+ "SessionEndRequest",
46
+ "SessionStartEvent",
47
+ "SessionStartRequest",
48
+ "SessionStartResponse",
49
+ "Severity",
50
+ "__version__",
51
+ ]
@@ -0,0 +1,11 @@
1
+ API_KEY_HEADER = "X-GamePulse-Key"
2
+ PROJECT_HEADER = "X-GamePulse-Project"
3
+ REQUEST_ID_HEADER = "X-Request-ID"
4
+
5
+ DEFAULT_BATCH_SIZE = 50
6
+ DEFAULT_FLUSH_INTERVAL_S = 2.0
7
+ MAX_BATCH_SIZE = 500
8
+ MAX_PAYLOAD_BYTES = 256 * 1024
9
+
10
+ DEFAULT_SESSION_TIMEOUT_S = 30 * 60
11
+ DEFAULT_HEARTBEAT_INTERVAL_S = 60
@@ -0,0 +1,38 @@
1
+ from enum import Enum
2
+
3
+
4
+ class EventCategory(str, Enum):
5
+ SYSTEM = "system"
6
+ PROGRESSION = "progression"
7
+ ECONOMY = "economy"
8
+ GAMEPLAY = "gameplay"
9
+ SOCIAL = "social"
10
+ ERROR = "error"
11
+ CUSTOM = "custom"
12
+
13
+
14
+ class Platform(str, Enum):
15
+ WINDOWS = "windows"
16
+ MACOS = "macos"
17
+ LINUX = "linux"
18
+ IOS = "ios"
19
+ ANDROID = "android"
20
+ WEB = "web"
21
+ CONSOLE = "console"
22
+ UNKNOWN = "unknown"
23
+
24
+
25
+ class Severity(str, Enum):
26
+ DEBUG = "debug"
27
+ INFO = "info"
28
+ WARNING = "warning"
29
+ ERROR = "error"
30
+ FATAL = "fatal"
31
+
32
+
33
+ class SessionEndReason(str, Enum):
34
+ NORMAL = "normal"
35
+ CRASH = "crash"
36
+ RAGE_QUIT = "rage_quit"
37
+ TIMEOUT = "timeout"
38
+ BACKGROUND = "background"
@@ -0,0 +1,103 @@
1
+ from __future__ import annotations
2
+
3
+ from datetime import UTC, datetime
4
+ from typing import Any
5
+ from uuid import UUID, uuid4
6
+
7
+ from pydantic import BaseModel, ConfigDict, Field
8
+
9
+ from gamepulse_core.enums import EventCategory, SessionEndReason, Severity
10
+
11
+
12
+ def _utcnow() -> datetime:
13
+ return datetime.now(UTC)
14
+
15
+
16
+ class BaseEvent(BaseModel):
17
+ """Wire-format event. SDK constructs these; API validates them."""
18
+
19
+ model_config = ConfigDict(use_enum_values=True, extra="forbid")
20
+
21
+ event_id: UUID = Field(default_factory=uuid4)
22
+ type: str
23
+ category: EventCategory
24
+ name: str
25
+ occurred_at: datetime = Field(default_factory=_utcnow)
26
+ session_id: UUID | None = None
27
+ player_id: str | None = None
28
+ payload: dict[str, Any] = Field(default_factory=dict)
29
+ sdk_version: str | None = None
30
+
31
+
32
+ # ---------- System ----------
33
+
34
+ class SessionStartEvent(BaseEvent):
35
+ category: EventCategory = EventCategory.SYSTEM
36
+ type: str = "system.session_start"
37
+ name: str = "session_start"
38
+
39
+
40
+ class SessionEndEvent(BaseEvent):
41
+ category: EventCategory = EventCategory.SYSTEM
42
+ type: str = "system.session_end"
43
+ name: str = "session_end"
44
+ end_reason: SessionEndReason = SessionEndReason.NORMAL
45
+
46
+
47
+ # ---------- Progression ----------
48
+
49
+ class LevelStartEvent(BaseEvent):
50
+ category: EventCategory = EventCategory.PROGRESSION
51
+ type: str = "progression.level_start"
52
+ name: str = "level_start"
53
+
54
+
55
+ class LevelCompleteEvent(BaseEvent):
56
+ category: EventCategory = EventCategory.PROGRESSION
57
+ type: str = "progression.level_complete"
58
+ name: str = "level_complete"
59
+
60
+
61
+ class LevelFailEvent(BaseEvent):
62
+ category: EventCategory = EventCategory.PROGRESSION
63
+ type: str = "progression.level_fail"
64
+ name: str = "level_fail"
65
+
66
+
67
+ # ---------- Economy ----------
68
+
69
+ class CurrencyEarnEvent(BaseEvent):
70
+ category: EventCategory = EventCategory.ECONOMY
71
+ type: str = "economy.currency_earn"
72
+ name: str = "currency_earn"
73
+
74
+
75
+ class CurrencySpendEvent(BaseEvent):
76
+ category: EventCategory = EventCategory.ECONOMY
77
+ type: str = "economy.currency_spend"
78
+ name: str = "currency_spend"
79
+
80
+
81
+ # ---------- Gameplay ----------
82
+
83
+ class GameplayEvent(BaseEvent):
84
+ category: EventCategory = EventCategory.GAMEPLAY
85
+ type: str = "gameplay.action"
86
+ name: str = "action"
87
+
88
+
89
+ # ---------- Errors ----------
90
+
91
+ class CrashEvent(BaseEvent):
92
+ category: EventCategory = EventCategory.ERROR
93
+ type: str = "error.crash"
94
+ name: str = "crash"
95
+ severity: Severity = Severity.ERROR
96
+
97
+
98
+ # ---------- Custom ----------
99
+
100
+ class CustomEvent(BaseEvent):
101
+ category: EventCategory = EventCategory.CUSTOM
102
+ type: str = "custom.event"
103
+ name: str = "event"
File without changes
@@ -0,0 +1,79 @@
1
+ from __future__ import annotations
2
+
3
+ from datetime import datetime
4
+ from typing import Any
5
+ from uuid import UUID
6
+
7
+ from pydantic import BaseModel, ConfigDict, Field
8
+
9
+ from gamepulse_core.constants import MAX_BATCH_SIZE
10
+ from gamepulse_core.enums import Platform, SessionEndReason, Severity
11
+ from gamepulse_core.events import BaseEvent
12
+
13
+
14
+ class DeviceContext(BaseModel):
15
+ model_config = ConfigDict(extra="allow")
16
+
17
+ platform: Platform = Platform.UNKNOWN
18
+ os_version: str | None = None
19
+ locale: str | None = None
20
+ python_version: str | None = None
21
+ app_version: str | None = None
22
+
23
+
24
+ # ---------- Players ----------
25
+
26
+ class IdentifyPlayerRequest(BaseModel):
27
+ external_id: str
28
+ country: str | None = None
29
+ platform: Platform | None = None
30
+ app_version: str | None = None
31
+ attributes: dict[str, Any] = Field(default_factory=dict)
32
+
33
+
34
+ # ---------- Sessions ----------
35
+
36
+ class SessionStartRequest(BaseModel):
37
+ player_external_id: str
38
+ started_at: datetime
39
+ device: DeviceContext = Field(default_factory=DeviceContext)
40
+ app_version: str | None = None
41
+
42
+
43
+ class SessionStartResponse(BaseModel):
44
+ session_id: UUID
45
+ player_id: UUID
46
+
47
+
48
+ class SessionEndRequest(BaseModel):
49
+ session_id: UUID
50
+ ended_at: datetime
51
+ end_reason: SessionEndReason = SessionEndReason.NORMAL
52
+
53
+
54
+ # ---------- Events ----------
55
+
56
+ class BatchEventsRequest(BaseModel):
57
+ player_external_id: str
58
+ events: list[BaseEvent] = Field(..., max_length=MAX_BATCH_SIZE)
59
+ device: DeviceContext | None = None
60
+
61
+
62
+ class BatchEventsResponse(BaseModel):
63
+ accepted: int
64
+ rejected: int = 0
65
+ duplicates: int = 0
66
+
67
+
68
+ # ---------- Crashes ----------
69
+
70
+ class CrashIngestRequest(BaseModel):
71
+ player_external_id: str
72
+ session_id: UUID | None = None
73
+ fingerprint: str
74
+ exc_type: str
75
+ message: str | None = None
76
+ stacktrace: str
77
+ severity: Severity = Severity.ERROR
78
+ occurred_at: datetime
79
+ context: dict[str, Any] = Field(default_factory=dict)
@@ -0,0 +1,2 @@
1
+ __version__ = "0.1.0"
2
+ SCHEMA_VERSION = "1"
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: gamepulse-core
3
+ Version: 0.1.0
4
+ Summary: Shared Pydantic models, enums, and schemas for the GamePulse analytics platform
5
+ Project-URL: Homepage, https://github.com/ronkochba2004-pixel/GamePulse-SDK
6
+ Project-URL: Repository, https://github.com/ronkochba2004-pixel/GamePulse-SDK
7
+ Project-URL: Bug Tracker, https://github.com/ronkochba2004-pixel/GamePulse-SDK/issues
8
+ Author-email: Ron Kochba <ronkochba2004@gmail.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: analytics,game-analytics,pydantic,schemas
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: pydantic>=2.7
24
+ Description-Content-Type: text/markdown
25
+
26
+ # gamepulse-core
27
+
28
+ Shared Pydantic models, enums, and schemas for the [GamePulse](https://github.com/ronkochba2004-pixel/GamePulse-SDK) analytics platform.
29
+
30
+ This package contains the wire-format types used by both the GamePulse API and the GamePulse Python SDK. It is an internal dependency — if you are integrating GamePulse into your game, install `gamepulse-sdk` instead.
31
+
32
+ ```bash
33
+ pip install gamepulse-sdk
34
+ ```
35
+
36
+ ## Contents
37
+
38
+ - **`gamepulse_core.events`** — Pydantic event models (`BaseEvent`, `LevelStartEvent`, `CurrencySpendEvent`, …)
39
+ - **`gamepulse_core.schemas`** — HTTP request/response schemas (`BatchEventsRequest`, `SessionStartRequest`, …)
40
+ - **`gamepulse_core.enums`** — `EventCategory`, `Platform`, `SessionEndReason`, `Severity`
41
+ - **`gamepulse_core.constants`** — API header names, limits, flush defaults
42
+ - **`gamepulse_core.version`** — `__version__`, `SCHEMA_VERSION`
43
+
44
+ ## Links
45
+
46
+ - [GitHub repository](https://github.com/ronkochba2004-pixel/GamePulse-SDK)
47
+ - [SDK package (gamepulse-sdk)](https://pypi.org/project/gamepulse-sdk/)
@@ -0,0 +1,11 @@
1
+ gamepulse_core/__init__.py,sha256=Wdkstn_y09zFNySyJvjDTeJFsiU9oQzu0w5iTtPMF0E,1188
2
+ gamepulse_core/constants.py,sha256=AdoiBqZTsDQgfKUsd4XU7m239oq8byymihzenzqvQRo,288
3
+ gamepulse_core/enums.py,sha256=BsQdtZKWWZKeW2juPD02RF872_60G1HQtWQszhKiqSY,713
4
+ gamepulse_core/events.py,sha256=FIW3mfNPE8z0bzZvzR0sTz8sBagO298o8fl1PBYCEHo,2662
5
+ gamepulse_core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ gamepulse_core/schemas.py,sha256=ubCo5gNH3fdMRUSLwoL7sTa5oY1y2zeVhMlCkFYMofU,1958
7
+ gamepulse_core/version.py,sha256=tccfbRdS-r3tzqJkmI51j1KU7w551tr05kCCGLBQgMo,43
8
+ gamepulse_core-0.1.0.dist-info/METADATA,sha256=vGYJbl4ttFIar65HlwCjCdA32vvc45MlwP_Itu2ZAUc,2165
9
+ gamepulse_core-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
10
+ gamepulse_core-0.1.0.dist-info/licenses/LICENSE,sha256=K3S2q5q96K8Hynhsgw6r-J_5-M2y5zO8Kcvet6uAEqI,1067
11
+ gamepulse_core-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Ron Kochba
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.