mirror of
https://github.com/mixpanel/mixpanel-swift
synced 2026-04-24 06:57:16 +00:00
1098 lines
53 KiB
HTML
1098 lines
53 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<title>MixpanelInstance Class Reference</title>
|
||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||
<meta charset='utf-8'>
|
||
<script src="../js/jquery.min.js" defer></script>
|
||
<script src="../js/jazzy.js" defer></script>
|
||
|
||
</head>
|
||
<body>
|
||
<a name="//apple_ref/swift/Class/MixpanelInstance" class="dashAnchor"></a>
|
||
<a title="MixpanelInstance Class Reference"></a>
|
||
<header>
|
||
<div class="content-wrapper">
|
||
<p><a href="../index.html">Mixpanel Docs</a> (100% documented)</p>
|
||
<p class="header-right"><a href="https://github.com/mixpanel/mixpanel-swift"><img src="../img/gh.png"/>View on GitHub</a></p>
|
||
</div>
|
||
</header>
|
||
<div class="content-wrapper">
|
||
<p id="breadcrumbs">
|
||
<a href="../index.html">Mixpanel Reference</a>
|
||
<img id="carat" src="../img/carat.png" />
|
||
MixpanelInstance Class Reference
|
||
</p>
|
||
</div>
|
||
<div class="content-wrapper">
|
||
<nav class="sidebar">
|
||
<ul class="nav-groups">
|
||
<li class="nav-group-name">
|
||
<a href="../Classes.html">Classes</a>
|
||
<ul class="nav-group-tasks">
|
||
<li class="nav-group-task">
|
||
<a href="../Classes/Mixpanel.html">Mixpanel</a>
|
||
</li>
|
||
<li class="nav-group-task">
|
||
<a href="../Classes/MixpanelInstance.html">MixpanelInstance</a>
|
||
</li>
|
||
<li class="nav-group-task">
|
||
<a href="../Classes/People.html">People</a>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li class="nav-group-name">
|
||
<a href="../Protocols.html">Protocols</a>
|
||
<ul class="nav-group-tasks">
|
||
<li class="nav-group-task">
|
||
<a href="../Protocols/MixpanelDelegate.html">MixpanelDelegate</a>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</nav>
|
||
<article class="main-content">
|
||
<section>
|
||
<section class="section">
|
||
<h1>MixpanelInstance</h1>
|
||
<div class="declaration">
|
||
<div class="language">
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">MixpanelInstance</span><span class="p">:</span> <span class="kt">CustomDebugStringConvertible</span><span class="p">,</span> <span class="kt">FlushDelegate</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
<p>The class that represents the Mixpanel Instance</p>
|
||
|
||
</section>
|
||
<section class="section task-group-section">
|
||
<div class="task-group">
|
||
<ul>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:vC8Mixpanel16MixpanelInstance8delegateGSqPS_16MixpanelDelegate__"></a>
|
||
<a name="//apple_ref/swift/Property/delegate" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:vC8Mixpanel16MixpanelInstance8delegateGSqPS_16MixpanelDelegate__">delegate</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>The a MixpanelDelegate object that gives control over Mixpanel network activity.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">delegate</span><span class="p">:</span> <span class="kt"><a href="../Protocols/MixpanelDelegate.html">MixpanelDelegate</a></span><span class="p">?</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:vC8Mixpanel16MixpanelInstance10distinctIdSS"></a>
|
||
<a name="//apple_ref/swift/Property/distinctId" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:vC8Mixpanel16MixpanelInstance10distinctIdSS">distinctId</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>distinctId string that uniquely identifies the current user.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">distinctId</span> <span class="o">=</span> <span class="s">""</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:vC8Mixpanel16MixpanelInstance6peopleGSQCS_6People_"></a>
|
||
<a name="//apple_ref/swift/Property/people" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:vC8Mixpanel16MixpanelInstance6peopleGSQCS_6People_">people</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Accessor to the Mixpanel People API object.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">people</span><span class="p">:</span> <span class="kt"><a href="../Classes/People.html">People</a></span><span class="o">!</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:vC8Mixpanel16MixpanelInstance28showNetworkActivityIndicatorSb"></a>
|
||
<a name="//apple_ref/swift/Property/showNetworkActivityIndicator" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:vC8Mixpanel16MixpanelInstance28showNetworkActivityIndicatorSb">showNetworkActivityIndicator</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Controls whether to show spinning network activity indicator when flushing
|
||
data to the Mixpanel servers. Defaults to true.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">showNetworkActivityIndicator</span> <span class="o">=</span> <span class="kc">true</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:vC8Mixpanel16MixpanelInstance13flushIntervalSd"></a>
|
||
<a name="//apple_ref/swift/Property/flushInterval" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:vC8Mixpanel16MixpanelInstance13flushIntervalSd">flushInterval</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Flush timer’s interval.
|
||
Setting a flush interval of 0 will turn off the flush timer.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">flushInterval</span><span class="p">:</span> <span class="kt">Double</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:vC8Mixpanel16MixpanelInstance17flushOnBackgroundSb"></a>
|
||
<a name="//apple_ref/swift/Property/flushOnBackground" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:vC8Mixpanel16MixpanelInstance17flushOnBackgroundSb">flushOnBackground</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Control whether the library should flush data to Mixpanel when the app
|
||
enters the background. Defaults to true.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">flushOnBackground</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:vC8Mixpanel16MixpanelInstance26useIPAddressForGeoLocationSb"></a>
|
||
<a name="//apple_ref/swift/Property/useIPAddressForGeoLocation" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:vC8Mixpanel16MixpanelInstance26useIPAddressForGeoLocationSb">useIPAddressForGeoLocation</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Controls whether to automatically send the client IP Address as part of
|
||
event tracking. With an IP address, the Mixpanel Dashboard will show you the users’ city.
|
||
Defaults to true.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">useIPAddressForGeoLocation</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:vC8Mixpanel16MixpanelInstance9serverURLSS"></a>
|
||
<a name="//apple_ref/swift/Property/serverURL" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:vC8Mixpanel16MixpanelInstance9serverURLSS">serverURL</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>The base URL used for Mixpanel API requests.
|
||
Useful if you need to proxy Mixpanel requests. Defaults to
|
||
<a href="https://api.mixpanel.com">https://api.mixpanel.com</a>.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">serverURL</span><span class="p">:</span> <span class="kt">String</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:vPs28CustomDebugStringConvertible16debugDescriptionSS"></a>
|
||
<a name="//apple_ref/swift/Property/debugDescription" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:vPs28CustomDebugStringConvertible16debugDescriptionSS">debugDescription</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>The base URL used for Mixpanel API requests.
|
||
Useful if you need to proxy Mixpanel requests. Defaults to
|
||
<a href="https://api.mixpanel.com">https://api.mixpanel.com</a>.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">debugDescription</span><span class="p">:</span> <span class="kt">String</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:vC8Mixpanel16MixpanelInstance14loggingEnabledSb"></a>
|
||
<a name="//apple_ref/swift/Property/loggingEnabled" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:vC8Mixpanel16MixpanelInstance14loggingEnabledSb">loggingEnabled</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>This allows enabling or disabling of all Mixpanel logs at run time.
|
||
- Note: All logging is disabled by default. Usually, this is only required
|
||
if you are running in to issues with the SDK and you need support.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">loggingEnabled</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="task-group">
|
||
<ul>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance8identifyFT10distinctIdSS_T_"></a>
|
||
<a name="//apple_ref/swift/Method/identify(distinctId:)" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance8identifyFT10distinctIdSS_T_">identify(distinctId:)</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Sets the distinct ID of the current user.</p>
|
||
|
||
<p>Mixpanel uses the IFV String (<code>UIDevice.current().identifierForVendor</code>)
|
||
as the default distinct ID. This ID will identify a user across all apps by the same
|
||
vendor, but cannot be used to link the same user across apps from different
|
||
vendors. If we are unable to get the IFV, we will fall back to generating a
|
||
random persistent UUID</p>
|
||
|
||
<p>For tracking events, you do not need to call <code>identify:</code> if you
|
||
want to use the default. However,
|
||
<strong>Mixpanel People always requires an explicit call to <code>identify:</code>.</strong>
|
||
If calls are made to
|
||
<code>set:</code>, <code>increment</code> or other <code><a href="../Classes/People.html">People</a></code>
|
||
methods prior to calling <code>identify:</code>, then they are queued up and
|
||
flushed once <code>identify:</code> is called.</p>
|
||
|
||
<p>If you’d like to use the default distinct ID for Mixpanel People as well
|
||
(recommended), call <code>identify:</code> using the current distinct ID:
|
||
<code>mixpanelInstance.identify(mixpanelInstance.distinctId)</code>.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">identify</span><span class="p">(</span><span class="nv">distinctId</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<h4>Parameters</h4>
|
||
<table class="graybox">
|
||
<tbody>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>distinctId</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>string that uniquely identifies the current user</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance11createAliasFTSS10distinctIdSS_T_"></a>
|
||
<a name="//apple_ref/swift/Method/createAlias(_:distinctId:)" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance11createAliasFTSS10distinctIdSS_T_">createAlias(_:distinctId:)</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Creates a distinctId alias from alias to the current id.</p>
|
||
|
||
<p>This method is used to map an identifier called an alias to the existing Mixpanel
|
||
distinct id. This causes all events and people requests sent with the alias to be
|
||
mapped back to the original distinct id. The recommended usage pattern is to call
|
||
both createAlias: and identify: when the user signs up, and only identify: (with
|
||
their new user ID) when they log in. This will keep your signup funnels working
|
||
correctly.</p>
|
||
|
||
<p>This makes the current id and ‘Alias’ interchangeable distinct ids.
|
||
Mixpanel.
|
||
mixpanelInstance.createAlias(<q>Alias</q>, mixpanelInstance.distinctId)</p>
|
||
|
||
<div class="aside aside-precondition">
|
||
<p class="aside-title">Precondition</p>
|
||
<p>You must call identify if you haven’t already
|
||
(e.g. when your app launches)</p>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">createAlias</span><span class="p">(</span><span class="n">_</span> <span class="nv">alias</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">distinctId</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<h4>Parameters</h4>
|
||
<table class="graybox">
|
||
<tbody>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>alias</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>the new distinct id that should represent the original</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>distinctId</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>the old distinct id that alias will be mapped to</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance5resetFT_T_"></a>
|
||
<a name="//apple_ref/swift/Method/reset()" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance5resetFT_T_">reset()</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Clears all stored properties including the distinct Id.
|
||
Useful if your app’s user logs out.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">reset</span><span class="p">()</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="task-group">
|
||
<ul>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance7archiveFT_T_"></a>
|
||
<a name="//apple_ref/swift/Method/archive()" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance7archiveFT_T_">archive()</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Writes current project info including the distinct Id, super properties,
|
||
and pending event and People record queues to disk.</p>
|
||
|
||
<p>This state will be recovered when the app is launched again if the Mixpanel
|
||
library is initialized with the same project token.
|
||
The library listens for app state changes and handles
|
||
persisting data as needed.</p>
|
||
|
||
<div class="aside aside-important">
|
||
<p class="aside-title">Important</p>
|
||
You do not need to call this method.**
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">archive</span><span class="p">()</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="task-group">
|
||
<ul>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance5flushFT10completionGSqFT_T___T_"></a>
|
||
<a name="//apple_ref/swift/Method/flush(completion:)" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance5flushFT10completionGSqFT_T___T_">flush(completion:)</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Uploads queued data to the Mixpanel server.</p>
|
||
|
||
<p>By default, queued data is flushed to the Mixpanel servers every minute (the
|
||
default for <code><a href="../Classes/MixpanelInstance.html#/s:vC8Mixpanel16MixpanelInstance13flushIntervalSd">flushInterval</a></code>), and on background (since
|
||
<code><a href="../Classes/MixpanelInstance.html#/s:vC8Mixpanel16MixpanelInstance17flushOnBackgroundSb">flushOnBackground</a></code> is on by default). You only need to call this
|
||
method manually if you want to force a flush at a particular moment.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">flush</span><span class="p">(</span><span class="nv">completion</span><span class="p">:</span> <span class="p">(()</span> <span class="o">-></span> <span class="kt">Void</span><span class="p">)?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<h4>Parameters</h4>
|
||
<table class="graybox">
|
||
<tbody>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>completion</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>an optional completion handler for when the flush has completed.</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="task-group">
|
||
<ul>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance5trackFT5eventGSqSS_10propertiesGSqGVs10DictionarySSPs9AnyObject____T_"></a>
|
||
<a name="//apple_ref/swift/Method/track(event:properties:)" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance5trackFT5eventGSqSS_10propertiesGSqGVs10DictionarySSPs9AnyObject____T_">track(event:properties:)</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Tracks an event with properties.
|
||
Properties are optional and can be added only if needed.</p>
|
||
|
||
<p>Properties will allow you to segment your events in your Mixpanel reports.
|
||
Property keys must be String objects and the supported value types are:
|
||
String, Int, UInt, Double, Float, [AnyObject], [String: AnyObject], Date, URL, and NSNull.
|
||
If the event is being timed, the timer will stop and be added as a property.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">track</span><span class="p">(</span><span class="nv">event</span><span class="p">:</span> <span class="kt">String</span><span class="p">?,</span> <span class="nv">properties</span><span class="p">:</span> <span class="kt">Properties</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<h4>Parameters</h4>
|
||
<table class="graybox">
|
||
<tbody>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>event</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>event name</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>properties</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>properties dictionary</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance21trackPushNotificationFTGVs10DictionaryCSo8NSObjectPs9AnyObject__5eventSS_T_"></a>
|
||
<a name="//apple_ref/swift/Method/trackPushNotification(_:event:)" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance21trackPushNotificationFTGVs10DictionaryCSo8NSObjectPs9AnyObject__5eventSS_T_">trackPushNotification(_:event:)</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Track a push notification using its payload sent from Mixpanel.</p>
|
||
|
||
<p>To simplify user interaction tracking, Mixpanel
|
||
automatically sends IDs for the relevant notification of each push.
|
||
This method parses the standard payload and queues a track call using this information.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">trackPushNotification</span><span class="p">(</span><span class="n">_</span> <span class="nv">userInfo</span><span class="p">:</span> <span class="p">[</span><span class="kt">NSObject</span><span class="p">:</span> <span class="kt">AnyObject</span><span class="p">],</span>
|
||
<span class="nv">event</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="s">"$campaign_received"</span><span class="p">)</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<h4>Parameters</h4>
|
||
<table class="graybox">
|
||
<tbody>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>userInfo</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>remote notification payload dictionary</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>event</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>optional, and usually shouldn’t be used, unless the results is needed to be tracked elsewhere.</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance4timeFT5eventSS_T_"></a>
|
||
<a name="//apple_ref/swift/Method/time(event:)" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance4timeFT5eventSS_T_">time(event:)</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Starts a timer that will be stopped and added as a property when a
|
||
corresponding event is tracked.</p>
|
||
|
||
<p>This method is intended to be used in advance of events that have
|
||
a duration. For example, if a developer were to track an <q>Image Upload</q> event
|
||
she might want to also know how long the upload took. Calling this method
|
||
before the upload code would implicitly cause the <code>track</code>
|
||
call to record its duration.</p>
|
||
|
||
<div class="aside aside-precondition">
|
||
<p class="aside-title">Precondition</p>
|
||
<p>// begin timing the image upload:
|
||
mixpanelInstance.time(event:<q>Image Upload</q>)
|
||
// upload the image:
|
||
self.uploadImageWithSuccessHandler() { _ in
|
||
// track the event
|
||
mixpanelInstance.track(<q>Image Upload</q>)
|
||
}</p>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">time</span><span class="p">(</span><span class="nv">event</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<h4>Parameters</h4>
|
||
<table class="graybox">
|
||
<tbody>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>event</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>the event name to be timed</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance16clearTimedEventsFT_T_"></a>
|
||
<a name="//apple_ref/swift/Method/clearTimedEvents()" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance16clearTimedEventsFT_T_">clearTimedEvents()</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Clears all current event timers.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">clearTimedEvents</span><span class="p">()</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance22currentSuperPropertiesFT_GVs10DictionarySSPs9AnyObject__"></a>
|
||
<a name="//apple_ref/swift/Method/currentSuperProperties()" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance22currentSuperPropertiesFT_GVs10DictionarySSPs9AnyObject__">currentSuperProperties()</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Returns the currently set super properties.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">currentSuperProperties</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Properties</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<h4>Return Value</h4>
|
||
<p>the current super properties</p>
|
||
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance20clearSuperPropertiesFT_T_"></a>
|
||
<a name="//apple_ref/swift/Method/clearSuperProperties()" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance20clearSuperPropertiesFT_T_">clearSuperProperties()</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Clears all currently set super properties.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">clearSuperProperties</span><span class="p">()</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance23registerSuperPropertiesFGVs10DictionarySSPs9AnyObject__T_"></a>
|
||
<a name="//apple_ref/swift/Method/registerSuperProperties(_:)" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance23registerSuperPropertiesFGVs10DictionarySSPs9AnyObject__T_">registerSuperProperties(_:)</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Registers super properties, overwriting ones that have already been set.</p>
|
||
|
||
<p>Super properties, once registered, are automatically sent as properties for
|
||
all event tracking calls. They save you having to maintain and add a common
|
||
set of properties to your events.
|
||
Property keys must be String objects and the supported value types are:
|
||
String, Int, UInt, Double, Float, [AnyObject], [String: AnyObject], Date, URL, and NSNull.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">registerSuperProperties</span><span class="p">(</span><span class="n">_</span> <span class="nv">properties</span><span class="p">:</span> <span class="kt">Properties</span><span class="p">)</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<h4>Parameters</h4>
|
||
<table class="graybox">
|
||
<tbody>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>properties</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>properties dictionary</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance27registerSuperPropertiesOnceFTGVs10DictionarySSPs9AnyObject__12defaultValueGSqPS2____T_"></a>
|
||
<a name="//apple_ref/swift/Method/registerSuperPropertiesOnce(_:defaultValue:)" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance27registerSuperPropertiesOnceFTGVs10DictionarySSPs9AnyObject__12defaultValueGSqPS2____T_">registerSuperPropertiesOnce(_:defaultValue:)</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Registers super properties without overwriting ones that have already been set,
|
||
unless the existing value is equal to defaultValue. defaultValue is optional.</p>
|
||
|
||
<p>Property keys must be String objects and the supported value types are:
|
||
String, Int, UInt, Double, Float, [AnyObject], [String: AnyObject], Date, URL, and NSNull.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">registerSuperPropertiesOnce</span><span class="p">(</span><span class="n">_</span> <span class="nv">properties</span><span class="p">:</span> <span class="kt">Properties</span><span class="p">,</span>
|
||
<span class="n">defaultValue</span><span class="p">:</span> <span class="kt">AnyObject</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<h4>Parameters</h4>
|
||
<table class="graybox">
|
||
<tbody>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>properties</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>properties dictionary</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>defaultValue</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>Optional. overwrite existing properties that have this value</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
<li class="item">
|
||
<div>
|
||
<code>
|
||
<a name="/s:FC8Mixpanel16MixpanelInstance23unregisterSuperPropertyFSST_"></a>
|
||
<a name="//apple_ref/swift/Method/unregisterSuperProperty(_:)" class="dashAnchor"></a>
|
||
<a class="token" href="#/s:FC8Mixpanel16MixpanelInstance23unregisterSuperPropertyFSST_">unregisterSuperProperty(_:)</a>
|
||
</code>
|
||
</div>
|
||
<div class="height-container">
|
||
<div class="pointer-container"></div>
|
||
<section class="section">
|
||
<div class="pointer"></div>
|
||
<div class="abstract">
|
||
<p>Removes a previously registered super property.</p>
|
||
|
||
<p>As an alternative to clearing all properties, unregistering specific super
|
||
properties prevents them from being recorded on future events. This operation
|
||
does not affect the value of other super properties. Any property name that is
|
||
not registered is ignored.
|
||
Note that after removing a super property, events will show the attribute as
|
||
having the value <code>undefined</code> in Mixpanel until a new value is
|
||
registered.</p>
|
||
|
||
</div>
|
||
<div class="declaration">
|
||
<h4>Declaration</h4>
|
||
<div class="language">
|
||
<p class="aside-title">Swift</p>
|
||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">unregisterSuperProperty</span><span class="p">(</span><span class="n">_</span> <span class="nv">propertyName</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
|
||
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<h4>Parameters</h4>
|
||
<table class="graybox">
|
||
<tbody>
|
||
<tr>
|
||
<td>
|
||
<code>
|
||
<em>propertyName</em>
|
||
</code>
|
||
</td>
|
||
<td>
|
||
<div>
|
||
<p>array of property name strings to remove</p>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</section>
|
||
</section>
|
||
<section id="footer">
|
||
<p>© 2016 <a class="link" href="http://mixpanel.com" target="_blank" rel="external">Mixpanel</a>. All rights reserved. (Last updated: 2016-07-28)</p>
|
||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||
</section>
|
||
</article>
|
||
</div>
|
||
</body>
|
||
</div>
|
||
</html>
|